Annotate static lifetimes too
This commit is contained in:
parent
c0cda2b278
commit
c5df620419
@ -983,15 +983,9 @@ pub trait PrettyPrinter<'tcx>:
|
||||
write!(self, "Sized")?;
|
||||
}
|
||||
|
||||
if let [re] = lifetimes.as_slice()
|
||||
&& re.is_static()
|
||||
{
|
||||
// Don't print a single static lifetime
|
||||
} else {
|
||||
for re in lifetimes {
|
||||
write!(self, " + ")?;
|
||||
self = self.print_region(re)?;
|
||||
}
|
||||
for re in lifetimes {
|
||||
write!(self, " + ")?;
|
||||
self = self.print_region(re)?;
|
||||
}
|
||||
|
||||
Ok(self)
|
||||
|
@ -16,7 +16,7 @@ enum E2 { V(Box<dyn Iterator<Item: Copy>>) }
|
||||
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
|
||||
enum E3 { V(dyn Iterator<Item: 'static>) }
|
||||
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
|
||||
//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)`
|
||||
//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
|
||||
|
||||
union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> }
|
||||
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
|
||||
@ -25,6 +25,6 @@ union U2 { f: ManuallyDrop<Box<dyn Iterator<Item: Copy>>> }
|
||||
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
|
||||
union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> }
|
||||
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
|
||||
//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)`
|
||||
//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
|
||||
|
||||
fn main() {}
|
||||
|
@ -70,13 +70,13 @@ help: the `Box` type always has a statically known size and allocates its conten
|
||||
LL | enum E1 { V(Box<dyn Iterator<Item: Copy>>) }
|
||||
| ++++ +
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)` cannot be known at compilation time
|
||||
error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)` cannot be known at compilation time
|
||||
--> $DIR/inside-adt.rs:17:13
|
||||
|
|
||||
LL | enum E3 { V(dyn Iterator<Item: 'static>) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized> + 'static)`
|
||||
= help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
|
||||
= note: no field of an enum variant may have a dynamically sized type
|
||||
= help: change the field's type to have a statically known size
|
||||
help: borrowed types always have a statically known size
|
||||
@ -107,14 +107,14 @@ help: the `Box` type always has a statically known size and allocates its conten
|
||||
LL | union U1 { f: Box<ManuallyDrop<dyn Iterator<Item: Copy>>> }
|
||||
| ++++ +
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)` cannot be known at compilation time
|
||||
error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)` cannot be known at compilation time
|
||||
--> $DIR/inside-adt.rs:26:15
|
||||
|
|
||||
LL | union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: within `ManuallyDrop<(dyn Iterator<Item = impl Sized> + 'static)>`, the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized> + 'static)`
|
||||
= note: required because it appears within the type `ManuallyDrop<(dyn Iterator<Item = impl Sized> + 'static)>`
|
||||
= help: within `ManuallyDrop<(dyn Iterator<Item = impl Sized + 'static> + 'static)>`, the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
|
||||
= note: required because it appears within the type `ManuallyDrop<(dyn Iterator<Item = impl Sized + 'static> + 'static)>`
|
||||
= note: no field of a union may have a dynamically sized type
|
||||
= help: change the field's type to have a statically known size
|
||||
help: borrowed types always have a statically known size
|
||||
|
@ -77,10 +77,10 @@ where
|
||||
|
||||
fn main() {
|
||||
accepts_trait(returns_opaque());
|
||||
//~^ ERROR type mismatch resolving `<impl Trait as Trait>::Associated == ()`
|
||||
//~^ ERROR type mismatch resolving `<impl Trait + 'static as Trait>::Associated == ()`
|
||||
|
||||
accepts_trait(returns_opaque_derived());
|
||||
//~^ ERROR type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()`
|
||||
//~^ ERROR type mismatch resolving `<impl DerivedTrait + 'static as Trait>::Associated == ()`
|
||||
|
||||
accepts_trait(returns_opaque_foo());
|
||||
//~^ ERROR type mismatch resolving `<impl Trait + Foo as Trait>::Associated == ()`
|
||||
@ -89,7 +89,7 @@ fn main() {
|
||||
//~^ ERROR type mismatch resolving `<impl DerivedTrait + Foo as Trait>::Associated == ()`
|
||||
|
||||
accepts_generic_trait(returns_opaque_generic());
|
||||
//~^ ERROR type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()`
|
||||
//~^ ERROR type mismatch resolving `<impl GenericTrait<()> + 'static as GenericTrait<()>>::Associated == ()`
|
||||
|
||||
accepts_generic_trait(returns_opaque_generic_foo());
|
||||
//~^ ERROR type mismatch resolving `<impl GenericTrait<()> + Foo as GenericTrait<()>>::Associated == ()`
|
||||
|
@ -132,7 +132,7 @@ note: required by a bound in `accepts_generic_trait`
|
||||
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `accepts_generic_trait`
|
||||
|
||||
error[E0271]: type mismatch resolving `<impl Trait as Trait>::Associated == ()`
|
||||
error[E0271]: type mismatch resolving `<impl Trait + 'static as Trait>::Associated == ()`
|
||||
--> $DIR/issue-87261.rs:79:19
|
||||
|
|
||||
LL | fn returns_opaque() -> impl Trait + 'static {
|
||||
@ -144,18 +144,18 @@ LL | accepts_trait(returns_opaque());
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found associated type `<impl Trait as Trait>::Associated`
|
||||
found associated type `<impl Trait + 'static as Trait>::Associated`
|
||||
note: required by a bound in `accepts_trait`
|
||||
--> $DIR/issue-87261.rs:43:27
|
||||
|
|
||||
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `accepts_trait`
|
||||
help: consider constraining the associated type `<impl Trait as Trait>::Associated` to `()`
|
||||
help: consider constraining the associated type `<impl Trait + 'static as Trait>::Associated` to `()`
|
||||
|
|
||||
LL | fn returns_opaque() -> impl Trait<Associated = ()> + 'static {
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0271]: type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()`
|
||||
error[E0271]: type mismatch resolving `<impl DerivedTrait + 'static as Trait>::Associated == ()`
|
||||
--> $DIR/issue-87261.rs:82:19
|
||||
|
|
||||
LL | fn returns_opaque_derived() -> impl DerivedTrait + 'static {
|
||||
@ -167,13 +167,13 @@ LL | accepts_trait(returns_opaque_derived());
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found associated type `<impl DerivedTrait as Trait>::Associated`
|
||||
found associated type `<impl DerivedTrait + 'static as Trait>::Associated`
|
||||
note: required by a bound in `accepts_trait`
|
||||
--> $DIR/issue-87261.rs:43:27
|
||||
|
|
||||
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `accepts_trait`
|
||||
help: consider constraining the associated type `<impl DerivedTrait as Trait>::Associated` to `()`
|
||||
help: consider constraining the associated type `<impl DerivedTrait + 'static as Trait>::Associated` to `()`
|
||||
|
|
||||
LL | fn returns_opaque_derived() -> impl DerivedTrait<Associated = ()> + 'static {
|
||||
| +++++++++++++++++
|
||||
@ -222,7 +222,7 @@ note: required by a bound in `accepts_trait`
|
||||
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `accepts_trait`
|
||||
|
||||
error[E0271]: type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()`
|
||||
error[E0271]: type mismatch resolving `<impl GenericTrait<()> + 'static as GenericTrait<()>>::Associated == ()`
|
||||
--> $DIR/issue-87261.rs:91:27
|
||||
|
|
||||
LL | fn returns_opaque_generic() -> impl GenericTrait<()> + 'static {
|
||||
@ -234,13 +234,13 @@ LL | accepts_generic_trait(returns_opaque_generic());
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found associated type `<impl GenericTrait<()> as GenericTrait<()>>::Associated`
|
||||
found associated type `<impl GenericTrait<()> + 'static as GenericTrait<()>>::Associated`
|
||||
note: required by a bound in `accepts_generic_trait`
|
||||
--> $DIR/issue-87261.rs:44:46
|
||||
|
|
||||
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `accepts_generic_trait`
|
||||
help: consider constraining the associated type `<impl GenericTrait<()> as GenericTrait<()>>::Associated` to `()`
|
||||
help: consider constraining the associated type `<impl GenericTrait<()> + 'static as GenericTrait<()>>::Associated` to `()`
|
||||
|
|
||||
LL | fn returns_opaque_generic() -> impl GenericTrait<(), Associated = ()> + 'static {
|
||||
| +++++++++++++++++
|
||||
|
Loading…
x
Reference in New Issue
Block a user