Merge remote-tracking branch 'origin/master' into gen

This commit is contained in:
Alex Crichton 2017-08-07 22:30:39 -07:00
commit c25ddf21f1
280 changed files with 17756 additions and 2240 deletions

View file

@ -0,0 +1,74 @@
// 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.
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]
// CHECK-LABEL: @zero_sized_elem
#[no_mangle]
pub fn zero_sized_elem() {
// CHECK-NOT: br label %slice_loop_header{{.*}}
// CHECK-NOT: call void @llvm.memset.p0i8
let x = [(); 4];
drop(&x);
}
// CHECK-LABEL: @zero_len_array
#[no_mangle]
pub fn zero_len_array() {
// CHECK-NOT: br label %slice_loop_header{{.*}}
// CHECK-NOT: call void @llvm.memset.p0i8
let x = [4; 0];
drop(&x);
}
// CHECK-LABEL: @byte_array
#[no_mangle]
pub fn byte_array() {
// CHECK: call void @llvm.memset.p0i8.i[[WIDTH:[0-9]+]](i8* {{.*}}, i8 7, i[[WIDTH]] 4
// CHECK-NOT: br label %slice_loop_header{{.*}}
let x = [7u8; 4];
drop(&x);
}
#[allow(dead_code)]
#[derive(Copy, Clone)]
enum Init {
Loop,
Memset,
}
// CHECK-LABEL: @byte_enum_array
#[no_mangle]
pub fn byte_enum_array() {
// CHECK: call void @llvm.memset.p0i8.i[[WIDTH:[0-9]+]](i8* {{.*}}, i8 {{.*}}, i[[WIDTH]] 4
// CHECK-NOT: br label %slice_loop_header{{.*}}
let x = [Init::Memset; 4];
drop(&x);
}
// CHECK-LABEL: @zeroed_integer_array
#[no_mangle]
pub fn zeroed_integer_array() {
// CHECK: call void @llvm.memset.p0i8.i[[WIDTH:[0-9]+]](i8* {{.*}}, i8 0, i[[WIDTH]] 16
// CHECK-NOT: br label %slice_loop_header{{.*}}
let x = [0u32; 4];
drop(&x);
}
// CHECK-LABEL: @nonzero_integer_array
#[no_mangle]
pub fn nonzero_integer_array() {
// CHECK: br label %slice_loop_header{{.*}}
// CHECK-NOT: call void @llvm.memset.p0i8
let x = [0x1a_2b_3c_4d_u32; 4];
drop(&x);
}

View 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.
//
// no-system-llvm
// compile-flags: -O
#![crate_type="lib"]
#[no_mangle]
pub fn sum_me() -> i32 {
// CHECK-LABEL: @sum_me
// CHECK-NEXT: {{^.*:$}}
// CHECK-NEXT: ret i32 6
vec![1, 2, 3].iter().sum::<i32>()
}

View file

@ -0,0 +1,51 @@
// 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.
// aux-build:attribute-with-error.rs
#![feature(proc_macro)]
extern crate attribute_with_error;
use attribute_with_error::foo;
#[foo]
fn test1() {
let a: i32 = "foo";
//~^ ERROR: mismatched types
}
fn test2() {
#![foo]
// FIXME: should have a type error here and assert it works but it doesn't
}
trait A {
// FIXME: should have a #[foo] attribute here and assert that it works
fn foo(&self) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
}
}
struct B;
impl A for B {
#[foo]
fn foo(&self) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
}
}
#[foo]
fn main() {
}

View file

@ -0,0 +1,30 @@
// 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.
// aux-build:attributes-included.rs
#![feature(proc_macro, rustc_attrs)]
extern crate attributes_included;
#[attributes_included::bar]
#[inline]
/// doc
#[attributes_included::foo]
#[inline]
/// doc
fn foo() {
let a: i32 = "foo"; //~ WARN: unused variable
}
#[rustc_error]
fn main() { //~ ERROR: compilation successful
foo()
}

View file

@ -0,0 +1,24 @@
// 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.
// force-host
// no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn foo(_attr: TokenStream, input: TokenStream) -> TokenStream {
input.into_iter().collect()
}

View file

@ -0,0 +1,130 @@
// 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.
// force-host
// no-prefer-dynamic
#![feature(proc_macro)]
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::{TokenStream, TokenTree, TokenNode, Delimiter, Literal};
#[proc_macro_attribute]
pub fn foo(attr: TokenStream, input: TokenStream) -> TokenStream {
assert!(attr.is_empty());
let input = input.into_iter().collect::<Vec<_>>();
{
let mut cursor = &input[..];
assert_inline(&mut cursor);
assert_doc(&mut cursor);
assert_inline(&mut cursor);
assert_doc(&mut cursor);
assert_foo(&mut cursor);
assert!(cursor.is_empty());
}
fold_stream(input.into_iter().collect())
}
#[proc_macro_attribute]
pub fn bar(attr: TokenStream, input: TokenStream) -> TokenStream {
assert!(attr.is_empty());
let input = input.into_iter().collect::<Vec<_>>();
{
let mut cursor = &input[..];
assert_inline(&mut cursor);
assert_doc(&mut cursor);
assert_invoc(&mut cursor);
assert_inline(&mut cursor);
assert_doc(&mut cursor);
assert_foo(&mut cursor);
assert!(cursor.is_empty());
}
input.into_iter().collect()
}
fn assert_inline(slice: &mut &[TokenTree]) {
match slice[0].kind {
TokenNode::Op('#', _) => {}
_ => panic!("expected '#' char"),
}
match slice[1].kind {
TokenNode::Group(Delimiter::Bracket, _) => {}
_ => panic!("expected brackets"),
}
*slice = &slice[2..];
}
fn assert_doc(slice: &mut &[TokenTree]) {
match slice[0].kind {
TokenNode::Literal(_) => {}
_ => panic!("expected literal doc comment got other"),
}
*slice = &slice[1..];
}
fn assert_invoc(slice: &mut &[TokenTree]) {
match slice[0].kind {
TokenNode::Op('#', _) => {}
_ => panic!("expected '#' char"),
}
match slice[1].kind {
TokenNode::Group(Delimiter::Bracket, _) => {}
_ => panic!("expected brackets"),
}
*slice = &slice[2..];
}
fn assert_foo(slice: &mut &[TokenTree]) {
match slice[0].kind {
TokenNode::Term(ref name) => assert_eq!(name.as_str(), "fn"),
_ => panic!("expected fn"),
}
match slice[1].kind {
TokenNode::Term(ref name) => assert_eq!(name.as_str(), "foo"),
_ => panic!("expected foo"),
}
match slice[2].kind {
TokenNode::Group(Delimiter::Parenthesis, ref s) => assert!(s.is_empty()),
_ => panic!("expected parens"),
}
match slice[3].kind {
TokenNode::Group(Delimiter::Brace, _) => {}
_ => panic!("expected braces"),
}
*slice = &slice[4..];
}
fn fold_stream(input: TokenStream) -> TokenStream {
input.into_iter().map(fold_tree).collect()
}
fn fold_tree(input: TokenTree) -> TokenTree {
TokenTree {
span: input.span,
kind: fold_node(input.kind),
}
}
fn fold_node(input: TokenNode) -> TokenNode {
match input {
TokenNode::Group(a, b) => TokenNode::Group(a, fold_stream(b)),
TokenNode::Op(a, b) => TokenNode::Op(a, b),
TokenNode::Term(a) => TokenNode::Term(a),
TokenNode::Literal(a) => {
if a.to_string() != "\"foo\"" {
TokenNode::Literal(a)
} else {
TokenNode::Literal(Literal::integer(3))
}
}
}
}

