1
Fork 0

Add test for useless_anonymous_reexport lint

This commit is contained in:
Guillaume Gomez 2023-03-10 22:20:29 +01:00
parent 2df7770d5e
commit ac4ea52980
4 changed files with 38 additions and 1 deletions

View file

@ -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_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}`

View file

@ -1533,6 +1533,7 @@ pub struct UnusedAllocationMutDiag;
#[derive(LintDiagnostic)]
#[diag(lint_useless_anonymous_reexport)]
#[note]
pub struct UselessAnonymousReexportDiag {
pub article: &'static str,
pub desc: &'static str,

View 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 _;

View 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