about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-17 15:08:50 +0000
committerbors <bors@rust-lang.org>2025-06-17 15:08:50 +0000
commit86d0aef80403f095d8bbabf44d9fdecfcd45f076 (patch)
tree5188883db34cd10db6dc7fb22c9d62a801800b1b /tests/ui
parent55d436467c351b56253deeba209ae2553d1c243f (diff)
parenta31e1f12d9c0fa1b8f5d19aa989f0e2236de3bb8 (diff)
downloadrust-86d0aef80403f095d8bbabf44d9fdecfcd45f076.tar.gz
rust-86d0aef80403f095d8bbabf44d9fdecfcd45f076.zip
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Sized Hierarchy: Part I

This patch implements the non-const parts of rust-lang/rfcs#3729. It introduces two new traits to the standard library, `MetaSized` and `PointeeSized`. See the RFC for the rationale behind these traits and to discuss whether this change makes sense in the abstract.

These traits are unstable (as is their constness), so users cannot refer to them without opting-in to `feature(sized_hierarchy)`. These traits are not behind `cfg`s as this would make implementation unfeasible, there would simply be too many `cfg`s required to add the necessary bounds everywhere. So, like `Sized`, these traits are automatically implemented by the compiler.

RFC 3729 describes changes which are necessary to preserve backwards compatibility given the introduction of these traits, which are implemented and as follows:

- `?Sized` is rewritten as `MetaSized`
- `MetaSized` is added as a default supertrait for all traits w/out an explicit sizedness supertrait already.

There are no edition migrations implemented in this,  as these are primarily required for the constness parts of the RFC and prior to stabilisation of this (and so will come in follow-up PRs alongside the const parts). All diagnostic output should remain the same (showing `?Sized` even if the compiler sees `MetaSized`) unless the `sized_hierarchy` feature is enabled.

Due to the use of unstable extern types in the standard library and rustc, some bounds in both projects have had to be relaxed already - this is unfortunate but unavoidable so that these extern types can continue to be used where they were before. Performing these relaxations in the standard library and rustc are desirable longer-term anyway, but some bounds are not as relaxed as they ideally would be due to the inability to relax `Deref::Target` (this will be investigated separately).

It is hoped that this is implemented such that it could be merged and these traits could exist "under the hood" without that being observable to the user (other than in any performance impact this has on the compiler, etc). Some details might leak through due to the standard library relaxations, but this has not been observed in test output.

**Notes:**

- Any commits starting with "upstream:" can be ignored, as these correspond to other upstream PRs that this is based on which have yet to be merged.
- This best reviewed commit-by-commit. I've attempted to make the implementation easy to follow and keep similar changes and test output updates together.
  - Each commit has a short description describing its purpose.
  - This patch is large but it's primarily in the test suite.
- I've worked on the performance of this patch and a few optimisations are implemented so that the performance impact is neutral-to-minor.
- `PointeeSized` is a different name from the RFC just to make it more obvious that it is different from `std::ptr::Pointee` but all the names are yet to be bikeshed anyway.
- `@nikomatsakis` has confirmed [that this can proceed as an experiment from the t-lang side](https://rust-lang.zulipchat.com/#narrow/channel/435869-project-goals/topic/SVE.20and.20SME.20on.20AArch64.20.28goals.23270.29/near/506196491)
- FCP in https://github.com/rust-lang/rust/pull/137944#issuecomment-2912207485

Fixes rust-lang/rust#79409.

r? `@ghost` (I'll discuss this with relevant teams to find a reviewer)
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/abi/fixed_x18.rs6
-rw-r--r--tests/ui/abi/shadow-call-stack-without-fixed-x18.rs8
-rw-r--r--tests/ui/attributes/dump-preds.stderr2
-rw-r--r--tests/ui/attributes/export/lang-item.rs8
-rw-r--r--tests/ui/attributes/export/lang-item.stderr14
-rw-r--r--tests/ui/codegen/mismatched-data-layouts.rs8
-rw-r--r--tests/ui/const-generics/unused-type-param-suggestion.rs1
-rw-r--r--tests/ui/const-generics/unused-type-param-suggestion.stderr1
-rw-r--r--tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs6
-rw-r--r--tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr26
-rw-r--r--tests/ui/debuginfo/dwarf-versions.rs8
-rw-r--r--tests/ui/extern/extern-type-diag-not-similar.rs7
-rw-r--r--tests/ui/extern/extern-type-diag-not-similar.stderr6
-rw-r--r--tests/ui/extern/extern-types-manual-sync-send.rs8
-rw-r--r--tests/ui/extern/extern-types-not-sync-send.rs8
-rw-r--r--tests/ui/extern/extern-types-not-sync-send.stderr16
-rw-r--r--tests/ui/extern/extern-types-pointer-cast.rs5
-rw-r--r--tests/ui/extern/extern-types-size_of_val.rs16
-rw-r--r--tests/ui/extern/extern-types-size_of_val.stderr39
-rw-r--r--tests/ui/extern/extern-types-thin-pointer.rs7
-rw-r--r--tests/ui/extern/extern-types-trait-impl.rs9
-rw-r--r--tests/ui/extern/extern-types-unsized.rs2
-rw-r--r--tests/ui/extern/extern-types-unsized.stderr30
-rw-r--r--tests/ui/extern/unsized-extern-derefmove.rs13
-rw-r--r--tests/ui/extern/unsized-extern-derefmove.stderr52
-rw-r--r--tests/ui/feature-gates/feature-gate-sized-hierarchy.rs29
-rw-r--r--tests/ui/feature-gates/feature-gate-sized-hierarchy.stderr42
-rw-r--r--tests/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs8
-rw-r--r--tests/ui/lang-items/issue-83471.rs10
-rw-r--r--tests/ui/lang-items/issue-83471.stderr30
-rw-r--r--tests/ui/lang-items/issue-87573.rs8
-rw-r--r--tests/ui/lang-items/issue-87573.stderr4
-rw-r--r--tests/ui/lang-items/lang-item-generic-requirements.rs8
-rw-r--r--tests/ui/lang-items/lang-item-generic-requirements.stderr24
-rw-r--r--tests/ui/lang-items/missing-copy-lang-item-issue-19660.rs8
-rw-r--r--tests/ui/lang-items/missing-copy-lang-item-issue-19660.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argc.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argv.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_args.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_ret.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_ty.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_ret.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.rs6
-rw-r--r--tests/ui/lang-items/start_lang_item_args.sigpipe.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.start_ret.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_args.too_many_args.stderr2
-rw-r--r--tests/ui/lang-items/start_lang_item_with_target_feature.rs9
-rw-r--r--tests/ui/lang-items/start_lang_item_with_target_feature.stderr2
-rw-r--r--tests/ui/layout/unconstrained-param-ice-137308.rs4
-rw-r--r--tests/ui/layout/unconstrained-param-ice-137308.stderr11
-rw-r--r--tests/ui/nll/issue-50716.rs3
-rw-r--r--tests/ui/nll/issue-50716.stderr20
-rw-r--r--tests/ui/offset-of/offset-of-dst-field.rs5
-rw-r--r--tests/ui/offset-of/offset-of-dst-field.stderr20
-rw-r--r--tests/ui/panic-handler/panic-handler-requires-panic-info.rs8
-rw-r--r--tests/ui/privacy/privacy1.rs10
-rw-r--r--tests/ui/privacy/privacy1.stderr62
-rw-r--r--tests/ui/privacy/privacy4.rs4
-rw-r--r--tests/ui/privacy/privacy4.stderr4
-rw-r--r--tests/ui/sized-hierarchy/alias-bounds.rs28
-rw-r--r--tests/ui/sized-hierarchy/auxiliary/pretty-print-dep.rs19
-rw-r--r--tests/ui/sized-hierarchy/auxiliary/pretty-print-no-feat-dep.rs7
-rw-r--r--tests/ui/sized-hierarchy/default-bound.rs49
-rw-r--r--tests/ui/sized-hierarchy/default-bound.stderr88
-rw-r--r--tests/ui/sized-hierarchy/default-supertrait.rs61
-rw-r--r--tests/ui/sized-hierarchy/default-supertrait.stderr125
-rw-r--r--tests/ui/sized-hierarchy/elaboration-opt-regions-1.rs18
-rw-r--r--tests/ui/sized-hierarchy/elaboration-opt-regions.rs18
-rw-r--r--tests/ui/sized-hierarchy/extern-type-behind-ptr.rs20
-rw-r--r--tests/ui/sized-hierarchy/impls.rs310
-rw-r--r--tests/ui/sized-hierarchy/impls.stderr394
-rw-r--r--tests/ui/sized-hierarchy/overflow.current.stderr45
-rw-r--r--tests/ui/sized-hierarchy/overflow.rs21
-rw-r--r--tests/ui/sized-hierarchy/pointee-supertrait.rs28
-rw-r--r--tests/ui/sized-hierarchy/pretty-print-no-feat-dep-has-feat.rs26
-rw-r--r--tests/ui/sized-hierarchy/pretty-print-no-feat-dep-has-feat.stderr42
-rw-r--r--tests/ui/sized-hierarchy/pretty-print-no-feat.rs19
-rw-r--r--tests/ui/sized-hierarchy/pretty-print-no-feat.stderr22
-rw-r--r--tests/ui/sized-hierarchy/pretty-print-opaque-no-feat.rs13
-rw-r--r--tests/ui/sized-hierarchy/pretty-print-opaque-no-feat.stderr12
-rw-r--r--tests/ui/sized-hierarchy/pretty-print-opaque.rs45
-rw-r--r--tests/ui/sized-hierarchy/pretty-print-opaque.stderr59
-rw-r--r--tests/ui/sized-hierarchy/pretty-print.rs28
-rw-r--r--tests/ui/sized-hierarchy/pretty-print.stderr43
-rw-r--r--tests/ui/sized-hierarchy/trait-aliases.rs9
-rw-r--r--tests/ui/stack-protector/warn-stack-protector-unsupported.rs9
-rw-r--r--tests/ui/symbol-names/foreign-types.rs5
-rw-r--r--tests/ui/symbol-names/foreign-types.stderr6
-rw-r--r--tests/ui/target-cpu/explicit-target-cpu.rs6
-rw-r--r--tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.rs8
-rw-r--r--tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.stderr4
-rw-r--r--tests/ui/target-feature/abi-incompatible-target-feature-attribute.riscv.stderr2
-rw-r--r--tests/ui/target-feature/abi-incompatible-target-feature-attribute.rs6
-rw-r--r--tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr2
-rw-r--r--tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs6
-rw-r--r--tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.rs8
-rw-r--r--tests/ui/target-feature/abi-required-target-feature-attribute.rs8
-rw-r--r--tests/ui/target-feature/abi-required-target-feature-flag-disable.rs6
-rw-r--r--tests/ui/target-feature/feature-hierarchy.rs10
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs8
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr2
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs6
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr2
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-cfg.rs20
-rw-r--r--tests/ui/target-feature/forbidden-target-feature-attribute.rs8
-rw-r--r--tests/ui/target-feature/forbidden-target-feature-attribute.stderr2
-rw-r--r--tests/ui/target-feature/forbidden-target-feature-cfg.rs8
-rw-r--r--tests/ui/target-feature/forbidden-target-feature-flag-disable.rs8
-rw-r--r--tests/ui/target-feature/forbidden-target-feature-flag.rs8
-rw-r--r--tests/ui/target-feature/target-cpu-lacks-required-target-feature.rs8
-rw-r--r--tests/ui/target-feature/tied-features-cli.rs10
-rw-r--r--tests/ui/target-feature/tied-features-no-implication-1.rs10
-rw-r--r--tests/ui/target-feature/tied-features-no-implication.pacg.stderr2
-rw-r--r--tests/ui/target-feature/tied-features-no-implication.rs10
-rw-r--r--tests/ui/traits/cache-reached-depth-ice.rs5
-rw-r--r--tests/ui/traits/cache-reached-depth-ice.stderr6
-rw-r--r--tests/ui/traits/const-traits/auxiliary/minicore.rs59
-rw-r--r--tests/ui/traits/default_auto_traits/backward-compatible-lazy-bounds-pass.rs8
-rw-r--r--tests/ui/traits/default_auto_traits/default-bounds.rs8
-rw-r--r--tests/ui/traits/default_auto_traits/default-bounds.stderr8
-rw-r--r--tests/ui/traits/default_auto_traits/extern-types.current.stderr6
-rw-r--r--tests/ui/traits/default_auto_traits/extern-types.next.stderr6
-rw-r--r--tests/ui/traits/default_auto_traits/extern-types.rs10
-rw-r--r--tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.rs8
-rw-r--r--tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.stderr6
-rw-r--r--tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.rs8
-rw-r--r--tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr18
-rw-r--r--tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.current.stderr20
-rw-r--r--tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.next.stderr18
-rw-r--r--tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.rs2
-rw-r--r--tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr7
-rw-r--r--tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr19
-rw-r--r--tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr16
-rw-r--r--tests/ui/traits/non_lifetime_binders/basic.rs7
-rw-r--r--tests/ui/traits/non_lifetime_binders/basic.stderr2
-rw-r--r--tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.rs7
-rw-r--r--tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.stderr20
-rw-r--r--tests/ui/traits/non_lifetime_binders/on-rpit.rs7
-rw-r--r--tests/ui/traits/non_lifetime_binders/on-rpit.stderr2
-rw-r--r--tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs9
-rw-r--r--tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr6
-rw-r--r--tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr2
-rw-r--r--tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr2
-rw-r--r--tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs13
-rw-r--r--tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr2
-rw-r--r--tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr2
-rw-r--r--tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs9
-rw-r--r--tests/ui/traits/non_lifetime_binders/universe-error1.rs9
-rw-r--r--tests/ui/traits/non_lifetime_binders/universe-error1.stderr8
-rw-r--r--tests/ui/traits/resolve-impl-before-constrain-check.rs1
-rw-r--r--tests/ui/traits/resolve-impl-before-constrain-check.stderr11
-rw-r--r--tests/ui/traits/unconstrained-projection-normalization-2.next.stderr11
-rw-r--r--tests/ui/traits/unconstrained-projection-normalization-2.rs1
156 files changed, 2456 insertions, 331 deletions
diff --git a/tests/ui/abi/fixed_x18.rs b/tests/ui/abi/fixed_x18.rs
index d64b845e5bd..09d16303033 100644
--- a/tests/ui/abi/fixed_x18.rs
+++ b/tests/ui/abi/fixed_x18.rs
@@ -20,7 +20,11 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+trait PointeeSized {}
+#[lang = "meta_sized"]
+trait MetaSized: PointeeSized {}
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
 
 //~? ERROR the `-Zfixed-x18` flag is not supported on the `
diff --git a/tests/ui/abi/shadow-call-stack-without-fixed-x18.rs b/tests/ui/abi/shadow-call-stack-without-fixed-x18.rs
index 74882fb5c55..b3bd0666ab2 100644
--- a/tests/ui/abi/shadow-call-stack-without-fixed-x18.rs
+++ b/tests/ui/abi/shadow-call-stack-without-fixed-x18.rs
@@ -7,8 +7,14 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+trait PointeeSized {}
+
+#[lang = "meta_sized"]
+trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
 
 #[no_mangle]
 pub fn foo() {}
diff --git a/tests/ui/attributes/dump-preds.stderr b/tests/ui/attributes/dump-preds.stderr
index bdfcbed71e9..99139761d7c 100644
--- a/tests/ui/attributes/dump-preds.stderr
+++ b/tests/ui/attributes/dump-preds.stderr
@@ -4,6 +4,7 @@ error: rustc_dump_predicates
 LL | trait Trait<T>: Iterator<Item: Copy>
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
+   = note: Binder { value: TraitPredicate(<Self as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }
    = note: Binder { value: TraitPredicate(<Self as std::iter::Iterator>, polarity:Positive), bound_vars: [] }
    = note: Binder { value: TraitPredicate(<<Self as std::iter::Iterator>::Item as std::marker::Copy>, polarity:Positive), bound_vars: [] }
    = note: Binder { value: TraitPredicate(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }
@@ -16,6 +17,7 @@ error: rustc_dump_predicates
 LL |     type Assoc<P: Eq>: std::ops::Deref<Target = ()>
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
+   = note: Binder { value: TraitPredicate(<Self as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }
    = note: Binder { value: TraitPredicate(<Self as std::iter::Iterator>, polarity:Positive), bound_vars: [] }
    = note: Binder { value: TraitPredicate(<<Self as std::iter::Iterator>::Item as std::marker::Copy>, polarity:Positive), bound_vars: [] }
    = note: Binder { value: TraitPredicate(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }
diff --git a/tests/ui/attributes/export/lang-item.rs b/tests/ui/attributes/export/lang-item.rs
index b923b41a957..92ca1d742e1 100644
--- a/tests/ui/attributes/export/lang-item.rs
+++ b/tests/ui/attributes/export/lang-item.rs
@@ -3,6 +3,14 @@
 #![crate_type = "sdylib"]
 #![no_core]
 
+#[lang = "pointee_sized"]
+//~^ ERROR lang items are not allowed in stable dylibs
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+//~^ ERROR lang items are not allowed in stable dylibs
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
 //~^ ERROR lang items are not allowed in stable dylibs
 trait Sized {}
diff --git a/tests/ui/attributes/export/lang-item.stderr b/tests/ui/attributes/export/lang-item.stderr
index 8c0741bdb6f..211c0b9b07b 100644
--- a/tests/ui/attributes/export/lang-item.stderr
+++ b/tests/ui/attributes/export/lang-item.stderr
@@ -1,8 +1,20 @@
 error: lang items are not allowed in stable dylibs
   --> $DIR/lang-item.rs:6:1
    |
+LL | #[lang = "pointee_sized"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: lang items are not allowed in stable dylibs
+  --> $DIR/lang-item.rs:10:1
+   |
+LL | #[lang = "meta_sized"]
+   | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: lang items are not allowed in stable dylibs
+  --> $DIR/lang-item.rs:14:1
+   |
 LL | #[lang = "sized"]
    | ^^^^^^^^^^^^^^^^^
 
-error: aborting due to 1 previous error
+error: aborting due to 3 previous errors
 
diff --git a/tests/ui/codegen/mismatched-data-layouts.rs b/tests/ui/codegen/mismatched-data-layouts.rs
index 194bcaa307f..6428b8c5247 100644
--- a/tests/ui/codegen/mismatched-data-layouts.rs
+++ b/tests/ui/codegen/mismatched-data-layouts.rs
@@ -9,7 +9,13 @@
 #![feature(lang_items, no_core, auto_traits)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+pub trait Sized: MetaSized {}
 
 //~? ERROR differs from LLVM target's
diff --git a/tests/ui/const-generics/unused-type-param-suggestion.rs b/tests/ui/const-generics/unused-type-param-suggestion.rs
index fb0ccb4fdcd..b8ae4f6b56b 100644
--- a/tests/ui/const-generics/unused-type-param-suggestion.rs
+++ b/tests/ui/const-generics/unused-type-param-suggestion.rs
@@ -25,3 +25,4 @@ type C<N: Sized> = ();
 type D<N: ?Sized> = ();
 //~^ ERROR type parameter `N` is never used
 //~| HELP consider removing `N`
+//~| HELP if you intended `N` to be a const parameter
diff --git a/tests/ui/const-generics/unused-type-param-suggestion.stderr b/tests/ui/const-generics/unused-type-param-suggestion.stderr
index 67b704d8bc7..a7aa477ab31 100644
--- a/tests/ui/const-generics/unused-type-param-suggestion.stderr
+++ b/tests/ui/const-generics/unused-type-param-suggestion.stderr
@@ -47,6 +47,7 @@ LL | type D<N: ?Sized> = ();
    |        ^ unused type parameter
    |
    = help: consider removing `N` or referring to it in the body of the type alias
+   = help: if you intended `N` to be a const parameter, use `const N: /* Type */` instead
 
 error: aborting due to 6 previous errors
 
diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs
index 423ff37baef..2372d1c3e3d 100644
--- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs
+++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs
@@ -7,7 +7,9 @@ extern "C" {
     type Opaque;
 }
 
-const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR layout
-const _ALIGN: usize = unsafe { align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR layout
+const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) };
+//~^ ERROR the size for values of type `Opaque` cannot be known
+const _ALIGN: usize = unsafe { align_of_val(&4 as *const i32 as *const Opaque) };
+//~^ ERROR the size for values of type `Opaque` cannot be known
 
 fn main() {}
diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr
index c78626bdefc..6d6bc157771 100644
--- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr
+++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr
@@ -1,15 +1,27 @@
-error[E0080]: `extern type` does not have known layout
-  --> $DIR/const-size_of_val-align_of_val-extern-type.rs:10:31
+error[E0277]: the size for values of type `Opaque` cannot be known
+  --> $DIR/const-size_of_val-align_of_val-extern-type.rs:10:43
    |
 LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) };
-   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_SIZE` failed here
+   |                               ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size
+   |                               |
+   |                               required by a bound introduced by this call
+   |
+   = help: the trait `MetaSized` is not implemented for `Opaque`
+note: required by a bound in `std::intrinsics::size_of_val`
+  --> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL
 
-error[E0080]: `extern type` does not have known layout
-  --> $DIR/const-size_of_val-align_of_val-extern-type.rs:11:32
+error[E0277]: the size for values of type `Opaque` cannot be known
+  --> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:45
    |
 LL | const _ALIGN: usize = unsafe { align_of_val(&4 as *const i32 as *const Opaque) };
-   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_ALIGN` failed here
+   |                                ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size
+   |                                |
+   |                                required by a bound introduced by this call
+   |
+   = help: the trait `MetaSized` is not implemented for `Opaque`
+note: required by a bound in `std::intrinsics::align_of_val`
+  --> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0080`.
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/debuginfo/dwarf-versions.rs b/tests/ui/debuginfo/dwarf-versions.rs
index 8f731f10ead..ccf33542960 100644
--- a/tests/ui/debuginfo/dwarf-versions.rs
+++ b/tests/ui/debuginfo/dwarf-versions.rs
@@ -29,8 +29,14 @@
 #![no_core]
 #![no_std]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 pub fn foo() {}
 
diff --git a/tests/ui/extern/extern-type-diag-not-similar.rs b/tests/ui/extern/extern-type-diag-not-similar.rs
index cd3eec9f1f7..21a2a20a644 100644
--- a/tests/ui/extern/extern-type-diag-not-similar.rs
+++ b/tests/ui/extern/extern-type-diag-not-similar.rs
@@ -3,7 +3,10 @@
 // Two extern types shouldn't really be considered similar just
 // because they are both extern types.
 
-#![feature(extern_types)]
+#![feature(extern_types, sized_hierarchy)]
+
+use std::marker::PointeeSized;
+
 extern "C" {
     type ShouldNotBeMentioned;
 }
@@ -14,7 +17,7 @@ extern "C" {
 
 unsafe impl Send for ShouldNotBeMentioned {}
 
-fn assert_send<T: Send + ?Sized>() {}
+fn assert_send<T: Send + PointeeSized>() {}
 
 fn main() {
     assert_send::<Foo>()
diff --git a/tests/ui/extern/extern-type-diag-not-similar.stderr b/tests/ui/extern/extern-type-diag-not-similar.stderr
index 3547f9b3ff6..f85ff1eead6 100644
--- a/tests/ui/extern/extern-type-diag-not-similar.stderr
+++ b/tests/ui/extern/extern-type-diag-not-similar.stderr
@@ -1,14 +1,14 @@
 error[E0277]: `Foo` cannot be sent between threads safely
-  --> $DIR/extern-type-diag-not-similar.rs:20:19
+  --> $DIR/extern-type-diag-not-similar.rs:23:19
    |
 LL |     assert_send::<Foo>()
    |                   ^^^ `Foo` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `Foo`
 note: required by a bound in `assert_send`
-  --> $DIR/extern-type-diag-not-similar.rs:17:19
+  --> $DIR/extern-type-diag-not-similar.rs:20:19
    |
-LL | fn assert_send<T: Send + ?Sized>() {}
+LL | fn assert_send<T: Send + PointeeSized>() {}
    |                   ^^^^ required by this bound in `assert_send`
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/extern/extern-types-manual-sync-send.rs b/tests/ui/extern/extern-types-manual-sync-send.rs
index 2df0cd4c923..b273dcea722 100644
--- a/tests/ui/extern/extern-types-manual-sync-send.rs
+++ b/tests/ui/extern/extern-types-manual-sync-send.rs
@@ -1,7 +1,9 @@
 //@ run-pass
 // Test that unsafe impl for Sync/Send can be provided for extern types.
 
-#![feature(extern_types)]
+#![feature(extern_types, sized_hierarchy)]
+
+use std::marker::PointeeSized;
 
 extern "C" {
     type A;
@@ -10,8 +12,8 @@ extern "C" {
 unsafe impl Sync for A {}
 unsafe impl Send for A {}
 
-fn assert_sync<T: ?Sized + Sync>() {}
-fn assert_send<T: ?Sized + Send>() {}
+fn assert_sync<T: PointeeSized + Sync>() {}
+fn assert_send<T: PointeeSized + Send>() {}
 
 fn main() {
     assert_sync::<A>();
diff --git a/tests/ui/extern/extern-types-not-sync-send.rs b/tests/ui/extern/extern-types-not-sync-send.rs
index ba82caced7a..3cac1aabea9 100644
--- a/tests/ui/extern/extern-types-not-sync-send.rs
+++ b/tests/ui/extern/extern-types-not-sync-send.rs
@@ -1,13 +1,15 @@
 // Make sure extern types are !Sync and !Send.
 
-#![feature(extern_types)]
+#![feature(extern_types, sized_hierarchy)]
+
+use std::marker::PointeeSized;
 
 extern "C" {
     type A;
 }
 
-fn assert_sync<T: ?Sized + Sync>() {}
-fn assert_send<T: ?Sized + Send>() {}
+fn assert_sync<T: PointeeSized + Sync>() {}
+fn assert_send<T: PointeeSized + Send>() {}
 
 fn main() {
     assert_sync::<A>();
diff --git a/tests/ui/extern/extern-types-not-sync-send.stderr b/tests/ui/extern/extern-types-not-sync-send.stderr
index 7865ddeda34..56bdd5be7cf 100644
--- a/tests/ui/extern/extern-types-not-sync-send.stderr
+++ b/tests/ui/extern/extern-types-not-sync-send.stderr
@@ -1,28 +1,28 @@
 error[E0277]: `A` cannot be shared between threads safely
-  --> $DIR/extern-types-not-sync-send.rs:13:19
+  --> $DIR/extern-types-not-sync-send.rs:15:19
    |
 LL |     assert_sync::<A>();
    |                   ^ `A` cannot be shared between threads safely
    |
    = help: the trait `Sync` is not implemented for `A`
 note: required by a bound in `assert_sync`
-  --> $DIR/extern-types-not-sync-send.rs:9:28
+  --> $DIR/extern-types-not-sync-send.rs:11:34
    |
-LL | fn assert_sync<T: ?Sized + Sync>() {}
-   |                            ^^^^ required by this bound in `assert_sync`
+LL | fn assert_sync<T: PointeeSized + Sync>() {}
+   |                                  ^^^^ required by this bound in `assert_sync`
 
 error[E0277]: `A` cannot be sent between threads safely
-  --> $DIR/extern-types-not-sync-send.rs:16:19
+  --> $DIR/extern-types-not-sync-send.rs:18:19
    |
 LL |     assert_send::<A>();
    |                   ^ `A` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `A`
 note: required by a bound in `assert_send`
-  --> $DIR/extern-types-not-sync-send.rs:10:28
+  --> $DIR/extern-types-not-sync-send.rs:12:34
    |
-LL | fn assert_send<T: ?Sized + Send>() {}
-   |                            ^^^^ required by this bound in `assert_send`
+LL | fn assert_send<T: PointeeSized + Send>() {}
+   |                                  ^^^^ required by this bound in `assert_send`
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/extern/extern-types-pointer-cast.rs b/tests/ui/extern/extern-types-pointer-cast.rs
index 78dbee77b9c..080ed91a632 100644
--- a/tests/ui/extern/extern-types-pointer-cast.rs
+++ b/tests/ui/extern/extern-types-pointer-cast.rs
@@ -2,7 +2,8 @@
 #![allow(dead_code)]
 // Test that pointers to extern types can be cast from/to usize,
 // despite being !Sized.
-#![feature(extern_types)]
+#![feature(extern_types, sized_hierarchy)]
+use std::marker::PointeeSized;
 
 extern "C" {
     type A;
@@ -13,7 +14,7 @@ struct Foo {
     tail: A,
 }
 
-struct Bar<T: ?Sized> {
+struct Bar<T: PointeeSized> {
     x: u8,
     tail: T,
 }
diff --git a/tests/ui/extern/extern-types-size_of_val.rs b/tests/ui/extern/extern-types-size_of_val.rs
index 399a5828ff3..3ff51b9b6b0 100644
--- a/tests/ui/extern/extern-types-size_of_val.rs
+++ b/tests/ui/extern/extern-types-size_of_val.rs
@@ -1,8 +1,4 @@
-//@ run-fail
-//@ check-run-results
-//@ exec-env:RUST_BACKTRACE=0
-//@ normalize-stderr: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL"
-//@ revisions: size align
+//@ check-fail
 #![feature(extern_types)]
 
 use std::mem::{align_of_val, size_of_val};
@@ -14,10 +10,8 @@ extern "C" {
 fn main() {
     let x: &A = unsafe { &*(1usize as *const A) };
 
-    // These don't have a dynamic size, so this should panic.
-    if cfg!(size) {
-        assert_eq!(size_of_val(x), 0);
-    } else {
-        assert_eq!(align_of_val(x), 1);
-    }
+    size_of_val(x);
+    //~^ ERROR the size for values of type `A` cannot be known
+    align_of_val(x);
+    //~^ ERROR the size for values of type `A` cannot be known
 }
diff --git a/tests/ui/extern/extern-types-size_of_val.stderr b/tests/ui/extern/extern-types-size_of_val.stderr
new file mode 100644
index 00000000000..8678c6c3d60
--- /dev/null
+++ b/tests/ui/extern/extern-types-size_of_val.stderr
@@ -0,0 +1,39 @@
+error[E0277]: the size for values of type `A` cannot be known
+  --> $DIR/extern-types-size_of_val.rs:13:17
+   |
+LL |     size_of_val(x);
+   |     ----------- ^ the trait `MetaSized` is not implemented for `A`
+   |     |
+   |     required by a bound introduced by this call
+   |
+   = note: the trait bound `A: MetaSized` is not satisfied
+note: required by a bound in `std::mem::size_of_val`
+  --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+help: consider borrowing here
+   |
+LL |     size_of_val(&x);
+   |                 +
+LL |     size_of_val(&mut x);
+   |                 ++++
+
+error[E0277]: the size for values of type `A` cannot be known
+  --> $DIR/extern-types-size_of_val.rs:15:18
+   |
+LL |     align_of_val(x);
+   |     ------------ ^ the trait `MetaSized` is not implemented for `A`
+   |     |
+   |     required by a bound introduced by this call
+   |
+   = note: the trait bound `A: MetaSized` is not satisfied
+note: required by a bound in `std::mem::align_of_val`
+  --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+help: consider borrowing here
+   |
+LL |     align_of_val(&x);
+   |                  +
+LL |     align_of_val(&mut x);
+   |                  ++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/extern/extern-types-thin-pointer.rs b/tests/ui/extern/extern-types-thin-pointer.rs
index 8e5911228b2..15777d456c2 100644
--- a/tests/ui/extern/extern-types-thin-pointer.rs
+++ b/tests/ui/extern/extern-types-thin-pointer.rs
@@ -2,8 +2,9 @@
 #![allow(dead_code)]
 // Test that pointers and references to extern types are thin, ie they have the same size and
 // alignment as a pointer to ().
-#![feature(extern_types)]
+#![feature(extern_types, sized_hierarchy)]
 
+use std::marker::PointeeSized;
 use std::mem::{align_of, size_of};
 
 extern "C" {
@@ -15,12 +16,12 @@ struct Foo {
     tail: A,
 }
 
-struct Bar<T: ?Sized> {
+struct Bar<T: PointeeSized> {
     x: u8,
     tail: T,
 }
 
-fn assert_thin<T: ?Sized>() {
+fn assert_thin<T: PointeeSized>() {
     assert_eq!(size_of::<*const T>(), size_of::<*const ()>());
     assert_eq!(align_of::<*const T>(), align_of::<*const ()>());
 
diff --git a/tests/ui/extern/extern-types-trait-impl.rs b/tests/ui/extern/extern-types-trait-impl.rs
index 44300b10514..07cb1efa801 100644
--- a/tests/ui/extern/extern-types-trait-impl.rs
+++ b/tests/ui/extern/extern-types-trait-impl.rs
@@ -1,13 +1,14 @@
 //@ run-pass
 #![allow(dead_code)]
 // Test that traits can be implemented for extern types.
-#![feature(extern_types)]
+#![feature(extern_types, sized_hierarchy)]
+use std::marker::PointeeSized;
 
 extern "C" {
     type A;
 }
 
-trait Foo {
+trait Foo: PointeeSized {
     fn foo(&self) {}
 }
 
@@ -15,9 +16,9 @@ impl Foo for A {
     fn foo(&self) {}
 }
 
-fn assert_foo<T: ?Sized + Foo>() {}
+fn assert_foo<T: PointeeSized + Foo>() {}
 
-fn use_foo<T: ?Sized + Foo>(x: &dyn Foo) {
+fn use_foo<T: PointeeSized + Foo>(x: &dyn Foo) {
     x.foo();
 }
 
diff --git a/tests/ui/extern/extern-types-unsized.rs b/tests/ui/extern/extern-types-unsized.rs
index 94a222a7e7e..46cdc24e083 100644
--- a/tests/ui/extern/extern-types-unsized.rs
+++ b/tests/ui/extern/extern-types-unsized.rs
@@ -27,7 +27,9 @@ fn main() {
 
     assert_sized::<Bar<A>>();
     //~^ ERROR the size for values of type
+    //~| ERROR the size for values of type
 
     assert_sized::<Bar<Bar<A>>>();
     //~^ ERROR the size for values of type
+    //~| ERROR the size for values of type
 }
diff --git a/tests/ui/extern/extern-types-unsized.stderr b/tests/ui/extern/extern-types-unsized.stderr
index a587d4dda55..43dd9800d6d 100644
--- a/tests/ui/extern/extern-types-unsized.stderr
+++ b/tests/ui/extern/extern-types-unsized.stderr
@@ -59,8 +59,21 @@ 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
+  --> $DIR/extern-types-unsized.rs:28:20
+   |
+LL |     assert_sized::<Bar<A>>();
+   |                    ^^^^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `A`
+note: required by a bound in `Bar`
+  --> $DIR/extern-types-unsized.rs:14:12
+   |
+LL | struct Bar<T: ?Sized> {
+   |            ^ required by this bound in `Bar`
+
 error[E0277]: the size for values of type `A` cannot be known at compilation time
-  --> $DIR/extern-types-unsized.rs:31:20
+  --> $DIR/extern-types-unsized.rs:32:20
    |
 LL |     assert_sized::<Bar<Bar<A>>>();
    |                    ^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -81,6 +94,19 @@ help: consider relaxing the implicit `Sized` restriction
 LL | fn assert_sized<T: ?Sized>() {}
    |                  ++++++++
 
-error: aborting due to 4 previous errors
+error[E0277]: the size for values of type `A` cannot be known
+  --> $DIR/extern-types-unsized.rs:32:20
+   |
+LL |     assert_sized::<Bar<Bar<A>>>();
+   |                    ^^^^^^^^^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `A`
+note: required by a bound in `Bar`
+  --> $DIR/extern-types-unsized.rs:14:12
+   |
+LL | struct Bar<T: ?Sized> {
+   |            ^ required by this bound in `Bar`
+
+error: aborting due to 6 previous errors
 
 For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/extern/unsized-extern-derefmove.rs b/tests/ui/extern/unsized-extern-derefmove.rs
index 4ec9e53f49d..c02375266ab 100644
--- a/tests/ui/extern/unsized-extern-derefmove.rs
+++ b/tests/ui/extern/unsized-extern-derefmove.rs
@@ -1,15 +1,20 @@
-//! Regression test for #79409
-
 #![feature(extern_types)]
 
-unsafe extern "C" {
+// Regression test for #79409
+
+extern "C" {
     type Device;
 }
 
 unsafe fn make_device() -> Box<Device> {
+//~^ ERROR the size for values of type `Device` cannot be known
     Box::from_raw(0 as *mut _)
+//~^ ERROR the size for values of type `Device` cannot be known
+//~| ERROR the size for values of type `Device` cannot be known
 }
 
 fn main() {
-    let d: Device = unsafe { *make_device() }; //~ERROR the size for values of type `Device` cannot be known at compilation time
+    let d: Device = unsafe { *make_device() };
+//~^ ERROR the size for values of type `Device` cannot be known
+//~| ERROR the size for values of type `Device` cannot be known
 }
diff --git a/tests/ui/extern/unsized-extern-derefmove.stderr b/tests/ui/extern/unsized-extern-derefmove.stderr
index c43184d94e1..d6be76a9d62 100644
--- a/tests/ui/extern/unsized-extern-derefmove.stderr
+++ b/tests/ui/extern/unsized-extern-derefmove.stderr
@@ -1,5 +1,43 @@
+error[E0277]: the size for values of type `Device` cannot be known
+  --> $DIR/unsized-extern-derefmove.rs:9:28
+   |
+LL | unsafe fn make_device() -> Box<Device> {
+   |                            ^^^^^^^^^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `Device`
+note: required by a bound in `Box`
+  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+
+error[E0277]: the size for values of type `Device` cannot be known
+  --> $DIR/unsized-extern-derefmove.rs:11:19
+   |
+LL |     Box::from_raw(0 as *mut _)
+   |     ------------- ^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Device`
+   |     |
+   |     required by a bound introduced by this call
+   |
+   = note: the trait bound `Device: MetaSized` is not satisfied
+note: required by a bound in `Box::<T>::from_raw`
+  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+help: consider borrowing here
+   |
+LL |     Box::from_raw(&0 as *mut _)
+   |                   +
+LL |     Box::from_raw(&mut 0 as *mut _)
+   |                   ++++
+
+error[E0277]: the size for values of type `Device` cannot be known
+  --> $DIR/unsized-extern-derefmove.rs:11:5
+   |
+LL |     Box::from_raw(0 as *mut _)
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `Device`
+note: required by a bound in `Box`
+  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+
 error[E0277]: the size for values of type `Device` cannot be known at compilation time
-  --> $DIR/unsized-extern-derefmove.rs:14:9
+  --> $DIR/unsized-extern-derefmove.rs:17:9
    |
 LL |     let d: Device = unsafe { *make_device() };
    |         ^ doesn't have a size known at compile-time
@@ -11,6 +49,16 @@ help: consider borrowing here
 LL |     let d: &Device = unsafe { *make_device() };
    |            +
 
-error: aborting due to 1 previous error
+error[E0277]: the size for values of type `Device` cannot be known
+  --> $DIR/unsized-extern-derefmove.rs:17:31
+   |
+LL |     let d: Device = unsafe { *make_device() };
+   |                               ^^^^^^^^^^^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `Device`
+note: required by a bound in `Box`
+  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+
+error: aborting due to 5 previous errors
 
 For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/feature-gates/feature-gate-sized-hierarchy.rs b/tests/ui/feature-gates/feature-gate-sized-hierarchy.rs
new file mode 100644
index 00000000000..33688c2e2ce
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-sized-hierarchy.rs
@@ -0,0 +1,29 @@
+#![feature(extern_types)]
+#![feature(sized_hierarchy)]
+
+use std::marker::{MetaSized, PointeeSized};
+
+fn needs_pointeesized<T: PointeeSized>() {}
+fn needs_metasized<T: MetaSized>() {}
+fn needs_sized<T: Sized>() {}
+
+fn main() {
+    needs_pointeesized::<u8>();
+    needs_metasized::<u8>();
+    needs_sized::<u8>();
+
+    needs_pointeesized::<str>();
+    needs_metasized::<str>();
+    needs_sized::<str>();
+//~^ ERROR the size for values of type `str` cannot be known at compilation time
+
+    extern "C" {
+        type Foo;
+    }
+
+    needs_pointeesized::<Foo>();
+    needs_metasized::<Foo>();
+//~^ ERROR the size for values of type `main::Foo` cannot be known
+    needs_sized::<Foo>();
+//~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+}
diff --git a/tests/ui/feature-gates/feature-gate-sized-hierarchy.stderr b/tests/ui/feature-gates/feature-gate-sized-hierarchy.stderr
new file mode 100644
index 00000000000..6a35fcfb0e8
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-sized-hierarchy.stderr
@@ -0,0 +1,42 @@
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+  --> $DIR/feature-gate-sized-hierarchy.rs:17:19
+   |
+LL |     needs_sized::<str>();
+   |                   ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `str`
+note: required by a bound in `needs_sized`
+  --> $DIR/feature-gate-sized-hierarchy.rs:8:19
+   |
+LL | fn needs_sized<T: Sized>() {}
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known
+  --> $DIR/feature-gate-sized-hierarchy.rs:25:23
+   |
+LL |     needs_metasized::<Foo>();
+   |                       ^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `main::Foo`
+note: required by a bound in `needs_metasized`
+  --> $DIR/feature-gate-sized-hierarchy.rs:7:23
+   |
+LL | fn needs_metasized<T: MetaSized>() {}
+   |                       ^^^^^^^^^ required by this bound in `needs_metasized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/feature-gate-sized-hierarchy.rs:27:19
+   |
+LL |     needs_sized::<Foo>();
+   |                   ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+note: required by a bound in `needs_sized`
+  --> $DIR/feature-gate-sized-hierarchy.rs:8:19
+   |
+LL | fn needs_sized<T: Sized>() {}
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs b/tests/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs
index 2a39d579c51..bb23f9fe5c6 100644
--- a/tests/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs
+++ b/tests/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs
@@ -13,8 +13,14 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+pub trait Sized: MetaSized {}
 
 //[BADFLAGS]~? ERROR incorrect value `leaf` for unstable option `branch-protection`
 //[BADFLAGSPC]~? ERROR incorrect value `pc` for unstable option `branch-protection`
diff --git a/tests/ui/lang-items/issue-83471.rs b/tests/ui/lang-items/issue-83471.rs
index 6be345ac507..f3ce9f25c13 100644
--- a/tests/ui/lang-items/issue-83471.rs
+++ b/tests/ui/lang-items/issue-83471.rs
@@ -4,9 +4,17 @@
 #![feature(no_core)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+//~^ ERROR: lang items are subject to change [E0658]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+//~^ ERROR: lang items are subject to change [E0658]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
 //~^ ERROR: lang items are subject to change [E0658]
-trait Sized {}
+trait Sized: MetaSized {}
 
 #[lang = "fn"]
 //~^ ERROR: lang items are subject to change [E0658]
diff --git a/tests/ui/lang-items/issue-83471.stderr b/tests/ui/lang-items/issue-83471.stderr
index 244b2efeaf1..e913c0bf10f 100644
--- a/tests/ui/lang-items/issue-83471.stderr
+++ b/tests/ui/lang-items/issue-83471.stderr
@@ -1,5 +1,5 @@
 error[E0573]: expected type, found built-in attribute `export_name`
-  --> $DIR/issue-83471.rs:15:13
+  --> $DIR/issue-83471.rs:23:13
    |
 LL |     fn call(export_name);
    |             ^^^^^^^^^^^ not a type
@@ -7,6 +7,24 @@ LL |     fn call(export_name);
 error[E0658]: lang items are subject to change
   --> $DIR/issue-83471.rs:7:1
    |
+LL | #[lang = "pointee_sized"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: add `#![feature(lang_items)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error[E0658]: lang items are subject to change
+  --> $DIR/issue-83471.rs:11:1
+   |
+LL | #[lang = "meta_sized"]
+   | ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: add `#![feature(lang_items)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error[E0658]: lang items are subject to change
+  --> $DIR/issue-83471.rs:15:1
+   |
 LL | #[lang = "sized"]
    | ^^^^^^^^^^^^^^^^^
    |
@@ -14,7 +32,7 @@ LL | #[lang = "sized"]
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0658]: lang items are subject to change
-  --> $DIR/issue-83471.rs:11:1
+  --> $DIR/issue-83471.rs:19:1
    |
 LL | #[lang = "fn"]
    | ^^^^^^^^^^^^^^
@@ -23,7 +41,7 @@ LL | #[lang = "fn"]
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 warning: anonymous parameters are deprecated and will be removed in the next edition
-  --> $DIR/issue-83471.rs:15:13
+  --> $DIR/issue-83471.rs:23:13
    |
 LL |     fn call(export_name);
    |             ^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: export_name`
@@ -33,7 +51,7 @@ LL |     fn call(export_name);
    = note: `#[warn(anonymous_parameters)]` on by default
 
 error[E0718]: `fn` lang item must be applied to a trait with 1 generic argument
-  --> $DIR/issue-83471.rs:11:1
+  --> $DIR/issue-83471.rs:19:1
    |
 LL | #[lang = "fn"]
    | ^^^^^^^^^^^^^^
@@ -42,12 +60,12 @@ LL | trait Fn {
    |         - this trait has 0 generic arguments
 
 error[E0425]: cannot find function `a` in this scope
-  --> $DIR/issue-83471.rs:21:5
+  --> $DIR/issue-83471.rs:29:5
    |
 LL |     a()
    |     ^ not found in this scope
 
-error: aborting due to 5 previous errors; 1 warning emitted
+error: aborting due to 7 previous errors; 1 warning emitted
 
 Some errors have detailed explanations: E0425, E0573, E0658, E0718.
 For more information about an error, try `rustc --explain E0425`.
diff --git a/tests/ui/lang-items/issue-87573.rs b/tests/ui/lang-items/issue-87573.rs
index 7b805e8b0cd..97146df0ba7 100644
--- a/tests/ui/lang-items/issue-87573.rs
+++ b/tests/ui/lang-items/issue-87573.rs
@@ -7,8 +7,14 @@
 
 pub static STATIC_BOOL: bool = true;
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
 
 #[lang = "copy"]
 trait Copy {}
diff --git a/tests/ui/lang-items/issue-87573.stderr b/tests/ui/lang-items/issue-87573.stderr
index 7085bb8c339..07f4f5d8ac8 100644
--- a/tests/ui/lang-items/issue-87573.stderr
+++ b/tests/ui/lang-items/issue-87573.stderr
@@ -1,5 +1,5 @@
 error[E0718]: `drop_in_place` lang item must be applied to a function with at least 1 generic argument
-  --> $DIR/issue-87573.rs:20:1
+  --> $DIR/issue-87573.rs:26:1
    |
 LL | #[lang = "drop_in_place"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | fn drop_fn() {
    |           - this function has 0 generic arguments
 
 error[E0718]: `start` lang item must be applied to a function with 1 generic argument
-  --> $DIR/issue-87573.rs:26:1
+  --> $DIR/issue-87573.rs:32:1
    |
 LL | #[lang = "start"]
    | ^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/lang-items/lang-item-generic-requirements.rs b/tests/ui/lang-items/lang-item-generic-requirements.rs
index 25a4ff283ba..168e22ad7db 100644
--- a/tests/ui/lang-items/lang-item-generic-requirements.rs
+++ b/tests/ui/lang-items/lang-item-generic-requirements.rs
@@ -4,8 +4,14 @@
 #![feature(lang_items, no_core)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait MyPointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MyMetaSized: MyPointeeSized {}
+
 #[lang = "sized"]
-trait MySized {}
+trait MySized: MyMetaSized {}
 
 #[lang = "add"]
 trait MyAdd<'a, T> {}
diff --git a/tests/ui/lang-items/lang-item-generic-requirements.stderr b/tests/ui/lang-items/lang-item-generic-requirements.stderr
index c82bdb00fd1..0b3088add61 100644
--- a/tests/ui/lang-items/lang-item-generic-requirements.stderr
+++ b/tests/ui/lang-items/lang-item-generic-requirements.stderr
@@ -1,5 +1,5 @@
 error[E0718]: `add` lang item must be applied to a trait with 1 generic argument
-  --> $DIR/lang-item-generic-requirements.rs:10:1
+  --> $DIR/lang-item-generic-requirements.rs:16:1
    |
 LL | #[lang = "add"]
    | ^^^^^^^^^^^^^^^
@@ -7,7 +7,7 @@ LL | trait MyAdd<'a, T> {}
    |            ------- this trait has 2 generic arguments
 
 error[E0718]: `drop_in_place` lang item must be applied to a function with at least 1 generic argument
-  --> $DIR/lang-item-generic-requirements.rs:14:1
+  --> $DIR/lang-item-generic-requirements.rs:20:1
    |
 LL | #[lang = "drop_in_place"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL | fn my_ptr_drop() {}
    |               - this function has 0 generic arguments
 
 error[E0718]: `index` lang item must be applied to a trait with 1 generic argument
-  --> $DIR/lang-item-generic-requirements.rs:18:1
+  --> $DIR/lang-item-generic-requirements.rs:24:1
    |
 LL | #[lang = "index"]
    | ^^^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL | trait MyIndex<'a, T> {}
    |              ------- this trait has 2 generic arguments
 
 error[E0718]: `phantom_data` lang item must be applied to a struct with 1 generic argument
-  --> $DIR/lang-item-generic-requirements.rs:22:1
+  --> $DIR/lang-item-generic-requirements.rs:28:1
    |
 LL | #[lang = "phantom_data"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -33,7 +33,7 @@ LL | struct MyPhantomData<T, U>;
    |                     ------ this struct has 2 generic arguments
 
 error[E0718]: `owned_box` lang item must be applied to a struct with at least 1 generic argument
-  --> $DIR/lang-item-generic-requirements.rs:28:1
+  --> $DIR/lang-item-generic-requirements.rs:34:1
    |
 LL | #[lang = "owned_box"]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -42,7 +42,7 @@ LL | struct Foo;
    |           - this struct has 0 generic arguments
 
 error[E0718]: `start` lang item must be applied to a function with 1 generic argument
-  --> $DIR/lang-item-generic-requirements.rs:34:1
+  --> $DIR/lang-item-generic-requirements.rs:40:1
    |
 LL | #[lang = "start"]
    | ^^^^^^^^^^^^^^^^^
@@ -51,7 +51,7 @@ LL | fn start(_: *const u8, _: isize, _: *const *const u8) -> isize {
    |         - this function has 0 generic arguments
 
 error[E0392]: type parameter `T` is never used
-  --> $DIR/lang-item-generic-requirements.rs:24:22
+  --> $DIR/lang-item-generic-requirements.rs:30:22
    |
 LL | struct MyPhantomData<T, U>;
    |                      ^ unused type parameter
@@ -60,7 +60,7 @@ LL | struct MyPhantomData<T, U>;
    = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
 
 error[E0392]: type parameter `U` is never used
-  --> $DIR/lang-item-generic-requirements.rs:24:25
+  --> $DIR/lang-item-generic-requirements.rs:30:25
    |
 LL | struct MyPhantomData<T, U>;
    |                         ^ unused type parameter
@@ -69,7 +69,7 @@ LL | struct MyPhantomData<T, U>;
    = help: if you intended `U` to be a const parameter, use `const U: /* Type */` instead
 
 error[E0369]: cannot add `{integer}` to `{integer}`
-  --> $DIR/lang-item-generic-requirements.rs:44:7
+  --> $DIR/lang-item-generic-requirements.rs:50:7
    |
 LL |     r + a;
    |     - ^ - {integer}
@@ -77,13 +77,13 @@ LL |     r + a;
    |     {integer}
 
 error[E0608]: cannot index into a value of type `[{integer}; 5]`
-  --> $DIR/lang-item-generic-requirements.rs:52:16
+  --> $DIR/lang-item-generic-requirements.rs:58:16
    |
 LL |     let _ = arr[2];
    |                ^^^
 
 error[E0308]: mismatched types
-  --> $DIR/lang-item-generic-requirements.rs:59:17
+  --> $DIR/lang-item-generic-requirements.rs:65:17
    |
 LL |     let _: () = Foo;
    |            --   ^^^ expected `()`, found `Foo`
@@ -91,7 +91,7 @@ LL |     let _: () = Foo;
    |            expected due to this
 
 error: requires `copy` lang_item
-  --> $DIR/lang-item-generic-requirements.rs:50:16
+  --> $DIR/lang-item-generic-requirements.rs:56:16
    |
 LL |     let arr = [0; 5];
    |                ^
diff --git a/tests/ui/lang-items/missing-copy-lang-item-issue-19660.rs b/tests/ui/lang-items/missing-copy-lang-item-issue-19660.rs
index f92a00e602c..35d5d079c68 100644
--- a/tests/ui/lang-items/missing-copy-lang-item-issue-19660.rs
+++ b/tests/ui/lang-items/missing-copy-lang-item-issue-19660.rs
@@ -2,8 +2,14 @@
 #![no_core]
 #![no_main]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized { }
+trait Sized: MetaSized { }
 
 struct S;
 
diff --git a/tests/ui/lang-items/missing-copy-lang-item-issue-19660.stderr b/tests/ui/lang-items/missing-copy-lang-item-issue-19660.stderr
index 9b25b1db292..7b9541f734f 100644
--- a/tests/ui/lang-items/missing-copy-lang-item-issue-19660.stderr
+++ b/tests/ui/lang-items/missing-copy-lang-item-issue-19660.stderr
@@ -1,5 +1,5 @@
 error: requires `copy` lang_item
-  --> $DIR/missing-copy-lang-item-issue-19660.rs:12:5
+  --> $DIR/missing-copy-lang-item-issue-19660.rs:18:5
    |
 LL |     argc
    |     ^^^^
diff --git a/tests/ui/lang-items/start_lang_item_args.argc.stderr b/tests/ui/lang-items/start_lang_item_args.argc.stderr
index cd7361255eb..82fd374a1c5 100644
--- a/tests/ui/lang-items/start_lang_item_args.argc.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.argc.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:75:38
+  --> $DIR/start_lang_item_args.rs:79:38
    |
 LL | fn start<T>(_main: fn() -> T, _argc: i8, _argv: *const *const u8, _sigpipe: u8) -> isize {
    |                                      ^^ expected `isize`, found `i8`
diff --git a/tests/ui/lang-items/start_lang_item_args.argv.stderr b/tests/ui/lang-items/start_lang_item_args.argv.stderr
index 1a5905ab8e6..6095f8fa532 100644
--- a/tests/ui/lang-items/start_lang_item_args.argv.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.argv.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:89:52
+  --> $DIR/start_lang_item_args.rs:93:52
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: u8, _sigpipe: u8) -> isize {
    |                                                    ^^ expected `*const *const u8`, found `u8`
diff --git a/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr b/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr
index c61ace3cd62..2a295c8990b 100644
--- a/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:82:52
+  --> $DIR/start_lang_item_args.rs:86:52
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const usize, _sigpipe: u8) -> isize {
    |                                                    ^^^^^^^^^^^^^^^^^^^ expected `u8`, found `usize`
diff --git a/tests/ui/lang-items/start_lang_item_args.main_args.stderr b/tests/ui/lang-items/start_lang_item_args.main_args.stderr
index ef943d6b3db..027fd16d410 100644
--- a/tests/ui/lang-items/start_lang_item_args.main_args.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.main_args.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:61:1
+  --> $DIR/start_lang_item_args.rs:65:1
    |
 LL | fn start<T>(_main: fn(i32) -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
diff --git a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
index 00395a05d33..0f295d350d1 100644
--- a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:68:20
+  --> $DIR/start_lang_item_args.rs:72:20
    |
 LL | fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
    |          -         ^^^^^^^^^^^ expected type parameter `T`, found `u16`
diff --git a/tests/ui/lang-items/start_lang_item_args.main_ty.stderr b/tests/ui/lang-items/start_lang_item_args.main_ty.stderr
index 193f25bab05..6e462c8b1a7 100644
--- a/tests/ui/lang-items/start_lang_item_args.main_ty.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.main_ty.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:54:20
+  --> $DIR/start_lang_item_args.rs:58:20
    |
 LL | fn start<T>(_main: u64, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
    |                    ^^^ expected fn pointer, found `u64`
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr b/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr
index 56b787d2ae3..90fa5e0d575 100644
--- a/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:15:1
+  --> $DIR/start_lang_item_args.rs:19:1
    |
 LL | fn start<T>() -> isize {
    | ^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr b/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr
index 2672efe51c9..879917cc800 100644
--- a/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:29:83
+  --> $DIR/start_lang_item_args.rs:33:83
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
    |                                                                                   ^ expected `isize`, found `()`
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr b/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr
index 98814dcd24a..d756909d735 100644
--- a/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:22:1
+  --> $DIR/start_lang_item_args.rs:26:1
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
diff --git a/tests/ui/lang-items/start_lang_item_args.rs b/tests/ui/lang-items/start_lang_item_args.rs
index 5bb99e2adc8..1da761545a8 100644
--- a/tests/ui/lang-items/start_lang_item_args.rs
+++ b/tests/ui/lang-items/start_lang_item_args.rs
@@ -8,7 +8,11 @@
 #[lang = "copy"]
 pub trait Copy {}
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
 
 #[cfg(missing_all_args)]
 #[lang = "start"]
diff --git a/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr b/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr
index e0a8496dba9..ba1dd4b4f79 100644
--- a/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:96:80
+  --> $DIR/start_lang_item_args.rs:100:80
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: i64) -> isize {
    |                                                                                ^^^ expected `u8`, found `i64`
diff --git a/tests/ui/lang-items/start_lang_item_args.start_ret.stderr b/tests/ui/lang-items/start_lang_item_args.start_ret.stderr
index 4437b0fdcfb..a11867997d3 100644
--- a/tests/ui/lang-items/start_lang_item_args.start_ret.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.start_ret.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:34:87
+  --> $DIR/start_lang_item_args.rs:38:87
    |
 LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> u8 {
    |                                                                                       ^^ expected `isize`, found `u8`
diff --git a/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr b/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr
index 8570d96fc62..ecccf8c74bc 100644
--- a/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr
@@ -1,5 +1,5 @@
 error[E0308]: lang item `start` function has wrong type
-  --> $DIR/start_lang_item_args.rs:41:1
+  --> $DIR/start_lang_item_args.rs:45:1
    |
 LL | / fn start<T>(
 LL | |
diff --git a/tests/ui/lang-items/start_lang_item_with_target_feature.rs b/tests/ui/lang-items/start_lang_item_with_target_feature.rs
index 18cd4c97040..19036819d3d 100644
--- a/tests/ui/lang-items/start_lang_item_with_target_feature.rs
+++ b/tests/ui/lang-items/start_lang_item_with_target_feature.rs
@@ -6,8 +6,15 @@
 
 #[lang = "copy"]
 pub trait Copy {}
+
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 #[lang = "start"]
 #[target_feature(enable = "avx2")]
diff --git a/tests/ui/lang-items/start_lang_item_with_target_feature.stderr b/tests/ui/lang-items/start_lang_item_with_target_feature.stderr
index 6214e3f8bc7..ce0b1d75574 100644
--- a/tests/ui/lang-items/start_lang_item_with_target_feature.stderr
+++ b/tests/ui/lang-items/start_lang_item_with_target_feature.stderr
@@ -1,5 +1,5 @@
 error: `start` lang item function is not allowed to have `#[target_feature]`
-  --> $DIR/start_lang_item_with_target_feature.rs:13:1
+  --> $DIR/start_lang_item_with_target_feature.rs:20:1
    |
 LL | #[target_feature(enable = "avx2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/layout/unconstrained-param-ice-137308.rs b/tests/ui/layout/unconstrained-param-ice-137308.rs
index c9b1e0a4b9e..03b7e759960 100644
--- a/tests/ui/layout/unconstrained-param-ice-137308.rs
+++ b/tests/ui/layout/unconstrained-param-ice-137308.rs
@@ -15,4 +15,6 @@ impl<C: ?Sized> A for u8 { //~ ERROR: the type parameter `C` is not constrained
 }
 
 #[rustc_layout(debug)]
-struct S([u8; <u8 as A>::B]); //~ ERROR: the type has an unknown layout
+struct S([u8; <u8 as A>::B]);
+//~^ ERROR: the type has an unknown layout
+//~| ERROR: type annotations needed
diff --git a/tests/ui/layout/unconstrained-param-ice-137308.stderr b/tests/ui/layout/unconstrained-param-ice-137308.stderr
index 615c131eb90..82cd1217c49 100644
--- a/tests/ui/layout/unconstrained-param-ice-137308.stderr
+++ b/tests/ui/layout/unconstrained-param-ice-137308.stderr
@@ -4,12 +4,19 @@ error[E0207]: the type parameter `C` is not constrained by the impl trait, self
 LL | impl<C: ?Sized> A for u8 {
    |      ^ unconstrained type parameter
 
+error[E0282]: type annotations needed
+  --> $DIR/unconstrained-param-ice-137308.rs:18:16
+   |
+LL | struct S([u8; <u8 as A>::B]);
+   |                ^^ cannot infer type for type parameter `C`
+
 error: the type has an unknown layout
   --> $DIR/unconstrained-param-ice-137308.rs:18:1
    |
 LL | struct S([u8; <u8 as A>::B]);
    | ^^^^^^^^
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0207`.
+Some errors have detailed explanations: E0207, E0282.
+For more information about an error, try `rustc --explain E0207`.
diff --git a/tests/ui/nll/issue-50716.rs b/tests/ui/nll/issue-50716.rs
index c2fc345fa2b..76c6fc5e7b9 100644
--- a/tests/ui/nll/issue-50716.rs
+++ b/tests/ui/nll/issue-50716.rs
@@ -1,4 +1,3 @@
-//
 // Regression test for the issue #50716: NLL ignores lifetimes bounds
 // derived from `Sized` requirements
 
@@ -6,7 +5,7 @@ trait A {
     type X: ?Sized;
 }
 
-fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
+fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>) //~ ERROR
 where
     for<'b> &'b T: A,
     <&'static T as A>::X: Sized
diff --git a/tests/ui/nll/issue-50716.stderr b/tests/ui/nll/issue-50716.stderr
index a09e7670515..edd7fd765da 100644
--- a/tests/ui/nll/issue-50716.stderr
+++ b/tests/ui/nll/issue-50716.stderr
@@ -1,5 +1,20 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-50716.rs:8:27
+   |
+LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
+   |                           ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
+   |
+   = note: expected trait `<<&'a T as A>::X as MetaSized>`
+              found trait `<<&'static T as A>::X as MetaSized>`
+note: the lifetime `'a` as defined here...
+  --> $DIR/issue-50716.rs:8:8
+   |
+LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
+   |        ^^
+   = note: ...does not necessarily outlive the static lifetime
+
 error: lifetime may not live long enough
-  --> $DIR/issue-50716.rs:14:14
+  --> $DIR/issue-50716.rs:13:14
    |
 LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
    |        -- lifetime `'a` defined here
@@ -7,5 +22,6 @@ LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
 LL |     let _x = *s;
    |              ^^ proving this value is `Sized` requires that `'a` must outlive `'static`
 
-error: aborting due to 1 previous error
+error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/offset-of/offset-of-dst-field.rs b/tests/ui/offset-of/offset-of-dst-field.rs
index 2e0bdb151e1..575a66fe302 100644
--- a/tests/ui/offset-of/offset-of-dst-field.rs
+++ b/tests/ui/offset-of/offset-of-dst-field.rs
@@ -1,5 +1,6 @@
-#![feature(extern_types)]
+#![feature(extern_types, sized_hierarchy)]
 
+use std::marker::PointeeSized;
 use std::mem::offset_of;
 
 struct Alpha {
@@ -26,7 +27,7 @@ struct Gamma {
     z: Extern,
 }
 
-struct Delta<T: ?Sized> {
+struct Delta<T: PointeeSized> {
     x: u8,
     y: u16,
     z: T,
diff --git a/tests/ui/offset-of/offset-of-dst-field.stderr b/tests/ui/offset-of/offset-of-dst-field.stderr
index 714bf7a0266..0953e86e222 100644
--- a/tests/ui/offset-of/offset-of-dst-field.stderr
+++ b/tests/ui/offset-of/offset-of-dst-field.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:36:5
+  --> $DIR/offset-of-dst-field.rs:37:5
    |
 LL |     offset_of!(Alpha, z);
    |     ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -8,7 +8,7 @@ LL |     offset_of!(Alpha, z);
    = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:37:5
+  --> $DIR/offset-of-dst-field.rs:38:5
    |
 LL |     offset_of!(Beta, z);
    |     ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -17,7 +17,7 @@ LL |     offset_of!(Beta, z);
    = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the size for values of type `Extern` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:38:5
+  --> $DIR/offset-of-dst-field.rs:39:5
    |
 LL |     offset_of!(Gamma, z);
    |     ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -26,7 +26,7 @@ LL |     offset_of!(Gamma, z);
    = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:40:5
+  --> $DIR/offset-of-dst-field.rs:41:5
    |
 LL |     offset_of!((u8, dyn Trait), 1);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -35,7 +35,7 @@ LL |     offset_of!((u8, dyn Trait), 1);
    = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the size for values of type `Extern` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:45:5
+  --> $DIR/offset-of-dst-field.rs:46:5
    |
 LL |     offset_of!(Delta<Extern>, z);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -44,7 +44,7 @@ LL |     offset_of!(Delta<Extern>, z);
    = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:46:5
+  --> $DIR/offset-of-dst-field.rs:47:5
    |
 LL |     offset_of!(Delta<dyn Trait>, z);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -53,21 +53,21 @@ LL |     offset_of!(Delta<dyn Trait>, z);
    = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:44:5
+  --> $DIR/offset-of-dst-field.rs:45:5
    |
 LL |     offset_of!(Delta<Alpha>, z);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
    = help: within `Alpha`, the trait `Sized` is not implemented for `[u8]`
 note: required because it appears within the type `Alpha`
-  --> $DIR/offset-of-dst-field.rs:5:8
+  --> $DIR/offset-of-dst-field.rs:6:8
    |
 LL | struct Alpha {
    |        ^^^^^
    = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the size for values of type `T` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:50:5
+  --> $DIR/offset-of-dst-field.rs:51:5
    |
 LL | fn generic_with_maybe_sized<T: ?Sized>() -> usize {
    |                             - this type parameter needs to be `Sized`
@@ -82,7 +82,7 @@ LL + fn generic_with_maybe_sized<T>() -> usize {
    |
 
 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
-  --> $DIR/offset-of-dst-field.rs:54:16
+  --> $DIR/offset-of-dst-field.rs:55:16
    |
 LL |     offset_of!(([u8], u8), 1);
    |                ^^^^^^^^^^ doesn't have a size known at compile-time
diff --git a/tests/ui/panic-handler/panic-handler-requires-panic-info.rs b/tests/ui/panic-handler/panic-handler-requires-panic-info.rs
index 0b8308ba753..618ac7d88dd 100644
--- a/tests/ui/panic-handler/panic-handler-requires-panic-info.rs
+++ b/tests/ui/panic-handler/panic-handler-requires-panic-info.rs
@@ -11,5 +11,11 @@ fn panic() -> ! {
     loop {}
 }
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
diff --git a/tests/ui/privacy/privacy1.rs b/tests/ui/privacy/privacy1.rs
index 6cd12b80782..16aacd81289 100644
--- a/tests/ui/privacy/privacy1.rs
+++ b/tests/ui/privacy/privacy1.rs
@@ -1,8 +1,14 @@
 #![feature(lang_items, no_core)]
 #![no_core] // makes debugging this test *a lot* easier (during resolve)
 
-#[lang="sized"]
-pub trait Sized {}
+#[lang = "sized"]
+pub trait Sized: MetaSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
 
 #[lang="copy"]
 pub trait Copy {}
diff --git a/tests/ui/privacy/privacy1.stderr b/tests/ui/privacy/privacy1.stderr
index 1f2f4a92c48..98750cee610 100644
--- a/tests/ui/privacy/privacy1.stderr
+++ b/tests/ui/privacy/privacy1.stderr
@@ -1,54 +1,54 @@
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:132:18
+  --> $DIR/privacy1.rs:138:18
    |
 LL |         use bar::baz::{foo, bar};
    |                  ^^^ private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
 
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:132:18
+  --> $DIR/privacy1.rs:138:18
    |
 LL |         use bar::baz::{foo, bar};
    |                  ^^^ private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:141:18
+  --> $DIR/privacy1.rs:147:18
    |
 LL |         use bar::baz;
    |                  ^^^ private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
 
 error[E0603]: module `i` is private
-  --> $DIR/privacy1.rs:165:20
+  --> $DIR/privacy1.rs:171:20
    |
 LL |     use self::foo::i::A;
    |                    ^ private module
    |
 note: the module `i` is defined here
-  --> $DIR/privacy1.rs:170:9
+  --> $DIR/privacy1.rs:176:9
    |
 LL |         mod i {
    |         ^^^^^
 
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:104:21
+  --> $DIR/privacy1.rs:110:21
    |
 LL |         crate::bar::baz::A::foo();
    |                     ^^^  - struct `A` is not publicly re-exported
@@ -56,13 +56,13 @@ LL |         crate::bar::baz::A::foo();
    |                     private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
 
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:105:21
+  --> $DIR/privacy1.rs:111:21
    |
 LL |         crate::bar::baz::A::bar();
    |                     ^^^  - struct `A` is not publicly re-exported
@@ -70,13 +70,13 @@ LL |         crate::bar::baz::A::bar();
    |                     private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
 
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:107:21
+  --> $DIR/privacy1.rs:113:21
    |
 LL |         crate::bar::baz::A.foo2();
    |                     ^^^  - unit struct `A` is not publicly re-exported
@@ -84,13 +84,13 @@ LL |         crate::bar::baz::A.foo2();
    |                     private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
 
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:108:21
+  --> $DIR/privacy1.rs:114:21
    |
 LL |         crate::bar::baz::A.bar2();
    |                     ^^^  - unit struct `A` is not publicly re-exported
@@ -98,13 +98,13 @@ LL |         crate::bar::baz::A.bar2();
    |                     private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
 
 error[E0603]: trait `B` is private
-  --> $DIR/privacy1.rs:112:21
+  --> $DIR/privacy1.rs:118:21
    |
 LL |         crate::bar::B::foo();
    |                     ^  --- associated function `foo` is not publicly re-exported
@@ -112,31 +112,31 @@ LL |         crate::bar::B::foo();
    |                     private trait
    |
 note: the trait `B` is defined here
-  --> $DIR/privacy1.rs:40:5
+  --> $DIR/privacy1.rs:46:5
    |
 LL |     trait B {
    |     ^^^^^^^
 
 error[E0603]: function `epriv` is private
-  --> $DIR/privacy1.rs:118:25
+  --> $DIR/privacy1.rs:124:25
    |
 LL |             crate::bar::epriv();
    |                         ^^^^^ private function
    |
 note: the function `epriv` is defined here
-  --> $DIR/privacy1.rs:65:9
+  --> $DIR/privacy1.rs:71:9
    |
 LL |         fn epriv();
    |         ^^^^^^^^^^^
 
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:127:21
+  --> $DIR/privacy1.rs:133:21
    |
 LL |         crate::bar::baz::foo();
    |                     ^^^ private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
@@ -147,13 +147,13 @@ LL +         bar::foo();
    |
 
 error[E0603]: module `baz` is private
-  --> $DIR/privacy1.rs:128:21
+  --> $DIR/privacy1.rs:134:21
    |
 LL |         crate::bar::baz::bar();
    |                     ^^^ private module
    |
 note: the module `baz` is defined here
-  --> $DIR/privacy1.rs:50:5
+  --> $DIR/privacy1.rs:56:5
    |
 LL |     mod baz {
    |     ^^^^^^^
@@ -164,19 +164,19 @@ LL +         bar::bar();
    |
 
 error[E0603]: trait `B` is private
-  --> $DIR/privacy1.rs:157:22
+  --> $DIR/privacy1.rs:163:22
    |
 LL |     impl crate::bar::B for f32 { fn foo() -> f32 { 1.0 } }
    |                      ^ private trait
    |
 note: the trait `B` is defined here
-  --> $DIR/privacy1.rs:40:5
+  --> $DIR/privacy1.rs:46:5
    |
 LL |     trait B {
    |     ^^^^^^^
 
 error[E0624]: associated function `bar` is private
-  --> $DIR/privacy1.rs:77:23
+  --> $DIR/privacy1.rs:83:23
    |
 LL |             fn bar() {}
    |             -------- private associated function defined here
@@ -185,7 +185,7 @@ LL |         self::baz::A::bar();
    |                       ^^^ private associated function
 
 error[E0624]: associated function `bar` is private
-  --> $DIR/privacy1.rs:95:13
+  --> $DIR/privacy1.rs:101:13
    |
 LL |         fn bar() {}
    |         -------- private associated function defined here
@@ -194,7 +194,7 @@ LL |     bar::A::bar();
    |             ^^^ private associated function
 
 error[E0624]: associated function `bar` is private
-  --> $DIR/privacy1.rs:102:24
+  --> $DIR/privacy1.rs:108:24
    |
 LL |         fn bar() {}
    |         -------- private associated function defined here
@@ -203,7 +203,7 @@ LL |         crate::bar::A::bar();
    |                        ^^^ private associated function
 
 error[E0624]: associated function `bar` is private
-  --> $DIR/privacy1.rs:105:29
+  --> $DIR/privacy1.rs:111:29
    |
 LL |             fn bar() {}
    |             -------- private associated function defined here
@@ -212,7 +212,7 @@ LL |         crate::bar::baz::A::bar();
    |                             ^^^ private associated function
 
 error[E0624]: method `bar2` is private
-  --> $DIR/privacy1.rs:108:28
+  --> $DIR/privacy1.rs:114:28
    |
 LL |             fn bar2(&self) {}
    |             -------------- private method defined here
diff --git a/tests/ui/privacy/privacy4.rs b/tests/ui/privacy/privacy4.rs
index 7341c7752bb..6091613271f 100644
--- a/tests/ui/privacy/privacy4.rs
+++ b/tests/ui/privacy/privacy4.rs
@@ -1,7 +1,9 @@
 #![feature(lang_items, no_core)]
 #![no_core] // makes debugging this test *a lot* easier (during resolve)
 
-#[lang = "sized"] pub trait Sized {}
+#[lang = "sized"] pub trait Sized: MetaSized {}
+#[lang = "meta_sized"] pub trait MetaSized: PointeeSized {}
+#[lang = "pointee_sized"] pub trait PointeeSized {}
 #[lang="copy"] pub trait Copy {}
 
 // Test to make sure that private items imported through globs remain private
diff --git a/tests/ui/privacy/privacy4.stderr b/tests/ui/privacy/privacy4.stderr
index 4aa3ae964c0..eeefd85645c 100644
--- a/tests/ui/privacy/privacy4.stderr
+++ b/tests/ui/privacy/privacy4.stderr
@@ -1,11 +1,11 @@
 error[E0603]: module `glob` is private
-  --> $DIR/privacy4.rs:21:14
+  --> $DIR/privacy4.rs:23:14
    |
 LL |     use bar::glob::gpriv;
    |              ^^^^ private module
    |
 note: the module `glob` is defined here
-  --> $DIR/privacy4.rs:13:5
+  --> $DIR/privacy4.rs:15:5
    |
 LL |     mod glob {
    |     ^^^^^^^^
diff --git a/tests/ui/sized-hierarchy/alias-bounds.rs b/tests/ui/sized-hierarchy/alias-bounds.rs
new file mode 100644
index 00000000000..87b4bab11b7
--- /dev/null
+++ b/tests/ui/sized-hierarchy/alias-bounds.rs
@@ -0,0 +1,28 @@
+//@ check-pass
+//@ compile-flags: --crate-type=lib
+//@ revisions: old next
+//@[next] compile-flags: -Znext-solver
+#![feature(sized_hierarchy)]
+
+use std::marker::{PointeeSized, MetaSized};
+
+trait Id: PointeeSized {
+    type This: PointeeSized;
+}
+
+impl<T: PointeeSized> Id for T {
+    type This = T;
+}
+
+fn requires_metasized<T: MetaSized>() {}
+
+fn foo<T>()
+where
+    T: PointeeSized,
+    <T as Id>::This: Sized
+{
+    // `T: Sized` from where bounds (`T: PointeeSized` removes any default bounds and
+    // `<T as Id>::This: Sized` normalizes to `T: Sized`). This should trivially satisfy
+    // `T: MetaSized`.
+    requires_metasized::<T>();
+}
diff --git a/tests/ui/sized-hierarchy/auxiliary/pretty-print-dep.rs b/tests/ui/sized-hierarchy/auxiliary/pretty-print-dep.rs
new file mode 100644
index 00000000000..a7d18d90368
--- /dev/null
+++ b/tests/ui/sized-hierarchy/auxiliary/pretty-print-dep.rs
@@ -0,0 +1,19 @@
+#![feature(sized_hierarchy)]
+
+use std::marker::{MetaSized, PointeeSized};
+
+pub trait SizedTr {}
+
+impl<T: Sized> SizedTr for T {}
+
+pub trait NegSizedTr {}
+
+impl<T: ?Sized> NegSizedTr for T {}
+
+pub trait MetaSizedTr {}
+
+impl<T: MetaSized> MetaSizedTr for T {}
+
+pub trait PointeeSizedTr: PointeeSized {}
+
+impl<T: PointeeSized> PointeeSizedTr for T {}
diff --git a/tests/ui/sized-hierarchy/auxiliary/pretty-print-no-feat-dep.rs b/tests/ui/sized-hierarchy/auxiliary/pretty-print-no-feat-dep.rs
new file mode 100644
index 00000000000..3314b0f356f
--- /dev/null
+++ b/tests/ui/sized-hierarchy/auxiliary/pretty-print-no-feat-dep.rs
@@ -0,0 +1,7 @@
+pub trait SizedTr {}
+
+impl<T: Sized> SizedTr for T {}
+
+pub trait NegSizedTr {}
+
+impl<T: ?Sized> NegSizedTr for T {}
diff --git a/tests/ui/sized-hierarchy/default-bound.rs b/tests/ui/sized-hierarchy/default-bound.rs
new file mode 100644
index 00000000000..12b2eb2b5c1
--- /dev/null
+++ b/tests/ui/sized-hierarchy/default-bound.rs
@@ -0,0 +1,49 @@
+//@ check-fail
+#![feature(extern_types, sized_hierarchy)]
+
+use std::marker::{MetaSized, PointeeSized};
+
+fn bare<T>() {}
+
+
+fn sized<T: Sized>() {}
+
+fn neg_sized<T: ?Sized>() {}
+
+
+fn metasized<T: MetaSized>() {}
+
+fn neg_metasized<T: ?MetaSized>() {}
+//~^ ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
+
+
+fn pointeesized<T: PointeeSized>() { }
+
+fn neg_pointeesized<T: ?PointeeSized>() { }
+//~^ ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
+
+
+fn main() {
+    // Functions which should have a `T: Sized` bound - check for an error given a non-Sized type:
+
+    bare::<[u8]>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    sized::<[u8]>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    metasized::<[u8]>();
+    pointeesized::<[u8]>();
+
+    // Functions which should have a `T: MetaSized` bound - check for an error given a
+    // non-MetaSized type:
+    unsafe extern "C" {
+        type Foo;
+    }
+
+    bare::<Foo>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known
+    sized::<Foo>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known
+    metasized::<Foo>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known
+    pointeesized::<Foo>();
+}
diff --git a/tests/ui/sized-hierarchy/default-bound.stderr b/tests/ui/sized-hierarchy/default-bound.stderr
new file mode 100644
index 00000000000..22f0fa29d3e
--- /dev/null
+++ b/tests/ui/sized-hierarchy/default-bound.stderr
@@ -0,0 +1,88 @@
+error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
+  --> $DIR/default-bound.rs:16:21
+   |
+LL | fn neg_metasized<T: ?MetaSized>() {}
+   |                     ^^^^^^^^^^
+
+error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
+  --> $DIR/default-bound.rs:22:24
+   |
+LL | fn neg_pointeesized<T: ?PointeeSized>() { }
+   |                        ^^^^^^^^^^^^^
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/default-bound.rs:29:12
+   |
+LL |     bare::<[u8]>();
+   |            ^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+note: required by an implicit `Sized` bound in `bare`
+  --> $DIR/default-bound.rs:6:9
+   |
+LL | fn bare<T>() {}
+   |         ^ required by the implicit `Sized` requirement on this type parameter in `bare`
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL | fn bare<T: ?Sized>() {}
+   |          ++++++++
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/default-bound.rs:31:13
+   |
+LL |     sized::<[u8]>();
+   |             ^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+note: required by a bound in `sized`
+  --> $DIR/default-bound.rs:9:13
+   |
+LL | fn sized<T: Sized>() {}
+   |             ^^^^^ required by this bound in `sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/default-bound.rs:42:12
+   |
+LL |     bare::<Foo>();
+   |            ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+note: required by an implicit `Sized` bound in `bare`
+  --> $DIR/default-bound.rs:6:9
+   |
+LL | fn bare<T>() {}
+   |         ^ required by the implicit `Sized` requirement on this type parameter in `bare`
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL | fn bare<T: ?Sized>() {}
+   |          ++++++++
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/default-bound.rs:44:13
+   |
+LL |     sized::<Foo>();
+   |             ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+note: required by a bound in `sized`
+  --> $DIR/default-bound.rs:9:13
+   |
+LL | fn sized<T: Sized>() {}
+   |             ^^^^^ required by this bound in `sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known
+  --> $DIR/default-bound.rs:46:17
+   |
+LL |     metasized::<Foo>();
+   |                 ^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `main::Foo`
+note: required by a bound in `metasized`
+  --> $DIR/default-bound.rs:14:17
+   |
+LL | fn metasized<T: MetaSized>() {}
+   |                 ^^^^^^^^^ required by this bound in `metasized`
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/sized-hierarchy/default-supertrait.rs b/tests/ui/sized-hierarchy/default-supertrait.rs
new file mode 100644
index 00000000000..b25acf9e6ea
--- /dev/null
+++ b/tests/ui/sized-hierarchy/default-supertrait.rs
@@ -0,0 +1,61 @@
+//@ check-fail
+#![feature(sized_hierarchy)]
+
+use std::marker::{MetaSized, PointeeSized};
+
+trait Sized_: Sized { }
+
+trait NegSized: ?Sized { }
+//~^ ERROR `?Trait` is not permitted in supertraits
+
+trait MetaSized_: MetaSized { }
+
+trait NegMetaSized: ?MetaSized { }
+//~^ ERROR `?Trait` is not permitted in supertraits
+
+
+trait PointeeSized_: PointeeSized { }
+
+trait NegPointeeSized: ?PointeeSized { }
+//~^ ERROR `?Trait` is not permitted in supertraits
+
+trait Bare {}
+
+fn requires_sized<T: Sized>() {}
+fn requires_metasized<T: MetaSized>() {}
+fn requires_pointeesized<T: PointeeSized>() {}
+
+fn with_sized_supertrait<T: PointeeSized + Sized_>() {
+    requires_sized::<T>();
+    requires_metasized::<T>();
+    requires_pointeesized::<T>();
+}
+
+fn with_metasized_supertrait<T: PointeeSized + MetaSized_>() {
+    requires_sized::<T>();
+    //~^ ERROR the size for values of type `T` cannot be known at compilation time
+    requires_metasized::<T>();
+    requires_pointeesized::<T>();
+}
+
+// It isn't really possible to write this one..
+fn with_pointeesized_supertrait<T: PointeeSized + PointeeSized_>() {
+    requires_sized::<T>();
+    //~^ ERROR the size for values of type `T` cannot be known
+    requires_metasized::<T>();
+    //~^ ERROR the size for values of type `T` cannot be known
+    requires_pointeesized::<T>();
+}
+
+// `T` won't inherit the `const MetaSized` implicit supertrait of `Bare`, so there is an error on
+// the bound, which is expected.
+fn with_bare_trait<T: PointeeSized + Bare>() {
+//~^ ERROR the size for values of type `T` cannot be known
+    requires_sized::<T>();
+    //~^ ERROR the size for values of type `T` cannot be known
+    requires_metasized::<T>();
+    //~^ ERROR the size for values of type `T` cannot be known
+    requires_pointeesized::<T>();
+}
+
+fn main() { }
diff --git a/tests/ui/sized-hierarchy/default-supertrait.stderr b/tests/ui/sized-hierarchy/default-supertrait.stderr
new file mode 100644
index 00000000000..de23936b900
--- /dev/null
+++ b/tests/ui/sized-hierarchy/default-supertrait.stderr
@@ -0,0 +1,125 @@
+error[E0658]: `?Trait` is not permitted in supertraits
+  --> $DIR/default-supertrait.rs:8:17
+   |
+LL | trait NegSized: ?Sized { }
+   |                 ^^^^^^
+   |
+   = note: traits are `?Sized` by default
+   = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error[E0658]: `?Trait` is not permitted in supertraits
+  --> $DIR/default-supertrait.rs:13:21
+   |
+LL | trait NegMetaSized: ?MetaSized { }
+   |                     ^^^^^^^^^^
+   |
+   = note: traits are `?MetaSized` by default
+   = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error[E0658]: `?Trait` is not permitted in supertraits
+  --> $DIR/default-supertrait.rs:19:24
+   |
+LL | trait NegPointeeSized: ?PointeeSized { }
+   |                        ^^^^^^^^^^^^^
+   |
+   = note: traits are `?PointeeSized` by default
+   = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error[E0277]: the size for values of type `T` cannot be known
+  --> $DIR/default-supertrait.rs:52:38
+   |
+LL | fn with_bare_trait<T: PointeeSized + Bare>() {
+   |                                      ^^^^ doesn't have a known size
+   |
+note: required by a bound in `Bare`
+  --> $DIR/default-supertrait.rs:22:1
+   |
+LL | trait Bare {}
+   | ^^^^^^^^^^^^^ required by this bound in `Bare`
+help: consider further restricting type parameter `T` with unstable trait `MetaSized`
+   |
+LL | fn with_bare_trait<T: PointeeSized + Bare + std::marker::MetaSized>() {
+   |                                           ++++++++++++++++++++++++
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+  --> $DIR/default-supertrait.rs:35:22
+   |
+LL | fn with_metasized_supertrait<T: PointeeSized + MetaSized_>() {
+   |                              - this type parameter needs to be `Sized`
+LL |     requires_sized::<T>();
+   |                      ^ doesn't have a size known at compile-time
+   |
+note: required by a bound in `requires_sized`
+  --> $DIR/default-supertrait.rs:24:22
+   |
+LL | fn requires_sized<T: Sized>() {}
+   |                      ^^^^^ required by this bound in `requires_sized`
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+  --> $DIR/default-supertrait.rs:43:22
+   |
+LL | fn with_pointeesized_supertrait<T: PointeeSized + PointeeSized_>() {
+   |                                 - this type parameter needs to be `Sized`
+LL |     requires_sized::<T>();
+   |                      ^ doesn't have a size known at compile-time
+   |
+note: required by a bound in `requires_sized`
+  --> $DIR/default-supertrait.rs:24:22
+   |
+LL | fn requires_sized<T: Sized>() {}
+   |                      ^^^^^ required by this bound in `requires_sized`
+
+error[E0277]: the size for values of type `T` cannot be known
+  --> $DIR/default-supertrait.rs:45:26
+   |
+LL |     requires_metasized::<T>();
+   |                          ^ doesn't have a known size
+   |
+note: required by a bound in `requires_metasized`
+  --> $DIR/default-supertrait.rs:25:26
+   |
+LL | fn requires_metasized<T: MetaSized>() {}
+   |                          ^^^^^^^^^ required by this bound in `requires_metasized`
+help: consider further restricting type parameter `T` with unstable trait `MetaSized`
+   |
+LL | fn with_pointeesized_supertrait<T: PointeeSized + PointeeSized_ + std::marker::MetaSized>() {
+   |                                                                 ++++++++++++++++++++++++
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+  --> $DIR/default-supertrait.rs:54:22
+   |
+LL | fn with_bare_trait<T: PointeeSized + Bare>() {
+   |                    - this type parameter needs to be `Sized`
+LL |
+LL |     requires_sized::<T>();
+   |                      ^ doesn't have a size known at compile-time
+   |
+note: required by a bound in `requires_sized`
+  --> $DIR/default-supertrait.rs:24:22
+   |
+LL | fn requires_sized<T: Sized>() {}
+   |                      ^^^^^ required by this bound in `requires_sized`
+
+error[E0277]: the size for values of type `T` cannot be known
+  --> $DIR/default-supertrait.rs:56:26
+   |
+LL |     requires_metasized::<T>();
+   |                          ^ doesn't have a known size
+   |
+note: required by a bound in `requires_metasized`
+  --> $DIR/default-supertrait.rs:25:26
+   |
+LL | fn requires_metasized<T: MetaSized>() {}
+   |                          ^^^^^^^^^ required by this bound in `requires_metasized`
+help: consider further restricting type parameter `T` with unstable trait `MetaSized`
+   |
+LL | fn with_bare_trait<T: PointeeSized + Bare + std::marker::MetaSized>() {
+   |                                           ++++++++++++++++++++++++
+
+error: aborting due to 9 previous errors
+
+Some errors have detailed explanations: E0277, E0658.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/sized-hierarchy/elaboration-opt-regions-1.rs b/tests/ui/sized-hierarchy/elaboration-opt-regions-1.rs
new file mode 100644
index 00000000000..d59227beae8
--- /dev/null
+++ b/tests/ui/sized-hierarchy/elaboration-opt-regions-1.rs
@@ -0,0 +1,18 @@
+//@ check-pass
+//@ compile-flags: --crate-type=lib
+//@ revisions: old next
+//@[next] compile-flags: -Znext-solver
+#![feature(sized_hierarchy)]
+
+use std::marker::{PhantomData, MetaSized, PointeeSized};
+
+struct Foo<'a, T: PointeeSized>(*mut &'a (), T);
+
+fn requires_metasized<'a, T: MetaSized>(f: &'a T) {}
+
+fn foo<'a, T: PointeeSized>(f: &Foo<'a, T>)
+where
+    Foo<'a, T>: Sized
+{
+    requires_metasized(f);
+}
diff --git a/tests/ui/sized-hierarchy/elaboration-opt-regions.rs b/tests/ui/sized-hierarchy/elaboration-opt-regions.rs
new file mode 100644
index 00000000000..66e600f3dc9
--- /dev/null
+++ b/tests/ui/sized-hierarchy/elaboration-opt-regions.rs
@@ -0,0 +1,18 @@
+//@ check-pass
+//@ compile-flags: --crate-type=lib
+//@ revisions: old next
+//@[next] compile-flags: -Znext-solver
+#![feature(sized_hierarchy)]
+
+use std::marker::{PhantomData, MetaSized, PointeeSized};
+
+struct Foo<'a, T: PointeeSized>(PhantomData<&'a T>, T);
+
+fn requires_metasized<T: MetaSized>() {}
+
+fn foo<'a, T: 'a + PointeeSized>()
+where
+    Foo<'a, T>: Sized
+{
+    requires_metasized::<Foo<'_, T>>();
+}
diff --git a/tests/ui/sized-hierarchy/extern-type-behind-ptr.rs b/tests/ui/sized-hierarchy/extern-type-behind-ptr.rs
new file mode 100644
index 00000000000..70a84aabf2c
--- /dev/null
+++ b/tests/ui/sized-hierarchy/extern-type-behind-ptr.rs
@@ -0,0 +1,20 @@
+//@ check-pass
+#![feature(extern_types, sized_hierarchy)]
+
+use std::marker::{MetaSized, PointeeSized};
+
+pub fn hash<T: PointeeSized>(_: *const T) {
+    unimplemented!();
+}
+
+unsafe extern "C" {
+    type Foo;
+}
+
+fn get() -> *const Foo {
+    unimplemented!()
+}
+
+fn main() {
+    hash::<Foo>(get());
+}
diff --git a/tests/ui/sized-hierarchy/impls.rs b/tests/ui/sized-hierarchy/impls.rs
new file mode 100644
index 00000000000..46697e47c4b
--- /dev/null
+++ b/tests/ui/sized-hierarchy/impls.rs
@@ -0,0 +1,310 @@
+//@ check-fail
+//@ edition: 2024
+
+#![allow(incomplete_features, internal_features)]
+#![feature(sized_hierarchy)]
+#![feature(coroutines, dyn_star, extern_types, f16, never_type, unsized_fn_params)]
+
+use std::fmt::Debug;
+use std::marker::{MetaSized, PointeeSized};
+
+// This test checks that `Sized` and `MetaSized` are automatically implemented appropriately.
+
+fn needs_sized<T: Sized>() { }
+fn takes_sized<T: Sized>(_t: T) { }
+
+fn needs_metasized<T: MetaSized>() { }
+fn takes_metasized<T: MetaSized>(_t: T) { }
+
+fn needs_pointeesized<T: PointeeSized>() { }
+fn takes_pointeesized<T: PointeeSized>(_t: T) { }
+
+fn main() {
+    // `bool`
+    needs_sized::<bool>();
+    needs_metasized::<bool>();
+    needs_pointeesized::<bool>();
+
+    // `char`
+    needs_sized::<char>();
+    needs_metasized::<char>();
+    needs_pointeesized::<char>();
+
+    // `i8`
+    needs_sized::<i8>();
+    needs_metasized::<i8>();
+    needs_pointeesized::<i8>();
+
+    // `i16`
+    needs_sized::<i16>();
+    needs_metasized::<i16>();
+    needs_pointeesized::<i16>();
+
+    // `i32`
+    needs_sized::<i32>();
+    needs_metasized::<i32>();
+    needs_pointeesized::<i32>();
+
+    // `i64`
+    needs_sized::<i64>();
+    needs_metasized::<i64>();
+    needs_pointeesized::<i64>();
+
+    // `i128`
+    needs_sized::<i128>();
+    needs_metasized::<i128>();
+    needs_pointeesized::<i128>();
+
+    // `u8`
+    needs_sized::<u8>();
+    needs_metasized::<u8>();
+    needs_pointeesized::<u8>();
+
+    // `u16`
+    needs_sized::<u16>();
+    needs_metasized::<u16>();
+    needs_pointeesized::<u16>();
+
+    // `u32`
+    needs_sized::<u32>();
+    needs_metasized::<u32>();
+    needs_pointeesized::<u32>();
+
+    // `u64`
+    needs_sized::<u64>();
+    needs_metasized::<u64>();
+    needs_pointeesized::<u64>();
+
+    // `u128`
+    needs_sized::<u128>();
+    needs_metasized::<u128>();
+    needs_pointeesized::<u128>();
+
+    // `f16`
+    needs_sized::<f16>();
+    needs_metasized::<f16>();
+    needs_pointeesized::<f16>();
+
+    // `f32`
+    needs_sized::<f32>();
+    needs_metasized::<f32>();
+    needs_pointeesized::<f32>();
+
+    // `f64`
+    needs_sized::<f64>();
+    needs_metasized::<f64>();
+    needs_pointeesized::<f64>();
+
+    // `*const`
+    needs_sized::<*const u8>();
+    needs_metasized::<*const u8>();
+    needs_pointeesized::<*const u8>();
+
+    // `*mut`
+    needs_sized::<*mut u8>();
+    needs_metasized::<*mut u8>();
+    needs_pointeesized::<*mut u8>();
+
+    // `&`
+    needs_sized::<&u8>();
+    needs_metasized::<&u8>();
+    needs_pointeesized::<&u8>();
+
+    // `&mut`
+    needs_sized::<&mut u8>();
+    needs_metasized::<&mut u8>();
+    needs_pointeesized::<&mut u8>();
+
+    // fn-def
+    fn foo(x: u8) -> u8 { x }
+    takes_sized(foo);
+    takes_metasized(foo);
+    takes_pointeesized(foo);
+
+    // fn-ptr
+    takes_sized::<fn(u8) -> u8>(foo);
+    takes_metasized::<fn(u8) -> u8>(foo);
+    takes_pointeesized::<fn(u8) -> u8>(foo);
+
+    // `[T; x]`
+    needs_sized::<[u8; 1]>();
+    needs_metasized::<[u8; 1]>();
+    needs_pointeesized::<[u8; 1]>();
+
+    // `|a| { a }`
+    takes_sized(|a| { a });
+    takes_metasized(|a| { a });
+    takes_pointeesized(|a| { a });
+
+    // `async |a| { a }`
+    takes_sized(async |a| { a });
+    takes_metasized(async |a| { a });
+    takes_pointeesized(async |a| { a });
+
+    // `|a| { yield a }`
+    takes_sized(#[coroutine] |a| { yield a });
+    takes_metasized(#[coroutine] |a| { yield a });
+    takes_pointeesized(#[coroutine] |a| { yield a });
+
+    // `!`
+    needs_sized::<!>();
+    needs_metasized::<!>();
+    needs_pointeesized::<!>();
+
+    // `dyn*`
+    needs_sized::<dyn* Debug>();
+    needs_metasized::<dyn* Debug>();
+    needs_pointeesized::<dyn* Debug>();
+
+    // `str`
+    needs_sized::<str>();
+    //~^ ERROR the size for values of type `str` cannot be known at compilation time
+    needs_metasized::<str>();
+    needs_pointeesized::<str>();
+
+    // `[T]`
+    needs_sized::<[u8]>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_metasized::<[u8]>();
+    needs_pointeesized::<[u8]>();
+
+    // `dyn Debug`
+    needs_sized::<dyn Debug>();
+    //~^ ERROR the size for values of type `dyn Debug` cannot be known at compilation time
+    needs_metasized::<dyn Debug>();
+    needs_pointeesized::<dyn Debug>();
+
+    // `extern type`
+    unsafe extern "C" {
+        type Foo;
+    }
+    needs_sized::<Foo>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    needs_metasized::<Foo>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known
+    needs_pointeesized::<Foo>();
+
+    // empty tuple
+    needs_sized::<()>();
+    needs_metasized::<()>();
+    needs_pointeesized::<()>();
+
+    // tuple w/ all elements sized
+    needs_sized::<(u32, u32)>();
+    needs_metasized::<(u32, u32)>();
+    needs_pointeesized::<(u32, u32)>();
+
+    // tuple w/ all elements metasized
+    needs_sized::<([u8], [u8])>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_metasized::<([u8], [u8])>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_pointeesized::<([u8], [u8])>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+
+    // tuple w/ all elements pointeesized
+    needs_sized::<(Foo, Foo)>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    needs_metasized::<(Foo, Foo)>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    //~| ERROR the size for values of type `main::Foo` cannot be known
+    needs_pointeesized::<(Foo, Foo)>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+
+    // tuple w/ last element metasized
+    needs_sized::<(u32, [u8])>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_metasized::<(u32, [u8])>();
+    needs_pointeesized::<(u32, [u8])>();
+
+    // tuple w/ last element pointeesized
+    needs_sized::<(u32, Foo)>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    needs_metasized::<(u32, Foo)>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known
+    needs_pointeesized::<(u32, Foo)>();
+
+    // struct w/ no fields
+    struct StructEmpty {}
+    needs_sized::<StructEmpty>();
+    needs_metasized::<StructEmpty>();
+    needs_pointeesized::<StructEmpty>();
+
+    // struct w/ all fields sized
+    struct StructAllFieldsSized { x: u32, y: u32 }
+    needs_sized::<StructAllFieldsSized>();
+    needs_metasized::<StructAllFieldsSized>();
+    needs_pointeesized::<StructAllFieldsSized>();
+
+    // struct w/ all fields metasized
+    struct StructAllFieldsMetaSized { x: [u8], y: [u8] }
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_sized::<StructAllFieldsMetaSized>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_metasized::<StructAllFieldsMetaSized>();
+    needs_pointeesized::<StructAllFieldsMetaSized>();
+
+    // struct w/ all fields unsized
+    struct StructAllFieldsUnsized { x: Foo, y: Foo }
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    needs_sized::<StructAllFieldsUnsized>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    needs_metasized::<StructAllFieldsUnsized>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known
+    needs_pointeesized::<StructAllFieldsUnsized>();
+
+    // struct w/ last fields metasized
+    struct StructLastFieldMetaSized { x: u32, y: [u8] }
+    needs_sized::<StructLastFieldMetaSized>();
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_metasized::<StructLastFieldMetaSized>();
+    needs_pointeesized::<StructLastFieldMetaSized>();
+
+    // struct w/ last fields unsized
+    struct StructLastFieldUnsized { x: u32, y: Foo }
+    needs_sized::<StructLastFieldUnsized>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    needs_metasized::<StructLastFieldUnsized>();
+    //~^ ERROR the size for values of type `main::Foo` cannot be known
+    needs_pointeesized::<StructLastFieldUnsized>();
+
+    // enum w/ no fields
+    enum EnumEmpty {}
+    needs_sized::<EnumEmpty>();
+    needs_metasized::<EnumEmpty>();
+    needs_pointeesized::<EnumEmpty>();
+
+    // enum w/ all variant fields sized
+    enum EnumAllFieldsSized { Qux { x: u32, y: u32 } }
+    needs_sized::<StructAllFieldsSized>();
+    needs_metasized::<StructAllFieldsSized>();
+    needs_pointeesized::<StructAllFieldsSized>();
+
+    // enum w/ all variant fields metasized
+    enum EnumAllFieldsMetaSized { Qux { x: [u8], y: [u8] } }
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_sized::<EnumAllFieldsMetaSized>();
+    needs_metasized::<EnumAllFieldsMetaSized>();
+    needs_pointeesized::<EnumAllFieldsMetaSized>();
+
+    // enum w/ all variant fields unsized
+    enum EnumAllFieldsUnsized { Qux { x: Foo, y: Foo } }
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    needs_sized::<EnumAllFieldsUnsized>();
+    needs_metasized::<EnumAllFieldsUnsized>();
+    needs_pointeesized::<EnumAllFieldsUnsized>();
+
+    // enum w/ last variant fields metasized
+    enum EnumLastFieldMetaSized { Qux { x: u32, y: [u8] } }
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+    needs_sized::<EnumLastFieldMetaSized>();
+    needs_metasized::<EnumLastFieldMetaSized>();
+    needs_pointeesized::<EnumLastFieldMetaSized>();
+
+    // enum w/ last variant fields unsized
+    enum EnumLastFieldUnsized { Qux { x: u32, y: Foo } }
+    //~^ ERROR the size for values of type `main::Foo` cannot be known at compilation time
+    needs_sized::<EnumLastFieldUnsized>();
+    needs_metasized::<EnumLastFieldUnsized>();
+    needs_pointeesized::<EnumLastFieldUnsized>();
+}
diff --git a/tests/ui/sized-hierarchy/impls.stderr b/tests/ui/sized-hierarchy/impls.stderr
new file mode 100644
index 00000000000..eebe4e0d706
--- /dev/null
+++ b/tests/ui/sized-hierarchy/impls.stderr
@@ -0,0 +1,394 @@
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:240:42
+   |
+LL |     struct StructAllFieldsMetaSized { x: [u8], y: [u8] }
+   |                                          ^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+   = note: only the last field of a struct 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
+   |
+LL |     struct StructAllFieldsMetaSized { x: &[u8], y: [u8] }
+   |                                          +
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     struct StructAllFieldsMetaSized { x: Box<[u8]>, y: [u8] }
+   |                                          ++++    +
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:248:40
+   |
+LL |     struct StructAllFieldsUnsized { x: Foo, y: Foo }
+   |                                        ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+   = note: only the last field of a struct 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
+   |
+LL |     struct StructAllFieldsUnsized { x: &Foo, y: Foo }
+   |                                        +
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     struct StructAllFieldsUnsized { x: Box<Foo>, y: Foo }
+   |                                        ++++   +
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:284:44
+   |
+LL |     enum EnumAllFieldsMetaSized { Qux { x: [u8], y: [u8] } }
+   |                                            ^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+   = 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
+   |
+LL |     enum EnumAllFieldsMetaSized { Qux { x: &[u8], y: [u8] } }
+   |                                            +
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     enum EnumAllFieldsMetaSized { Qux { x: Box<[u8]>, y: [u8] } }
+   |                                            ++++    +
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:291:42
+   |
+LL |     enum EnumAllFieldsUnsized { Qux { x: Foo, y: Foo } }
+   |                                          ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+   = 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
+   |
+LL |     enum EnumAllFieldsUnsized { Qux { x: &Foo, y: Foo } }
+   |                                          +
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     enum EnumAllFieldsUnsized { Qux { x: Box<Foo>, y: Foo } }
+   |                                          ++++   +
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:298:52
+   |
+LL |     enum EnumLastFieldMetaSized { Qux { x: u32, y: [u8] } }
+   |                                                    ^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+   = 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
+   |
+LL |     enum EnumLastFieldMetaSized { Qux { x: u32, y: &[u8] } }
+   |                                                    +
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     enum EnumLastFieldMetaSized { Qux { x: u32, y: Box<[u8]> } }
+   |                                                    ++++    +
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:305:50
+   |
+LL |     enum EnumLastFieldUnsized { Qux { x: u32, y: Foo } }
+   |                                                  ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+   = 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
+   |
+LL |     enum EnumLastFieldUnsized { Qux { x: u32, y: &Foo } }
+   |                                                  +
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     enum EnumLastFieldUnsized { Qux { x: u32, y: Box<Foo> } }
+   |                                                  ++++   +
+
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+  --> $DIR/impls.rs:160:19
+   |
+LL |     needs_sized::<str>();
+   |                   ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `str`
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:166:19
+   |
+LL |     needs_sized::<[u8]>();
+   |                   ^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
+  --> $DIR/impls.rs:172:19
+   |
+LL |     needs_sized::<dyn Debug>();
+   |                   ^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `dyn Debug`
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:181:19
+   |
+LL |     needs_sized::<Foo>();
+   |                   ^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known
+  --> $DIR/impls.rs:183:23
+   |
+LL |     needs_metasized::<Foo>();
+   |                       ^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `main::Foo`
+note: required by a bound in `needs_metasized`
+  --> $DIR/impls.rs:16:23
+   |
+LL | fn needs_metasized<T: MetaSized>() { }
+   |                       ^^^^^^^^^ required by this bound in `needs_metasized`
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:198:19
+   |
+LL |     needs_sized::<([u8], [u8])>();
+   |                   ^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+   = note: only the last element of a tuple may have a dynamically sized type
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:200:23
+   |
+LL |     needs_metasized::<([u8], [u8])>();
+   |                       ^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+   = note: only the last element of a tuple may have a dynamically sized type
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:202:26
+   |
+LL |     needs_pointeesized::<([u8], [u8])>();
+   |                          ^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+   = note: only the last element of a tuple may have a dynamically sized type
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:206:19
+   |
+LL |     needs_sized::<(Foo, Foo)>();
+   |                   ^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+   = note: only the last element of a tuple may have a dynamically sized type
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:208:23
+   |
+LL |     needs_metasized::<(Foo, Foo)>();
+   |                       ^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+   = note: only the last element of a tuple may have a dynamically sized type
+
+error[E0277]: the size for values of type `main::Foo` cannot be known
+  --> $DIR/impls.rs:208:23
+   |
+LL |     needs_metasized::<(Foo, Foo)>();
+   |                       ^^^^^^^^^^ doesn't have a known size
+   |
+   = help: within `(main::Foo, main::Foo)`, the trait `MetaSized` is not implemented for `main::Foo`
+   = note: required because it appears within the type `(main::Foo, main::Foo)`
+note: required by a bound in `needs_metasized`
+  --> $DIR/impls.rs:16:23
+   |
+LL | fn needs_metasized<T: MetaSized>() { }
+   |                       ^^^^^^^^^ required by this bound in `needs_metasized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:211:26
+   |
+LL |     needs_pointeesized::<(Foo, Foo)>();
+   |                          ^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `main::Foo`
+   = note: only the last element of a tuple may have a dynamically sized type
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:215:19
+   |
+LL |     needs_sized::<(u32, [u8])>();
+   |                   ^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: within `(u32, [u8])`, the trait `Sized` is not implemented for `[u8]`
+   = note: required because it appears within the type `(u32, [u8])`
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:221:19
+   |
+LL |     needs_sized::<(u32, Foo)>();
+   |                   ^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: within `(u32, main::Foo)`, the trait `Sized` is not implemented for `main::Foo`
+   = note: required because it appears within the type `(u32, main::Foo)`
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known
+  --> $DIR/impls.rs:223:23
+   |
+LL |     needs_metasized::<(u32, Foo)>();
+   |                       ^^^^^^^^^^ doesn't have a known size
+   |
+   = help: within `(u32, main::Foo)`, the trait `MetaSized` is not implemented for `main::Foo`
+   = note: required because it appears within the type `(u32, main::Foo)`
+note: required by a bound in `needs_metasized`
+  --> $DIR/impls.rs:16:23
+   |
+LL | fn needs_metasized<T: MetaSized>() { }
+   |                       ^^^^^^^^^ required by this bound in `needs_metasized`
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:242:19
+   |
+LL |     needs_sized::<StructAllFieldsMetaSized>();
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: within `StructAllFieldsMetaSized`, the trait `Sized` is not implemented for `[u8]`
+note: required because it appears within the type `StructAllFieldsMetaSized`
+  --> $DIR/impls.rs:240:12
+   |
+LL |     struct StructAllFieldsMetaSized { x: [u8], y: [u8] }
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:250:19
+   |
+LL |     needs_sized::<StructAllFieldsUnsized>();
+   |                   ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: within `StructAllFieldsUnsized`, the trait `Sized` is not implemented for `main::Foo`
+note: required because it appears within the type `StructAllFieldsUnsized`
+  --> $DIR/impls.rs:248:12
+   |
+LL |     struct StructAllFieldsUnsized { x: Foo, y: Foo }
+   |            ^^^^^^^^^^^^^^^^^^^^^^
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known
+  --> $DIR/impls.rs:252:23
+   |
+LL |     needs_metasized::<StructAllFieldsUnsized>();
+   |                       ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size
+   |
+   = help: within `StructAllFieldsUnsized`, the trait `MetaSized` is not implemented for `main::Foo`
+note: required because it appears within the type `StructAllFieldsUnsized`
+  --> $DIR/impls.rs:248:12
+   |
+LL |     struct StructAllFieldsUnsized { x: Foo, y: Foo }
+   |            ^^^^^^^^^^^^^^^^^^^^^^
+note: required by a bound in `needs_metasized`
+  --> $DIR/impls.rs:16:23
+   |
+LL | fn needs_metasized<T: MetaSized>() { }
+   |                       ^^^^^^^^^ required by this bound in `needs_metasized`
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/impls.rs:258:19
+   |
+LL |     needs_sized::<StructLastFieldMetaSized>();
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: within `StructLastFieldMetaSized`, the trait `Sized` is not implemented for `[u8]`
+note: required because it appears within the type `StructLastFieldMetaSized`
+  --> $DIR/impls.rs:257:12
+   |
+LL |     struct StructLastFieldMetaSized { x: u32, y: [u8] }
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time
+  --> $DIR/impls.rs:265:19
+   |
+LL |     needs_sized::<StructLastFieldUnsized>();
+   |                   ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: within `StructLastFieldUnsized`, the trait `Sized` is not implemented for `main::Foo`
+note: required because it appears within the type `StructLastFieldUnsized`
+  --> $DIR/impls.rs:264:12
+   |
+LL |     struct StructLastFieldUnsized { x: u32, y: Foo }
+   |            ^^^^^^^^^^^^^^^^^^^^^^
+note: required by a bound in `needs_sized`
+  --> $DIR/impls.rs:13:19
+   |
+LL | fn needs_sized<T: Sized>() { }
+   |                   ^^^^^ required by this bound in `needs_sized`
+
+error[E0277]: the size for values of type `main::Foo` cannot be known
+  --> $DIR/impls.rs:267:23
+   |
+LL |     needs_metasized::<StructLastFieldUnsized>();
+   |                       ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size
+   |
+   = help: within `StructLastFieldUnsized`, the trait `MetaSized` is not implemented for `main::Foo`
+note: required because it appears within the type `StructLastFieldUnsized`
+  --> $DIR/impls.rs:264:12
+   |
+LL |     struct StructLastFieldUnsized { x: u32, y: Foo }
+   |            ^^^^^^^^^^^^^^^^^^^^^^
+note: required by a bound in `needs_metasized`
+  --> $DIR/impls.rs:16:23
+   |
+LL | fn needs_metasized<T: MetaSized>() { }
+   |                       ^^^^^^^^^ required by this bound in `needs_metasized`
+
+error: aborting due to 27 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/sized-hierarchy/overflow.current.stderr b/tests/ui/sized-hierarchy/overflow.current.stderr
new file mode 100644
index 00000000000..e90548aa78c
--- /dev/null
+++ b/tests/ui/sized-hierarchy/overflow.current.stderr
@@ -0,0 +1,45 @@
+error[E0275]: overflow evaluating the requirement `Element: MetaSized`
+  --> $DIR/overflow.rs:16:16
+   |
+LL | struct Element(<Box<Box<Element>> as ParseTokens>::Output);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: required for `Box<Element>` to implement `ParseTokens`
+  --> $DIR/overflow.rs:12:31
+   |
+LL | impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> {
+   |      -                        ^^^^^^^^^^^     ^^^^^^
+   |      |
+   |      unsatisfied trait bound introduced here
+   = note: 1 redundant requirement hidden
+   = note: required for `Box<Box<Element>>` to implement `ParseTokens`
+
+error[E0275]: overflow evaluating the requirement `Box<Element>: ParseTokens`
+  --> $DIR/overflow.rs:18:22
+   |
+LL | impl ParseTokens for Element {
+   |                      ^^^^^^^
+   |
+note: required for `Box<Box<Element>>` to implement `ParseTokens`
+  --> $DIR/overflow.rs:12:31
+   |
+LL | impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> {
+   |         -----------           ^^^^^^^^^^^     ^^^^^^
+   |         |
+   |         unsatisfied trait bound introduced here
+note: required because it appears within the type `Element`
+  --> $DIR/overflow.rs:16:8
+   |
+LL | struct Element(<Box<Box<Element>> as ParseTokens>::Output);
+   |        ^^^^^^^
+note: required by a bound in `ParseTokens`
+  --> $DIR/overflow.rs:9:1
+   |
+LL | / trait ParseTokens {
+LL | |     type Output;
+LL | | }
+   | |_^ required by this bound in `ParseTokens`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/sized-hierarchy/overflow.rs b/tests/ui/sized-hierarchy/overflow.rs
new file mode 100644
index 00000000000..e1af4885e53
--- /dev/null
+++ b/tests/ui/sized-hierarchy/overflow.rs
@@ -0,0 +1,21 @@
+//@ compile-flags: --crate-type=lib
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] check-pass
+//@[next] compile-flags: -Znext-solver
+
+use std::marker::PhantomData;
+
+trait ParseTokens {
+    type Output;
+}
+impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> {
+    type Output = ();
+}
+
+struct Element(<Box<Box<Element>> as ParseTokens>::Output);
+//[current]~^ ERROR overflow evaluating
+impl ParseTokens for Element {
+//[current]~^ ERROR overflow evaluating
+    type Output = ();
+}
diff --git a/tests/ui/sized-hierarchy/pointee-supertrait.rs b/tests/ui/sized-hierarchy/pointee-supertrait.rs
new file mode 100644
index 00000000000..4bf486890bf
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pointee-supertrait.rs
@@ -0,0 +1,28 @@
+//@ check-pass
+#![feature(sized_hierarchy)]
+
+// This is a reduction of some code in `library/core/src/cmp.rs` that would ICE if a default
+// `Pointee` bound is added - motivating the current status quo of `PointeeSized` being syntactic
+// sugar for an absense of any bounds whatsoever.
+
+use std::marker::PhantomData;
+
+pub trait Bar<'a> {
+    type Foo;
+}
+
+pub struct Foo<'a, T: Bar<'a>> {
+    phantom: PhantomData<&'a T>,
+}
+
+impl<'a, 'b, T> PartialEq<Foo<'b, T>> for Foo<'a, T>
+    where
+        T: for<'c> Bar<'c>,
+        <T as Bar<'a>>::Foo: PartialEq<<T as Bar<'b>>::Foo>,
+{
+    fn eq(&self, _: &Foo<'b, T>) -> bool {
+        loop {}
+    }
+}
+
+fn main() { }
diff --git a/tests/ui/sized-hierarchy/pretty-print-no-feat-dep-has-feat.rs b/tests/ui/sized-hierarchy/pretty-print-no-feat-dep-has-feat.rs
new file mode 100644
index 00000000000..0412ff651ce
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print-no-feat-dep-has-feat.rs
@@ -0,0 +1,26 @@
+//@ aux-build:pretty-print-dep.rs
+//@ compile-flags: --crate-type=lib
+
+extern crate pretty_print_dep;
+use pretty_print_dep::{SizedTr, NegSizedTr, MetaSizedTr, PointeeSizedTr};
+
+// Test that printing the sizedness trait bounds in the conflicting impl error without enabling
+// `sized_hierarchy` will continue to print `?Sized`, even if the dependency is compiled with
+// `sized_hierarchy`.
+//
+// It isn't possible to write a test that matches the multiline note containing the important
+// diagnostic output being tested - so check the stderr changes carefully!
+
+struct X<T>(T);
+
+impl<T: Sized> SizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `SizedTr` for type `X<_>`
+
+impl<T: ?Sized> NegSizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `NegSizedTr` for type `X<_>`
+
+impl<T: ?Sized> MetaSizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `MetaSizedTr` for type `X<_>`
+
+impl<T: ?Sized> PointeeSizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `PointeeSizedTr` for type `X<_>`
diff --git a/tests/ui/sized-hierarchy/pretty-print-no-feat-dep-has-feat.stderr b/tests/ui/sized-hierarchy/pretty-print-no-feat-dep-has-feat.stderr
new file mode 100644
index 00000000000..cb9bfd178f8
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print-no-feat-dep-has-feat.stderr
@@ -0,0 +1,42 @@
+error[E0119]: conflicting implementations of trait `SizedTr` for type `X<_>`
+  --> $DIR/pretty-print-no-feat-dep-has-feat.rs:16:1
+   |
+LL | impl<T: Sized> SizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_dep`:
+           - impl<T> SizedTr for T;
+
+error[E0119]: conflicting implementations of trait `NegSizedTr` for type `X<_>`
+  --> $DIR/pretty-print-no-feat-dep-has-feat.rs:19:1
+   |
+LL | impl<T: ?Sized> NegSizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_dep`:
+           - impl<T> NegSizedTr for T
+             where T: ?Sized;
+
+error[E0119]: conflicting implementations of trait `MetaSizedTr` for type `X<_>`
+  --> $DIR/pretty-print-no-feat-dep-has-feat.rs:22:1
+   |
+LL | impl<T: ?Sized> MetaSizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_dep`:
+           - impl<T> MetaSizedTr for T
+             where T: ?Sized;
+
+error[E0119]: conflicting implementations of trait `PointeeSizedTr` for type `X<_>`
+  --> $DIR/pretty-print-no-feat-dep-has-feat.rs:25:1
+   |
+LL | impl<T: ?Sized> PointeeSizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_dep`:
+           - impl<T> PointeeSizedTr for T
+             where T: ?Sized;
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/sized-hierarchy/pretty-print-no-feat.rs b/tests/ui/sized-hierarchy/pretty-print-no-feat.rs
new file mode 100644
index 00000000000..d5800be5828
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print-no-feat.rs
@@ -0,0 +1,19 @@
+//@ aux-build:pretty-print-no-feat-dep.rs
+//@ compile-flags: --crate-type=lib
+
+extern crate pretty_print_no_feat_dep;
+use pretty_print_no_feat_dep::{SizedTr, NegSizedTr};
+
+// Test that printing the sizedness trait bounds in the conflicting impl error without enabling
+// `sized_hierarchy` will continue to print `?Sized`.
+//
+// It isn't possible to write a test that matches the multiline note containing the important
+// diagnostic output being tested - so check the stderr changes carefully!
+
+struct X<T>(T);
+
+impl<T: Sized> SizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `SizedTr` for type `X<_>`
+
+impl<T: ?Sized> NegSizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `NegSizedTr` for type `X<_>`
diff --git a/tests/ui/sized-hierarchy/pretty-print-no-feat.stderr b/tests/ui/sized-hierarchy/pretty-print-no-feat.stderr
new file mode 100644
index 00000000000..1d50f0145fe
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print-no-feat.stderr
@@ -0,0 +1,22 @@
+error[E0119]: conflicting implementations of trait `SizedTr` for type `X<_>`
+  --> $DIR/pretty-print-no-feat.rs:15:1
+   |
+LL | impl<T: Sized> SizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_no_feat_dep`:
+           - impl<T> SizedTr for T;
+
+error[E0119]: conflicting implementations of trait `NegSizedTr` for type `X<_>`
+  --> $DIR/pretty-print-no-feat.rs:18:1
+   |
+LL | impl<T: ?Sized> NegSizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_no_feat_dep`:
+           - impl<T> NegSizedTr for T
+             where T: ?Sized;
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/sized-hierarchy/pretty-print-opaque-no-feat.rs b/tests/ui/sized-hierarchy/pretty-print-opaque-no-feat.rs
new file mode 100644
index 00000000000..955108a2074
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print-opaque-no-feat.rs
@@ -0,0 +1,13 @@
+//@ compile-flags: --crate-type=lib
+
+pub trait Tr {}
+impl Tr for u32 {}
+
+pub fn foo() -> Box<impl Tr + ?Sized> {
+    if true {
+        let x = foo();
+        let y: Box<dyn Tr> = x;
+//~^ ERROR: the size for values of type `impl Tr + ?Sized` cannot be known
+    }
+    Box::new(1u32)
+}
diff --git a/tests/ui/sized-hierarchy/pretty-print-opaque-no-feat.stderr b/tests/ui/sized-hierarchy/pretty-print-opaque-no-feat.stderr
new file mode 100644
index 00000000000..bbe19870937
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print-opaque-no-feat.stderr
@@ -0,0 +1,12 @@
+error[E0277]: the size for values of type `impl Tr + ?Sized` cannot be known at compilation time
+  --> $DIR/pretty-print-opaque-no-feat.rs:9:30
+   |
+LL |         let y: Box<dyn Tr> = x;
+   |                              ^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `impl Tr + ?Sized`
+   = note: required for the cast from `Box<impl Tr + ?Sized>` to `Box<dyn Tr>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/sized-hierarchy/pretty-print-opaque.rs b/tests/ui/sized-hierarchy/pretty-print-opaque.rs
new file mode 100644
index 00000000000..2aceee23a01
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print-opaque.rs
@@ -0,0 +1,45 @@
+//@ compile-flags: --crate-type=lib
+#![feature(sized_hierarchy)]
+
+use std::marker::{MetaSized, PointeeSized};
+
+pub trait Tr: PointeeSized {}
+impl Tr for u32 {}
+
+pub fn sized() -> Box<impl Tr + Sized> {
+    if true {
+        let x = sized();
+        let y: Box<dyn Tr> = x;
+    }
+    Box::new(1u32)
+}
+
+pub fn neg_sized() -> Box<impl Tr + ?Sized> {
+    if true {
+        let x = neg_sized();
+        let y: Box<dyn Tr> = x;
+//~^ ERROR: the size for values of type `impl Tr + MetaSized` cannot be known
+    }
+    Box::new(1u32)
+}
+
+pub fn metasized() -> Box<impl Tr + MetaSized> {
+    if true {
+        let x = metasized();
+        let y: Box<dyn Tr> = x;
+//~^ ERROR: the size for values of type `impl Tr + MetaSized` cannot be known
+    }
+    Box::new(1u32)
+}
+
+pub fn pointeesized() -> Box<impl Tr + PointeeSized> {
+//~^ ERROR: the size for values of type `impl Tr + PointeeSized` cannot be known
+    if true {
+        let x = pointeesized();
+//~^ ERROR: the size for values of type `impl Tr + PointeeSized` cannot be known
+        let y: Box<dyn Tr> = x;
+//~^ ERROR: the size for values of type `impl Tr + PointeeSized` cannot be known
+//~| ERROR: the size for values of type `impl Tr + PointeeSized` cannot be known
+    }
+    Box::new(1u32)
+}
diff --git a/tests/ui/sized-hierarchy/pretty-print-opaque.stderr b/tests/ui/sized-hierarchy/pretty-print-opaque.stderr
new file mode 100644
index 00000000000..ecf4d912be8
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print-opaque.stderr
@@ -0,0 +1,59 @@
+error[E0277]: the size for values of type `impl Tr + PointeeSized` cannot be known
+  --> $DIR/pretty-print-opaque.rs:35:26
+   |
+LL | pub fn pointeesized() -> Box<impl Tr + PointeeSized> {
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `impl Tr + PointeeSized`
+note: required by a bound in `Box`
+  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+
+error[E0277]: the size for values of type `impl Tr + MetaSized` cannot be known at compilation time
+  --> $DIR/pretty-print-opaque.rs:20:30
+   |
+LL |         let y: Box<dyn Tr> = x;
+   |                              ^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `impl Tr + MetaSized`
+   = note: required for the cast from `Box<impl Tr + MetaSized>` to `Box<dyn Tr>`
+
+error[E0277]: the size for values of type `impl Tr + MetaSized` cannot be known at compilation time
+  --> $DIR/pretty-print-opaque.rs:29:30
+   |
+LL |         let y: Box<dyn Tr> = x;
+   |                              ^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `impl Tr + MetaSized`
+   = note: required for the cast from `Box<impl Tr + MetaSized>` to `Box<dyn Tr>`
+
+error[E0277]: the size for values of type `impl Tr + PointeeSized` cannot be known
+  --> $DIR/pretty-print-opaque.rs:38:17
+   |
+LL |         let x = pointeesized();
+   |                 ^^^^^^^^^^^^^^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `impl Tr + PointeeSized`
+note: required by a bound in `Box`
+  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+
+error[E0277]: the size for values of type `impl Tr + PointeeSized` cannot be known at compilation time
+  --> $DIR/pretty-print-opaque.rs:40:30
+   |
+LL |         let y: Box<dyn Tr> = x;
+   |                              ^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `impl Tr + PointeeSized`
+   = note: required for the cast from `Box<impl Tr + PointeeSized>` to `Box<dyn Tr>`
+
+error[E0277]: the size for values of type `impl Tr + PointeeSized` cannot be known
+  --> $DIR/pretty-print-opaque.rs:40:30
+   |
+LL |         let y: Box<dyn Tr> = x;
+   |                              ^ doesn't have a known size
+   |
+   = help: the trait `MetaSized` is not implemented for `impl Tr + PointeeSized`
+   = note: required for the cast from `Box<impl Tr + PointeeSized>` to `Box<dyn Tr>`
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/sized-hierarchy/pretty-print.rs b/tests/ui/sized-hierarchy/pretty-print.rs
new file mode 100644
index 00000000000..0908e76490c
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print.rs
@@ -0,0 +1,28 @@
+//@ aux-build:pretty-print-dep.rs
+//@ compile-flags: --crate-type=lib
+#![feature(sized_hierarchy)]
+
+// Test that printing the sizedness trait bounds in the conflicting impl error with
+// `sized_hierarchy` enabled prints all of the appropriate bounds.
+//
+// It isn't possible to write a test that matches the multiline note containing the important
+// diagnostic output being tested - so check the stderr changes carefully!
+
+use std::marker::{MetaSized, PointeeSized};
+
+extern crate pretty_print_dep;
+use pretty_print_dep::{SizedTr, MetaSizedTr, PointeeSizedTr};
+
+struct X<T>(T);
+
+impl<T: Sized> SizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `SizedTr` for type `X<_>`
+
+impl<T: ?Sized> pretty_print_dep::NegSizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `NegSizedTr` for type `X<_>`
+
+impl<T: MetaSized> MetaSizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `MetaSizedTr` for type `X<_>`
+
+impl<T: PointeeSized> PointeeSizedTr for X<T> {}
+//~^ ERROR conflicting implementations of trait `PointeeSizedTr` for type `X<_>`
diff --git a/tests/ui/sized-hierarchy/pretty-print.stderr b/tests/ui/sized-hierarchy/pretty-print.stderr
new file mode 100644
index 00000000000..3602c804945
--- /dev/null
+++ b/tests/ui/sized-hierarchy/pretty-print.stderr
@@ -0,0 +1,43 @@
+error[E0119]: conflicting implementations of trait `SizedTr` for type `X<_>`
+  --> $DIR/pretty-print.rs:18:1
+   |
+LL | impl<T: Sized> SizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_dep`:
+           - impl<T> SizedTr for T
+             where T: Sized;
+
+error[E0119]: conflicting implementations of trait `NegSizedTr` for type `X<_>`
+  --> $DIR/pretty-print.rs:21:1
+   |
+LL | impl<T: ?Sized> pretty_print_dep::NegSizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_dep`:
+           - impl<T> NegSizedTr for T
+             where T: MetaSized;
+
+error[E0119]: conflicting implementations of trait `MetaSizedTr` for type `X<_>`
+  --> $DIR/pretty-print.rs:24:1
+   |
+LL | impl<T: MetaSized> MetaSizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_dep`:
+           - impl<T> MetaSizedTr for T
+             where T: MetaSized;
+
+error[E0119]: conflicting implementations of trait `PointeeSizedTr` for type `X<_>`
+  --> $DIR/pretty-print.rs:27:1
+   |
+LL | impl<T: PointeeSized> PointeeSizedTr for X<T> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `pretty_print_dep`:
+           - impl<T> PointeeSizedTr for T
+             where T: PointeeSized;
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/sized-hierarchy/trait-aliases.rs b/tests/ui/sized-hierarchy/trait-aliases.rs
new file mode 100644
index 00000000000..ffec302adaa
--- /dev/null
+++ b/tests/ui/sized-hierarchy/trait-aliases.rs
@@ -0,0 +1,9 @@
+//@ check-pass
+//@ compile-flags: --crate-type=lib
+#![feature(trait_alias)]
+
+// Checks that `?Sized` in a trait alias doesn't trigger an ICE.
+
+use std::ops::{Index, IndexMut};
+
+pub trait SlicePrereq<T> = ?Sized + IndexMut<usize, Output = <[T] as Index<usize>>::Output>;
diff --git a/tests/ui/stack-protector/warn-stack-protector-unsupported.rs b/tests/ui/stack-protector/warn-stack-protector-unsupported.rs
index dc61e35a089..a635976c842 100644
--- a/tests/ui/stack-protector/warn-stack-protector-unsupported.rs
+++ b/tests/ui/stack-protector/warn-stack-protector-unsupported.rs
@@ -11,8 +11,15 @@
 #![no_std]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
+
 #[lang = "copy"]
 trait Copy {}
 
diff --git a/tests/ui/symbol-names/foreign-types.rs b/tests/ui/symbol-names/foreign-types.rs
index 2a9aadfcb83..b863e8c1759 100644
--- a/tests/ui/symbol-names/foreign-types.rs
+++ b/tests/ui/symbol-names/foreign-types.rs
@@ -2,13 +2,16 @@
 //@ compile-flags: -C symbol-mangling-version=v0
 
 #![feature(extern_types)]
+#![feature(sized_hierarchy)]
 #![feature(rustc_attrs)]
 
+use std::marker::PointeeSized;
+
 extern "C" {
     type ForeignType;
 }
 
-struct Check<T: ?Sized>(T);
+struct Check<T: PointeeSized>(T);
 
 #[rustc_symbol_name]
 //~^ ERROR symbol-name(_RMCs
diff --git a/tests/ui/symbol-names/foreign-types.stderr b/tests/ui/symbol-names/foreign-types.stderr
index 63044991485..4640ceae811 100644
--- a/tests/ui/symbol-names/foreign-types.stderr
+++ b/tests/ui/symbol-names/foreign-types.stderr
@@ -1,17 +1,17 @@
 error: symbol-name(_RMCsCRATE_HASH_13foreign_typesINtB<REF>_5CheckNtB<REF>_11ForeignTypeE)
-  --> $DIR/foreign-types.rs:13:1
+  --> $DIR/foreign-types.rs:16:1
    |
 LL | #[rustc_symbol_name]
    | ^^^^^^^^^^^^^^^^^^^^
 
 error: demangling(<foreign_types[fcdd87e190ad88e3]::Check<foreign_types[fcdd87e190ad88e3]::ForeignType>>)
-  --> $DIR/foreign-types.rs:13:1
+  --> $DIR/foreign-types.rs:16:1
    |
 LL | #[rustc_symbol_name]
    | ^^^^^^^^^^^^^^^^^^^^
 
 error: demangling-alt(<foreign_types::Check<foreign_types::ForeignType>>)
-  --> $DIR/foreign-types.rs:13:1
+  --> $DIR/foreign-types.rs:16:1
    |
 LL | #[rustc_symbol_name]
    | ^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/target-cpu/explicit-target-cpu.rs b/tests/ui/target-cpu/explicit-target-cpu.rs
index cd4c2384bc1..e4ae73b513b 100644
--- a/tests/ui/target-cpu/explicit-target-cpu.rs
+++ b/tests/ui/target-cpu/explicit-target-cpu.rs
@@ -29,6 +29,12 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang="sized"]
 trait Sized {}
 
diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.rs b/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.rs
index 270874a9f58..41d5de89ae6 100644
--- a/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.rs
+++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.rs
@@ -5,8 +5,14 @@
 #![no_core]
 #![deny(aarch64_softfloat_neon)]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 #[target_feature(enable = "neon")]
 //~^ERROR: enabling the `neon` target feature on the current target is unsound
diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.stderr
index bf745291a5a..a8a7063daeb 100644
--- a/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.stderr
+++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.stderr
@@ -1,5 +1,5 @@
 error: enabling the `neon` target feature on the current target is unsound due to ABI issues
-  --> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:11:18
+  --> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:17:18
    |
 LL | #[target_feature(enable = "neon")]
    |                  ^^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ error: aborting due to 1 previous error
 
 Future incompatibility report: Future breakage diagnostic:
 error: enabling the `neon` target feature on the current target is unsound due to ABI issues
-  --> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:11:18
+  --> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:17:18
    |
 LL | #[target_feature(enable = "neon")]
    |                  ^^^^^^^^^^^^^^^
diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.riscv.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.riscv.stderr
index 49c5479275f..1b9b8e0a789 100644
--- a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.riscv.stderr
+++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.riscv.stderr
@@ -1,5 +1,5 @@
 error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
-  --> $DIR/abi-incompatible-target-feature-attribute.rs:15:90
+  --> $DIR/abi-incompatible-target-feature-attribute.rs:21:90
    |
 LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
    |                                                                                          ^^^^^^^^^^^^
diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.rs b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.rs
index a8733440759..c07b6c448e9 100644
--- a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.rs
+++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.rs
@@ -9,6 +9,12 @@
 #![feature(no_core, lang_items, riscv_target_feature, x87_target_feature)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
 pub trait Sized {}
 
diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr
index 81471fd7e30..e1409497232 100644
--- a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr
+++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr
@@ -1,5 +1,5 @@
 error: target feature `soft-float` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
-  --> $DIR/abi-incompatible-target-feature-attribute.rs:15:32
+  --> $DIR/abi-incompatible-target-feature-attribute.rs:21:32
    |
 LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
    |                                ^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs
index 68e1d3b9ddc..302cceccf69 100644
--- a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs
+++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs
@@ -11,6 +11,12 @@
 #![feature(no_core, lang_items, riscv_target_feature)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
 pub trait Sized {}
 #[lang = "freeze"]
diff --git a/tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.rs b/tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.rs
index 0013d033b9c..876134002ed 100644
--- a/tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.rs
+++ b/tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.rs
@@ -8,7 +8,13 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 //~? WARN unstable feature specified for `-Ctarget-feature`: `x87`
diff --git a/tests/ui/target-feature/abi-required-target-feature-attribute.rs b/tests/ui/target-feature/abi-required-target-feature-attribute.rs
index 95723c57f94..5eb9e85f85f 100644
--- a/tests/ui/target-feature/abi-required-target-feature-attribute.rs
+++ b/tests/ui/target-feature/abi-required-target-feature-attribute.rs
@@ -6,8 +6,14 @@
 #![feature(no_core, lang_items, x87_target_feature)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 #[target_feature(enable = "x87")]
 pub unsafe fn my_fun() {}
diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs
index 98723e99c36..89736afe718 100644
--- a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs
+++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs
@@ -20,6 +20,12 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
 pub trait Sized {}
 
diff --git a/tests/ui/target-feature/feature-hierarchy.rs b/tests/ui/target-feature/feature-hierarchy.rs
index 315ec983a19..ccf32a35f72 100644
--- a/tests/ui/target-feature/feature-hierarchy.rs
+++ b/tests/ui/target-feature/feature-hierarchy.rs
@@ -12,10 +12,18 @@
 // Tests vetting "feature hierarchies" in the cases where we impose them.
 
 // Supporting minimal rust core code
+#[lang = "pointee_sized"]
+trait PointeeSized {}
+
+#[lang = "meta_sized"]
+trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
+
 #[lang = "copy"]
 trait Copy {}
+
 impl Copy for bool {}
 
 #[stable(feature = "test", since = "1.0.0")]
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs
index 215e64979f7..e96e17a4212 100644
--- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs
@@ -4,8 +4,14 @@
 #![feature(no_core, lang_items, riscv_target_feature)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 #[target_feature(enable = "d")]
 //~^ERROR: cannot be enabled with
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr
index 84d27463b38..9406c3bbfdc 100644
--- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr
@@ -1,5 +1,5 @@
 error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
-  --> $DIR/forbidden-hardfloat-target-feature-attribute-e-d.rs:10:18
+  --> $DIR/forbidden-hardfloat-target-feature-attribute-e-d.rs:16:18
    |
 LL | #[target_feature(enable = "d")]
    |                  ^^^^^^^^^^^^
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs
index d74f4a1d4b1..70075b1bb78 100644
--- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs
@@ -4,6 +4,12 @@
 #![feature(no_core, lang_items, riscv_target_feature)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
 pub trait Sized {}
 
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr
index af0e53f34f2..8c98d847e17 100644
--- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr
@@ -1,5 +1,5 @@
 error: target feature `zfinx` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
-  --> $DIR/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs:10:18
+  --> $DIR/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs:16:18
    |
 LL | #[target_feature(enable = "zdinx")]
    |                  ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-cfg.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-cfg.rs
new file mode 100644
index 00000000000..2692cf802f2
--- /dev/null
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-cfg.rs
@@ -0,0 +1,20 @@
+//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
+//@ needs-llvm-components: x86
+//@ check-pass
+#![feature(no_core, lang_items)]
+#![no_core]
+#![allow(unexpected_cfgs)]
+
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
+#[lang = "sized"]
+pub trait Sized: MetaSized {}
+
+// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this
+// complains about the missing macro rather than showing the error... but that's good enough.
+#[cfg(not(target_feature = "x87"))]
+compile_error!("the x87 feature *should* be exposed in `cfg`");
diff --git a/tests/ui/target-feature/forbidden-target-feature-attribute.rs b/tests/ui/target-feature/forbidden-target-feature-attribute.rs
index 6bb6f8aaffb..a59747ec80f 100644
--- a/tests/ui/target-feature/forbidden-target-feature-attribute.rs
+++ b/tests/ui/target-feature/forbidden-target-feature-attribute.rs
@@ -4,8 +4,14 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 #[target_feature(enable = "forced-atomics")]
 //~^ERROR: cannot be enabled with
diff --git a/tests/ui/target-feature/forbidden-target-feature-attribute.stderr b/tests/ui/target-feature/forbidden-target-feature-attribute.stderr
index f8ea0c0e793..65814e8edcf 100644
--- a/tests/ui/target-feature/forbidden-target-feature-attribute.stderr
+++ b/tests/ui/target-feature/forbidden-target-feature-attribute.stderr
@@ -1,5 +1,5 @@
 error: target feature `forced-atomics` cannot be enabled with `#[target_feature]`: unsound because it changes the ABI of atomic operations
-  --> $DIR/forbidden-target-feature-attribute.rs:10:18
+  --> $DIR/forbidden-target-feature-attribute.rs:16:18
    |
 LL | #[target_feature(enable = "forced-atomics")]
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/target-feature/forbidden-target-feature-cfg.rs b/tests/ui/target-feature/forbidden-target-feature-cfg.rs
index e848ffde018..c21eb63257a 100644
--- a/tests/ui/target-feature/forbidden-target-feature-cfg.rs
+++ b/tests/ui/target-feature/forbidden-target-feature-cfg.rs
@@ -6,8 +6,14 @@
 #![no_core]
 #![allow(unexpected_cfgs)]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 // The compile_error macro does not exist, so if the `cfg` evaluates to `true` this
 // complains about the missing macro rather than showing the error... but that's good enough.
diff --git a/tests/ui/target-feature/forbidden-target-feature-flag-disable.rs b/tests/ui/target-feature/forbidden-target-feature-flag-disable.rs
index d394dbe7b15..4d4d833caab 100644
--- a/tests/ui/target-feature/forbidden-target-feature-flag-disable.rs
+++ b/tests/ui/target-feature/forbidden-target-feature-flag-disable.rs
@@ -8,7 +8,13 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 //~? WARN target feature `forced-atomics` cannot be disabled with `-Ctarget-feature`: unsound because it changes the ABI of atomic operations
diff --git a/tests/ui/target-feature/forbidden-target-feature-flag.rs b/tests/ui/target-feature/forbidden-target-feature-flag.rs
index a04d7e34753..6e3e60e0409 100644
--- a/tests/ui/target-feature/forbidden-target-feature-flag.rs
+++ b/tests/ui/target-feature/forbidden-target-feature-flag.rs
@@ -8,7 +8,13 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 //~? WARN target feature `forced-atomics` cannot be enabled with `-Ctarget-feature`: unsound because it changes the ABI of atomic operations
diff --git a/tests/ui/target-feature/target-cpu-lacks-required-target-feature.rs b/tests/ui/target-feature/target-cpu-lacks-required-target-feature.rs
index be6cd2b6faf..fcb8c382741 100644
--- a/tests/ui/target-feature/target-cpu-lacks-required-target-feature.rs
+++ b/tests/ui/target-feature/target-cpu-lacks-required-target-feature.rs
@@ -7,7 +7,13 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
 
 //~? WARN target feature `sse2` must be enabled to ensure that the ABI of the current target can be implemented correctly
diff --git a/tests/ui/target-feature/tied-features-cli.rs b/tests/ui/target-feature/tied-features-cli.rs
index ce1dc3224a1..e9de4561ced 100644
--- a/tests/ui/target-feature/tied-features-cli.rs
+++ b/tests/ui/target-feature/tied-features-cli.rs
@@ -14,8 +14,14 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
-#[lang="sized"]
-trait Sized {}
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
+#[lang = "sized"]
+pub trait Sized: MetaSized {}
 
 fn main() {}
 
diff --git a/tests/ui/target-feature/tied-features-no-implication-1.rs b/tests/ui/target-feature/tied-features-no-implication-1.rs
index 63a1d77dae9..6c6e9e06b6e 100644
--- a/tests/ui/target-feature/tied-features-no-implication-1.rs
+++ b/tests/ui/target-feature/tied-features-no-implication-1.rs
@@ -6,8 +6,14 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
-#[lang="sized"]
-trait Sized {}
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
+#[lang = "sized"]
+pub trait Sized: MetaSized {}
 
 // In this test, demonstrate that +paca and +pacg both result in the tied feature error if there
 // isn't something causing an error.
diff --git a/tests/ui/target-feature/tied-features-no-implication.pacg.stderr b/tests/ui/target-feature/tied-features-no-implication.pacg.stderr
index 4ff42d31e94..8b034c098d0 100644
--- a/tests/ui/target-feature/tied-features-no-implication.pacg.stderr
+++ b/tests/ui/target-feature/tied-features-no-implication.pacg.stderr
@@ -1,5 +1,5 @@
 error[E0428]: the name `foo` is defined multiple times
-  --> $DIR/tied-features-no-implication.rs:27:1
+  --> $DIR/tied-features-no-implication.rs:33:1
    |
 LL | fn foo() {}
    | -------- previous definition of the value `foo` here
diff --git a/tests/ui/target-feature/tied-features-no-implication.rs b/tests/ui/target-feature/tied-features-no-implication.rs
index 1625f71431a..5e38d5329f3 100644
--- a/tests/ui/target-feature/tied-features-no-implication.rs
+++ b/tests/ui/target-feature/tied-features-no-implication.rs
@@ -7,8 +7,14 @@
 #![feature(no_core, lang_items)]
 #![no_core]
 
-#[lang="sized"]
-trait Sized {}
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
+#[lang = "sized"]
+pub trait Sized: MetaSized {}
 
 // Can't use `compile_error!` here without `core`/`std` but requiring these makes this test only
 // work if you have libcore built in the sysroot for `aarch64-unknown-linux-gnu`. Can't run this
diff --git a/tests/ui/traits/cache-reached-depth-ice.rs b/tests/ui/traits/cache-reached-depth-ice.rs
index 8c2391113d7..bc62adf4842 100644
--- a/tests/ui/traits/cache-reached-depth-ice.rs
+++ b/tests/ui/traits/cache-reached-depth-ice.rs
@@ -1,4 +1,5 @@
-#![feature(rustc_attrs)]
+#![feature(rustc_attrs, sized_hierarchy)]
+use std::marker::PointeeSized;
 
 // Test for a particular corner case where the evaluation
 // cache can get out of date. The problem here is that
@@ -37,7 +38,7 @@ struct C {
 }
 
 #[rustc_evaluate_where_clauses]
-fn test<X: ?Sized + Send>() {}
+fn test<X: PointeeSized + Send>() {}
 
 fn main() {
     test::<A>();
diff --git a/tests/ui/traits/cache-reached-depth-ice.stderr b/tests/ui/traits/cache-reached-depth-ice.stderr
index e84ebc91ae1..fd76dc92dfb 100644
--- a/tests/ui/traits/cache-reached-depth-ice.stderr
+++ b/tests/ui/traits/cache-reached-depth-ice.stderr
@@ -1,8 +1,8 @@
 error: evaluate(Binder { value: TraitPredicate(<A as std::marker::Send>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
-  --> $DIR/cache-reached-depth-ice.rs:43:5
+  --> $DIR/cache-reached-depth-ice.rs:44:5
    |
-LL | fn test<X: ?Sized + Send>() {}
-   |                     ---- predicate
+LL | fn test<X: PointeeSized + Send>() {}
+   |                           ---- predicate
 ...
 LL |     test::<A>();
    |     ^^^^^^^^^
diff --git a/tests/ui/traits/const-traits/auxiliary/minicore.rs b/tests/ui/traits/const-traits/auxiliary/minicore.rs
index 08d7817548d..073337b2ac6 100644
--- a/tests/ui/traits/const-traits/auxiliary/minicore.rs
+++ b/tests/ui/traits/const-traits/auxiliary/minicore.rs
@@ -12,20 +12,27 @@
     fundamental,
     marker_trait_attr,
     const_trait_impl,
-    const_destruct
+    const_destruct,
 )]
 #![allow(internal_features, incomplete_features)]
 #![no_std]
 #![no_core]
 
+#[lang = "pointee_sized"]
+pub trait PointeeSized {}
+
+#[lang = "meta_sized"]
+pub trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-pub trait Sized {}
+pub trait Sized: MetaSized {}
+
 #[lang = "copy"]
 pub trait Copy {}
 
 impl Copy for bool {}
 impl Copy for u8 {}
-impl<T: ?Sized> Copy for &T {}
+impl<T: PointeeSized> Copy for &T {}
 
 #[lang = "add"]
 #[const_trait]
@@ -106,17 +113,17 @@ pub trait Tuple {}
 #[lang = "legacy_receiver"]
 pub trait LegacyReceiver {}
 
-impl<T: ?Sized> LegacyReceiver for &T {}
+impl<T: PointeeSized> LegacyReceiver for &T {}
 
-impl<T: ?Sized> LegacyReceiver for &mut T {}
+impl<T: PointeeSized> LegacyReceiver for &mut T {}
 
 #[lang = "receiver"]
 pub trait Receiver {
     #[lang = "receiver_target"]
-    type Target: ?Sized;
+    type Target: MetaSized;
 }
 
-impl<T: Deref + ?Sized> Receiver for T {
+impl<T: Deref + MetaSized> Receiver for T {
     type Target = <T as Deref>::Target;
 }
 
@@ -162,15 +169,15 @@ fn panic_fmt() {}
 
 #[lang = "index"]
 #[const_trait]
-pub trait Index<Idx: ?Sized> {
-    type Output: ?Sized;
+pub trait Index<Idx: PointeeSized> {
+    type Output: MetaSized;
 
     fn index(&self, index: Idx) -> &Self::Output;
 }
 
 #[const_trait]
-pub unsafe trait SliceIndex<T: ?Sized> {
-    type Output: ?Sized;
+pub unsafe trait SliceIndex<T: PointeeSized> {
+    type Output: MetaSized;
     fn index(self, slice: &T) -> &Self::Output;
 }
 
@@ -199,23 +206,23 @@ where
 }
 
 #[lang = "unsize"]
-pub trait Unsize<T: ?Sized> {}
+pub trait Unsize<T: PointeeSized>: PointeeSized {}
 
 #[lang = "coerce_unsized"]
-pub trait CoerceUnsized<T: ?Sized> {}
+pub trait CoerceUnsized<T: PointeeSized> {}
 
-impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
+impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
 
 #[lang = "deref"]
 #[const_trait]
 pub trait Deref {
     #[lang = "deref_target"]
-    type Target: ?Sized;
+    type Target: MetaSized;
 
     fn deref(&self) -> &Self::Target;
 }
 
-impl<T: ?Sized> const Deref for &T {
+impl<T: MetaSized> const Deref for &T {
     type Target = T;
 
     fn deref(&self) -> &T {
@@ -223,7 +230,7 @@ impl<T: ?Sized> const Deref for &T {
     }
 }
 
-impl<T: ?Sized> const Deref for &mut T {
+impl<T: MetaSized> const Deref for &mut T {
     type Target = T;
 
     fn deref(&self) -> &T {
@@ -307,14 +314,14 @@ fn from_str(s: &str) -> Result<bool, ()> {
 
 #[lang = "eq"]
 #[const_trait]
-pub trait PartialEq<Rhs: ?Sized = Self> {
+pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
     fn eq(&self, other: &Rhs) -> bool;
     fn ne(&self, other: &Rhs) -> bool {
         !self.eq(other)
     }
 }
 
-impl<A: ?Sized, B: ?Sized> const PartialEq<&B> for &A
+impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &A
 where
     A: ~const PartialEq<B>,
 {
@@ -357,7 +364,7 @@ impl<P> Pin<P> {
     }
 }
 
-impl<'a, T: ?Sized> Pin<&'a T> {
+impl<'a, T: PointeeSized> Pin<&'a T> {
     const fn get_ref(self) -> &'a T {
         self.pointer
     }
@@ -372,7 +379,7 @@ impl<P: Deref> Pin<P> {
     }
 }
 
-impl<'a, T: ?Sized> Pin<&'a mut T> {
+impl<'a, T: PointeeSized> Pin<&'a mut T> {
     const unsafe fn get_unchecked_mut(self) -> &'a mut T {
         self.pointer
     }
@@ -418,7 +425,7 @@ impl<T: Clone> Clone for RefCell<T> {
     }
 }
 
-struct RefCell<T: ?Sized> {
+struct RefCell<T: PointeeSized> {
     borrow: UnsafeCell<()>,
     value: UnsafeCell<T>,
 }
@@ -427,7 +434,7 @@ impl<T> RefCell<T> {
         loop {}
     }
 }
-impl<T: ?Sized> RefCell<T> {
+impl<T: PointeeSized> RefCell<T> {
     fn borrow(&self) -> Ref<'_, T> {
         loop {}
     }
@@ -435,16 +442,16 @@ impl<T: ?Sized> RefCell<T> {
 
 #[lang = "unsafe_cell"]
 #[repr(transparent)]
-struct UnsafeCell<T: ?Sized> {
+struct UnsafeCell<T: PointeeSized> {
     value: T,
 }
 
-struct Ref<'b, T: ?Sized + 'b> {
+struct Ref<'b, T: PointeeSized + 'b> {
     value: *const T,
     borrow: &'b UnsafeCell<()>,
 }
 
-impl<T: ?Sized> Deref for Ref<'_, T> {
+impl<T: MetaSized> Deref for Ref<'_, T> {
     type Target = T;
 
     #[inline]
diff --git a/tests/ui/traits/default_auto_traits/backward-compatible-lazy-bounds-pass.rs b/tests/ui/traits/default_auto_traits/backward-compatible-lazy-bounds-pass.rs
index 3818456d3a6..745b6ee9bc5 100644
--- a/tests/ui/traits/default_auto_traits/backward-compatible-lazy-bounds-pass.rs
+++ b/tests/ui/traits/default_auto_traits/backward-compatible-lazy-bounds-pass.rs
@@ -5,8 +5,14 @@
 #![no_std]
 #![no_core]
 
+#[lang = "pointee_sized"]
+trait PointeeSized {}
+
+#[lang = "meta_sized"]
+trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
 
 #[lang = "default_trait1"]
 auto trait DefaultTrait1 {}
diff --git a/tests/ui/traits/default_auto_traits/default-bounds.rs b/tests/ui/traits/default_auto_traits/default-bounds.rs
index 64733a40034..8535f82fc01 100644
--- a/tests/ui/traits/default_auto_traits/default-bounds.rs
+++ b/tests/ui/traits/default_auto_traits/default-bounds.rs
@@ -11,8 +11,14 @@
 #![no_std]
 #![no_core]
 
+#[lang = "pointee_sized"]
+trait PointeeSized {}
+
+#[lang = "meta_sized"]
+trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
 
 #[lang = "copy"]
 pub trait Copy {}
diff --git a/tests/ui/traits/default_auto_traits/default-bounds.stderr b/tests/ui/traits/default_auto_traits/default-bounds.stderr
index 10fdcc43417..318fc57fc9c 100644
--- a/tests/ui/traits/default_auto_traits/default-bounds.stderr
+++ b/tests/ui/traits/default_auto_traits/default-bounds.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `Forbidden: SyncDrop` is not satisfied
-  --> $DIR/default-bounds.rs:37:9
+  --> $DIR/default-bounds.rs:43:9
    |
 LL |     bar(Forbidden);
    |     --- ^^^^^^^^^ the trait `SyncDrop` is not implemented for `Forbidden`
@@ -7,13 +7,13 @@ LL |     bar(Forbidden);
    |     required by a bound introduced by this call
    |
 note: required by a bound in `bar`
-  --> $DIR/default-bounds.rs:33:8
+  --> $DIR/default-bounds.rs:39:8
    |
 LL | fn bar<T: Leak>(_: T) {}
    |        ^ required by this bound in `bar`
 
 error[E0277]: the trait bound `Forbidden: Leak` is not satisfied
-  --> $DIR/default-bounds.rs:37:9
+  --> $DIR/default-bounds.rs:43:9
    |
 LL |     bar(Forbidden);
    |     --- ^^^^^^^^^ the trait `Leak` is not implemented for `Forbidden`
@@ -21,7 +21,7 @@ LL |     bar(Forbidden);
    |     required by a bound introduced by this call
    |
 note: required by a bound in `bar`
-  --> $DIR/default-bounds.rs:33:11
+  --> $DIR/default-bounds.rs:39:11
    |
 LL | fn bar<T: Leak>(_: T) {}
    |           ^^^^ required by this bound in `bar`
diff --git a/tests/ui/traits/default_auto_traits/extern-types.current.stderr b/tests/ui/traits/default_auto_traits/extern-types.current.stderr
index e1bd99b900f..593204382e3 100644
--- a/tests/ui/traits/default_auto_traits/extern-types.current.stderr
+++ b/tests/ui/traits/default_auto_traits/extern-types.current.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `extern_non_leak::Opaque: Leak` is not satisfied
-  --> $DIR/extern-types.rs:44:13
+  --> $DIR/extern-types.rs:50:13
    |
 LL |         foo(x);
    |         --- ^ the trait `Leak` is not implemented for `extern_non_leak::Opaque`
@@ -7,9 +7,9 @@ LL |         foo(x);
    |         required by a bound introduced by this call
    |
 note: required by a bound in `foo`
-  --> $DIR/extern-types.rs:20:8
+  --> $DIR/extern-types.rs:26:8
    |
-LL | fn foo<T: ?Sized>(_: &T) {}
+LL | fn foo<T: PointeeSized>(_: &T) {}
    |        ^ required by this bound in `foo`
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/traits/default_auto_traits/extern-types.next.stderr b/tests/ui/traits/default_auto_traits/extern-types.next.stderr
index e1bd99b900f..593204382e3 100644
--- a/tests/ui/traits/default_auto_traits/extern-types.next.stderr
+++ b/tests/ui/traits/default_auto_traits/extern-types.next.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `extern_non_leak::Opaque: Leak` is not satisfied
-  --> $DIR/extern-types.rs:44:13
+  --> $DIR/extern-types.rs:50:13
    |
 LL |         foo(x);
    |         --- ^ the trait `Leak` is not implemented for `extern_non_leak::Opaque`
@@ -7,9 +7,9 @@ LL |         foo(x);
    |         required by a bound introduced by this call
    |
 note: required by a bound in `foo`
-  --> $DIR/extern-types.rs:20:8
+  --> $DIR/extern-types.rs:26:8
    |
-LL | fn foo<T: ?Sized>(_: &T) {}
+LL | fn foo<T: PointeeSized>(_: &T) {}
    |        ^ required by this bound in `foo`
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/traits/default_auto_traits/extern-types.rs b/tests/ui/traits/default_auto_traits/extern-types.rs
index 822d4c0637f..df106d83171 100644
--- a/tests/ui/traits/default_auto_traits/extern-types.rs
+++ b/tests/ui/traits/default_auto_traits/extern-types.rs
@@ -7,8 +7,14 @@
 #![no_std]
 #![no_core]
 
+#[lang = "pointee_sized"]
+trait PointeeSized {}
+
+#[lang = "meta_sized"]
+trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
 
 #[lang = "copy"]
 pub trait Copy {}
@@ -17,7 +23,7 @@ pub trait Copy {}
 auto trait Leak {}
 
 // implicit T: Leak here
-fn foo<T: ?Sized>(_: &T) {}
+fn foo<T: PointeeSized>(_: &T) {}
 
 mod extern_leak {
     use crate::*;
diff --git a/tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.rs b/tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.rs
index 49f2faba146..5069cd256b2 100644
--- a/tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.rs
+++ b/tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.rs
@@ -12,8 +12,14 @@
 #![no_std]
 #![no_core]
 
+#[lang = "pointee_sized"]
+trait PointeeSized {}
+
+#[lang = "meta_sized"]
+trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
 
 #[lang = "copy"]
 pub trait Copy {}
diff --git a/tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.stderr b/tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.stderr
index b7ffb66e60b..48745e40268 100644
--- a/tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.stderr
+++ b/tests/ui/traits/default_auto_traits/maybe-bounds-in-dyn-traits.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `NonLeakS: Leak` is not satisfied
-  --> $DIR/maybe-bounds-in-dyn-traits.rs:53:25
+  --> $DIR/maybe-bounds-in-dyn-traits.rs:59:25
    |
 LL |     let _: &dyn Trait = &NonLeakS;
    |                         ^^^^^^^^^ the trait `Leak` is not implemented for `NonLeakS`
@@ -7,13 +7,13 @@ LL |     let _: &dyn Trait = &NonLeakS;
    = note: required for the cast from `&NonLeakS` to `&dyn Trait + Leak`
 
 error[E0277]: the trait bound `dyn Trait: Leak` is not satisfied
-  --> $DIR/maybe-bounds-in-dyn-traits.rs:58:7
+  --> $DIR/maybe-bounds-in-dyn-traits.rs:64:7
    |
 LL |     x.leak_foo();
    |       ^^^^^^^^ the trait `Leak` is not implemented for `dyn Trait`
    |
 note: required by a bound in `Trait::leak_foo`
-  --> $DIR/maybe-bounds-in-dyn-traits.rs:45:5
+  --> $DIR/maybe-bounds-in-dyn-traits.rs:51:5
    |
 LL |     fn leak_foo(&self) {}
    |     ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait::leak_foo`
diff --git a/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.rs b/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.rs
index 4cb38bc8e79..b3801baaf70 100644
--- a/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.rs
+++ b/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.rs
@@ -14,8 +14,14 @@
 #![no_std]
 #![no_core]
 
+#[lang = "pointee_sized"]
+trait PointeeSized {}
+
+#[lang = "meta_sized"]
+trait MetaSized: PointeeSized {}
+
 #[lang = "sized"]
-trait Sized {}
+trait Sized: MetaSized {}
 
 #[lang = "legacy_receiver"]
 trait LegacyReceiver {}
diff --git a/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr b/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr
index 3dd8418b100..bc797c9d976 100644
--- a/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr
+++ b/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr
@@ -1,23 +1,23 @@
 error[E0277]: the trait bound `NonLeakS: Leak` is not satisfied
-  --> $DIR/maybe-bounds-in-traits.rs:61:22
+  --> $DIR/maybe-bounds-in-traits.rs:67:22
    |
 LL |         type Leak2 = NonLeakS;
    |                      ^^^^^^^^ the trait `Leak` is not implemented for `NonLeakS`
    |
 note: required by a bound in `Test3::Leak2`
-  --> $DIR/maybe-bounds-in-traits.rs:61:9
+  --> $DIR/maybe-bounds-in-traits.rs:67:9
    |
 LL |         type Leak2 = NonLeakS;
    |         ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Test3::Leak2`
 
 error[E0277]: the trait bound `Self: Leak` is not satisfied
-  --> $DIR/maybe-bounds-in-traits.rs:49:29
+  --> $DIR/maybe-bounds-in-traits.rs:55:29
    |
 LL |         type MaybeLeakSelf: TestBase1<Self> where Self: ?Leak;
    |                             ^^^^^^^^^^^^^^^ the trait `Leak` is not implemented for `Self`
    |
 note: required by a bound in `TestBase1`
-  --> $DIR/maybe-bounds-in-traits.rs:45:21
+  --> $DIR/maybe-bounds-in-traits.rs:51:21
    |
 LL |     trait TestBase1<T: ?Sized> {}
    |                     ^ required by this bound in `TestBase1`
@@ -27,7 +27,7 @@ LL |     trait Test1<T>: Leak {
    |                   ++++++
 
 error[E0658]: `&mut Self` cannot be used as the type of `self` without the `arbitrary_self_types` feature
-  --> $DIR/maybe-bounds-in-traits.rs:99:31
+  --> $DIR/maybe-bounds-in-traits.rs:105:31
    |
 LL |         fn mut_maybe_leak_foo(&mut self) where Self: ?Leak {}
    |                               ^^^^^^^^^
@@ -38,13 +38,13 @@ LL |         fn mut_maybe_leak_foo(&mut self) where Self: ?Leak {}
    = help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
 
 error[E0277]: the trait bound `Self: Leak` is not satisfied
-  --> $DIR/maybe-bounds-in-traits.rs:86:43
+  --> $DIR/maybe-bounds-in-traits.rs:92:43
    |
 LL |         const CNonLeak: usize = size_of::<Self>() where Self: ?Leak;
    |                                           ^^^^ the trait `Leak` is not implemented for `Self`
    |
 note: required by a bound in `size_of`
-  --> $DIR/maybe-bounds-in-traits.rs:80:22
+  --> $DIR/maybe-bounds-in-traits.rs:86:22
    |
 LL |     const fn size_of<T: ?Sized>() -> usize {
    |                      ^ required by this bound in `size_of`
@@ -54,13 +54,13 @@ LL |     trait Trait: Leak {
    |                ++++++
 
 error[E0277]: the trait bound `NonLeakS: Leak` is not satisfied
-  --> $DIR/maybe-bounds-in-traits.rs:109:18
+  --> $DIR/maybe-bounds-in-traits.rs:115:18
    |
 LL |         NonLeakS.leak_foo();
    |                  ^^^^^^^^ the trait `Leak` is not implemented for `NonLeakS`
    |
 note: required by a bound in `methods::Trait::leak_foo`
-  --> $DIR/maybe-bounds-in-traits.rs:95:9
+  --> $DIR/maybe-bounds-in-traits.rs:101:9
    |
 LL |         fn leak_foo(&self) {}
    |         ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait::leak_foo`
diff --git a/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.current.stderr b/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.current.stderr
index dd9393fae85..d99a4cbd378 100644
--- a/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.current.stderr
+++ b/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.current.stderr
@@ -1,20 +1,5 @@
-error[E0308]: mismatched types
-  --> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:13:23
-   |
-LL |     (MyType<'a, T>,): Sized,
-   |                       ^^^^^ lifetime mismatch
-   |
-   = note: expected trait `<MyType<'a, T> as Sized>`
-              found trait `<MyType<'static, T> as Sized>`
-note: the lifetime `'a` as defined here...
-  --> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:11:8
-   |
-LL | fn foo<'a, T: ?Sized>()
-   |        ^^
-   = note: ...does not necessarily outlive the static lifetime
-
 error: lifetime may not live long enough
-  --> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:22:5
+  --> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:20:5
    |
 LL | fn foo<'a, T: ?Sized>()
    |        -- lifetime `'a` defined here
@@ -22,6 +7,5 @@ LL | fn foo<'a, T: ?Sized>()
 LL |     is_sized::<(MyType<'a, T>,)>();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
 
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.next.stderr b/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.next.stderr
index 05861877d41..d99a4cbd378 100644
--- a/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.next.stderr
+++ b/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.next.stderr
@@ -1,18 +1,5 @@
-error[E0478]: lifetime bound not satisfied
-  --> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:13:23
-   |
-LL |     (MyType<'a, T>,): Sized,
-   |                       ^^^^^
-   |
-note: lifetime parameter instantiated with the lifetime `'a` as defined here
-  --> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:11:8
-   |
-LL | fn foo<'a, T: ?Sized>()
-   |        ^^
-   = note: but lifetime parameter must outlive the static lifetime
-
 error: lifetime may not live long enough
-  --> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:22:5
+  --> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:20:5
    |
 LL | fn foo<'a, T: ?Sized>()
    |        -- lifetime `'a` defined here
@@ -20,6 +7,5 @@ LL | fn foo<'a, T: ?Sized>()
 LL |     is_sized::<(MyType<'a, T>,)>();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
 
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0478`.
diff --git a/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.rs b/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.rs
index ae7a6c9bba3..6ddc0628dd1 100644
--- a/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.rs
+++ b/tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.rs
@@ -11,8 +11,6 @@ fn is_sized<T>() {}
 fn foo<'a, T: ?Sized>()
 where
     (MyType<'a, T>,): Sized,
-    //[current]~^ ERROR mismatched types
-    //[next]~^^ ERROR lifetime bound not satisfied
     MyType<'static, T>: Sized,
 {
     // Preferring the builtin `Sized` impl of tuples
diff --git a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr
index 8901805a20f..1eb445f4848 100644
--- a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr
+++ b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr
@@ -12,6 +12,13 @@ LL | impl<T: Bound, U> Trait<U> for T {
    |         -----     ^^^^^^^^     ^
    |         |
    |         unsatisfied trait bound introduced here
+note: required by a bound in `Bound`
+  --> $DIR/normalizes-to-is-not-productive.rs:8:1
+   |
+LL | / trait Bound {
+LL | |     fn method();
+LL | | }
+   | |_^ required by this bound in `Bound`
 
 error[E0277]: the trait bound `Foo: Bound` is not satisfied
   --> $DIR/normalizes-to-is-not-productive.rs:47:19
diff --git a/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr b/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr
index d179c805962..8d8909625ff 100644
--- a/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr
+++ b/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr
@@ -19,6 +19,23 @@ error[E0275]: overflow evaluating the requirement `<() as A<T>>::Assoc: A<T>`
 LL |         Self::Assoc: A<T>,
    |                      ^^^^
 
+error[E0275]: overflow evaluating the requirement `<() as A<T>>::Assoc: MetaSized`
+  --> $DIR/normalize-param-env-2.rs:24:22
+   |
+LL |         Self::Assoc: A<T>,
+   |                      ^^^^
+   |
+note: required by a bound in `A`
+  --> $DIR/normalize-param-env-2.rs:9:1
+   |
+LL | / trait A<T> {
+LL | |     type Assoc;
+LL | |
+LL | |     fn f()
+...  |
+LL | | }
+   | |_^ required by this bound in `A`
+
 error[E0275]: overflow evaluating the requirement `<() as A<T>>::Assoc well-formed`
   --> $DIR/normalize-param-env-2.rs:24:22
    |
@@ -46,6 +63,6 @@ LL |     where
 LL |         Self::Assoc: A<T>,
    |                      ^^^^ required by this bound in `A::f`
 
-error: aborting due to 5 previous errors
+error: aborting due to 6 previous errors
 
 For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr b/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr
index f5fd9ce9864..9f7f74f9466 100644
--- a/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr
+++ b/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr
@@ -4,6 +4,20 @@ error[E0275]: overflow evaluating the requirement `<T as Trait>::Assoc: Trait`
 LL |     <T as Trait>::Assoc: Trait,
    |                          ^^^^^
 
-error: aborting due to 1 previous error
+error[E0275]: overflow evaluating the requirement `<T as Trait>::Assoc: MetaSized`
+  --> $DIR/normalize-param-env-4.rs:19:26
+   |
+LL |     <T as Trait>::Assoc: Trait,
+   |                          ^^^^^
+   |
+note: required by a bound in `Trait`
+  --> $DIR/normalize-param-env-4.rs:7:1
+   |
+LL | / trait Trait {
+LL | |     type Assoc;
+LL | | }
+   | |_^ required by this bound in `Trait`
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/traits/non_lifetime_binders/basic.rs b/tests/ui/traits/non_lifetime_binders/basic.rs
index 533891bf830..09c0244ec95 100644
--- a/tests/ui/traits/non_lifetime_binders/basic.rs
+++ b/tests/ui/traits/non_lifetime_binders/basic.rs
@@ -1,12 +1,15 @@
 //@ check-pass
 // Basic test that show's we can successfully typeck a `for<T>` where clause.
 
+#![feature(sized_hierarchy)]
 #![feature(non_lifetime_binders)]
 //~^ WARN the feature `non_lifetime_binders` is incomplete
 
-trait Trait {}
+use std::marker::PointeeSized;
 
-impl<T: ?Sized> Trait for T {}
+trait Trait: PointeeSized {}
+
+impl<T: PointeeSized> Trait for T {}
 
 fn foo()
 where
diff --git a/tests/ui/traits/non_lifetime_binders/basic.stderr b/tests/ui/traits/non_lifetime_binders/basic.stderr
index 0fd16c5d0ee..9f2df2238d1 100644
--- a/tests/ui/traits/non_lifetime_binders/basic.stderr
+++ b/tests/ui/traits/non_lifetime_binders/basic.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/basic.rs:4:12
+  --> $DIR/basic.rs:5:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.rs b/tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.rs
index 74c23a59bee..22044c2e662 100644
--- a/tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.rs
+++ b/tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.rs
@@ -1,11 +1,14 @@
 // Make sure not to construct predicates with escaping bound vars in `diagnostic_hir_wf_check`.
 // Regression test for <https://github.com/rust-lang/rust/issues/139330>.
 
+#![feature(sized_hierarchy)]
 #![feature(non_lifetime_binders)]
 //~^ WARN the feature `non_lifetime_binders` is incomplete
 
-trait A<T: ?Sized> {}
-impl<T: ?Sized> A<T> for () {}
+use std::marker::PointeeSized;
+
+trait A<T: PointeeSized> {}
+impl<T: PointeeSized> A<T> for () {}
 
 trait B {}
 struct W<T: B>(T);
diff --git a/tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.stderr b/tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.stderr
index df99f4a67ab..8270fbeef0f 100644
--- a/tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.stderr
+++ b/tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/diagnostic-hir-wf-check.rs:4:12
+  --> $DIR/diagnostic-hir-wf-check.rs:5:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
@@ -8,24 +8,24 @@ LL | #![feature(non_lifetime_binders)]
    = note: `#[warn(incomplete_features)]` on by default
 
 error[E0277]: the trait bound `(): B` is not satisfied
-  --> $DIR/diagnostic-hir-wf-check.rs:13:12
+  --> $DIR/diagnostic-hir-wf-check.rs:16:12
    |
 LL | fn b() -> (W<()>, impl for<C> A<C>) { (W(()), ()) }
    |            ^^^^^ the trait `B` is not implemented for `()`
    |
 help: this trait has no implementations, consider adding one
-  --> $DIR/diagnostic-hir-wf-check.rs:10:1
+  --> $DIR/diagnostic-hir-wf-check.rs:13:1
    |
 LL | trait B {}
    | ^^^^^^^
 note: required by a bound in `W`
-  --> $DIR/diagnostic-hir-wf-check.rs:11:13
+  --> $DIR/diagnostic-hir-wf-check.rs:14:13
    |
 LL | struct W<T: B>(T);
    |             ^ required by this bound in `W`
 
 error[E0277]: the trait bound `(): B` is not satisfied
-  --> $DIR/diagnostic-hir-wf-check.rs:13:42
+  --> $DIR/diagnostic-hir-wf-check.rs:16:42
    |
 LL | fn b() -> (W<()>, impl for<C> A<C>) { (W(()), ()) }
    |                                        - ^^ the trait `B` is not implemented for `()`
@@ -33,29 +33,29 @@ LL | fn b() -> (W<()>, impl for<C> A<C>) { (W(()), ()) }
    |                                        required by a bound introduced by this call
    |
 help: this trait has no implementations, consider adding one
-  --> $DIR/diagnostic-hir-wf-check.rs:10:1
+  --> $DIR/diagnostic-hir-wf-check.rs:13:1
    |
 LL | trait B {}
    | ^^^^^^^
 note: required by a bound in `W`
-  --> $DIR/diagnostic-hir-wf-check.rs:11:13
+  --> $DIR/diagnostic-hir-wf-check.rs:14:13
    |
 LL | struct W<T: B>(T);
    |             ^ required by this bound in `W`
 
 error[E0277]: the trait bound `(): B` is not satisfied
-  --> $DIR/diagnostic-hir-wf-check.rs:13:40
+  --> $DIR/diagnostic-hir-wf-check.rs:16:40
    |
 LL | fn b() -> (W<()>, impl for<C> A<C>) { (W(()), ()) }
    |                                        ^^^^^ the trait `B` is not implemented for `()`
    |
 help: this trait has no implementations, consider adding one
-  --> $DIR/diagnostic-hir-wf-check.rs:10:1
+  --> $DIR/diagnostic-hir-wf-check.rs:13:1
    |
 LL | trait B {}
    | ^^^^^^^
 note: required by a bound in `W`
-  --> $DIR/diagnostic-hir-wf-check.rs:11:13
+  --> $DIR/diagnostic-hir-wf-check.rs:14:13
    |
 LL | struct W<T: B>(T);
    |             ^ required by this bound in `W`
diff --git a/tests/ui/traits/non_lifetime_binders/on-rpit.rs b/tests/ui/traits/non_lifetime_binders/on-rpit.rs
index 4d1cacb1890..1364f63a373 100644
--- a/tests/ui/traits/non_lifetime_binders/on-rpit.rs
+++ b/tests/ui/traits/non_lifetime_binders/on-rpit.rs
@@ -1,11 +1,14 @@
 //@ check-pass
 
+#![feature(sized_hierarchy)]
 #![feature(non_lifetime_binders)]
 //~^ WARN the feature `non_lifetime_binders` is incomplete
 
-trait Trait<T: ?Sized> {}
+use std::marker::PointeeSized;
 
-impl<T: ?Sized> Trait<T> for i32 {}
+trait Trait<T: PointeeSized> {}
+
+impl<T: PointeeSized> Trait<T> for i32 {}
 
 fn produce() -> impl for<T> Trait<T> {
     16
diff --git a/tests/ui/traits/non_lifetime_binders/on-rpit.stderr b/tests/ui/traits/non_lifetime_binders/on-rpit.stderr
index 34c56068c5c..c8396c38548 100644
--- a/tests/ui/traits/non_lifetime_binders/on-rpit.stderr
+++ b/tests/ui/traits/non_lifetime_binders/on-rpit.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/on-rpit.rs:3:12
+  --> $DIR/on-rpit.rs:4:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs
index 96345732f0f..aab5479334e 100644
--- a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs
+++ b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs
@@ -1,19 +1,22 @@
+#![feature(sized_hierarchy)]
 #![feature(non_lifetime_binders)]
 //~^ WARN the feature `non_lifetime_binders` is incomplete
 
+use std::marker::PointeeSized;
+
 trait Foo: for<T> Bar<T> {}
 
-trait Bar<T: ?Sized> {
+trait Bar<T: PointeeSized>: PointeeSized {
     fn method(&self) {}
 }
 
-fn needs_bar(x: &(impl Bar<i32> + ?Sized)) {
+fn needs_bar(x: &(impl Bar<i32> + PointeeSized)) {
     x.method();
 }
 
 impl Foo for () {}
 
-impl<T: ?Sized> Bar<T> for () {}
+impl<T: PointeeSized> Bar<T> for () {}
 
 fn main() {
     let x: &dyn Foo = &();
diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr
index aead19c4527..b32915ff549 100644
--- a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr
+++ b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/supertrait-dyn-compatibility.rs:1:12
+  --> $DIR/supertrait-dyn-compatibility.rs:2:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
@@ -8,14 +8,14 @@ LL | #![feature(non_lifetime_binders)]
    = note: `#[warn(incomplete_features)]` on by default
 
 error[E0038]: the trait `Foo` is not dyn compatible
-  --> $DIR/supertrait-dyn-compatibility.rs:19:17
+  --> $DIR/supertrait-dyn-compatibility.rs:22:17
    |
 LL |     let x: &dyn Foo = &();
    |                 ^^^ `Foo` is not dyn compatible
    |
 note: for a trait to be dyn compatible it needs to allow building a vtable
       for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
-  --> $DIR/supertrait-dyn-compatibility.rs:4:12
+  --> $DIR/supertrait-dyn-compatibility.rs:7:12
    |
 LL | trait Foo: for<T> Bar<T> {}
    |       ---  ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr
index 3e5854ea1c8..6551253d2e9 100644
--- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr
+++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/unifying-placeholders-in-query-response-2.rs:6:12
+  --> $DIR/unifying-placeholders-in-query-response-2.rs:7:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr
index 3e5854ea1c8..6551253d2e9 100644
--- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr
+++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/unifying-placeholders-in-query-response-2.rs:6:12
+  --> $DIR/unifying-placeholders-in-query-response-2.rs:7:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs
index 2066887ea59..d900bd429e6 100644
--- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs
+++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs
@@ -3,19 +3,22 @@
 //@[next] compile-flags: -Znext-solver
 //@ check-pass
 
+#![feature(sized_hierarchy)]
 #![feature(non_lifetime_binders)]
 //~^ WARN the feature `non_lifetime_binders` is incomplete
 
-trait Id {
-    type Output: ?Sized;
+use std::marker::PointeeSized;
+
+trait Id: PointeeSized {
+    type Output: PointeeSized;
 }
 
-impl<T: ?Sized> Id for T {
+impl<T: PointeeSized> Id for T {
     type Output = T;
 }
 
-trait Everyone {}
-impl<T: ?Sized> Everyone for T {}
+trait Everyone: PointeeSized {}
+impl<T: PointeeSized> Everyone for T {}
 
 fn hello() where for<T> <T as Id>::Output: Everyone {}
 
diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr
index 0224e5763e0..fecdc860f8e 100644
--- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr
+++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/unifying-placeholders-in-query-response.rs:6:12
+  --> $DIR/unifying-placeholders-in-query-response.rs:7:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr
index 0224e5763e0..fecdc860f8e 100644
--- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr
+++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/unifying-placeholders-in-query-response.rs:6:12
+  --> $DIR/unifying-placeholders-in-query-response.rs:7:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs
index 5334118e9ac..04e34531f4d 100644
--- a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs
+++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs
@@ -3,15 +3,18 @@
 //@[next] compile-flags: -Znext-solver
 //@ check-pass
 
+#![feature(sized_hierarchy)]
 #![feature(non_lifetime_binders)]
 //~^ WARN the feature `non_lifetime_binders` is incomplete
 
-pub trait Foo<T: ?Sized> {
-    type Bar<K: ?Sized>: ?Sized;
+use std::marker::PointeeSized;
+
+pub trait Foo<T: PointeeSized> {
+    type Bar<K: PointeeSized>: PointeeSized;
 }
 
 impl Foo<usize> for () {
-    type Bar<K: ?Sized> = K;
+    type Bar<K: PointeeSized> = K;
 }
 
 pub fn f<T1, T2>(a: T1, b: T2)
diff --git a/tests/ui/traits/non_lifetime_binders/universe-error1.rs b/tests/ui/traits/non_lifetime_binders/universe-error1.rs
index eadee6b711e..b4e8e3a8aad 100644
--- a/tests/ui/traits/non_lifetime_binders/universe-error1.rs
+++ b/tests/ui/traits/non_lifetime_binders/universe-error1.rs
@@ -1,12 +1,15 @@
+#![feature(sized_hierarchy)]
 #![feature(non_lifetime_binders)]
 //~^ WARN the feature `non_lifetime_binders` is incomplete
 
-trait Other<U: ?Sized> {}
+use std::marker::PointeeSized;
 
-impl<U: ?Sized> Other<U> for U {}
+trait Other<U: PointeeSized>: PointeeSized {}
+
+impl<U: PointeeSized> Other<U> for U {}
 
 #[rustfmt::skip]
-fn foo<U: ?Sized>()
+fn foo<U: PointeeSized>()
 where
     for<T> T: Other<U> {}
 
diff --git a/tests/ui/traits/non_lifetime_binders/universe-error1.stderr b/tests/ui/traits/non_lifetime_binders/universe-error1.stderr
index ecc97e283be..b997e7379e2 100644
--- a/tests/ui/traits/non_lifetime_binders/universe-error1.stderr
+++ b/tests/ui/traits/non_lifetime_binders/universe-error1.stderr
@@ -1,5 +1,5 @@
 warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/universe-error1.rs:1:12
+  --> $DIR/universe-error1.rs:2:12
    |
 LL | #![feature(non_lifetime_binders)]
    |            ^^^^^^^^^^^^^^^^^^^^
@@ -8,15 +8,15 @@ LL | #![feature(non_lifetime_binders)]
    = note: `#[warn(incomplete_features)]` on by default
 
 error[E0277]: the trait bound `T: Other<_>` is not satisfied
-  --> $DIR/universe-error1.rs:14:11
+  --> $DIR/universe-error1.rs:17:11
    |
 LL |     foo::<_>();
    |           ^ the trait `Other<_>` is not implemented for `T`
    |
 note: required by a bound in `foo`
-  --> $DIR/universe-error1.rs:11:15
+  --> $DIR/universe-error1.rs:14:15
    |
-LL | fn foo<U: ?Sized>()
+LL | fn foo<U: PointeeSized>()
    |    --- required by a bound in this function
 LL | where
 LL |     for<T> T: Other<U> {}
diff --git a/tests/ui/traits/resolve-impl-before-constrain-check.rs b/tests/ui/traits/resolve-impl-before-constrain-check.rs
index 87f9c241e40..50d1a874551 100644
--- a/tests/ui/traits/resolve-impl-before-constrain-check.rs
+++ b/tests/ui/traits/resolve-impl-before-constrain-check.rs
@@ -15,6 +15,7 @@ use foo::*;
 
 fn test() -> impl Sized {
     <() as Callable>::call()
+//~^ ERROR: type annotations needed
 }
 
 fn main() {}
diff --git a/tests/ui/traits/resolve-impl-before-constrain-check.stderr b/tests/ui/traits/resolve-impl-before-constrain-check.stderr
index e8e569ba625..13fbfdb855c 100644
--- a/tests/ui/traits/resolve-impl-before-constrain-check.stderr
+++ b/tests/ui/traits/resolve-impl-before-constrain-check.stderr
@@ -4,6 +4,13 @@ error[E0207]: the type parameter `V` is not constrained by the impl trait, self
 LL |     impl<V: ?Sized> Callable for () {
    |          ^ unconstrained type parameter
 
-error: aborting due to 1 previous error
+error[E0282]: type annotations needed
+  --> $DIR/resolve-impl-before-constrain-check.rs:17:6
+   |
+LL |     <() as Callable>::call()
+   |      ^^ cannot infer type for type parameter `V`
+
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0207`.
+Some errors have detailed explanations: E0207, E0282.
+For more information about an error, try `rustc --explain E0207`.
diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr
index 2bb389c6ec1..3eacab33e46 100644
--- a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr
+++ b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr
@@ -4,6 +4,13 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
 LL | impl<T: ?Sized> Every for Thing {
    |      ^ unconstrained type parameter
 
-error: aborting due to 1 previous error
+error[E0282]: type annotations needed
+  --> $DIR/unconstrained-projection-normalization-2.rs:19:11
+   |
+LL | fn foo(_: <Thing as Every>::Assoc) {}
+   |           ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for associated type `<Thing as Every>::Assoc`
+
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0207`.
+Some errors have detailed explanations: E0207, E0282.
+For more information about an error, try `rustc --explain E0207`.
diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.rs b/tests/ui/traits/unconstrained-projection-normalization-2.rs
index 6b584c436c6..9d95c73eea7 100644
--- a/tests/ui/traits/unconstrained-projection-normalization-2.rs
+++ b/tests/ui/traits/unconstrained-projection-normalization-2.rs
@@ -17,5 +17,6 @@ impl<T: ?Sized> Every for Thing {
 }
 
 fn foo(_: <Thing as Every>::Assoc) {}
+//[next]~^ ERROR: type annotations needed
 
 fn main() {}