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

OR_PATTERNS_BACK_COMPAT lint ignores crate boundaries #86567

Closed
digama0 opened this issue Jun 23, 2021 · 7 comments · Fixed by #86574
Closed

OR_PATTERNS_BACK_COMPAT lint ignores crate boundaries #86567

digama0 opened this issue Jun 23, 2021 · 7 comments · Fixed by #86574
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@digama0
Copy link
Contributor

digama0 commented Jun 23, 2021

Code in main crate:

#![warn(or_patterns_back_compat)]
#[macro_use] extern crate bar;
fn main() { foo!(_|); }

Crate bar:

#[macro_export] macro_rules! foo { ($x:pat|) => {} }

Result:

$ cargo check
    Checking bar v0.1.0 (/bar)
    Checking test v0.1.0 (/test)
warning: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
 --> /bar/src/lib.rs:1:37
  |
1 | #[macro_export] macro_rules! foo { ($x:pat|) => {} }
  |                                     ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
  |
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![warn(or_patterns_back_compat)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
  = note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869>

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.19s

This lint should be suppressed, because it originates in another crate.

  • rustc --version: rustc 1.55.0-nightly (6a758ea7e 2021-06-22)
@digama0 digama0 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 23, 2021
@inquisitivecrystal
Copy link
Contributor

I'm going to take a look and see if I can figure this out.

@rustbot label +A-macros +C-bug
@rustbot claim

@rustbot rustbot added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. labels Jun 23, 2021
@m-ou-se
Copy link
Member

m-ou-se commented Jun 23, 2021

This is probably something to be fixed as part of #86330. @rylev said he'll look into it.

@m-ou-se
Copy link
Member

m-ou-se commented Jun 23, 2021

Looks like this is unrelated to the future incompatibility lint mechanism, but a bug with the or pattern lint specifically. It seems to trigger not only on the macro_rules definition, but also when such a definition is used.

@m-ou-se
Copy link
Member

m-ou-se commented Jun 23, 2021

That seems somewhat related to #85709. Though that PR doesn't fix it.

@rylev
Copy link
Member

rylev commented Jun 23, 2021

@inquisitivecrystal I'm going to take a look into this as part of #86330. Let me know if you've already started looking into this.

@m-ou-se
Copy link
Member

m-ou-se commented Jun 23, 2021

This is fixed by #86574

@inquisitivecrystal
Copy link
Contributor

inquisitivecrystal commented Jun 23, 2021

I thought the problem was that the lint was being passed the wrong NodeId. That would make it pretty separate from anything else, though it might make sense to deal with it in #86574, which is touching a lot of the same code anyway. I was pretty close to a draft implementation last night, though I hadn't actually reached the point of testing that it works, so I could well have been totally wrong about where the problem was. If someone else is rewriting the same code, it doesn't really make sense for me to finish my implementation.

@inquisitivecrystal inquisitivecrystal removed their assignment Jun 23, 2021
@bors bors closed this as completed in 079aa83 Jun 25, 2021
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. 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