Add test for useless_anonymous_reexport lint
This commit is contained in:
parent
2df7770d5e
commit
ac4ea52980
4 changed files with 38 additions and 1 deletions
|
@ -510,4 +510,4 @@ lint_opaque_hidden_inferred_bound = opaque type `{$ty}` does not satisfy its ass
|
||||||
lint_opaque_hidden_inferred_bound_sugg = add this bound
|
lint_opaque_hidden_inferred_bound_sugg = add this bound
|
||||||
|
|
||||||
lint_useless_anonymous_reexport = useless anonymous re-export
|
lint_useless_anonymous_reexport = useless anonymous re-export
|
||||||
.note = only anonymous re-exports of traits are useful, this is {$article} `${desc}`
|
.note = only anonymous re-exports of traits are useful, this is {$article} `{$desc}`
|
||||||
|
|
|
@ -1533,6 +1533,7 @@ pub struct UnusedAllocationMutDiag;
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(lint_useless_anonymous_reexport)]
|
#[diag(lint_useless_anonymous_reexport)]
|
||||||
|
#[note]
|
||||||
pub struct UselessAnonymousReexportDiag {
|
pub struct UselessAnonymousReexportDiag {
|
||||||
pub article: &'static str,
|
pub article: &'static str,
|
||||||
pub desc: &'static str,
|
pub desc: &'static str,
|
||||||
|
|
16
tests/ui/lint/anonymous-reexport.rs
Normal file
16
tests/ui/lint/anonymous-reexport.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#![deny(useless_anonymous_reexport)]
|
||||||
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
|
mod my_mod {
|
||||||
|
pub trait Foo {}
|
||||||
|
pub type TyFoo = dyn Foo;
|
||||||
|
pub struct Bar;
|
||||||
|
pub type TyBar = Bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use self::my_mod::Foo as _;
|
||||||
|
pub use self::my_mod::TyFoo as _;
|
||||||
|
pub use self::my_mod::Bar as _; //~ ERROR
|
||||||
|
pub use self::my_mod::TyBar as _; //~ ERROR
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use self::my_mod::TyBar as _;
|
20
tests/ui/lint/anonymous-reexport.stderr
Normal file
20
tests/ui/lint/anonymous-reexport.stderr
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
error: useless anonymous re-export
|
||||||
|
--> $DIR/anonymous-reexport.rs:13:1
|
||||||
|
|
|
||||||
|
LL | pub use self::my_mod::Bar as _;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/anonymous-reexport.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(useless_anonymous_reexport)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: useless anonymous re-export
|
||||||
|
--> $DIR/anonymous-reexport.rs:14:1
|
||||||
|
|
|
||||||
|
LL | pub use self::my_mod::TyBar as _;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue