-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
I'm going to stop making MCVEs for these in the interest of time; I'll link the original code so you can replicate.
I tried this code: https://github.com/rust-lang/rust/blob/a6ff925f8b5598a1f6d84964525baa1d4a08fd63/compiler/rustc_middle/src/mir/interpret/mod.rs#L72-L75
#[macro_export]
macro_rules! throw_ub {
($($tt:tt)*) => { Err::<!, _>(err_ub!($($tt)*))? };
}
I expected to see this happen: Clippy only changes the relevant parts of the code
Instead, this happened: Clippy turns err_ub
into throw_ub
(??)
error: recursion limit reached while expanding `throw_ub!`
--> compiler/rustc_middle/src/mir/interpret/mod.rs:74:34
|
73 | / macro_rules! throw_ub {
74 | | ($($tt:tt)*) => { return Err(throw_ub!(InvalidUninitBytes(None)).into()) };
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation (#2)
75 | | }
| | -
| | |
| |_in this expansion of `throw_ub!` (#1)
| in this expansion of `throw_ub!` (#2)
|
::: compiler/rustc_middle/src/mir/interpret/allocation.rs:298:21
|
298 | None => throw_ub!(UnterminatedCString(ptr.erase_tag())),
| ----------------------------------------------- in this macro invocation (#1)
|
= help: consider adding a `#![recursion_limit="1024"]` attribute to your crate (`rustc_middle`)
error: aborting due to previous error
Original diagnostics will follow.
warning: returning an `Err(_)` with the `?` operator
--> compiler/rustc_middle/src/mir/interpret/mod.rs:74:23
|
73 | / macro_rules! throw_ub {
74 | | ($($tt:tt)*) => { Err::<!, _>(err_ub!($($tt)*))? };
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `return Err(throw_ub!(UnterminatedCString(ptr.erase_tag())).into())`
75 | | }
| |_- in this expansion of `throw_ub!`
|
::: compiler/rustc_middle/src/mir/interpret/allocation.rs:298:21
|
298 | None => throw_ub!(UnterminatedCString(ptr.erase_tag())),
| ----------------------------------------------- in this macro invocation
|
= note: `#[warn(clippy::try_err)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#try_err
Meta
cargo clippy -V
: clippy 0.0.212 (4760b8f 2020-10-25)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing