diff options
| author | bors <bors@rust-lang.org> | 2022-09-15 21:06:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-15 21:06:36 +0000 |
| commit | cf9ed0dd5836201843d28bbad50abfbe1913af2a (patch) | |
| tree | 6edf886d1ef7f6ec75bacc6a9f85540cfcb4545d /src/test | |
| parent | df34db9b032b15efd86df3544cc75e6d55dc492e (diff) | |
| parent | 7893ca74e53b76068a2afae17ddf752f21a160ff (diff) | |
Auto merge of #101831 - compiler-errors:issue-75899, r=jackh726
Normalize struct field types in `confirm_builtin_unsize_candidate` Fixes #75899 --- edited to move the normalization into `confirm_builtin_unsize_candidate` instead of the coercion code.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/unsized/issue-75899-but-gats.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/unsized/issue-75899.rs | 18 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/unsized/issue-75899-but-gats.rs b/src/test/ui/unsized/issue-75899-but-gats.rs new file mode 100644 index 00000000000..5716817f43d --- /dev/null +++ b/src/test/ui/unsized/issue-75899-but-gats.rs @@ -0,0 +1,21 @@ +// check-pass + +use std::fmt::Debug; +use std::marker::PhantomData; + +trait Foo { + type Gat<'a>: ?Sized where Self: 'a; +} + +struct Bar<'a, T: Foo + 'a>(T::Gat<'a>); + +struct Baz<T: ?Sized>(PhantomData<T>); + +impl<T: ?Sized> Foo for Baz<T> { + type Gat<'a> = T where Self: 'a; +} + +fn main() { + let x = Bar::<'_, Baz<()>>(()); + let y: &Bar<'_, Baz<dyn Debug>> = &x; +} diff --git a/src/test/ui/unsized/issue-75899.rs b/src/test/ui/unsized/issue-75899.rs new file mode 100644 index 00000000000..abff17e11b5 --- /dev/null +++ b/src/test/ui/unsized/issue-75899.rs @@ -0,0 +1,18 @@ +// check-pass + +trait Trait {} +impl<T> Trait for T {} + +trait Noop { + type Assoc: ?Sized; +} +impl<T: ?Sized> Noop for T { + type Assoc = T; +} + +struct NoopNewtype<T: ?Sized + Noop>(T::Assoc); +fn coerce_newtype<T: Trait>(x: &NoopNewtype<T>) -> &NoopNewtype<dyn Trait + '_> { + x +} + +fn main() {} |
