Skip to content

Commit 89cb4d7

Browse files
authored
Rollup merge of #72572 - JohnTitor:add-tests, r=matthewjasper
Add some regression tests Closes #68532 Closes #70121 Closes #71042 CC #56445 r? @matthewjasper since they (except for #71042) are related to #72362.
2 parents c09f0eb + 6315d0c commit 89cb4d7

5 files changed

+79
-0
lines changed

src/test/ui/impl-trait/issue-56445.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-629426939
2+
// check-pass
3+
4+
#![crate_type = "lib"]
5+
6+
use std::marker::PhantomData;
7+
8+
pub struct S<'a>
9+
{
10+
pub m1: PhantomData<&'a u8>,
11+
pub m2: [u8; S::size()],
12+
}
13+
14+
impl<'a> S<'a>
15+
{
16+
pub const fn size() -> usize { 1 }
17+
18+
pub fn new() -> Self
19+
{
20+
Self
21+
{
22+
m1: PhantomData,
23+
m2: [0; Self::size()],
24+
}
25+
}
26+
}

src/test/ui/impl-trait/issue-68532.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
3+
pub struct A<'a>(&'a ());
4+
5+
impl<'a> A<'a> {
6+
const N: usize = 68;
7+
8+
pub fn foo(&self) {
9+
let _b = [0; Self::N];
10+
}
11+
}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(impl_trait_in_bindings)]
2+
#![allow(incomplete_features)]
3+
4+
fn main() {
5+
const C: impl Copy = 0;
6+
match C {
7+
C | _ => {} //~ ERROR: opaque types cannot be used in patterns
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: opaque types cannot be used in patterns
2+
--> $DIR/issue-71042-opaquely-typed-constant-used-in-pattern.rs:7:9
3+
|
4+
LL | C | _ => {}
5+
| ^
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
pub type Successors<'a> = impl Iterator<Item = &'a ()>;
6+
7+
pub fn f<'a>() -> Successors<'a> {
8+
None.into_iter()
9+
}
10+
11+
pub trait Tr {
12+
type Item;
13+
}
14+
15+
impl<'a> Tr for &'a () {
16+
type Item = Successors<'a>;
17+
}
18+
19+
pub fn kazusa<'a>() -> <&'a () as Tr>::Item {
20+
None.into_iter()
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)