Rollup merge of #69192 - JohnTitor:add-tests, r=Centril

Add more regression tests

Closes #39618
Closes #51798
Closes #62894
Closes #63952
Closes #68653

r? @Centril
This commit is contained in:
Dylan DPC 2020-02-18 16:07:24 +01:00 committed by GitHub
commit d1f175b2ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 159 additions and 0 deletions

View File

@ -0,0 +1,28 @@
// Regression test for #63952, shouldn't hang.
use std::usize;
#[repr(C)]
#[derive(Copy, Clone)]
struct SliceRepr {
ptr: *const u8,
len: usize,
}
union SliceTransmute {
repr: SliceRepr,
slice: &'static [u8],
}
// bad slice: length too big to even exist anywhere
const SLICE_WAY_TOO_LONG: &[u8] = unsafe { //~ ERROR: it is undefined behavior to use this value
SliceTransmute {
repr: SliceRepr {
ptr: &42,
len: usize::MAX,
},
}
.slice
};
fn main() {}

View File

@ -0,0 +1,17 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/issue-63952.rs:18:1
|
LL | / const SLICE_WAY_TOO_LONG: &[u8] = unsafe {
LL | | SliceTransmute {
LL | | repr: SliceRepr {
LL | | ptr: &42,
... |
LL | | .slice
LL | | };
| |__^ invalid slice: total size is bigger than largest supported object
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.

View File

@ -0,0 +1,16 @@
// A regression test for #68653, which was fixed by #68938.
// check-pass
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
trait Fun {
type F<'a: 'a>;
}
impl <T> Fun for T {
type F<'a> = Self;
}
fn main() {}

View File

@ -0,0 +1,3 @@
#![crate_type = "lib"]
pub fn vec() -> Vec<u8> { vec![] }

View File

@ -0,0 +1,14 @@
// edition:2018
// aux-build:issue-51798.rs
// check-pass
extern crate issue_51798;
mod server {
fn f() {
let mut v = issue_51798::vec();
v.clear();
}
}
fn main() {}

View File

@ -0,0 +1,7 @@
// Regression test for #62894, shouldn't crash.
// error-pattern: this file contains an unclosed delimiter
// error-pattern: expected one of `(`, `[`, or `{`, found keyword `fn`
fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
fn main() {}

View File

@ -0,0 +1,47 @@
error: this file contains an unclosed delimiter
--> $DIR/issue-62894.rs:7:14
|
LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
| - - - unclosed delimiter
| | |
| | unclosed delimiter
| unclosed delimiter
LL |
LL | fn main() {}
| ^
error: this file contains an unclosed delimiter
--> $DIR/issue-62894.rs:7:14
|
LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
| - - - unclosed delimiter
| | |
| | unclosed delimiter
| unclosed delimiter
LL |
LL | fn main() {}
| ^
error: this file contains an unclosed delimiter
--> $DIR/issue-62894.rs:7:14
|
LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
| - - - unclosed delimiter
| | |
| | unclosed delimiter
| unclosed delimiter
LL |
LL | fn main() {}
| ^
error: expected one of `(`, `[`, or `{`, found keyword `fn`
--> $DIR/issue-62894.rs:7:1
|
LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
| - expected one of `(`, `[`, or `{`
LL |
LL | fn main() {}
| ^^ unexpected token
error: aborting due to 4 previous errors

View File

@ -0,0 +1,27 @@
// Regression test for #39618, shouldn't crash.
// FIXME(JohnTitor): Centril pointed out this looks suspicions, we should revisit here.
// More context: https://github.com/rust-lang/rust/pull/69192#discussion_r379846796
// check-pass
#![feature(specialization)]
trait Foo {
fn foo(&self);
}
trait Bar {
fn bar(&self);
}
impl<T> Bar for T where T: Foo {
fn bar(&self) {}
}
impl<T> Foo for T where T: Bar {
fn foo(&self) {}
}
impl Foo for u64 {}
fn main() {}