Description
What happened
This code fails to compile:
#![deny(rust_2018_idioms)]
mod blah {
#![allow(rust_2018_idioms)]
struct Thing<'a>(&'a i32);
struct Bar<T>(T);
fn foo(b: Bar<Thing>) {}
}
with the error:
error: hidden lifetime parameters in types are deprecated
--> src/lib.rs:10:19
|
10 | fn foo(b: Bar<Thing>) {}
| ^^^^^- help: indicate the anonymous lifetime: `<'_>`
|
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![deny(rust_2018_idioms)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(elided_lifetimes_in_paths)]` implied by `#[deny(rust_2018_idioms)]`
and I expected the inner allow
to override the outer deny
.
Variations
What's weird is that this code, with unused_variables
instead of rust_2018_idioms
, compiles (with other warnings) as I expect:
#![deny(unused_variables)]
mod blah {
#![allow(unused_variables)]
struct Thing<'a>(&'a i32);
struct Bar<T>(T);
fn foo(b: Bar<Thing>) {}
}
(and removing the allow
causes it to not compile as I would expect)
AND this code compiles (with other warnings) as I expect:
#![deny(rust_2018_idioms)]
mod blah {
#![allow(rust_2018_idioms)]
extern crate rand;
use rand::Rng;
}
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:
#![deny(rust_2018_idioms)]
mod blah {
#![allow(elided_lifetimes_in_paths)]
struct Thing<'a>(&'a i32);
struct Bar<T>(T);
fn foo(b: Bar<Thing>) {}
}
This I would also expect to compile but does not:
#![deny(elided_lifetimes_in_paths)]
mod blah {
#![allow(elided_lifetimes_in_paths)]
struct Thing<'a>(&'a i32);
struct Bar<T>(T);
fn foo(b: Bar<Thing>) {}
}
I started thinking maybe it had something to do with allow-by-default lints, but this compiles as I would expect:
#![deny(missing_docs)]
//! hi
/// Hi
pub mod blah {
#![allow(missing_docs)]
pub struct Foo {
pub field: i32,
}
}
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.