Skip to content

Commit a341710

Browse files
authored
Rollup merge of rust-lang#77388 - JohnTitor:add-tests, r=Dylan-DPC
Add some regression tests Closes rust-lang#66501 Closes rust-lang#68951 Closes rust-lang#72565 Closes rust-lang#74244 Closes rust-lang#75299 The first issue is fixed in 1.43.0, other issues are fixed in the recent nightly.
2 parents eda4050 + 38f460f commit a341710

File tree

7 files changed

+77
-0
lines changed

7 files changed

+77
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// compile-flags: -Zmir-opt-level=3
2+
// run-pass
3+
4+
#![feature(const_generics)]
5+
#![allow(incomplete_features)]
6+
fn main() {
7+
fn foo<const N: usize>() -> [u8; N] {
8+
[0; N]
9+
}
10+
let _x = foo::<1>();
11+
}

src/test/ui/issues/issue-68951.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
3+
fn main() {
4+
let array = [0x42u8; 10];
5+
for b in &array {
6+
let lo = b & 0xf;
7+
let hi = (b >> 4) & 0xf;
8+
}
9+
}

src/test/ui/pattern/issue-66501.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
3+
#![allow(unreachable_patterns)]
4+
5+
fn main() {
6+
const CONST: &[Option<()>; 1] = &[Some(())];
7+
match &[Some(())] {
8+
&[None] => {}
9+
CONST => {}
10+
&[Some(())] => {}
11+
}
12+
}

src/test/ui/pattern/issue-72565.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const F: &'static dyn PartialEq<u32> = &7u32;
2+
3+
fn main() {
4+
let a: &dyn PartialEq<u32> = &7u32;
5+
match a {
6+
F => panic!(), //~ ERROR: `&dyn PartialEq<u32>` cannot be used in patterns
7+
}
8+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: `&dyn PartialEq<u32>` cannot be used in patterns
2+
--> $DIR/issue-72565.rs:6:9
3+
|
4+
LL | F => panic!(),
5+
| ^
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![feature(type_alias_impl_trait)]
2+
3+
trait Allocator {
4+
type Buffer;
5+
}
6+
7+
struct DefaultAllocator;
8+
9+
impl<T> Allocator for DefaultAllocator {
10+
//~^ ERROR: the type parameter `T` is not constrained
11+
type Buffer = ();
12+
}
13+
14+
type A = impl Fn(<DefaultAllocator as Allocator>::Buffer);
15+
16+
fn foo() -> A {
17+
|_| ()
18+
}
19+
20+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/issue-74244.rs:9:6
3+
|
4+
LL | impl<T> Allocator for DefaultAllocator {
5+
| ^ unconstrained type parameter
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)