Skip to content

Commit

Permalink
Rollup merge of #77388 - JohnTitor:add-tests, r=Dylan-DPC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JohnTitor authored Oct 4, 2020
2 parents 44ce38a + 38f460f commit f09c962
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/issues/issue-75299.rs
Original file line number Diff line number Diff line change
@@ -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>();
}
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-68951.rs
Original file line number Diff line number Diff line change
@@ -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;
}
}
12 changes: 12 additions & 0 deletions src/test/ui/pattern/issue-66501.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// check-pass

#![allow(unreachable_patterns)]

fn main() {
const CONST: &[Option<()>; 1] = &[Some(())];
match &[Some(())] {
&[None] => {}
CONST => {}
&[Some(())] => {}
}
}
8 changes: 8 additions & 0 deletions src/test/ui/pattern/issue-72565.rs
Original file line number Diff line number Diff line change
@@ -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
}
}
8 changes: 8 additions & 0 deletions src/test/ui/pattern/issue-72565.stderr
Original file line number Diff line number Diff line change
@@ -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

20 changes: 20 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-74244.rs
Original file line number Diff line number Diff line change
@@ -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() {}
9 changes: 9 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-74244.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit f09c962

Please sign in to comment.