View file

@ -15,5 +15,6 @@ enum Field {
fn main() {
let s = Field::Fool { joke: 0 };
//~^ ERROR E0559
//~| NOTE field does not exist - did you mean `x`?
//~| NOTE `Field::Fool` does not have this field
//~| NOTE available fields are: `x`
}

View file

@ -16,4 +16,5 @@ fn main() {
let s = Simba { mother: 1, father: 0 };
//~^ ERROR E0560
//~| NOTE `Simba` does not have this field
//~| NOTE available fields are: `mother`
}

View file

@ -0,0 +1,22 @@
// 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.
mod inner {
pub struct Foo;
impl Foo {
fn method(&self) {}
}
}
fn main() {
let foo = inner::Foo;
foo.method(); //~ ERROR method `method` is private [E0624]
}

View file

@ -14,6 +14,7 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
#![feature(asm, rustc_attrs)]

View file

@ -11,6 +11,7 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
#![feature(asm)]

View file

@ -14,6 +14,7 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
#![feature(asm, rustc_attrs)]

View file

@ -11,6 +11,7 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
#![feature(asm)]

View file

@ -11,6 +11,7 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
#![feature(asm)]

View file

@ -11,6 +11,7 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
#![feature(asm)]

View file

@ -43,23 +43,19 @@ fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
(a, b)
}
// FIXME(#32330)
//#[cfg(transmute)] // one instantiations: BAD
//fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
// bar(foo, x) //[transmute] ERROR E0495
//}
#[cfg(transmute)] // one instantiations: BAD
fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
bar(foo, x) //[transmute]~ ERROR E0495
}
// FIXME(#32330)
//#[cfg(krisskross)] // two instantiations, mixing and matching: BAD
//fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
// let a = bar(foo, y); //[krisskross] ERROR E0495
// let b = bar(foo, x); //[krisskross] ERROR E0495
// (a, b)
//}
#[cfg(krisskross)] // two instantiations, mixing and matching: BAD
fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
let a = bar(foo, y); //[krisskross]~ ERROR E0495
let b = bar(foo, x); //[krisskross]~ ERROR E0495
(a, b)
}
#[rustc_error]
fn main() { }
//[ok]~^ ERROR compilation successful
//[oneuse]~^^ ERROR compilation successful
//[transmute]~^^^ ERROR compilation successful
//[krisskross]~^^^^ ERROR compilation successful

View file

@ -42,35 +42,29 @@ fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
(a, b)
}
// FIXME(#32330)
//#[cfg(oneuse)] // one instantiation: BAD
//fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
// let f = foo; // <-- No consistent type can be inferred for `f` here.
// let a = bar(f, x); //[oneuse] ERROR E0495
// let b = bar(f, y);
// (a, b)
//}
#[cfg(oneuse)] // one instantiation: BAD
fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
let f = foo; // <-- No consistent type can be inferred for `f` here.
let a = bar(f, x); //[oneuse]~^ ERROR E0495
let b = bar(f, y);
(a, b)
}
// FIXME(#32330)
//#[cfg(transmute)] // one instantiations: BAD
//fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
// // Cannot instantiate `foo` with any lifetime other than `'a`,
// // since it is provided as input.
//
// bar(foo, x) //[transmute] ERROR E0495
//}
#[cfg(transmute)] // one instantiations: BAD
fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
// Cannot instantiate `foo` with any lifetime other than `'a`,
// since it is provided as input.
// FIXME(#32330)
//#[cfg(krisskross)] // two instantiations, mixing and matching: BAD
//fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
// let a = bar(foo, y); //[krisskross] ERROR E0495
// let b = bar(foo, x); //[krisskross] ERROR E0495
// (a, b)
//}
bar(foo, x) //[transmute]~ ERROR E0495
}
#[cfg(krisskross)] // two instantiations, mixing and matching: BAD
fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
let a = bar(foo, y); //[krisskross]~ ERROR E0495
let b = bar(foo, x); //[krisskross]~ ERROR E0495
(a, b)
}
#[rustc_error]
fn main() { }
//[ok]~^ ERROR compilation successful
//[oneuse]~^^ ERROR compilation successful
//[transmute]~^^^ ERROR compilation successful
//[krisskross]~^^^^ ERROR compilation successful

View file

@ -91,9 +91,6 @@ check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
// - if we are covariant, then 'a and 'b can be set to the call-site
// intersection;
// - if we are contravariant, then 'a can be inferred to 'static.
//
// FIXME(#32330) this is true, but we are not currently impl'ing this
// full semantics
check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32),
for<'a> fn(&'a u32, &'a u32)) }
check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>),

View file

@ -15,5 +15,6 @@ enum Homura {
fn main() {
let homura = Homura::Akemi { kaname: () };
//~^ ERROR variant `Homura::Akemi` has no field named `kaname`
//~| NOTE field does not exist - did you mean `madoka`?
//~| NOTE `Homura::Akemi` does not have this field
//~| NOTE available fields are: `madoka`
}

View file

@ -1,67 +0,0 @@
// 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.
// these two HELPs are actually in a new line between this line and the `enum Fruit` line
enum Fruit { //~ HELP possible candidate is found in another module, you can import it into scope
//~^ HELP possible candidate is found in another module, you can import it into scope
Apple(i64),
Orange(i64),
}
fn should_return_fruit() -> Apple {
//~^ ERROR cannot find type `Apple` in this scope
//~| NOTE not found in this scope
//~| HELP you can try using the variant's enum
Apple(5)
//~^ ERROR cannot find function `Apple` in this scope
//~| NOTE not found in this scope
}
fn should_return_fruit_too() -> Fruit::Apple {
//~^ ERROR expected type, found variant `Fruit::Apple`
//~| HELP you can try using the variant's enum
//~| NOTE not a type
Apple(5)
//~^ ERROR cannot find function `Apple` in this scope
//~| NOTE not found in this scope
}
fn foo() -> Ok {
//~^ ERROR expected type, found variant `Ok`
//~| NOTE not a type
//~| HELP there is an enum variant
//~| HELP there is an enum variant
Ok(())
}
fn bar() -> Variant3 {
//~^ ERROR cannot find type `Variant3` in this scope
//~| HELP you can try using the variant's enum
//~| NOTE not found in this scope
}
fn qux() -> Some {
//~^ ERROR expected type, found variant `Some`
//~| NOTE not a type
//~| HELP there is an enum variant
//~| HELP there is an enum variant
Some(1)
}
fn main() {}
mod x {
enum Enum {
Variant1,
Variant2(),
Variant3(usize),
Variant4 {},
}
}

View file

@ -0,0 +1,23 @@
// 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(unused)]
fn f() {
let mut x: Box<()> = Box::new(());
|| {
&mut x
};
}
#[rustc_error]
fn main() {} //~ ERROR compilation successful

View file

@ -9,10 +9,15 @@
// except according to those terms.
#![feature(rustc_attrs)]
#![allow(warnings)]
#![allow(unused)]
fn f() {
let x: Box<()> = Box::new(());
|| {
&x
};
}
#[rustc_error]
fn main() { //~ ERROR compilation successful
/// crash
let x = 0;
}
fn main() {} //~ ERROR compilation successful

View 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)]
#![allow(unused)]
fn f() {
let mut x: Vec<()> = Vec::new();
|| {
|| {
x.push(())
}
};
}
#[rustc_error]
fn main() {} //~ ERROR compilation successful

View 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)]
#![allow(unused)]
fn f() {
let x: Vec<()> = Vec::new();
|| {
|| {
x.len()
}
};
}
#[rustc_error]
fn main() {} //~ ERROR compilation successful

View file

