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.
This commit is contained in:
commit
b0081b36b4
13
src/test/compile-fail/issue-34222-1.rs
Normal file
13
src/test/compile-fail/issue-34222-1.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
/// comment //~ ERROR found a documentation comment that doesn't document anything
|
||||||
|
}
|
18
src/test/compile-fail/issue-34222.rs
Normal file
18
src/test/compile-fail/issue-34222.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
|
#![allow(warnings)]
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
/// crash
|
||||||
|
let x = 0;
|
||||||
|
}
|
21
src/test/compile-fail/issue-34373.rs
Normal file
21
src/test/compile-fail/issue-34373.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![allow(warnings)]
|
||||||
|
|
||||||
|
trait Trait<T> {
|
||||||
|
fn foo(_: T) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
||||||
|
type DefaultFoo = Foo; //~ ERROR unsupported cyclic reference
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
}
|
40
src/test/compile-fail/issue-35570.rs
Normal file
40
src/test/compile-fail/issue-35570.rs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
|
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
|
trait Trait1<T> {}
|
||||||
|
trait Trait2<'a> {
|
||||||
|
type Ty;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _ice(param: Box<for <'a> Trait1<<() as Trait2<'a>>::Ty>>) {
|
||||||
|
let _e: (usize, usize) = unsafe{mem::transmute(param)};
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Lifetime<'a> {
|
||||||
|
type Out;
|
||||||
|
}
|
||||||
|
impl<'a> Lifetime<'a> for () {
|
||||||
|
type Out = &'a ();
|
||||||
|
}
|
||||||
|
fn foo<'a>(x: &'a ()) -> <() as Lifetime<'a>>::Out {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
|
||||||
|
fn takes_lifetime(_f: for<'a> fn(&'a ()) -> <() as Lifetime<'a>>::Out) {
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
takes_lifetime(foo);
|
||||||
|
}
|
32
src/test/compile-fail/issue-36839.rs
Normal file
32
src/test/compile-fail/issue-36839.rs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
|
|
||||||
|
pub trait Foo {
|
||||||
|
type Bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Broken {
|
||||||
|
type Assoc;
|
||||||
|
fn broken(&self) where Self::Assoc: Foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Broken for T {
|
||||||
|
type Assoc = ();
|
||||||
|
fn broken(&self) where Self::Assoc: Foo {
|
||||||
|
let _x: <Self::Assoc as Foo>::Bar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
let _m: &Broken<Assoc=()> = &();
|
||||||
|
}
|
29
src/test/compile-fail/issue-37051.rs
Normal file
29
src/test/compile-fail/issue-37051.rs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs, associated_type_defaults)]
|
||||||
|
#![allow(warnings)]
|
||||||
|
|
||||||
|
trait State: Sized {
|
||||||
|
type NextState: State = StateMachineEnded;
|
||||||
|
fn execute(self) -> Option<Self::NextState>;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StateMachineEnded;
|
||||||
|
|
||||||
|
impl State for StateMachineEnded {
|
||||||
|
fn execute(self) -> Option<Self::NextState> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
}
|
28
src/test/compile-fail/issue-37323.rs
Normal file
28
src/test/compile-fail/issue-37323.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
|
#![allow(warnings)]
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Point {
|
||||||
|
}
|
||||||
|
|
||||||
|
struct NestedA<'a, 'b> {
|
||||||
|
x: &'a NestedB<'b>
|
||||||
|
//~^ ERROR E0491
|
||||||
|
}
|
||||||
|
|
||||||
|
struct NestedB<'a> {
|
||||||
|
x: &'a i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
}
|
26
src/test/compile-fail/issue-37366.rs
Normal file
26
src/test/compile-fail/issue-37366.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// ignore-emscripten
|
||||||
|
|
||||||
|
#![feature(rustc_attrs, asm)]
|
||||||
|
|
||||||
|
macro_rules! interrupt_handler {
|
||||||
|
() => {
|
||||||
|
unsafe fn _interrupt_handler() {
|
||||||
|
asm!("pop eax" :::: "intel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
interrupt_handler!{}
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
}
|
25
src/test/compile-fail/issue-37510.rs
Normal file
25
src/test/compile-fail/issue-37510.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
|
|
||||||
|
fn foo(_: &mut i32) -> bool { true }
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
let opt = Some(92);
|
||||||
|
let mut x = 62;
|
||||||
|
|
||||||
|
if let Some(_) = opt {
|
||||||
|
|
||||||
|
} else if foo(&mut x) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
18
src/test/compile-fail/issue-37515.rs
Normal file
18
src/test/compile-fail/issue-37515.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
|
|
||||||
|
type Z = for<'x> Send;
|
||||||
|
//~^ WARN type alias is never used
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
}
|
18
src/test/compile-fail/issue-38381.rs
Normal file
18
src/test/compile-fail/issue-38381.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
|
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
let _x: fn(&i32) -> <&i32 as Deref>::Target = unimplemented!();
|
||||||
|
}
|
20
src/test/compile-fail/issue-41998.rs
Normal file
20
src/test/compile-fail/issue-41998.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(rustc_attrs)]
|
||||||
|
|
||||||
|
#[rustc_error]
|
||||||
|
fn main() { //~ ERROR compilation successful
|
||||||
|
if ('x' as char) < ('y' as char) {
|
||||||
|
print!("x");
|
||||||
|
} else {
|
||||||
|
print!("y");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user