Skip to content

Commit f6f9cbe

Browse files
committed
Add tests to fixed ICEs
Closes rust-lang#27078. Closes rust-lang#27985. Closes rust-lang#39848. Closes rust-lang#42164. Closes rust-lang#42479. Closes rust-lang#45152. Closes rust-lang#45662. Closes rust-lang#45876. Closes rust-lang#45965.
1 parent 2e83f3c commit f6f9cbe

8 files changed

+192
-0
lines changed

src/test/compile-fail/E0532.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+
fn main() {
12+
let value = 1;
13+
14+
match SomeStruct(value) {
15+
StructConst1(_) => { },
16+
//~^ ERROR expected tuple struct/variant, found constant `StructConst1`
17+
_ => { },
18+
}
19+
20+
struct SomeStruct(u8);
21+
22+
const StructConst1 : SomeStruct = SomeStruct(1);
23+
const StructConst2 : SomeStruct = SomeStruct(2);
24+
}

src/test/compile-fail/issue-27078.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+
#![feature(associated_consts)]
12+
13+
trait Foo {
14+
const BAR: i32;
15+
fn foo(self) -> &'static i32 {
16+
//~^ ERROR the trait bound `Self: std::marker::Sized` is not satisfied
17+
&<Self>::BAR
18+
}
19+
}
20+
21+
fn main() {}

src/test/compile-fail/issue-39848.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+
macro_rules! get_opt {
12+
($tgt:expr, $field:ident) => {
13+
if $tgt.has_$field() {}
14+
}
15+
}
16+
17+
fn main() {
18+
get_opt!(bar, foo);
19+
//~^ ERROR expected `{`, found `foo`
20+
}

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

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
let a = |r: f64| if r != 0.0(r != 0.0) { 1.0 } else { 0.0 };
13+
//~^ ERROR expected function, found `{float}`
14+
}
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+
// #45662
12+
13+
#![feature(repr_align)]
14+
#![feature(attr_literals)]
15+
16+
#[repr(align(16))]
17+
pub struct A {
18+
y: i64,
19+
}
20+
21+
pub extern "C" fn foo(x: A) {}
22+
23+
fn main() {}
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(conservative_impl_trait)]
12+
13+
use std::iter::once;
14+
15+
struct Foo {
16+
x: i32,
17+
}
18+
19+
impl Foo {
20+
fn inside(&self) -> impl Iterator<Item = &i32> {
21+
once(&self.x)
22+
}
23+
}
24+
25+
fn main() {
26+
println!("hi");
27+
}

src/test/run-pass/issue-45152.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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(unsize, coerce_unsized)]
12+
13+
#[repr(packed)]
14+
struct UnalignedPtr<'a, T: ?Sized>
15+
where T: 'a,
16+
{
17+
data: &'a T,
18+
}
19+
20+
fn main() {
21+
22+
impl<'a, T, U> std::ops::CoerceUnsized<UnalignedPtr<'a, U>> for UnalignedPtr<'a, T>
23+
where
24+
T: std::marker::Unsize<U> + ?Sized,
25+
U: ?Sized,
26+
{ }
27+
28+
let arr = [1, 2, 3];
29+
let arr_unaligned: UnalignedPtr<[i32; 3]> = UnalignedPtr { data: &arr };
30+
let arr_unaligned: UnalignedPtr<[i32]> = arr_unaligned;
31+
}
+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+
// #42164
12+
13+
#![feature(decl_macro)]
14+
#![allow(dead_code)]
15+
16+
pub macro m($inner_str:expr) {
17+
#[doc = $inner_str]
18+
struct S;
19+
}
20+
21+
macro_rules! define_f {
22+
($name:expr) => {
23+
#[export_name = $name]
24+
fn f() {}
25+
}
26+
}
27+
28+
fn main() {
29+
define_f!(concat!("exported_", "f"));
30+
m!(stringify!(foo));
31+
}
32+

0 commit comments

Comments
 (0)