diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/attributes/auxiliary/rustc_confusables_across_crate.rs | 11 | ||||
-rw-r--r-- | tests/ui/attributes/invalid-doc-attr.rs | 32 | ||||
-rw-r--r-- | tests/ui/attributes/invalid-doc-attr.stderr | 78 | ||||
-rw-r--r-- | tests/ui/attributes/macro_export_on_decl_macro.rs | 9 | ||||
-rw-r--r-- | tests/ui/attributes/macro_export_on_decl_macro.stderr | 16 | ||||
-rw-r--r-- | tests/ui/attributes/rustc_confusables.rs | 47 | ||||
-rw-r--r-- | tests/ui/attributes/rustc_confusables.stderr | 68 |
7 files changed, 151 insertions, 110 deletions
diff --git a/tests/ui/attributes/auxiliary/rustc_confusables_across_crate.rs b/tests/ui/attributes/auxiliary/rustc_confusables_across_crate.rs new file mode 100644 index 000000000..2fb2d3ad4 --- /dev/null +++ b/tests/ui/attributes/auxiliary/rustc_confusables_across_crate.rs @@ -0,0 +1,11 @@ +#![feature(rustc_attrs)] + +pub struct BTreeSet; + +impl BTreeSet { + #[rustc_confusables("push", "test_b")] + pub fn insert(&self) {} + + #[rustc_confusables("pulled")] + pub fn pull(&self) {} +} diff --git a/tests/ui/attributes/invalid-doc-attr.rs b/tests/ui/attributes/invalid-doc-attr.rs deleted file mode 100644 index c231e43b3..000000000 --- a/tests/ui/attributes/invalid-doc-attr.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![crate_type = "lib"] -#![deny(warnings)] - -#[doc(test(no_crate_inject))] -//~^ ERROR can only be applied at the crate level -//~| WARN is being phased out -//~| HELP to apply to the crate, use an inner attribute -//~| SUGGESTION ! -#[doc(inline)] -//~^ ERROR can only be applied to a `use` item -//~| WARN is being phased out -pub fn foo() {} - -pub mod bar { - #![doc(test(no_crate_inject))] - //~^ ERROR can only be applied at the crate level - //~| WARN is being phased out - - #[doc(test(no_crate_inject))] - //~^ ERROR can only be applied at the crate level - //~| WARN is being phased out - #[doc(inline)] - //~^ ERROR can only be applied to a `use` item - //~| WARN is being phased out - pub fn baz() {} -} - -#[doc(inline)] -#[doc(no_inline)] -//~^^ ERROR conflicting doc inlining attributes -//~| HELP remove one of the conflicting attributes -pub use bar::baz; diff --git a/tests/ui/attributes/invalid-doc-attr.stderr b/tests/ui/attributes/invalid-doc-attr.stderr deleted file mode 100644 index b23b8ded8..000000000 --- a/tests/ui/attributes/invalid-doc-attr.stderr +++ /dev/null @@ -1,78 +0,0 @@ -error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:4:7 - | -LL | #[doc(test(no_crate_inject))] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> - = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information -note: the lint level is defined here - --> $DIR/invalid-doc-attr.rs:2:9 - | -LL | #![deny(warnings)] - | ^^^^^^^^ - = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` -help: to apply to the crate, use an inner attribute - | -LL | #![doc(test(no_crate_inject))] - | + - -error: this attribute can only be applied to a `use` item - --> $DIR/invalid-doc-attr.rs:9:7 - | -LL | #[doc(inline)] - | ^^^^^^ only applicable on `use` items -... -LL | pub fn foo() {} - | ------------ not a `use` item - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> - = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#inline-and-no_inline> for more information - -error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:15:12 - | -LL | #![doc(test(no_crate_inject))] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> - = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information - -error: conflicting doc inlining attributes - --> $DIR/invalid-doc-attr.rs:28:7 - | -LL | #[doc(inline)] - | ^^^^^^ this attribute... -LL | #[doc(no_inline)] - | ^^^^^^^^^ ...conflicts with this attribute - | - = help: remove one of the conflicting attributes - -error: this attribute can only be applied at the crate level - --> $DIR/invalid-doc-attr.rs:19:11 - | -LL | #[doc(test(no_crate_inject))] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> - = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information - -error: this attribute can only be applied to a `use` item - --> $DIR/invalid-doc-attr.rs:22:11 - | -LL | #[doc(inline)] - | ^^^^^^ only applicable on `use` items -... -LL | pub fn baz() {} - | ------------ not a `use` item - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> - = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#inline-and-no_inline> for more information - -error: aborting due to 6 previous errors - diff --git a/tests/ui/attributes/macro_export_on_decl_macro.rs b/tests/ui/attributes/macro_export_on_decl_macro.rs new file mode 100644 index 000000000..e6fe66ac6 --- /dev/null +++ b/tests/ui/attributes/macro_export_on_decl_macro.rs @@ -0,0 +1,9 @@ +// Using #[macro_export] on a decl macro has no effect and should warn + +#![feature(decl_macro)] +#![deny(unused)] + +#[macro_export] //~ ERROR `#[macro_export]` has no effect on declarative macro definitions +pub macro foo() {} + +fn main() {} diff --git a/tests/ui/attributes/macro_export_on_decl_macro.stderr b/tests/ui/attributes/macro_export_on_decl_macro.stderr new file mode 100644 index 000000000..565e07919 --- /dev/null +++ b/tests/ui/attributes/macro_export_on_decl_macro.stderr @@ -0,0 +1,16 @@ +error: `#[macro_export]` has no effect on declarative macro definitions + --> $DIR/macro_export_on_decl_macro.rs:6:1 + | +LL | #[macro_export] + | ^^^^^^^^^^^^^^^ + | + = note: declarative macros follow the same exporting rules as regular items +note: the lint level is defined here + --> $DIR/macro_export_on_decl_macro.rs:4:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]` + +error: aborting due to previous error + diff --git a/tests/ui/attributes/rustc_confusables.rs b/tests/ui/attributes/rustc_confusables.rs new file mode 100644 index 000000000..352e91d06 --- /dev/null +++ b/tests/ui/attributes/rustc_confusables.rs @@ -0,0 +1,47 @@ +// aux-build: rustc_confusables_across_crate.rs + +#![feature(rustc_attrs)] + +extern crate rustc_confusables_across_crate; + +use rustc_confusables_across_crate::BTreeSet; + +fn main() { + // Misspellings (similarly named methods) take precedence over `rustc_confusables`. + let x = BTreeSet {}; + x.inser(); + //~^ ERROR no method named + //~| HELP there is a method with a similar name + x.foo(); + //~^ ERROR no method named + x.push(); + //~^ ERROR no method named + //~| HELP you might have meant to use `insert` + x.test(); + //~^ ERROR no method named + x.pulled(); + //~^ ERROR no method named + //~| HELP there is a method with a similar name +} + +struct Bar; + +impl Bar { + #[rustc_confusables()] + //~^ ERROR expected at least one confusable name + fn baz() {} + + #[rustc_confusables] + //~^ ERROR malformed `rustc_confusables` attribute input + //~| HELP must be of the form + fn qux() {} + + #[rustc_confusables(invalid_meta_item)] + //~^ ERROR expected a quoted string literal + //~| HELP consider surrounding this with quotes + fn quux() {} +} + +#[rustc_confusables("blah")] +//~^ ERROR attribute should be applied to an inherent method +fn not_inherent_impl_method() {} diff --git a/tests/ui/attributes/rustc_confusables.stderr b/tests/ui/attributes/rustc_confusables.stderr new file mode 100644 index 000000000..9fd4470cd --- /dev/null +++ b/tests/ui/attributes/rustc_confusables.stderr @@ -0,0 +1,68 @@ +error: malformed `rustc_confusables` attribute input + --> $DIR/rustc_confusables.rs:34:5 + | +LL | #[rustc_confusables] + | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` + +error: attribute should be applied to an inherent method + --> $DIR/rustc_confusables.rs:45:1 + | +LL | #[rustc_confusables("blah")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: expected at least one confusable name + --> $DIR/rustc_confusables.rs:30:5 + | +LL | #[rustc_confusables()] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0539]: expected a quoted string literal + --> $DIR/rustc_confusables.rs:39:25 + | +LL | #[rustc_confusables(invalid_meta_item)] + | ^^^^^^^^^^^^^^^^^ + | +help: consider surrounding this with quotes + | +LL | #[rustc_confusables("invalid_meta_item")] + | + + + +error[E0599]: no method named `inser` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:12:7 + | +LL | x.inser(); + | ^^^^^ help: there is a method with a similar name: `insert` + +error[E0599]: no method named `foo` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:15:7 + | +LL | x.foo(); + | ^^^ method not found in `BTreeSet` + +error[E0599]: no method named `push` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:17:7 + | +LL | x.push(); + | ^^^^ method not found in `BTreeSet` + | +help: you might have meant to use `insert` + | +LL | x.insert(); + | ~~~~~~ + +error[E0599]: no method named `test` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:20:7 + | +LL | x.test(); + | ^^^^ method not found in `BTreeSet` + +error[E0599]: no method named `pulled` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope + --> $DIR/rustc_confusables.rs:22:7 + | +LL | x.pulled(); + | ^^^^^^ help: there is a method with a similar name: `pull` + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0539, E0599. +For more information about an error, try `rustc --explain E0539`. |