Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more regression tests #69192

Merged
merged 6 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/test/ui/consts/issue-63952.rs
Original file line number Diff line number Diff line change
@@ -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() {}
17 changes: 17 additions & 0 deletions src/test/ui/consts/issue-63952.stderr
Original file line number Diff line number Diff line change
@@ -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`.
16 changes: 16 additions & 0 deletions src/test/ui/generic-associated-types/issue-68653.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// A regression test for #68653, which was fixed by #68938.

// check-pass
JohnTitor marked this conversation as resolved.
Show resolved Hide resolved

#![allow(incomplete_features)]
#![feature(generic_associated_types)]

trait Fun {
type F<'a: 'a>;
}

impl <T> Fun for T {
type F<'a> = Self;
}

fn main() {}
3 changes: 3 additions & 0 deletions src/test/ui/issues/auxiliary/issue-51798.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#![crate_type = "lib"]

pub fn vec() -> Vec<u8> { vec![] }
14 changes: 14 additions & 0 deletions src/test/ui/issues/issue-51798.rs
Original file line number Diff line number Diff line change
@@ -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() {}
7 changes: 7 additions & 0 deletions src/test/ui/parser/issue-62894.rs
Original file line number Diff line number Diff line change
@@ -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() {}
47 changes: 47 additions & 0 deletions src/test/ui/parser/issue-62894.stderr
Original file line number Diff line number Diff line change
@@ -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

27 changes: 27 additions & 0 deletions src/test/ui/specialization/issue-39618.rs
Original file line number Diff line number Diff line change
@@ -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 {}
Comment on lines +17 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks suspicions... There's no default anywhere, yet logically, we have u64: Foo, hence where T: Foo is discharged, hence u64: Bar, hence T: Bar is discharged, and thus impl<T> Foo for T applies (and so we have overlap).

cc @jonas-schievink (I thought this had been fixed?)
cc @matthewjasper & @nikomatsakis


fn main() {}