Skip to content

Commit 622e8c0

Browse files
Add tests for a few issues.
1 parent 78d8416 commit 622e8c0

13 files changed

+325
-0
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
/// comment //~ ERROR found a documentation comment that doesn't document anything
13+
}

src/test/compile-fail/issue-34222.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
#![allow(warnings)]
13+
14+
#[rustc_error]
15+
fn main() { //~ ERROR compilation successful
16+
/// crash
17+
let x = 0;
18+
}

src/test/compile-fail/issue-34373.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![allow(warnings)]
12+
13+
trait Trait<T> {
14+
fn foo(_: T) {}
15+
}
16+
17+
pub struct Foo<T = Box<Trait<DefaultFoo>>>;
18+
type DefaultFoo = Foo; //~ ERROR unsupported cyclic reference
19+
20+
fn main() {
21+
}

src/test/compile-fail/issue-35570.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
13+
use std::mem;
14+
15+
trait Trait1<T> {}
16+
trait Trait2<'a> {
17+
type Ty;
18+
}
19+
20+
fn _ice(param: Box<for <'a> Trait1<<() as Trait2<'a>>::Ty>>) {
21+
let _e: (usize, usize) = unsafe{mem::transmute(param)};
22+
}
23+
24+
trait Lifetime<'a> {
25+
type Out;
26+
}
27+
impl<'a> Lifetime<'a> for () {
28+
type Out = &'a ();
29+
}
30+
fn foo<'a>(x: &'a ()) -> <() as Lifetime<'a>>::Out {
31+
x
32+
}
33+
34+
fn takes_lifetime(_f: for<'a> fn(&'a ()) -> <() as Lifetime<'a>>::Out) {
35+
}
36+
37+
#[rustc_error]
38+
fn main() { //~ ERROR compilation successful
39+
takes_lifetime(foo);
40+
}

src/test/compile-fail/issue-36839.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
13+
pub trait Foo {
14+
type Bar;
15+
}
16+
17+
pub trait Broken {
18+
type Assoc;
19+
fn broken(&self) where Self::Assoc: Foo;
20+
}
21+
22+
impl<T> Broken for T {
23+
type Assoc = ();
24+
fn broken(&self) where Self::Assoc: Foo {
25+
let _x: <Self::Assoc as Foo>::Bar;
26+
}
27+
}
28+
29+
#[rustc_error]
30+
fn main() { //~ ERROR compilation successful
31+
let _m: &Broken<Assoc=()> = &();
32+
}

src/test/compile-fail/issue-37051.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs, associated_type_defaults)]
12+
#![allow(warnings)]
13+
14+
trait State: Sized {
15+
type NextState: State = StateMachineEnded;
16+
fn execute(self) -> Option<Self::NextState>;
17+
}
18+
19+
struct StateMachineEnded;
20+
21+
impl State for StateMachineEnded {
22+
fn execute(self) -> Option<Self::NextState> {
23+
None
24+
}
25+
}
26+
27+
#[rustc_error]
28+
fn main() { //~ ERROR compilation successful
29+
}

src/test/compile-fail/issue-37323.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
#![allow(warnings)]
13+
14+
#[derive(Debug)]
15+
struct Point {
16+
}
17+
18+
struct NestedA<'a, 'b> {
19+
x: &'a NestedB<'b>
20+
//~^ ERROR E0491
21+
}
22+
23+
struct NestedB<'a> {
24+
x: &'a i32,
25+
}
26+
27+
fn main() {
28+
}

src/test/compile-fail/issue-37366.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs, asm)]
12+
13+
macro_rules! interrupt_handler {
14+
() => {
15+
unsafe fn _interrupt_handler() {
16+
asm!("pop eax" :::: "intel");
17+
}
18+
}
19+
}
20+
interrupt_handler!{}
21+
22+
#[rustc_error]
23+
fn main() { //~ ERROR compilation successful
24+
}

src/test/compile-fail/issue-37508.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![no_std]
12+
#![feature(rustc_attrs, thread_local, lang_items)]
13+
14+
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
15+
#[lang = "eh_personality"] extern fn eh_personality() {}
16+
17+
pub struct BB;
18+
19+
#[thread_local]
20+
static mut KEY: Key = Key {
21+
inner: BB,
22+
dtor_running: false,
23+
};
24+
25+
pub unsafe fn set() -> Option<&'static BB> {
26+
if KEY.dtor_running {
27+
return None
28+
}
29+
Some(&KEY.inner)
30+
}
31+
32+
pub struct Key {
33+
inner: BB,
34+
dtor_running: bool,
35+
}
36+
37+
#[rustc_error]
38+
fn main() { //~ ERROR compilation successful
39+
}

src/test/compile-fail/issue-37510.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
13+
fn foo(_: &mut i32) -> bool { true }
14+
15+
#[rustc_error]
16+
fn main() { //~ ERROR compilation successful
17+
let opt = Some(92);
18+
let mut x = 62;
19+
20+
if let Some(_) = opt {
21+
22+
} else if foo(&mut x) {
23+
24+
}
25+
}

src/test/compile-fail/issue-37515.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
13+
type Z = for<'x> Send;
14+
//~^ WARN type alias is never used
15+
16+
#[rustc_error]
17+
fn main() { //~ ERROR compilation successful
18+
}

src/test/compile-fail/issue-38381.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
13+
use std::ops::Deref;
14+
15+
#[rustc_error]
16+
fn main() { //~ ERROR compilation successful
17+
let _x: fn(&i32) -> <&i32 as Deref>::Target = unimplemented!();
18+
}

src/test/compile-fail/issue-41998.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
13+
#[rustc_error]
14+
fn main() { //~ ERROR compilation successful
15+
if ('x' as char) < ('y' as char) {
16+
print!("x");
17+
} else {
18+
print!("y");
19+
}
20+
}

0 commit comments

Comments
 (0)