Closed
Description
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:
- https://github.com/cedric-h/sorry - https://crater-reports.s3.amazonaws.com/pr-87190-3/try%23a7a572ce3edd6d476191fbfe92c9c1986e009b34/gh/cedric-h.sorry/log.txt
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