Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect unused_import lint firing for a function-local macro_rules! #78894

Closed
danielhenrymantilla opened this issue Nov 9, 2020 · 1 comment · Fixed by #121961
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. E-help-wanted Call for participation: Help is requested to fix this issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@danielhenrymantilla
Copy link
Contributor

danielhenrymantilla commented Nov 9, 2020

I tried this code:

fn main ()
{
    m!();
    // where
    macro_rules! m {
        () => ();
    } use m;
}

I expected to see this happen: no warning.

Instead, this happened: I get a warning saying:

warning: the item `m` is imported redundantly
 --> src/main.rs:7:11
  |
5 | /     macro_rules! m {
6 | |         () => ();
7 | |     } use m;
  | |     -     ^
  | |_____|
  |       the item `m` is already defined here
  |
  = note: `#[warn(unused_imports)]` on by default

This is incorrect since removing that use "statement" leads to the code not compiling.

Meta

Affects all three versions currently available in the Playground (1.47.0 -> 1.49.0)

@danielhenrymantilla danielhenrymantilla added the C-bug Category: This is a bug. label Nov 9, 2020
@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Nov 9, 2020
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
jonasbb added a commit to jonasbb/serde_with that referenced this issue Feb 19, 2024
The bug rust#78894 in rustc is now a problem, since more warnings are
issued.

rust-lang/rust#78894
rust-lang/rust#117772
jonasbb added a commit to jonasbb/serde_with that referenced this issue Feb 19, 2024
The bug rust#78894 in rustc is now a problem, since more warnings are
issued.

rust-lang/rust#78894
rust-lang/rust#117772
@petrochenkov
Copy link
Contributor

This issue no longer reproduces and can be closed when a corresponding test is added.

@petrochenkov petrochenkov added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 2, 2024
@est31 est31 added the E-help-wanted Call for participation: Help is requested to fix this issue. label Mar 3, 2024
surechen added a commit to surechen/rust that referenced this issue Mar 4, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 5, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 5, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#121280 (Implement MaybeUninit::fill{,_with,_from})
 - rust-lang#121438 (std support for wasm32 panic=unwind)
 - rust-lang#121658 (Hint user to update nightly on ICEs produced from outdated nightly)
 - rust-lang#121959 (Removing absolute path in proc-macro)
 - rust-lang#121961 (add test for rust-lang#78894 rust-lang#71450)
 - rust-lang#121975 (hir_analysis: enums return `None` in `find_field`)
 - rust-lang#121978 (Fix duplicated path in the "not found dylib" error)
 - rust-lang#121991 (Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`)
 - rust-lang#122016 (will_wake tests fail on Miri and that is expected)
 - rust-lang#122018 (only set noalias on Box with the global allocator)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 5, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 5, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#121202 (Limit the number of names and values in check-cfg diagnostics)
 - rust-lang#121301 (errors: share `SilentEmitter` between rustc and rustfmt)
 - rust-lang#121658 (Hint user to update nightly on ICEs produced from outdated nightly)
 - rust-lang#121846 (only compare ambiguity item that have hard error)
 - rust-lang#121961 (add test for rust-lang#78894 rust-lang#71450)
 - rust-lang#121975 (hir_analysis: enums return `None` in `find_field`)
 - rust-lang#121978 (Fix duplicated path in the "not found dylib" error)
 - rust-lang#121991 (Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 6, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#121202 (Limit the number of names and values in check-cfg diagnostics)
 - rust-lang#121301 (errors: share `SilentEmitter` between rustc and rustfmt)
 - rust-lang#121658 (Hint user to update nightly on ICEs produced from outdated nightly)
 - rust-lang#121846 (only compare ambiguity item that have hard error)
 - rust-lang#121961 (add test for rust-lang#78894 rust-lang#71450)
 - rust-lang#121975 (hir_analysis: enums return `None` in `find_field`)
 - rust-lang#121978 (Fix duplicated path in the "not found dylib" error)
 - rust-lang#121991 (Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 5cdf870 Mar 6, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 6, 2024
Rollup merge of rust-lang#121961 - surechen:add_test_20240304, r=petrochenkov

add test for rust-lang#78894 rust-lang#71450

fixes rust-lang#78894
fixes rust-lang#71450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. E-help-wanted Call for participation: Help is requested to fix this issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants