Rollup merge of #77388 - JohnTitor:add-tests, r=Dylan-DPC

Add some regression tests

Closes #66501
Closes #68951
Closes #72565
Closes #74244
Closes #75299

The first issue is fixed in 1.43.0, other issues are fixed in the recent nightly.
This commit is contained in:
Yuki Okushi 2020-10-04 11:45:01 +09:00 committed by GitHub
commit f09c962a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,11 @@
// compile-flags: -Zmir-opt-level=3
// run-pass
#![feature(const_generics)]
#![allow(incomplete_features)]
fn main() {
fn foo<const N: usize>() -> [u8; N] {
[0; N]
}
let _x = foo::<1>();
}

View File

@ -0,0 +1,9 @@
// check-pass
fn main() {
let array = [0x42u8; 10];
for b in &array {
let lo = b & 0xf;
let hi = (b >> 4) & 0xf;
}
}

View File

@ -0,0 +1,12 @@
// check-pass
#![allow(unreachable_patterns)]
fn main() {
const CONST: &[Option<()>; 1] = &[Some(())];
match &[Some(())] {
&[None] => {}
CONST => {}
&[Some(())] => {}
}
}

View File

@ -0,0 +1,8 @@
const F: &'static dyn PartialEq<u32> = &7u32;
fn main() {
let a: &dyn PartialEq<u32> = &7u32;
match a {
F => panic!(), //~ ERROR: `&dyn PartialEq<u32>` cannot be used in patterns
}
}

View File

@ -0,0 +1,8 @@
error: `&dyn PartialEq<u32>` cannot be used in patterns
--> $DIR/issue-72565.rs:6:9
|
LL | F => panic!(),
| ^
error: aborting due to previous error

View File

@ -0,0 +1,20 @@
#![feature(type_alias_impl_trait)]
trait Allocator {
type Buffer;
}
struct DefaultAllocator;
impl<T> Allocator for DefaultAllocator {
//~^ ERROR: the type parameter `T` is not constrained
type Buffer = ();
}
type A = impl Fn(<DefaultAllocator as Allocator>::Buffer);
fn foo() -> A {
|_| ()
}
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-74244.rs:9:6
|
LL | impl<T> Allocator for DefaultAllocator {
| ^ unconstrained type parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0207`.