diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-03 20:51:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-03 20:51:54 +0200 |
| commit | 3a9d4325896d0b5615a26140adc0145dfbe75b46 (patch) | |
| tree | b9c4275e83108915e9ed74eb7d20d932d19f09cf /tests | |
| parent | e488ee7efd6ceb87496bfb3f35ddaaf3394421b6 (diff) | |
| parent | 33cb33441de5086e5daa2d951619c279fc394681 (diff) | |
| download | rust-3a9d4325896d0b5615a26140adc0145dfbe75b46.tar.gz rust-3a9d4325896d0b5615a26140adc0145dfbe75b46.zip | |
Rollup merge of #128581 - jieyouxu:checked-attr, r=nnethercote
Assert that all attributes are actually checked via `CheckAttrVisitor` and aren't accidentally usable on completely unrelated HIR nodes ``@oli-obk's`` #128444 with unreachable case removed to avoid that PR bitrotting away. Based on #128402. This PR will make adding a new attribute ICE on any use of that attribute unless it gets a handler added in `rustc_passes::CheckAttrVisitor`. r? ``@nnethercote`` (since you were the reviewer of the original PR)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/coroutine/invalid_attr_usage.rs | 11 | ||||
| -rw-r--r-- | tests/ui/coroutine/invalid_attr_usage.stderr | 14 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/coroutine/invalid_attr_usage.rs b/tests/ui/coroutine/invalid_attr_usage.rs new file mode 100644 index 00000000000..995a3aa3100 --- /dev/null +++ b/tests/ui/coroutine/invalid_attr_usage.rs @@ -0,0 +1,11 @@ +//! The `coroutine` attribute is only allowed on closures. + +#![feature(coroutines)] + +#[coroutine] +//~^ ERROR: attribute should be applied to closures +struct Foo; + +#[coroutine] +//~^ ERROR: attribute should be applied to closures +fn main() {} diff --git a/tests/ui/coroutine/invalid_attr_usage.stderr b/tests/ui/coroutine/invalid_attr_usage.stderr new file mode 100644 index 00000000000..316a0117e5d --- /dev/null +++ b/tests/ui/coroutine/invalid_attr_usage.stderr @@ -0,0 +1,14 @@ +error: attribute should be applied to closures + --> $DIR/invalid_attr_usage.rs:5:1 + | +LL | #[coroutine] + | ^^^^^^^^^^^^ + +error: attribute should be applied to closures + --> $DIR/invalid_attr_usage.rs:9:1 + | +LL | #[coroutine] + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + |
