parent
95e5605108
commit
d2b8e6090c
7 changed files with 44 additions and 8 deletions
|
|
@ -1696,14 +1696,14 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
let (pred, item_def_id, span) = match (obligation.predicate.kind(), &obligation.cause.code)
|
||||
{
|
||||
(
|
||||
ty::PredicateKind::Trait(pred, _),
|
||||
ObligationCauseCode::BindingObligation(item_def_id, span),
|
||||
) => (pred, item_def_id, span),
|
||||
_ => return,
|
||||
};
|
||||
let (pred, item_def_id, span) =
|
||||
match (obligation.predicate.kind(), &obligation.cause.code.peel_derives()) {
|
||||
(
|
||||
ty::PredicateKind::Trait(pred, _),
|
||||
ObligationCauseCode::BindingObligation(item_def_id, span),
|
||||
) => (pred, item_def_id, span),
|
||||
_ => return,
|
||||
};
|
||||
|
||||
let node = match (
|
||||
self.tcx.hir().get_if_local(*item_def_id),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ LL | impl Foo<[isize]> for usize { }
|
|||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `[isize]`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | trait Foo<T: ?Sized> : Sized { fn take(self, x: &T) { } } // Note: T is sized
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `[usize]` cannot be known at compilation time
|
||||
--> $DIR/dst-sized-trait-param.rs:10:6
|
||||
|
|
|
|||
12
src/test/ui/extern/extern-types-unsized.stderr
vendored
12
src/test/ui/extern/extern-types-unsized.stderr
vendored
|
|
@ -26,6 +26,10 @@ LL | assert_sized::<Foo>();
|
|||
= help: within `Foo`, the trait `std::marker::Sized` is not implemented for `A`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: required because it appears within the type `Foo`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn assert_sized<T: ?Sized>() { }
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `A` cannot be known at compilation time
|
||||
--> $DIR/extern-types-unsized.rs:28:5
|
||||
|
|
@ -39,6 +43,10 @@ LL | assert_sized::<Bar<A>>();
|
|||
= help: within `Bar<A>`, the trait `std::marker::Sized` is not implemented for `A`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: required because it appears within the type `Bar<A>`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn assert_sized<T: ?Sized>() { }
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `A` cannot be known at compilation time
|
||||
--> $DIR/extern-types-unsized.rs:31:5
|
||||
|
|
@ -53,6 +61,10 @@ LL | assert_sized::<Bar<Bar<A>>>();
|
|||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: required because it appears within the type `Bar<A>`
|
||||
= note: required because it appears within the type `Bar<Bar<A>>`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn assert_sized<T: ?Sized>() { }
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ LL | impl<'self> Serializable<str> for &'self str {
|
|||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `str`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | trait Serializable<'self, T: ?Sized> {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ LL | impl<X: ?Sized> T2<X> for S4<X> {
|
|||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `X`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | trait T2<Z: ?Sized> {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ LL | f5(x1);
|
|||
= help: within `S<X>`, the trait `std::marker::Sized` is not implemented for `X`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: required because it appears within the type `S<X>`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn f5<Y: ?Sized>(x: &Y) {}
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `X` cannot be known at compilation time
|
||||
--> $DIR/unsized3.rs:40:8
|
||||
|
|
@ -91,6 +95,10 @@ LL | f5(&(32, *x1));
|
|||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: required because it appears within the type `S<X>`
|
||||
= note: required because it appears within the type `({integer}, S<X>)`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn f5<Y: ?Sized>(x: &Y) {}
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ LL | impl<X: ?Sized + T> T1<X> for S3<X> {
|
|||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `X`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | trait T1<Z: T + ?Sized> {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue