Skip to content

Commit b0081b3

Browse files
committed
Auto merge of #42724 - Mark-Simulacrum:tests, r=alexcrichton
Add tests for a few issues. Fixes #41998 Fixes #38381 Fixes #37515 Fixes #37510 Fixes #37366 Fixes #37323 Fixes #37051 Fixes #36839 Fixes #35570 Fixes #34373 Fixes #34222 Certainly not all of the E-needstest issues right now, but I started to get bored.
2 parents 1ccc330 + 2346169 commit b0081b3

12 files changed

+288
-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

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
// ignore-emscripten
12+
13+
#![feature(rustc_attrs, asm)]
14+
15+
macro_rules! interrupt_handler {
16+
() => {
17+
unsafe fn _interrupt_handler() {
18+
asm!("pop eax" :::: "intel");
19+
}
20+
}
21+
}
22+
interrupt_handler!{}
23+
24+
#[rustc_error]
25+
fn main() { //~ ERROR compilation successful
26+
}

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)