The rust_2021_prelude_collisions lint suggestion seems to expand the expression for a macro, but I don't think it should. The following:
#![warn(rust_2021_prelude_collisions)]
fn bar() {}
macro_rules! foo {
() => {{
$crate::bar();
S
}};
}
trait MyTry<T> {
fn try_into(self) -> Result<T, ()>;
}
struct S;
impl MyTry<i32> for S {
fn try_into(self) -> Result<i32, ()> {
unimplemented!();
}
}
fn main() {
foo!().try_into().unwrap();
}
The suggestion recommends replacing it with:
MyTry::try_into({
$crate::bar();
S
}).unwrap();
which will not compile. I would expect it to suggest:
MyTry::try_into(foo!()).unwrap();
Found during the crater run for:
Meta
rustc --version --verbose:
rustc 1.56.0-nightly (b03ccace5 2021-08-24)
binary: rustc
commit-hash: b03ccace573bb91e27625c190a0f7807045a1012
commit-date: 2021-08-24
host: x86_64-apple-darwin
release: 1.56.0-nightly
LLVM version: 13.0.0
The
rust_2021_prelude_collisionslint suggestion seems to expand the expression for a macro, but I don't think it should. The following:The suggestion recommends replacing it with:
which will not compile. I would expect it to suggest:
Found during the crater run for:
Meta
rustc --version --verbose: