Fix checking of auto trait bounds in trait objects.
Any auto trait is allowed in trait object bounds. Fix duplicate check of type and lifetime parameter count.
This commit is contained in:
parent
d762b1d6c6
commit
f46f388cb2
7 changed files with 16 additions and 30 deletions
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
fn main() {
|
||||
let _: Box<std::io::Read + std::io::Write>;
|
||||
//~^ ERROR only Send/Sync traits can be used as additional traits in a trait object [E0225]
|
||||
//~| NOTE non-Send/Sync additional trait
|
||||
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
|
||||
//~| NOTE non-auto additional trait
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ trait Trait {}
|
|||
|
||||
pub fn main() {
|
||||
let x: Vec<Trait + Sized> = Vec::new();
|
||||
//~^ ERROR only Send/Sync traits can be used as additional traits in a trait object
|
||||
//~^ ERROR only auto traits can be used as additional traits in a trait object
|
||||
//~| ERROR the trait bound `Trait: std::marker::Sized` is not satisfied
|
||||
//~| ERROR the trait bound `Trait: std::marker::Sized` is not satisfied
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ type Test = Add +
|
|||
//~| NOTE missing reference to `RHS`
|
||||
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types
|
||||
//~| ERROR E0225
|
||||
//~| NOTE non-Send/Sync additional trait
|
||||
//~| NOTE non-auto additional trait
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ fn size_of_copy<T: Copy+?Sized>() -> usize { mem::size_of::<T>() }
|
|||
|
||||
fn main() {
|
||||
size_of_copy::<Misc+Copy>();
|
||||
//~^ ERROR only Send/Sync traits can be used as additional traits in a trait object
|
||||
//~^ ERROR only auto traits can be used as additional traits in a trait object
|
||||
//~| ERROR the trait bound `Misc: std::marker::Copy` is not satisfied
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,7 @@ fn main() {
|
|||
take_auto(AutoBool(true));
|
||||
take_auto_unsafe(0);
|
||||
take_auto_unsafe(AutoBool(true));
|
||||
|
||||
/// Auto traits are allowed in trait object bounds.
|
||||
let _: &(Send + Auto) = &0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue