-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
entry: disallow explicit/interior mutability for read-only storage cl…
…asses.
- Loading branch information
Showing
3 changed files
with
168 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Tests that | ||
// build-fail | ||
|
||
use core::sync::atomic::AtomicU32; | ||
use spirv_std::{image::Image2d, spirv}; | ||
|
||
#[spirv(fragment)] | ||
pub fn main( | ||
#[spirv(descriptor_set = 0, binding = 0)] implicit_uniform_constant_mut: &mut Image2d, | ||
#[spirv(uniform_constant, descriptor_set = 0, binding = 0)] uniform_constant_mut: &mut Image2d, | ||
#[spirv(uniform, descriptor_set = 0, binding = 0)] uniform_mut: &mut u32, | ||
#[spirv(uniform, descriptor_set = 0, binding = 0)] uniform_interior_mut: &AtomicU32, | ||
#[spirv(push_constant)] push_constant_mut: &mut u32, | ||
#[spirv(push_constant)] push_constant_interior_mut: &AtomicU32, | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
error: entry-point requires a mutable reference... | ||
--> $DIR/mutability-errors.rs:9:78 | ||
| | ||
9 | #[spirv(descriptor_set = 0, binding = 0)] implicit_uniform_constant_mut: &mut Image2d, | ||
| ^^^^^^^^^^^^ | ||
| | ||
note: ...but storage class `UniformConstant` is read-only | ||
--> $DIR/mutability-errors.rs:9:78 | ||
| | ||
9 | #[spirv(descriptor_set = 0, binding = 0)] implicit_uniform_constant_mut: &mut Image2d, | ||
| ^^^^^^^^^^^^ `UniformConstant` implied by type | ||
|
||
warning: redundant storage class specifier, storage class is inferred from type | ||
--> $DIR/mutability-errors.rs:10:13 | ||
| | ||
10 | #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] uniform_constant_mut: &mut Image2d, | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: entry-point requires a mutable reference... | ||
--> $DIR/mutability-errors.rs:10:87 | ||
| | ||
10 | #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] uniform_constant_mut: &mut Image2d, | ||
| ^^^^^^^^^^^^ | ||
| | ||
note: ...but storage class `UniformConstant` is read-only | ||
--> $DIR/mutability-errors.rs:10:13 | ||
| | ||
10 | #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] uniform_constant_mut: &mut Image2d, | ||
| ^^^^^^^^^^^^^^^^ `UniformConstant` specified in attribute | ||
|
||
error: entry-point requires a mutable reference... | ||
--> $DIR/mutability-errors.rs:11:69 | ||
| | ||
11 | #[spirv(uniform, descriptor_set = 0, binding = 0)] uniform_mut: &mut u32, | ||
| ^^^^^^^^ | ||
| | ||
note: ...but storage class `Uniform` is read-only | ||
--> $DIR/mutability-errors.rs:11:13 | ||
| | ||
11 | #[spirv(uniform, descriptor_set = 0, binding = 0)] uniform_mut: &mut u32, | ||
| ^^^^^^^ `Uniform` specified in attribute | ||
|
||
error: entry-point requires interior mutability... | ||
--> $DIR/mutability-errors.rs:12:78 | ||
| | ||
12 | #[spirv(uniform, descriptor_set = 0, binding = 0)] uniform_interior_mut: &AtomicU32, | ||
| ^^^^^^^^^^ | ||
| | ||
note: ...but storage class `Uniform` is read-only | ||
--> $DIR/mutability-errors.rs:12:13 | ||
| | ||
12 | #[spirv(uniform, descriptor_set = 0, binding = 0)] uniform_interior_mut: &AtomicU32, | ||
| ^^^^^^^ `Uniform` specified in attribute | ||
|
||
error: entry-point requires a mutable reference... | ||
--> $DIR/mutability-errors.rs:13:48 | ||
| | ||
13 | #[spirv(push_constant)] push_constant_mut: &mut u32, | ||
| ^^^^^^^^ | ||
| | ||
note: ...but storage class `PushConstant` is read-only | ||
--> $DIR/mutability-errors.rs:13:13 | ||
| | ||
13 | #[spirv(push_constant)] push_constant_mut: &mut u32, | ||
| ^^^^^^^^^^^^^ `PushConstant` specified in attribute | ||
|
||
error: entry-point requires interior mutability... | ||
--> $DIR/mutability-errors.rs:14:57 | ||
| | ||
14 | #[spirv(push_constant)] push_constant_interior_mut: &AtomicU32, | ||
| ^^^^^^^^^^ | ||
| | ||
note: ...but storage class `PushConstant` is read-only | ||
--> $DIR/mutability-errors.rs:14:13 | ||
| | ||
14 | #[spirv(push_constant)] push_constant_interior_mut: &AtomicU32, | ||
| ^^^^^^^^^^^^^ `PushConstant` specified in attribute | ||
|
||
error: aborting due to 6 previous errors; 1 warning emitted | ||
|