Incorrect dyn addition for `Trait + 'a` (Rust 2015)
ksqsf opened this issue · 1 comments
ksqsf commented
#![allow(unused)]
mod sub {
pub trait Trait {}
}
struct T;
impl ::sub::Trait for T {}
fn main() {
use ::std::sync::Arc;
let p : Arc<::sub::Trait + 'static>;
}
In the code above, rustfix cannot figure out how to add dyn
with parentheses, complaining:
The following errors were reported:
error[E0433]: failed to resolve: use of undeclared type or module `dyn`
--> src/lib.rs:12:17
|
12 | let p : Arc<dyn ::sub::Trait + 'static>;
| ^^^ use of undeclared type or module `dyn`
warning: trait objects without an explicit `dyn` are deprecated
--> src/lib.rs:12:17
|
12 | let p : Arc<dyn ::sub::Trait + 'static>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn dyn ::sub::Trait + 'static`
|
= note: `#[warn(bare_trait_objects)]` on by default
When used with --broken-code
enabled, it simply adds a dyn
without parentheses, effectively breaking the code.
ehuss commented
Thanks for the report! This is a known issue tracked in rust-lang/rust#63330.