-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Can't allow elided_lifetimes_in_paths
inside a module that denies rust_2018_idioms
, other lints work
#71957
Comments
I think the issue is that |
Oh that's... unexpected and undocumented... |
I agree; that line does look suspicious! (I've self-assigned this because while I've been out of the compiler-development game for a while, and probably still won't be available for a some weeks yet, I wrote the modern form of this lint and should hope to help fix any bugs in it as part of its promotion to a 2021 lint.) |
It turns out that thanks to #73300, there's at least a "ignored unless specified at crate level" lint on the attribute, but that's still not ideal. I don't think there's a good reason for elided-lifetimes-in-paths to need to be at the crate level; I think it just turned out that way because of my incompetence in #52069. Guided by intuition rather than understanding, I tried this diff: diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs
index 6afed35..d43a034 100644
--- a/compiler/rustc_ast_lowering/src/path.rs
+++ b/compiler/rustc_ast_lowering/src/path.rs
@@ -322,7 +322,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
AnonymousLifetimeMode::PassThrough | AnonymousLifetimeMode::ReportError => {
self.resolver.lint_buffer().buffer_lint_with_diagnostic(
ELIDED_LIFETIMES_IN_PATHS,
- CRATE_NODE_ID,
+ segment.id,
path_span,
"hidden lifetime parameters in types are deprecated",
BuiltinLintDiagnostics::ElidedLifetimesInPaths( But that doesn't work; we can't build the standard library:
Maybe there's some way to not buffer the lint when we're inside a macro? (I remember there being something like this, but I've been out of the compiler game for a year and a half and forgot where to find everything.) |
I ... don't think I know what I'm doing here. 😿 This diff (trying to ignore macro code, inspired by the diff in my previous comment failing inside a Derive macro) diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs
index 6afed35..82825c6 100644
--- a/compiler/rustc_ast_lowering/src/path.rs
+++ b/compiler/rustc_ast_lowering/src/path.rs
@@ -320,9 +320,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
err.emit();
}
AnonymousLifetimeMode::PassThrough | AnonymousLifetimeMode::ReportError => {
+ if path_span.ctxt().outer_expn_data().is_root() {
self.resolver.lint_buffer().buffer_lint_with_diagnostic(
ELIDED_LIFETIMES_IN_PATHS,
- CRATE_NODE_ID,
+ segment.id,
path_span,
"hidden lifetime parameters in types are deprecated",
BuiltinLintDiagnostics::ElidedLifetimesInPaths(
@@ -337,6 +338,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
}
+ }
let res = self.expect_full_res(segment.id); hits a similar failure:
|
Note that the opposite may also be desirable: some macros may want to spot the elided lifetimes present in a given type, and without type-level information, it is impossible to guess how many lifetime parameters does a given But given the fact the crate is only allowed to be used at the top-level of the crate, this is not possible yet.
|
What happened
This code fails to compile:
with the error:
and I expected the inner
allow
to override the outerdeny
.Variations
What's weird is that this code, with
unused_variables
instead ofrust_2018_idioms
, compiles (with other warnings) as I expect:(and removing the
allow
causes it to not compile as I would expect)AND this code compiles (with other warnings) as I expect:
so it seems to be something to do with
elided_lifetimes_in_paths
in particular...?I also tried this, which I would expect to compile but does not:
This I would also expect to compile but does not:
I started thinking maybe it had something to do with allow-by-default lints, but this compiles as I would expect:
Sooo I don't have any real guesses without compiler internals knowledge 🤷♀️
Related
It sounds related to this issue: #70819
but I decided to file a new issue because that one appears to be about the same "scope level" and I think I'm doing different scope levels? Please close if this is a dupe!
Versions
I'm using stable 1.43; I also confirmed that 1.42 and 1.41 have the same behavior so this is not a recent regression.
I also confirmed that beta 1.44.0-beta.2 and nightly 2020-05-05 f8d394e have the same behavior.
Why this matters
I'm trying to
include!
code generated by a build script from another crate that generates 2015 edition Rust, from within a crate where I'd like to enforce 2018 idioms.The text was updated successfully, but these errors were encountered: