Skip to content

Commit 3bed3bd

Browse files
Rollup merge of #42734 - MaloJaffre:tests, r=Mark-Simulacrum
Add tests for various issues Fixes #11740. Fixes #19601. Fixes #22603 Fixes #22789. Fixes #26614. r? @Mark-Simulacrum.
2 parents db9c12c + 5fe89e8 commit 3bed3bd

File tree

5 files changed

+124
-0
lines changed

5 files changed

+124
-0
lines changed

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

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
struct Attr {
15+
name: String,
16+
value: String,
17+
}
18+
19+
struct Element {
20+
attrs: Vec<Box<Attr>>,
21+
}
22+
23+
impl Element {
24+
pub unsafe fn get_attr<'a>(&'a self, name: &str) {
25+
self.attrs
26+
.iter()
27+
.find(|attr| {
28+
let attr: &&Box<Attr> = std::mem::transmute(attr);
29+
true
30+
});
31+
}
32+
}
33+
34+
#[rustc_error]
35+
fn main() { //~ ERROR compilation successful
36+
let element = Element { attrs: Vec::new() };
37+
let _ = unsafe { element.get_attr("foo") };
38+
}

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

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
trait A<T> {}
15+
struct B<T> where B<T>: A<B<T>> { t: T }
16+
17+
#[rustc_error]
18+
fn main() { //~ ERROR compilation successful
19+
}

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

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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(unboxed_closures, fn_traits, rustc_attrs)]
12+
13+
struct Foo;
14+
15+
impl<A> FnOnce<(A,)> for Foo {
16+
type Output = ();
17+
extern "rust-call" fn call_once(self, (_,): (A,)) {
18+
}
19+
}
20+
#[rustc_error]
21+
fn main() { //~ ERROR compilation successful
22+
println!("{:?}", Foo("bar"));
23+
}

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

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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(unboxed_closures, fn_traits, rustc_attrs)]
12+
13+
#[rustc_error]
14+
fn main() { //~ ERROR compilation successful
15+
let k = |x: i32| { x + 1 };
16+
Fn::call(&k, (0,));
17+
}

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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
trait Mirror {
15+
type It;
16+
}
17+
18+
impl<T> Mirror for T {
19+
type It = Self;
20+
}
21+
22+
23+
#[rustc_error]
24+
fn main() { //~ ERROR compilation successful
25+
let c: <u32 as Mirror>::It = 5;
26+
const CCCC: <u32 as Mirror>::It = 5;
27+
}

0 commit comments

Comments
 (0)