@ -13,7 +13,8 @@ struct S(u8, u16);
fn main() {
let s = S{0b1: 10, 0: 11};
//~^ ERROR struct `S` has no field named `0b1`
//~| NOTE field does not exist - did you mean `1`?
//~| NOTE `S` does not have this field
//~| NOTE available fields are: `0`, `1`
match s {
S{0: a, 0x1: b, ..} => {}
//~^ ERROR does not have a field named `0x1`

View file

@ -18,5 +18,6 @@ fn main() {
bar: 0
//~^ ERROR struct `BuildData` has no field named `bar`
//~| NOTE `BuildData` does not have this field
//~| NOTE available fields are: `foo`
};
}

View file

@ -27,7 +27,8 @@ fn main () {
//~| NOTE field does not exist - did you mean `a`?
bb: 20,
//~^ ERROR struct `xc::B` has no field named `bb`
//~| NOTE field does not exist - did you mean `a`?
//~| NOTE `xc::B` does not have this field
//~| NOTE available fields are: `a`
};
// local crate struct
let l = A {

View file

@ -20,6 +20,7 @@ fn main() {
let u = U { a: 0, b: 1, c: 2 }; //~ ERROR union expressions should have exactly one field
//~^ ERROR union `U` has no field named `c`
//~| NOTE `U` does not have this field
//~| NOTE available fields are: `a`, `b`
let u = U { ..u }; //~ ERROR union expressions should have exactly one field
//~^ ERROR functional record update syntax requires a struct

View file

@ -0,0 +1,30 @@
// 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.
#![deny(unused_doc_comment)]
fn foo() {
/// a //~ ERROR doc comment not used by rustdoc
let x = 12;
/// b //~ doc comment not used by rustdoc
match x {
/// c //~ ERROR doc comment not used by rustdoc
1 => {},
_ => {}
}
/// foo //~ ERROR doc comment not used by rustdoc
unsafe {}
}
fn main() {
foo();
}

View file

@ -57,13 +57,6 @@ the lines being too long.
compiletest handles dumping the MIR before and after every pass for you. The
test writer only has to specify the file names of the dumped files (not the
full path to the file) and what lines to expect. I added an option to rustc
full path to the file) and what lines to expect. There is an option to rustc
that tells it to dump the mir into some directly (rather then always dumping to
the current directory).
Lines match ignoring whitespace, and the prefix "//" is removed of course.
It also currently strips trailing comments -- partly because the full file path
in "scope comments" is unpredictable and partly because tidy complains about
the lines being too long.
the current directory).

View file

@ -47,42 +47,36 @@ fn main() {
// StorageDead(_3);
// StorageLive(_4);
// _4 = std::option::Option<std::boxed::Box<u32>>::None;
// StorageLive(_5);
// StorageLive(_6);
// StorageLive(_7);
// _7 = _4;
// replace(_6 <- _7) -> [return: bb6, unwind: bb7];
// _6 = _4;
// replace(_5 <- _6) -> [return: bb1, unwind: bb5];
// }
// bb1: {
// resume;
// drop(_6) -> [return: bb6, unwind: bb4];
// }
// bb2: {
// drop(_4) -> bb1;
// resume;
// }
// bb3: {
// goto -> bb2;
// drop(_4) -> bb2;
// }
// bb4: {
// drop(_6) -> bb3;
// drop(_5) -> bb3;
// }
// bb5: {
// goto -> bb4;
// drop(_6) -> bb4;
// }
// bb6: {
// drop(_7) -> [return: bb8, unwind: bb4];
// StorageDead(_6);
// _0 = ();
// drop(_5) -> [return: bb7, unwind: bb3];
// }
// bb7: {
// drop(_7) -> bb5;
// StorageDead(_5);
// drop(_4) -> bb8;
// }
// bb8: {
// StorageDead(_7);
// _0 = ();
// drop(_6) -> [return: bb9, unwind: bb2];
// }
// bb9: {
// StorageDead(_6);
// drop(_4) -> bb10;
// }
// bb10: {
// StorageDead(_4);
// StorageDead(_2);
// StorageDead(_1);

View file

@ -25,7 +25,7 @@ fn main() {}
// bb0: {
// _2 = _1;
// _3 = _2;
// _0 = Baz { x: _3, y: const F32(0), z: const false };
// _0 = Baz { x: _3, y: const 0f32, z: const false };
// return;
// }
// END rustc.node13.Deaggregator.before.mir
@ -34,7 +34,7 @@ fn main() {}
// _2 = _1;
// _3 = _2;
// (_0.0: usize) = _3;
// (_0.1: f32) = const F32(0);
// (_0.1: f32) = const 0f32;
// (_0.2: bool) = const false;
// return;
// }

View file

@ -32,41 +32,41 @@ fn foo(i: i32) {
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// let mut _0: ();
// let _1: D;
// let _3: i32;
// let _4: &'6_2rce i32;
// let _2: i32;
// let _3: &'6_2rce i32;
// let _7: &'6_4rce i32;
// let mut _5: ();
// let mut _6: i32;
//
// let mut _4: ();
// let mut _5: i32;
// let mut _6: ();
// bb0: {
// StorageLive(_1);
// _1 = D::{{constructor}}(const 0i32,);
// StorageLive(_2);
// _2 = const 0i32;
// StorageLive(_3);
// _3 = const 0i32;
// StorageLive(_4);
// _4 = &'6_2rce _3;
// StorageLive(_6);
// _6 = (*_4);
// _5 = const foo(_6) -> [return: bb2, unwind: bb3];
// _3 = &'6_2rce _2;
// StorageLive(_5);
// _5 = (*_3);
// _4 = const foo(_5) -> [return: bb1, unwind: bb3];
// }
// bb1: {
// resume;
// }
// bb2: {
// StorageDead(_6);
// StorageDead(_5);
// StorageLive(_7);
// _7 = &'6_4rce _3;
// _7 = &'6_4rce _2;
// _0 = ();
// StorageDead(_7);
// EndRegion('6_4rce);
// StorageDead(_4);
// EndRegion('6_2rce);
// StorageDead(_3);
// EndRegion('6_2rce);
// StorageDead(_2);
// drop(_1) -> bb4;
// }
// bb2: {
// resume;
// }
// bb3: {
// EndRegion('6_2rce);
// drop(_1) -> bb1;
// drop(_1) -> bb2;
// }
// bb4: {
// StorageDead(_1);

View file

@ -31,32 +31,31 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// let mut _0: ();
// let _1: D;
// let mut _2: ();
// let mut _3: ();
// let mut _4: [closure@NodeId(18) d: &'19mce D];
// let mut _5: &'19mce D;
//
// let mut _3: [closure@NodeId(18) d:&'19mce D];
// let mut _4: &'19mce D;
// let mut _5: ();
// bb0: {
// StorageLive(_1);
// _1 = D::{{constructor}}(const 0i32,);
// StorageLive(_3);
// StorageLive(_4);
// StorageLive(_5);
// _5 = &'19mce _1;
// _4 = [closure@NodeId(18)] { d: _5 };
// StorageDead(_5);
// _3 = const foo(_4) -> [return: bb2, unwind: bb3];
// _4 = &'19mce _1;
// _3 = [closure@NodeId(18)] { d: _4 };
// StorageDead(_4);
// _2 = const foo(_3) -> [return: bb1, unwind: bb3];
// }
// bb1: {
// resume;
// }
// bb2: {
// StorageDead(_4);
// StorageDead(_3);
// EndRegion('19mce);
// _0 = ();
// drop(_1) -> bb4;
// }
// bb2: {
// resume;
// }
// bb3: {
// EndRegion('19mce);
// drop(_1) -> bb1;
// drop(_1) -> bb2;
// }
// bb4: {
// StorageDead(_1);

View file

@ -27,35 +27,35 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// END RUST SOURCE
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// fn main() -> () {
// let mut _0: ();
// let _1: D;
// let mut _2: ();
// let mut _3: ();
// let mut _4: [closure@NodeId(22) d:&'23mce D];
// let mut _5: &'23mce D;
//
// let mut _3: [closure@NodeId(22) d:&'23mce D];
// let mut _4: &'23mce D;
// let mut _5: ();
// bb0: {
// StorageLive(_1);
// _1 = D::{{constructor}}(const 0i32,);
// StorageLive(_3);
// StorageLive(_4);
// StorageLive(_5);
// _5 = &'23mce _1;
// _4 = [closure@NodeId(22)] { d: _5 };
// StorageDead(_5);
// _3 = const foo(_4) -> [return: bb2, unwind: bb3];
// _4 = &'23mce _1;
// _3 = [closure@NodeId(22)] { d: _4 };
// StorageDead(_4);
// _2 = const foo(_3) -> [return: bb1, unwind: bb3];
// }
// bb1: {
// resume;
// }
// bb2: {
// StorageDead(_4);
// StorageDead(_3);
// EndRegion('23mce);
// _0 = ();
// drop(_1) -> bb4;
// }
// bb2: {
// resume;
// }
// bb3: {
// EndRegion('23mce);
// drop(_1) -> bb1;
// drop(_1) -> bb2;
// }
// bb4: {
// StorageDead(_1);

View file

@ -31,18 +31,18 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// let mut _0: ();
// let _1: D;
// let mut _2: ();
// let mut _3: ();
// let mut _4: [closure@NodeId(22) d:D];
// let mut _5: D;
// let mut _3: [closure@NodeId(22) d:D];
// let mut _4: D;
// let mut _5: ();
//
// bb0: {
// StorageLive(_1);
// _1 = D::{{constructor}}(const 0i32,);
// StorageLive(_3);
// StorageLive(_4);
// StorageLive(_5);
// _5 = _1;
// _4 = [closure@NodeId(22)] { d: _5 };
// drop(_5) -> [return: bb4, unwind: bb3];
// _4 = _1;
// _3 = [closure@NodeId(22)] { d: _4 };
// drop(_4) -> [return: bb4, unwind: bb3];
// }
// bb1: {
// resume;
@ -51,17 +51,17 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// drop(_1) -> bb1;
// }
// bb3: {
// drop(_4) -> bb2;
// drop(_3) -> bb2;
// }
// bb4: {
// StorageDead(_5);
// _3 = const foo(_4) -> [return: bb5, unwind: bb3];
// StorageDead(_4);
// _2 = const foo(_3) -> [return: bb5, unwind: bb3];
// }
// bb5: {
// drop(_4) -> [return: bb6, unwind: bb2];
// drop(_3) -> [return: bb6, unwind: bb2];
// }
// bb6: {
// StorageDead(_4);
// StorageDead(_3);
// _0 = ();
// drop(_1) -> bb7;
// }
@ -76,16 +76,16 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// fn main::{{closure}}(_1: [closure@NodeId(22) d:D]) -> i32 {
// let mut _0: i32;
// let _2: &'14_0rce D;
// let mut _3: ();
// let mut _4: i32;
// let mut _3: i32;
// let mut _4: ();
//
// bb0: {
// StorageLive(_2);
// _2 = &'14_0rce (_1.0: D);
// StorageLive(_4);
// _4 = ((*_2).0: i32);
// _0 = _4;
// StorageDead(_4);
// StorageLive(_3);
// _3 = ((*_2).0: i32);
// _0 = _3;
// StorageDead(_3);
// StorageDead(_2);
// EndRegion('14_0rce);
// drop(_1) -> bb1;

View file

@ -29,44 +29,43 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// END RUST SOURCE
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// fn main() -> () {
// let mut _0: ();
// let _1: D;
// let _3: &'6_1rce D;
// let mut _2: ();
// let mut _4: ();
// let mut _5: [closure@NodeId(22) r:&'6_1rce D];
// let mut _6: &'6_1rce D;
//
// bb0: {
// StorageLive(_1);
// _1 = D::{{constructor}}(const 0i32,);
// StorageLive(_3);
// _3 = &'6_1rce _1;
// StorageLive(_5);
// StorageLive(_6);
// _6 = _3;
// _5 = [closure@NodeId(22)] { r: _6 };
// StorageDead(_6);
// _4 = const foo(_5) -> [return: bb2, unwind: bb3];
// }
// bb1: {
// resume;
// }
// bb2: {
// StorageDead(_5);
// _0 = ();
// StorageDead(_3);
// EndRegion('6_1rce);
// drop(_1) -> bb4;
// }
// bb3: {
// EndRegion('6_1rce);
// drop(_1) -> bb1;
// }
// bb4: {
// StorageDead(_1);
// return;
// }
// let mut _0: ();
// let _1: D;
// let _2: &'6_1rce D;
// let mut _3: ();
// let mut _4: [closure@NodeId(22) r:&'6_1rce D];
// let mut _5: &'6_1rce D;
// let mut _6: ();
// bb0: {
// StorageLive(_1);
// _1 = D::{{constructor}}(const 0i32,);
// StorageLive(_2);
// _2 = &'6_1rce _1;
// StorageLive(_4);
// StorageLive(_5);
// _5 = _2;
// _4 = [closure@NodeId(22)] { r: _5 };
// StorageDead(_5);
// _3 = const foo(_4) -> [return: bb1, unwind: bb3];
// }
// bb1: {
// StorageDead(_4);
// _0 = ();
// StorageDead(_2);
// EndRegion('6_1rce);
// drop(_1) -> bb4;
// }
// bb2: {
// resume;
// }
// bb3: {
// EndRegion('6_1rce);
// drop(_1) -> bb2;
// }
// bb4: {
// StorageDead(_1);
// return;
// }
// }
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir

View file

@ -34,18 +34,23 @@ impl S {
// END RUST SOURCE
// START rustc.node4.ElaborateDrops.after.mir
// let mut _0: ();
// let _1: ();
// let mut _2: S;
// let mut _3: ();
// let mut _3: S;
// let mut _4: S;
// let mut _5: S;
// let mut _5: ();
// let mut _6: bool;
//
// bb0: {
// END rustc.node4.ElaborateDrops.after.mir
// START rustc.node13.ElaborateDrops.after.mir
// let mut _2: ();
// let mut _4: ();
// let mut _5: S;
// let mut _0: ();
// let _1: S;
// let mut _2: S;
// let mut _3: ();
// let mut _4: S;
// let mut _5: ();
// let mut _6: S;
// let mut _7: bool;
//

View file

@ -0,0 +1,59 @@
// 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-tidy-linelength
// compile-flags: -Z verbose -Z mir-emit-validate=1
struct Test(i32);
impl Test {
// Make sure we run the pass on a method, not just on bare functions.
fn foo(&self, _x: &mut i32) {}
}
fn main() {
let mut x = 0;
Test(0).foo(&mut x);
// Also test closures
let c = |x: &mut i32| { let y = &*x; *y };
c(&mut x);
}
// FIXME: Also test code generated inside the closure, make sure it has validation. Unfortunately,
// the interesting lines of code also contain name of the source file, so we cannot test for it.
// END RUST SOURCE
// START rustc.node12.EraseRegions.after.mir
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(5) => validate_1/8cd878b::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(5) => validate_1/8cd878b::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]);
// return;
// }
// END rustc.node12.EraseRegions.after.mir
// START rustc.node23.EraseRegions.after.mir
// fn main() -> () {
// bb0: {
// Validate(Suspend(ReScope(Misc(NodeId(34)))), [_1: i32]);
// _6 = &ReErased mut _1;
// Validate(Acquire, [(*_6): i32/ReScope(Misc(NodeId(34)))]);
// Validate(Suspend(ReScope(Misc(NodeId(34)))), [(*_6): i32/ReScope(Misc(NodeId(34)))]);
// _5 = &ReErased mut (*_6);
// Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(34)))]);
// Validate(Release, [_2: (), _3: &ReScope(Misc(NodeId(34))) Test, _5: &ReScope(Misc(NodeId(34))) mut i32]);
// _2 = const Test::foo(_3, _5) -> bb1;
// }
//
// bb1: {
// Validate(Acquire, [_2: ()]);
// EndRegion(ReScope(Misc(NodeId(34))));
// return;
// }
// }
// END rustc.node23.EraseRegions.after.mir

View file

@ -0,0 +1,27 @@
// 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-tidy-linelength
// compile-flags: -Z verbose -Z mir-emit-validate=1
fn main() {
let _x : Box<[i32]> = Box::new([1, 2, 3]);
}
// END RUST SOURCE
// START rustc.node4.EraseRegions.after.mir
// fn main() -> () {
// bb1: {
// Validate(Release, [_2: std::boxed::Box<[i32; 3]>]);
// _1 = _2 as std::boxed::Box<[i32]> (Unsize);
// Validate(Acquire, [_1: std::boxed::Box<[i32]>]);
// }
// }
// END rustc.node4.EraseRegions.after.mir

View file

@ -0,0 +1,50 @@
// 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-tidy-linelength
// compile-flags: -Z verbose -Z mir-emit-validate=1
struct Test {
x: i32
}
fn foo(_x: &i32) {}
fn main() {
// These internal unsafe functions should have no effect on the code generation.
unsafe fn _unused1() {}
fn _unused2(x: *const i32) -> i32 { unsafe { *x }}
let t = Test { x: 0 };
let t = &t;
foo(&t.x);
}
// END RUST SOURCE
// START rustc.node16.EraseRegions.after.mir
// fn main() -> () {
// let mut _5: &ReErased i32;
// bb0: {
// Validate(Suspend(ReScope(Misc(NodeId(46)))), [((*_2).0: i32): i32/ReScope(Remainder(BlockRemainder { block: NodeId(18), first_statement_index: 3 })) (imm)]);
// _5 = &ReErased ((*_2).0: i32);
// Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(46))) (imm)]);
// Validate(Suspend(ReScope(Misc(NodeId(46)))), [(*_5): i32/ReScope(Misc(NodeId(46))) (imm)]);
// _4 = &ReErased (*_5);
// Validate(Acquire, [(*_4): i32/ReScope(Misc(NodeId(46))) (imm)]);
// Validate(Release, [_3: (), _4: &ReScope(Misc(NodeId(46))) i32]);
// _3 = const foo(_4) -> bb1;
// }
// bb1: {
// EndRegion(ReScope(Misc(NodeId(46))));
// EndRegion(ReScope(Remainder(BlockRemainder { block: NodeId(18), first_statement_index: 3 })));
// return;
// }
// }
// END rustc.node16.EraseRegions.after.mir

View file

@ -0,0 +1,60 @@
// 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-tidy-linelength
// compile-flags: -Z verbose -Z mir-emit-validate=1
// Make sure unsafe fns and fns with an unsafe block only get restricted validation.
unsafe fn write_42(x: *mut i32) -> bool {
let test_closure = |x: *mut i32| *x = 23;
test_closure(x);
*x = 42;
true
}
fn test(x: &mut i32) {
unsafe { write_42(x) };
}
fn main() {
test(&mut 0);
let test_closure = unsafe { |x: &mut i32| write_42(x) };
test_closure(&mut 0);
}
// FIXME: Also test code generated inside the closure, make sure it only does restricted validation
// because it is entirely inside an unsafe block. Unfortunately, the interesting lines of code also
// contain name of the source file, so we cannot test for it.
// END RUST SOURCE
// START rustc.node4.EraseRegions.after.mir
// fn write_42(_1: *mut i32) -> bool {
// bb0: {
// Validate(Acquire, [_1: *mut i32]);
// Validate(Release, [_1: *mut i32]);
// return;
// }
// }
// END rustc.node4.EraseRegions.after.mir
// START rustc.node31.EraseRegions.after.mir
// fn test(_1: &ReErased mut i32) -> () {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(4) => validate_4/8cd878b::test[0] }, BrAnon(0)) mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(4) => validate_4/8cd878b::test[0] }, BrAnon(0)) mut i32]);
// _3 = const write_42(_4) -> bb1;
// }
// bb1: {
// Validate(Acquire, [_3: bool]);
// Validate(Release, [_3: bool]);
// }
// }
// END rustc.node31.EraseRegions.after.mir

View file

@ -0,0 +1,44 @@
// 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-tidy-linelength
// compile-flags: -Z verbose -Z mir-emit-validate=2
// Make sure unsafe fns and fns with an unsafe block only get full validation.
unsafe fn write_42(x: *mut i32) -> bool {
*x = 42;
true
}
fn test(x: &mut i32) {
unsafe { write_42(x) };
}
fn main() {
test(&mut 0);
let test_closure = unsafe { |x: &mut i32| write_42(x) };
test_closure(&mut 0);
}
// FIXME: Also test code generated inside the closure, make sure it has validation. Unfortunately,
// the interesting lines of code also contain name of the source file, so we cannot test for it.
// END RUST SOURCE
// START rustc.node17.EraseRegions.after.mir
// fn test(_1: &ReErased mut i32) -> () {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(4) => validate_5/8cd878b::test[0] }, BrAnon(0)) mut i32]);
// Validate(Release, [_3: bool, _4: *mut i32]);
// _3 = const write_42(_4) -> bb1;
// }
// }
// END rustc.node17.EraseRegions.after.mir

View file

@ -25,7 +25,7 @@ all:
# Should not link dead code...
$(RUSTC) -Z print-link-args dummy.rs 2>&1 | \
grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF'
grep -e '--gc-sections' -e '-z[^ ]* [^ ]*\<ignore\>' -e '-dead_strip' -e '/OPT:REF'
# ... unless you specifically ask to keep it
$(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \
(! grep -e '--gc-sections' -e '-dead_strip' -e '/OPT:REF')
(! grep -e '--gc-sections' -e '-z[^ ]* [^ ]*\<ignore\>' -e '-dead_strip' -e '/OPT:REF')

View file

@ -54,11 +54,7 @@ impl<'a> CompilerCalls<'a> for JitCalls {
state.session.abort_if_errors();
let trans = state.trans.unwrap();
assert_eq!(trans.modules.len(), 1);
let rs_llmod = match trans.modules[0].source {
ModuleSource::Preexisting(_) => unimplemented!(),
ModuleSource::Translated(llvm) => llvm.llmod,
};
unsafe { rustc_llvm::LLVMDumpModule(rs_llmod) };
println!("name of compiled module = {}", trans.modules[0].name);
});
cc
}

View file

@ -5,7 +5,7 @@ all: default
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg | grep x86_64
$(RUSTC) --target i686-pc-windows-msvc --print cfg | grep msvc
$(RUSTC) --target i686-apple-darwin --print cfg | grep macos
$(RUSTC) --target i686-unknown-linux-gnu --print cfg | grep sse2
$(RUSTC) --target i686-unknown-linux-gnu --print cfg | grep gnu
ifdef IS_WINDOWS
default:

View file

@ -82,7 +82,7 @@ ifeq ($(UNAME),Bitrig)
EXTRACXXFLAGS := -lc++ -lc++abi
else
ifeq ($(UNAME),SunOS)
EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket
EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv
else
ifeq ($(UNAME),OpenBSD)
EXTRACFLAGS := -lm -lpthread

View file

@ -0,0 +1,5 @@
-include ../tools.mk
all:
$(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \
| grep -q "panicked at 'encountered error with .-Z treat_err_as_bug'"

View 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.
#![crate_type="rlib"]
pub static C: u32 = 0-1;

View file

@ -39,3 +39,6 @@ pub fn main() { }
#[cfg(target_arch = "wasm32")]
pub fn main() { }
#[cfg(target_arch = "sparc64")]
pub fn main() { }

View file

@ -15,7 +15,6 @@
// memory, which makes for some *confusing* logs. That's why these are here
// instead of in std.
#![reexport_test_harness_main = "test_main"]
#![feature(libc, std_misc, duration)]
extern crate libc;

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-aarch64
// ignore-emscripten no threads support
#![feature(libc)]

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-aarch64
// ignore-emscripten
#![feature(io, process_capture)]

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-aarch64
// ignore-emscripten
use std::process::Command;

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-aarch64
// ignore-emscripten
#![feature(std_misc, os)]

View file

@ -0,0 +1,74 @@
// 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(unused)]
fn main() {
}
fn foo() {
let b = mk::<
Forward<(Box<Future<Error = u32>>,)>,
>();
b.map_err(|_| ()).join();
}
fn mk<T>() -> T {
loop {}
}
impl<I: Future<Error = E>, E> Future for (I,) {
type Error = E;
}
struct Forward<T: Future> {
_a: T,
}
impl<T: Future> Future for Forward<T>
where
T::Error: From<u32>,
{
type Error = T::Error;
}
trait Future {
type Error;
fn map_err<F, E>(self, _: F) -> (Self, F)
where
F: FnOnce(Self::Error) -> E,
Self: Sized,
{
loop {}
}
fn join(self) -> (MaybeDone<Self>, ())
where
Self: Sized,
{
loop {}
}
}
impl<S: ?Sized + Future> Future for Box<S> {
type Error = S::Error;
}
enum MaybeDone<A: Future> {
_Done(A::Error),
}
impl<U, A: Future, F> Future for (A, F)
where
F: FnOnce(A::Error) -> U,
{
type Error = U;
}

View file

@ -16,7 +16,6 @@
// non-ASCII characters. The child process ensures all the strings are
// intact.
// ignore-aarch64
// ignore-emscripten
use std::io::prelude::*;

View file

@ -11,7 +11,6 @@
// Be sure that when a SIGPIPE would have been received that the entire process
// doesn't die in a ball of fire, but rather it's gracefully handled.
// ignore-aarch64
// ignore-emscripten
use std::env;

View file

@ -7,6 +7,7 @@
// <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.
// min-llvm-version 4.0
#![feature(cfg_target_feature)]

View file

@ -12,6 +12,7 @@
// FIXME: This test case makes little-endian assumptions.
// ignore-s390x
// ignore-sparc
extern crate union;
use std::mem::{size_of, align_of, zeroed};

View 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.
#![feature(const_fn)]
const fn foo(x: u32) -> u32 {
x
}
fn main() {
const X: u32 = 0-1;
const Y: u32 = foo(0-1);
println!("{} {}", X, Y);
}

View file

@ -0,0 +1,28 @@
warning: constant evaluation error: attempt to subtract with overflow. This will become a HARD ERROR in the future
--> $DIR/issue-43197.rs:18:20
|
18 | const X: u32 = 0-1;
| ^^^
|
= note: #[warn(const_err)] on by default
warning: constant evaluation error: attempt to subtract with overflow. This will become a HARD ERROR in the future
--> $DIR/issue-43197.rs:19:20
|
19 | const Y: u32 = foo(0-1);
| ^^^^^^^^
error[E0080]: constant evaluation error
--> $DIR/issue-43197.rs:18:20
|
18 | const X: u32 = 0-1;
| ^^^ attempt to subtract with overflow
error[E0080]: constant evaluation error
--> $DIR/issue-43197.rs:19:24
|
19 | const Y: u32 = foo(0-1);
| ^^^ attempt to subtract with overflow
error: aborting due to 2 previous errors

View file

@ -3,6 +3,8 @@ error[E0609]: no field `zz` on type `Foo`
|
17 | f.zz;
| ^^ unknown field
|
= note: available fields are: `bar`
error: aborting due to previous error

View file

@ -0,0 +1,43 @@
// 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.
mod submodule {
#[derive(Default)]
pub struct Demo {
pub favorite_integer: isize,
secret_integer: isize,
pub innocently_misspellable: (),
another_field: bool,
yet_another_field: bool,
always_more_fields: bool,
and_ever: bool,
}
impl Demo {
fn new_with_secret_two() -> Self {
Self { secret_integer: 2, inocently_mispellable: () }
}
fn new_with_secret_three() -> Self {
Self { secret_integer: 3, egregiously_nonexistent_field: () }
}
}
}
fn main() {
use submodule::Demo;
let demo = Demo::default();
let innocent_field_misaccess = demo.inocently_mispellable;
// note shouldn't suggest private fields
let egregious_field_misaccess = demo.egregiously_nonexistent_field;
}

View file

@ -0,0 +1,30 @@
error[E0560]: struct `submodule::Demo` has no field named `inocently_mispellable`
--> $DIR/issue-42599_available_fields_note.rs:26:39
|
26 | Self { secret_integer: 2, inocently_mispellable: () }
| ^^^^^^^^^^^^^^^^^^^^^^ field does not exist - did you mean `innocently_misspellable`?
error[E0560]: struct `submodule::Demo` has no field named `egregiously_nonexistent_field`
--> $DIR/issue-42599_available_fields_note.rs:30:39
|
30 | Self { secret_integer: 3, egregiously_nonexistent_field: () }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `submodule::Demo` does not have this field
|
= note: available fields are: `favorite_integer`, `secret_integer`, `innocently_misspellable`, `another_field`, `yet_another_field` ... and 2 others
error[E0609]: no field `inocently_mispellable` on type `submodule::Demo`
--> $DIR/issue-42599_available_fields_note.rs:40:41
|
40 | let innocent_field_misaccess = demo.inocently_mispellable;
| ^^^^^^^^^^^^^^^^^^^^^ did you mean `innocently_misspellable`?
error[E0609]: no field `egregiously_nonexistent_field` on type `submodule::Demo`
--> $DIR/issue-42599_available_fields_note.rs:42:42
|
42 | let egregious_field_misaccess = demo.egregiously_nonexistent_field;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown field
|
= note: available fields are: `favorite_integer`, `innocently_misspellable`
error: aborting due to 4 previous errors

View file

@ -33,11 +33,27 @@ fn should_return_fruit_too() -> Fruit::Apple {
//~| NOTE not found in this scope
}
fn foo() -> Ok {
//~^ ERROR expected type, found variant `Ok`
//~| NOTE not a type
//~| HELP there is an enum variant
//~| HELP there is an enum variant
Ok(())
}
fn bar() -> Variant3 {
//~^ ERROR cannot find type `Variant3` in this scope
//~| NOTE not found in this scope
}
fn qux() -> Some {
//~^ ERROR expected type, found variant `Some`
//~| NOTE not a type
//~| HELP there is an enum variant
//~| HELP there is an enum variant
Some(1)
}
fn main() {}
mod x {

View file

@ -38,14 +38,32 @@ help: possible candidate is found in another module, you can import it into scop
12 | use Fruit::Apple;
|
error[E0412]: cannot find type `Variant3` in this scope
error[E0573]: expected type, found variant `Ok`
--> $DIR/issue-35675.rs:36:13
|
36 | fn bar() -> Variant3 {
36 | fn foo() -> Ok {
| ^^ not a type
|
= help: there is an enum variant `std::prelude::v1::Ok`, try using `std::prelude::v1`?
= help: there is an enum variant `std::result::Result::Ok`, try using `std::result::Result`?
error[E0412]: cannot find type `Variant3` in this scope
--> $DIR/issue-35675.rs:44:13
|
44 | fn bar() -> Variant3 {
| ^^^^^^^^
| |
| not found in this scope
| help: you can try using the variant's enum: `x::Enum`
error: aborting due to 5 previous errors
error[E0573]: expected type, found variant `Some`
--> $DIR/issue-35675.rs:49:13
|
49 | fn qux() -> Some {
| ^^^^ not a type
|
= help: there is an enum variant `std::prelude::v1::Option::Some`, try using `std::prelude::v1::Option`?
= help: there is an enum variant `std::prelude::v1::Some`, try using `std::prelude::v1`?
error: aborting due to 7 previous errors

View file

@ -0,0 +1,31 @@
// Copyright 2016 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.
mod private {
pub trait Future {
fn wait(&self) where Self: Sized;
}
impl Future for Box<Future> {
fn wait(&self) { }
}
}
//use private::Future;
fn bar(arg: Box<private::Future>) {
arg.wait();
//~^ ERROR the `wait` method cannot be invoked on a trait object
//~| another candidate was found in the following trait, perhaps add a `use` for it:
}
fn main() {
}

View file

@ -0,0 +1,11 @@
error: the `wait` method cannot be invoked on a trait object
--> $DIR/issue-35976.rs:24:9
|
24 | arg.wait();
| ^^^^
|
= note: another candidate was found in the following trait, perhaps add a `use` for it:
candidate #1: `use private::Future;`
error: aborting due to previous error

View file

@ -2,9 +2,9 @@ error[E0623]: lifetime mismatch
--> $DIR/ex3-both-anon-regions-2.rs:12:9
|
11 | fn foo((v, w): (&u8, &u8), x: &u8) {
| --- --- these references must have the same lifetime
| --- --- these references are not declared with the same lifetime...
12 | v = x;
| ^ data from `x` flows here
| ^ ...but data from `x` flows here
error: aborting due to previous error

View file

@ -2,9 +2,9 @@ error[E0623]: lifetime mismatch
--> $DIR/ex3-both-anon-regions-3.rs:12:9
|
11 | fn foo((v, w): (&u8, &u8), (x, y): (&u8, &u8)) {
| --- --- these references must have the same lifetime
| --- --- these references are not declared with the same lifetime...
12 | v = x;
| ^ data flows here
| ^ ...but data flows here
error: aborting due to previous error

View file

@ -4,17 +4,17 @@ error[E0623]: lifetime mismatch
--> $DIR/ex3-both-anon-regions-4.rs:12:13
|
11 | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
| --- --- these references must have the same lifetime
| --- --- these references are not declared with the same lifetime...
12 | z.push((x,y));
| ^ data flows into `z` here
| ^ ...but data flows into `z` here
error[E0623]: lifetime mismatch
--> $DIR/ex3-both-anon-regions-4.rs:12:15
|
11 | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
| --- --- these references must have the same lifetime
| --- --- these references are not declared with the same lifetime...
12 | z.push((x,y));
| ^ data flows into `z` here
| ^ ...but data flows into `z` here
error: aborting due to 3 previous errors

View file

@ -2,9 +2,9 @@ error[E0623]: lifetime mismatch
--> $DIR/ex3-both-anon-regions.rs:12:12
|
11 | fn foo(x: &mut Vec<&u8>, y: &u8) {
| --- --- these references must have the same lifetime
| --- --- these references are not declared with the same lifetime...
12 | x.push(y);
| ^ data from `y` flows into `x` here
| ^ ...but data from `y` flows into `x` here
error: aborting due to previous error

View file

@ -6,8 +6,6 @@ error[E0308]: mismatched types
|
= note: expected type `fn(&'cx S) -> &'cx S`
found type `fn(&'a S) -> &S {bar::<'_>}`
= note: lifetime parameter `'b` declared on fn `bar` appears only in the return type, but here is required to be higher-ranked, which means that `'b` must appear in both argument and return types
= note: this error is the result of a recent bug fix; for more information, see issue #33685 <https://github.com/rust-lang/rust/issues/33685>
error: aborting due to previous error

View file

@ -0,0 +1,42 @@
// 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.
#![deny(dead_code)]
union U1 {
a: u8, // should not be reported
b: u8, // should not be reported
c: u8, // should be reported
}
union U2 {
a: u8, // should be reported
b: u8, // should not be reported
c: u8, // should not be reported
}
union NoDropLike { a: u8 } // should be reported as unused
union U {
a: u8, // should not be reported
b: u8, // should not be reported
c: u8, // should be reported
}
type A = U;
fn main() {
let u = U1 { a: 0 };
let _a = unsafe { u.b };
let u = U2 { c: 0 };
let _b = unsafe { u.b };
let _u = NoDropLike { a: 10 };
let u = A { a: 0 };
let _b = unsafe { u.b };
}

View file

@ -0,0 +1,32 @@
error: field is never used: `c`
--> $DIR/union-fields.rs:16:5
|
16 | c: u8, // should be reported
| ^^^^^
|
note: lint level defined here
--> $DIR/union-fields.rs:11:9
|
11 | #![deny(dead_code)]
| ^^^^^^^^^
error: field is never used: `a`
--> $DIR/union-fields.rs:19:5
|
19 | a: u8, // should be reported
| ^^^^^
error: field is never used: `a`
--> $DIR/union-fields.rs:23:20
|
23 | union NoDropLike { a: u8 } // should be reported as unused
| ^^^^^
error: field is never used: `c`
--> $DIR/union-fields.rs:28:5
|
28 | c: u8, // should be reported
| ^^^^^
error: aborting due to 4 previous errors