diff options
| author | bors <bors@rust-lang.org> | 2023-12-04 19:46:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-04 19:46:46 +0000 |
| commit | a28077b28a02b92985b3a3faecf92813155f1ea1 (patch) | |
| tree | 2b3b10b83a2f87104f139d2e634ac83a9cc38066 /tests | |
| parent | 79e9716c980570bfd1f666e3b16ac583f0168962 (diff) | |
| parent | de148ecd5c7b1675460843a8a35a370e4360a257 (diff) | |
| download | rust-1.74.1.tar.gz rust-1.74.1.zip | |
Auto merge of #118607 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum 1.74.1
[stable] 1.74.1 release This includes backports of: * Dispose llvm::TargetMachines prior to llvm::Context being disposed #118464 * clarify fn discriminant guarantees: only free lifetimes may get erased #118006 * Move subtyper below reveal_all and change reveal_all #116415 * Make subtyping explicit in MIR #115025 (needed for above) As well as infrastructure fix: * Don't ask for a specific branch in cargotest #118597 r? `@Mark-Simulacrum`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/impl-trait/impl-subtyper.rs | 18 | ||||
| -rw-r--r-- | tests/ui/impl-trait/impl-subtyper2.rs | 7 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/normalize-alias-type.rs | 32 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/tait-normalize.rs | 14 | ||||
| -rw-r--r-- | tests/ui/type/subtyping-opaque-type.rs | 19 |
5 files changed, 90 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/impl-subtyper.rs b/tests/ui/impl-trait/impl-subtyper.rs new file mode 100644 index 00000000000..2d99cdd4f50 --- /dev/null +++ b/tests/ui/impl-trait/impl-subtyper.rs @@ -0,0 +1,18 @@ +// check-pass + +#![crate_type = "lib"] +fn checkpoints() -> impl Iterator { + Some(()).iter().flat_map(|_| std::iter::once(())) +} + +fn block_checkpoints() -> impl Iterator { + checkpoints() +} + +fn iter_raw() -> impl Iterator { + let mut iter = block_checkpoints(); + + (0..9).map(move |_| { + iter.next(); + }) +} diff --git a/tests/ui/impl-trait/impl-subtyper2.rs b/tests/ui/impl-trait/impl-subtyper2.rs new file mode 100644 index 00000000000..2e0acbae68b --- /dev/null +++ b/tests/ui/impl-trait/impl-subtyper2.rs @@ -0,0 +1,7 @@ +// check-pass + +fn ages() -> Option<impl Iterator> { + None::<std::slice::Iter<()>> +} + +fn main(){} diff --git a/tests/ui/type-alias-impl-trait/normalize-alias-type.rs b/tests/ui/type-alias-impl-trait/normalize-alias-type.rs new file mode 100644 index 00000000000..7c62002b931 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/normalize-alias-type.rs @@ -0,0 +1,32 @@ +// check-pass +// compile-flags: -Z mir-opt-level=3 +#![feature(type_alias_impl_trait)] +#![crate_type = "lib"] +pub trait Tr { + fn get(&self) -> u32; +} + +impl Tr for (u32,) { + #[inline] + fn get(&self) -> u32 { self.0 } +} + +pub fn tr1() -> impl Tr { + (32,) +} + +pub fn tr2() -> impl Tr { + struct Inner { + x: X, + } + type X = impl Tr; + impl Tr for Inner { + fn get(&self) -> u32 { + self.x.get() + } + } + + Inner { + x: tr1(), + } +} diff --git a/tests/ui/type-alias-impl-trait/tait-normalize.rs b/tests/ui/type-alias-impl-trait/tait-normalize.rs new file mode 100644 index 00000000000..26d94dbb42a --- /dev/null +++ b/tests/ui/type-alias-impl-trait/tait-normalize.rs @@ -0,0 +1,14 @@ +// check-pass + +#![feature(type_alias_impl_trait)] + +fn enum_upvar() { + type T = impl Copy; + let foo: T = Some((1u32, 2u32)); + let x = move || match foo { + None => (), + Some((a, b)) => (), + }; +} + +fn main(){} diff --git a/tests/ui/type/subtyping-opaque-type.rs b/tests/ui/type/subtyping-opaque-type.rs new file mode 100644 index 00000000000..beda232ea8b --- /dev/null +++ b/tests/ui/type/subtyping-opaque-type.rs @@ -0,0 +1,19 @@ +// check-pass +// compile-flags: -Zvalidate-mir +trait Duh {} + +impl Duh for i32 {} + +trait Trait { + type Assoc: Duh; +} + +impl<R: Duh, F: FnMut() -> R> Trait for F { + type Assoc = R; +} + +fn foo() -> impl Trait<Assoc = impl Send> { + || 42 +} + +fn main() {} |
