Update miri to rustc changes

This commit is contained in:
Oliver Schneider 2017-12-06 09:25:29 +01:00
parent d4c442d65c
commit acdf83f228
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9
2782 changed files with 85305 additions and 46634 deletions

View file

@ -106,7 +106,7 @@ result is then compared against reference files named
those files doesn't exist, the output must be empty. If the test run
fails, we will print out the current output, but it is also saved in
`build/<target-triple>/test/ui/hello_world/main.stdout` (this path is
printed as part of the test failure mesage), so you can run `diff` and
printed as part of the test failure message), so you can run `diff` and
so forth.
### Editing and updating the reference files

View file

@ -10,8 +10,9 @@
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zinline-in-all-cgus
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<drop_in_place_intrinsic::StructWithDtor[0]> @@ drop_in_place_intrinsic.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<drop_in_place_intrinsic::StructWithDtor[0]> @@ drop_in_place_intrinsic0[Internal]
struct StructWithDtor(u32);
impl Drop for StructWithDtor {
@ -22,7 +23,7 @@ impl Drop for StructWithDtor {
//~ TRANS_ITEM fn drop_in_place_intrinsic::main[0]
fn main() {
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]; 2]> @@ drop_in_place_intrinsic.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]; 2]> @@ drop_in_place_intrinsic0[Internal]
let x = [StructWithDtor(0), StructWithDtor(1)];
drop_slice_in_place(&x);
@ -34,7 +35,7 @@ fn drop_slice_in_place(x: &[StructWithDtor]) {
// This is the interesting thing in this test case: Normally we would
// not have drop-glue for the unsized [StructWithDtor]. This has to be
// generated though when the drop_in_place() intrinsic is used.
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]]> @@ drop_in_place_intrinsic.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]]> @@ drop_in_place_intrinsic0[Internal]
::std::ptr::drop_in_place(x as *const _ as *mut [StructWithDtor]);
}
}

View file

@ -10,6 +10,7 @@
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zinline-in-all-cgus
#![deny(dead_code)]
@ -45,7 +46,7 @@ enum EnumNoDrop<T1, T2> {
struct NonGenericNoDrop(i32);
struct NonGenericWithDrop(i32);
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::NonGenericWithDrop[0]> @@ generic_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::NonGenericWithDrop[0]> @@ generic_drop_glue0[Internal]
impl Drop for NonGenericWithDrop {
//~ TRANS_ITEM fn generic_drop_glue::{{impl}}[2]::drop[0]
@ -54,11 +55,11 @@ impl Drop for NonGenericWithDrop {
//~ TRANS_ITEM fn generic_drop_glue::main[0]
fn main() {
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<i8, char>> @@ generic_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<i8, char>> @@ generic_drop_glue0[Internal]
//~ TRANS_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<i8, char>
let _ = StructWithDrop { x: 0i8, y: 'a' }.x;
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>> @@ generic_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>> @@ generic_drop_glue0[Internal]
//~ TRANS_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>
let _ = StructWithDrop { x: "&str", y: NonGenericNoDrop(0) }.y;
@ -67,17 +68,17 @@ fn main() {
// This is supposed to generate drop-glue because it contains a field that
// needs to be dropped.
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructNoDrop[0]<generic_drop_glue::NonGenericWithDrop[0], f64>> @@ generic_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructNoDrop[0]<generic_drop_glue::NonGenericWithDrop[0], f64>> @@ generic_drop_glue0[Internal]
let _ = StructNoDrop { x: NonGenericWithDrop(0), y: 0f64 }.y;
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<i32, i64>> @@ generic_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<i32, i64>> @@ generic_drop_glue0[Internal]
//~ TRANS_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<i32, i64>
let _ = match EnumWithDrop::A::<i32, i64>(0) {
EnumWithDrop::A(x) => x,
EnumWithDrop::B(x) => x as i32
};
//~TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<f64, f32>> @@ generic_drop_glue.cgu-0[Internal]
//~TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<f64, f32>> @@ generic_drop_glue0[Internal]
//~ TRANS_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<f64, f32>
let _ = match EnumWithDrop::B::<f64, f32>(1.0) {
EnumWithDrop::A(x) => x,

View file

@ -10,6 +10,7 @@
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zinline-in-all-cgus
#![deny(dead_code)]
@ -31,13 +32,13 @@ impl<T> Trait for Struct<T> {
fn main() {
let s1 = Struct { _a: 0u32 };
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<instantiation_through_vtable::Struct[0]<u32>> @@ instantiation_through_vtable.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<instantiation_through_vtable::Struct[0]<u32>> @@ instantiation_through_vtable0[Internal]
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::foo[0]<u32>
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u32>
let _ = &s1 as &Trait;
let s1 = Struct { _a: 0u64 };
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<instantiation_through_vtable::Struct[0]<u64>> @@ instantiation_through_vtable.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<instantiation_through_vtable::Struct[0]<u64>> @@ instantiation_through_vtable0[Internal]
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::foo[0]<u64>
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u64>
let _ = &s1 as &Trait;

View file

@ -10,10 +10,11 @@
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zinline-in-all-cgus
#![deny(dead_code)]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<non_generic_drop_glue::StructWithDrop[0]> @@ non_generic_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<non_generic_drop_glue::StructWithDrop[0]> @@ non_generic_drop_glue0[Internal]
struct StructWithDrop {
x: i32
}
@ -27,7 +28,7 @@ struct StructNoDrop {
x: i32
}
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<non_generic_drop_glue::EnumWithDrop[0]> @@ non_generic_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<non_generic_drop_glue::EnumWithDrop[0]> @@ non_generic_drop_glue0[Internal]
enum EnumWithDrop {
A(i32)
}

View file

@ -10,14 +10,15 @@
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zinline-in-all-cgus
#![deny(dead_code)]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Root[0]> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Root[0]> @@ transitive_drop_glue0[Internal]
struct Root(Intermediate);
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Intermediate[0]> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Intermediate[0]> @@ transitive_drop_glue0[Internal]
struct Intermediate(Leaf);
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Leaf[0]> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::Leaf[0]> @@ transitive_drop_glue0[Internal]
struct Leaf;
impl Drop for Leaf {
@ -38,15 +39,15 @@ fn main() {
let _ = Root(Intermediate(Leaf));
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::RootGen[0]<u32>> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::IntermediateGen[0]<u32>> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::LeafGen[0]<u32>> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::RootGen[0]<u32>> @@ transitive_drop_glue0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::IntermediateGen[0]<u32>> @@ transitive_drop_glue0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::LeafGen[0]<u32>> @@ transitive_drop_glue0[Internal]
//~ TRANS_ITEM fn transitive_drop_glue::{{impl}}[1]::drop[0]<u32>
let _ = RootGen(IntermediateGen(LeafGen(0u32)));
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::RootGen[0]<i16>> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::IntermediateGen[0]<i16>> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::LeafGen[0]<i16>> @@ transitive_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::RootGen[0]<i16>> @@ transitive_drop_glue0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::IntermediateGen[0]<i16>> @@ transitive_drop_glue0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<transitive_drop_glue::LeafGen[0]<i16>> @@ transitive_drop_glue0[Internal]
//~ TRANS_ITEM fn transitive_drop_glue::{{impl}}[1]::drop[0]<i16>
let _ = RootGen(IntermediateGen(LeafGen(0i16)));
}

View file

@ -10,10 +10,11 @@
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zinline-in-all-cgus
#![deny(dead_code)]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<tuple_drop_glue::Dropped[0]> @@ tuple_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<tuple_drop_glue::Dropped[0]> @@ tuple_drop_glue0[Internal]
struct Dropped;
impl Drop for Dropped {
@ -23,10 +24,10 @@ impl Drop for Dropped {
//~ TRANS_ITEM fn tuple_drop_glue::main[0]
fn main() {
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<(u32, tuple_drop_glue::Dropped[0])> @@ tuple_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<(u32, tuple_drop_glue::Dropped[0])> @@ tuple_drop_glue0[Internal]
let x = (0u32, Dropped);
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<(i16, (tuple_drop_glue::Dropped[0], bool))> @@ tuple_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<(tuple_drop_glue::Dropped[0], bool)> @@ tuple_drop_glue.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<(i16, (tuple_drop_glue::Dropped[0], bool))> @@ tuple_drop_glue0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<(tuple_drop_glue::Dropped[0], bool)> @@ tuple_drop_glue0[Internal]
let x = (0i16, (Dropped, true));
}

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.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// NB: We do not expect *any* translation item to be generated here.
#![feature(const_fn)]
#![deny(dead_code)]
#![crate_type = "rlib"]
pub const fn foo(x: u32) -> u32 {
x + 0xf00
}

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.
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=lazy
// NB: We do not expect *any* translation item to be generated here.
#![deny(dead_code)]
#![crate_type = "rlib"]
#[inline]
pub fn foo() -> bool {
[1, 2] == [3, 4]
}

View file

@ -10,6 +10,7 @@
// ignore-tidy-linelength
// compile-flags:-Zprint-trans-items=eager
// compile-flags:-Zinline-in-all-cgus
#![deny(dead_code)]
#![feature(coerce_unsized)]
@ -57,13 +58,13 @@ fn main()
{
// simple case
let bool_sized = &true;
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<bool> @@ unsizing.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<bool> @@ unsizing0[Internal]
//~ TRANS_ITEM fn unsizing::{{impl}}[0]::foo[0]
let _bool_unsized = bool_sized as &Trait;
let char_sized = &'a';
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<char> @@ unsizing.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<char> @@ unsizing0[Internal]
//~ TRANS_ITEM fn unsizing::{{impl}}[1]::foo[0]
let _char_unsized = char_sized as &Trait;
@ -73,13 +74,13 @@ fn main()
_b: 2,
_c: 3.0f64
};
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<f64> @@ unsizing.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<f64> @@ unsizing0[Internal]
//~ TRANS_ITEM fn unsizing::{{impl}}[2]::foo[0]
let _struct_unsized = struct_sized as &Struct<Trait>;
// custom coercion
let wrapper_sized = Wrapper(&0u32);
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<u32> @@ unsizing.cgu-0[Internal]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<u32> @@ unsizing0[Internal]
//~ TRANS_ITEM fn unsizing::{{impl}}[3]::foo[0]
let _wrapper_sized = wrapper_sized as Wrapper<Trait>;
}

View file

@ -13,9 +13,10 @@
// We specify -Z incremental here because we want to test the partitioning for
// incremental compilation
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/extern-drop-glue
// compile-flags:-Zinline-in-all-cgus
#![allow(dead_code)]
#![crate_type="lib"]
#![crate_type="rlib"]
// aux-build:cgu_extern_drop_glue.rs
extern crate cgu_extern_drop_glue;
@ -24,20 +25,20 @@ extern crate cgu_extern_drop_glue;
struct LocalStruct(cgu_extern_drop_glue::Struct);
//~ TRANS_ITEM fn extern_drop_glue::user[0] @@ extern_drop_glue[Internal]
fn user()
//~ TRANS_ITEM fn extern_drop_glue::user[0] @@ extern_drop_glue[External]
pub fn user()
{
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<extern_drop_glue::LocalStruct[0]> @@ extern_drop_glue[Internal]
let _ = LocalStruct(cgu_extern_drop_glue::Struct(0));
}
mod mod1 {
pub mod mod1 {
use cgu_extern_drop_glue;
struct LocalStruct(cgu_extern_drop_glue::Struct);
//~ TRANS_ITEM fn extern_drop_glue::mod1[0]::user[0] @@ extern_drop_glue-mod1[Internal]
fn user()
//~ TRANS_ITEM fn extern_drop_glue::mod1[0]::user[0] @@ extern_drop_glue-mod1[External]
pub fn user()
{
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<extern_drop_glue::mod1[0]::LocalStruct[0]> @@ extern_drop_glue-mod1[Internal]
let _ = LocalStruct(cgu_extern_drop_glue::Struct(0));

View file

@ -12,6 +12,7 @@
// We specify -Z incremental here because we want to test the partitioning for
// incremental compilation
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/inlining-from-extern-crate
// compile-flags:-Zinline-in-all-cgus
#![crate_type="lib"]
@ -34,10 +35,10 @@ pub fn user()
cgu_explicit_inlining::never_inlined();
}
mod mod1 {
pub mod mod1 {
use cgu_explicit_inlining;
//~ TRANS_ITEM fn inlining_from_extern_crate::mod1[0]::user[0] @@ inlining_from_extern_crate-mod1[Internal]
//~ TRANS_ITEM fn inlining_from_extern_crate::mod1[0]::user[0] @@ inlining_from_extern_crate-mod1[External]
pub fn user()
{
cgu_explicit_inlining::inlined();
@ -47,10 +48,10 @@ mod mod1 {
}
}
mod mod2 {
pub mod mod2 {
use cgu_explicit_inlining;
//~ TRANS_ITEM fn inlining_from_extern_crate::mod2[0]::user[0] @@ inlining_from_extern_crate-mod2[Internal]
//~ TRANS_ITEM fn inlining_from_extern_crate::mod2[0]::user[0] @@ inlining_from_extern_crate-mod2[External]
pub fn user()
{
cgu_explicit_inlining::always_inlined();

View file

@ -12,9 +12,10 @@
// We specify -Z incremental here because we want to test the partitioning for
// incremental compilation
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-drop-glue
// compile-flags:-Zinline-in-all-cgus
#![allow(dead_code)]
#![crate_type="lib"]
#![crate_type="rlib"]
//~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<local_drop_glue::Struct[0]> @@ local_drop_glue[Internal] local_drop_glue-mod1[Internal]
struct Struct {
@ -31,8 +32,8 @@ struct Outer {
_a: Struct
}
//~ TRANS_ITEM fn local_drop_glue::user[0] @@ local_drop_glue[Internal]
fn user()
//~ TRANS_ITEM fn local_drop_glue::user[0] @@ local_drop_glue[External]
pub fn user()
{
let _ = Outer {
_a: Struct {
@ -41,7 +42,7 @@ fn user()
};
}
mod mod1
pub mod mod1
{
use super::Struct;
@ -52,8 +53,8 @@ mod mod1
_b: (u32, Struct),
}
//~ TRANS_ITEM fn local_drop_glue::mod1[0]::user[0] @@ local_drop_glue-mod1[Internal]
fn user()
//~ TRANS_ITEM fn local_drop_glue::mod1[0]::user[0] @@ local_drop_glue-mod1[External]
pub fn user()
{
let _ = Struct2 {
_a: Struct { _a: 0 },

View file

@ -0,0 +1,54 @@
// 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.
// ignore-tidy-linelength
// We specify -Z incremental here because we want to test the partitioning for
// incremental compilation
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-inlining-but-not-all
// compile-flags:-Zinline-in-all-cgus=no
#![allow(dead_code)]
#![crate_type="lib"]
mod inline {
//~ TRANS_ITEM fn local_inlining_but_not_all::inline[0]::inlined_function[0] @@ local_inlining_but_not_all-inline[External]
#[inline]
pub fn inlined_function()
{
}
}
pub mod user1 {
use super::inline;
//~ TRANS_ITEM fn local_inlining_but_not_all::user1[0]::foo[0] @@ local_inlining_but_not_all-user1[External]
pub fn foo() {
inline::inlined_function();
}
}
pub mod user2 {
use super::inline;
//~ TRANS_ITEM fn local_inlining_but_not_all::user2[0]::bar[0] @@ local_inlining_but_not_all-user2[External]
pub fn bar() {
inline::inlined_function();
}
}
pub mod non_user {
//~ TRANS_ITEM fn local_inlining_but_not_all::non_user[0]::baz[0] @@ local_inlining_but_not_all-non_user[External]
pub fn baz() {
}
}

View file

@ -12,6 +12,7 @@
// We specify -Z incremental here because we want to test the partitioning for
// incremental compilation
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-inlining
// compile-flags:-Zinline-in-all-cgus
#![allow(dead_code)]
#![crate_type="lib"]
@ -27,28 +28,28 @@ mod inline {
}
}
mod user1 {
pub mod user1 {
use super::inline;
//~ TRANS_ITEM fn local_inlining::user1[0]::foo[0] @@ local_inlining-user1[Internal]
fn foo() {
//~ TRANS_ITEM fn local_inlining::user1[0]::foo[0] @@ local_inlining-user1[External]
pub fn foo() {
inline::inlined_function();
}
}
mod user2 {
pub mod user2 {
use super::inline;
//~ TRANS_ITEM fn local_inlining::user2[0]::bar[0] @@ local_inlining-user2[Internal]
fn bar() {
//~ TRANS_ITEM fn local_inlining::user2[0]::bar[0] @@ local_inlining-user2[External]
pub fn bar() {
inline::inlined_function();
}
}
mod non_user {
pub mod non_user {
//~ TRANS_ITEM fn local_inlining::non_user[0]::baz[0] @@ local_inlining-non_user[Internal]
fn baz() {
//~ TRANS_ITEM fn local_inlining::non_user[0]::baz[0] @@ local_inlining-non_user[External]
pub fn baz() {
}
}

View file

@ -12,9 +12,10 @@
// We specify -Z incremental here because we want to test the partitioning for
// incremental compilation
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/local-transitive-inlining
// compile-flags:-Zinline-in-all-cgus
#![allow(dead_code)]
#![crate_type="lib"]
#![crate_type="rlib"]
mod inline {
@ -36,19 +37,19 @@ mod direct_user {
}
}
mod indirect_user {
pub mod indirect_user {
use super::direct_user;
//~ TRANS_ITEM fn local_transitive_inlining::indirect_user[0]::bar[0] @@ local_transitive_inlining-indirect_user[Internal]
fn bar() {
//~ TRANS_ITEM fn local_transitive_inlining::indirect_user[0]::bar[0] @@ local_transitive_inlining-indirect_user[External]
pub fn bar() {
direct_user::foo();
}
}
mod non_user {
pub mod non_user {
//~ TRANS_ITEM fn local_transitive_inlining::non_user[0]::baz[0] @@ local_transitive_inlining-non_user[Internal]
fn baz() {
//~ TRANS_ITEM fn local_transitive_inlining::non_user[0]::baz[0] @@ local_transitive_inlining-non_user[External]
pub fn baz() {
}
}

View file

@ -13,7 +13,7 @@
// incremental compilation
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/statics
#![crate_type="lib"]
#![crate_type="rlib"]
//~ TRANS_ITEM static statics::FOO[0] @@ statics[Internal]
static FOO: u32 = 0;
@ -21,8 +21,8 @@ static FOO: u32 = 0;
//~ TRANS_ITEM static statics::BAR[0] @@ statics[Internal]
static BAR: u32 = 0;
//~ TRANS_ITEM fn statics::function[0] @@ statics[Internal]
fn function() {
//~ TRANS_ITEM fn statics::function[0] @@ statics[External]
pub fn function() {
//~ TRANS_ITEM static statics::function[0]::FOO[0] @@ statics[Internal]
static FOO: u32 = 0;
@ -30,15 +30,15 @@ fn function() {
static BAR: u32 = 0;
}
mod mod1 {
pub mod mod1 {
//~ TRANS_ITEM static statics::mod1[0]::FOO[0] @@ statics-mod1[Internal]
static FOO: u32 = 0;
//~ TRANS_ITEM static statics::mod1[0]::BAR[0] @@ statics-mod1[Internal]
static BAR: u32 = 0;
//~ TRANS_ITEM fn statics::mod1[0]::function[0] @@ statics-mod1[Internal]
fn function() {
//~ TRANS_ITEM fn statics::mod1[0]::function[0] @@ statics-mod1[External]
pub fn function() {
//~ TRANS_ITEM static statics::mod1[0]::function[0]::FOO[0] @@ statics-mod1[Internal]
static FOO: u32 = 0;

View file

@ -13,6 +13,7 @@
// We specify -Z incremental here because we want to test the partitioning for
// incremental compilation
// compile-flags:-Zprint-trans-items=lazy -Zincremental=tmp/partitioning-tests/vtable-through-const
// compile-flags:-Zinline-in-all-cgus
// This test case makes sure, that references made through constants are
// recorded properly in the InliningMap.

View 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.
// Checks the signature of the implicitly generated native main()
// entry point. It must match C's `int main(int, char **)`.
// This test is for targets with 16bit c_int only.
// ignore-aarch64
// ignore-arm
// ignore-asmjs
// ignore-hexagon
// ignore-mips
// ignore-powerpc
// ignore-powerpc64
// ignore-s390x
// ignore-sparc
// ignore-wasm32
// ignore-x86
// ignore-x86_64
// ignore-xcore
fn main() {
}
// CHECK: define i16 @main(i16, i8**)

View 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.
// Checks the signature of the implicitly generated native main()
// entry point. It must match C's `int main(int, char **)`.
// This test is for targets with 32bit c_int only.
// ignore-msp430
fn main() {
}
// CHECK: define i32 @main(i32, i8**)

View file

@ -14,7 +14,6 @@
// ignore-arm
// ignore-aarch64
// min-llvm-version 3.8
// compile-flags: -C no-prepopulate-passes

View file

@ -9,13 +9,14 @@
// except according to those terms.
// compile-flags: -C no-prepopulate-passes
// ignore-tidy-linelength
#![crate_type = "lib"]
// Hack to get the correct size for the length part in slices
// CHECK: @helper([[USIZE:i[0-9]+]])
// CHECK: @helper([[USIZE:i[0-9]+]] %arg0)
#[no_mangle]
fn helper(_: usize) {
pub fn helper(_: usize) {
}
// CHECK-LABEL: @no_op_slice_adjustment
@ -23,9 +24,9 @@ fn helper(_: usize) {
pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
// We used to generate an extra alloca and memcpy for the block's trailing expression value, so
// check that we copy directly to the return value slot
// CHECK: %2 = insertvalue { i8*, [[USIZE]] } undef, i8* %0, 0
// CHECK: %3 = insertvalue { i8*, [[USIZE]] } %2, [[USIZE]] %1, 1
// CHECK: ret { i8*, [[USIZE]] } %3
// CHECK: %0 = insertvalue { [0 x i8]*, [[USIZE]] } undef, [0 x i8]* %x.0, 0
// CHECK: %1 = insertvalue { [0 x i8]*, [[USIZE]] } %0, [[USIZE]] %x.1, 1
// CHECK: ret { [0 x i8]*, [[USIZE]] } %1
{ x }
}

View file

@ -42,7 +42,6 @@ pub fn align64(i : i32) -> Align64 {
#[no_mangle]
pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 {
// CHECK: %n64 = alloca %Nested64, align 64
// CHECK: %a = alloca %Align64, align 64
let n64 = Nested64 { a, b, c, d };
n64
}
@ -51,7 +50,6 @@ pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 {
#[no_mangle]
pub fn enum64(a: Align64) -> Enum64 {
// CHECK: %e64 = alloca %Enum64, align 64
// CHECK: %a = alloca %Align64, align 64
let e64 = Enum64::A(a);
e64
}

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.
#[no_mangle]
pub fn bar() {
}

View file

@ -54,7 +54,7 @@ pub fn inline_enum_const() -> E<i8, i16> {
#[no_mangle]
pub fn low_align_const() -> E<i16, [i16; 3]> {
// Check that low_align_const and high_align_const use the same constant
// CHECK: load {{.*}} bitcast ({ i16, i16, [4 x i8] }** [[LOW_HIGH_REF]]
// CHECK: load {{.*}} bitcast ({ i16, [0 x i8], i16, [4 x i8] }** [[LOW_HIGH_REF]]
*&E::A(0)
}
@ -62,6 +62,6 @@ pub fn low_align_const() -> E<i16, [i16; 3]> {
#[no_mangle]
pub fn high_align_const() -> E<i16, i32> {
// Check that low_align_const and high_align_const use the same constant
// CHECK: load {{.*}} bitcast ({ i16, i16, [4 x i8] }** [[LOW_HIGH_REF]]
// CHECK: load {{.*}} bitcast ({ i16, [0 x i8], i16, [4 x i8] }** [[LOW_HIGH_REF]]
*&E::A(0)
}

View file

@ -59,28 +59,28 @@
#![crate_type = "lib"]
mod tests {
// CHECK: @f1(i32 inreg, i32 inreg, i32)
pub mod tests {
// CHECK: @f1(i32 inreg %arg0, i32 inreg %arg1, i32 %arg2)
#[no_mangle]
extern "fastcall" fn f1(_: i32, _: i32, _: i32) {}
pub extern "fastcall" fn f1(_: i32, _: i32, _: i32) {}
// CHECK: @f2(i32* inreg, i32* inreg, i32*)
// CHECK: @f2(i32* inreg %arg0, i32* inreg %arg1, i32* %arg2)
#[no_mangle]
extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {}
pub extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {}
// CHECK: @f3(float, i32 inreg, i32 inreg, i32)
// CHECK: @f3(float %arg0, i32 inreg %arg1, i32 inreg %arg2, i32 %arg3)
#[no_mangle]
extern "fastcall" fn f3(_: f32, _: i32, _: i32, _: i32) {}
pub extern "fastcall" fn f3(_: f32, _: i32, _: i32, _: i32) {}
// CHECK: @f4(i32 inreg, float, i32 inreg, i32)
// CHECK: @f4(i32 inreg %arg0, float %arg1, i32 inreg %arg2, i32 %arg3)
#[no_mangle]
extern "fastcall" fn f4(_: i32, _: f32, _: i32, _: i32) {}
pub extern "fastcall" fn f4(_: i32, _: f32, _: i32, _: i32) {}
// CHECK: @f5(i64, i32)
// CHECK: @f5(i64 %arg0, i32 %arg1)
#[no_mangle]
extern "fastcall" fn f5(_: i64, _: i32) {}
pub extern "fastcall" fn f5(_: i64, _: i32) {}
// CHECK: @f6(i1 inreg zeroext, i32 inreg, i32)
// CHECK: @f6(i1 inreg zeroext %arg0, i32 inreg %arg1, i32 %arg2)
#[no_mangle]
extern "fastcall" fn f6(_: bool, _: i32, _: i32) {}
pub extern "fastcall" fn f6(_: bool, _: i32, _: i32) {}
}

View file

@ -19,7 +19,7 @@ use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
#[no_mangle]
pub fn add(x: f32, y: f32) -> f32 {
// CHECK: fadd float
// CHECK-NOT fast
// CHECK-NOT: fast
x + y
}

View file

@ -9,74 +9,75 @@
// except according to those terms.
// compile-flags: -C no-prepopulate-passes
// ignore-tidy-linelength
#![crate_type = "lib"]
#![feature(custom_attribute)]
pub struct S {
_field: [i64; 4],
_field: [i32; 8],
}
pub struct UnsafeInner {
_field: std::cell::UnsafeCell<i16>,
}
// CHECK: zeroext i1 @boolean(i1 zeroext)
// CHECK: zeroext i1 @boolean(i1 zeroext %x)
#[no_mangle]
pub fn boolean(x: bool) -> bool {
x
}
// CHECK: @readonly_borrow(i32* noalias readonly dereferenceable(4))
// CHECK: @readonly_borrow(i32* noalias readonly dereferenceable(4) %arg0)
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
pub fn readonly_borrow(_: &i32) {
}
// CHECK: @static_borrow(i32* noalias readonly dereferenceable(4))
// CHECK: @static_borrow(i32* noalias readonly dereferenceable(4) %arg0)
// static borrow may be captured
#[no_mangle]
pub fn static_borrow(_: &'static i32) {
}
// CHECK: @named_borrow(i32* noalias readonly dereferenceable(4))
// CHECK: @named_borrow(i32* noalias readonly dereferenceable(4) %arg0)
// borrow with named lifetime may be captured
#[no_mangle]
pub fn named_borrow<'r>(_: &'r i32) {
}
// CHECK: @unsafe_borrow(%UnsafeInner* dereferenceable(2))
// CHECK: @unsafe_borrow(i16* dereferenceable(2) %arg0)
// unsafe interior means this isn't actually readonly and there may be aliases ...
#[no_mangle]
pub fn unsafe_borrow(_: &UnsafeInner) {
}
// CHECK: @mutable_unsafe_borrow(%UnsafeInner* dereferenceable(2))
// CHECK: @mutable_unsafe_borrow(i16* dereferenceable(2) %arg0)
// ... unless this is a mutable borrow, those never alias
// ... except that there's this LLVM bug that forces us to not use noalias, see #29485
#[no_mangle]
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
}
// CHECK: @mutable_borrow(i32* dereferenceable(4))
// CHECK: @mutable_borrow(i32* dereferenceable(4) %arg0)
// FIXME #25759 This should also have `nocapture`
// ... there's this LLVM bug that forces us to not use noalias, see #29485
#[no_mangle]
pub fn mutable_borrow(_: &mut i32) {
}
// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32))
// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32) %arg0)
#[no_mangle]
pub fn indirect_struct(_: S) {
}
// CHECK: @borrowed_struct(%S* noalias readonly dereferenceable(32))
// CHECK: @borrowed_struct(%S* noalias readonly dereferenceable(32) %arg0)
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
pub fn borrowed_struct(_: &S) {
}
// CHECK: noalias dereferenceable(4) i32* @_box(i32* noalias dereferenceable(4))
// CHECK: noalias align 4 dereferenceable(4) i32* @_box(i32* noalias dereferenceable(4) %x)
#[no_mangle]
pub fn _box(x: Box<i32>) -> Box<i32> {
x
@ -86,55 +87,55 @@ pub fn _box(x: Box<i32>) -> Box<i32> {
#[no_mangle]
pub fn struct_return() -> S {
S {
_field: [0, 0, 0, 0]
_field: [0, 0, 0, 0, 0, 0, 0, 0]
}
}
// Hack to get the correct size for the length part in slices
// CHECK: @helper([[USIZE:i[0-9]+]])
// CHECK: @helper([[USIZE:i[0-9]+]] %arg0)
#[no_mangle]
fn helper(_: usize) {
pub fn helper(_: usize) {
}
// CHECK: @slice(i8* noalias nonnull readonly, [[USIZE]])
// CHECK: @slice([0 x i8]* noalias nonnull readonly %arg0.0, [[USIZE]] %arg0.1)
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
fn slice(_: &[u8]) {
pub fn slice(_: &[u8]) {
}
// CHECK: @mutable_slice(i8* nonnull, [[USIZE]])
// CHECK: @mutable_slice([0 x i8]* nonnull %arg0.0, [[USIZE]] %arg0.1)
// FIXME #25759 This should also have `nocapture`
// ... there's this LLVM bug that forces us to not use noalias, see #29485
#[no_mangle]
fn mutable_slice(_: &mut [u8]) {
pub fn mutable_slice(_: &mut [u8]) {
}
// CHECK: @unsafe_slice(%UnsafeInner* nonnull, [[USIZE]])
// CHECK: @unsafe_slice([0 x i16]* nonnull %arg0.0, [[USIZE]] %arg0.1)
// unsafe interior means this isn't actually readonly and there may be aliases ...
#[no_mangle]
pub fn unsafe_slice(_: &[UnsafeInner]) {
}
// CHECK: @str(i8* noalias nonnull readonly, [[USIZE]])
// CHECK: @str([0 x i8]* noalias nonnull readonly %arg0.0, [[USIZE]] %arg0.1)
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
fn str(_: &[u8]) {
pub fn str(_: &[u8]) {
}
// CHECK: @trait_borrow({}* nonnull, {}* noalias nonnull readonly)
// CHECK: @trait_borrow(%"core::ops::drop::Drop"* nonnull %arg0.0, {}* noalias nonnull readonly %arg0.1)
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
fn trait_borrow(_: &Drop) {
pub fn trait_borrow(_: &Drop) {
}
// CHECK: @trait_box({}* noalias nonnull, {}* noalias nonnull readonly)
// CHECK: @trait_box(%"core::ops::drop::Drop"* noalias nonnull, {}* noalias nonnull readonly)
#[no_mangle]
fn trait_box(_: Box<Drop>) {
pub fn trait_box(_: Box<Drop>) {
}
// CHECK: { i16*, [[USIZE]] } @return_slice(i16* noalias nonnull readonly, [[USIZE]])
// CHECK: { [0 x i16]*, [[USIZE]] } @return_slice([0 x i16]* noalias nonnull readonly %x.0, [[USIZE]] %x.1)
#[no_mangle]
fn return_slice(x: &[u16]) -> &[u16] {
pub fn return_slice(x: &[u16]) -> &[u16] {
x
}

View file

@ -15,7 +15,7 @@
#[no_mangle]
pub struct F32(f32);
// CHECK: define float @add_newtype_f32(float, float)
// CHECK: define float @add_newtype_f32(float %a, float %b)
#[inline(never)]
#[no_mangle]
pub fn add_newtype_f32(a: F32, b: F32) -> F32 {
@ -25,7 +25,7 @@ pub fn add_newtype_f32(a: F32, b: F32) -> F32 {
#[no_mangle]
pub struct F64(f64);
// CHECK: define double @add_newtype_f64(double, double)
// CHECK: define double @add_newtype_f64(double %a, double %b)
#[inline(never)]
#[no_mangle]
pub fn add_newtype_f64(a: F64, b: F64) -> F64 {

View file

@ -13,6 +13,7 @@
// ignore-x86
// ignore-arm
// ignore-emscripten
// ignore-gnux32
// ignore 32-bit platforms (LLVM has a bug with them)
// See issue #37945.

View file

@ -22,12 +22,12 @@ pub enum E {
B(f32)
}
// CHECK: @VAR2 = constant {{.*}} { i32 0, i32 666 }, section ".test_two"
// CHECK: @VAR2 = constant {{.*}}, section ".test_two"
#[no_mangle]
#[link_section = ".test_two"]
pub static VAR2: E = E::A(666);
// CHECK: @VAR3 = constant {{.*}} { i32 1, float 1.000000e+00 }, section ".test_three"
// CHECK: @VAR3 = constant {{.*}}, section ".test_three"
#[no_mangle]
#[link_section = ".test_three"]
pub static VAR3: E = E::B(1.);

View file

@ -8,14 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// The minimum LLVM version is set to 3.8, but really this test
// depends on a patch that is was committed to upstream LLVM before
// 4.0; and also backported to the Rust LLVM fork.
// This test depends on a patch that was committed to upstream LLVM
// before 4.0, formerly backported to the Rust LLVM fork.
// ignore-tidy-linelength
// ignore-windows
// ignore-macos
// min-llvm-version 3.8
// min-llvm-version 4.0
// compile-flags: -g -C no-prepopulate-passes

View file

@ -8,14 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// The minimum LLVM version is set to 3.8, but really this test
// depends on a patch that is was committed to upstream LLVM before
// 4.0; and also backported to the Rust LLVM fork.
// This test depends on a patch that was committed to upstream LLVM
// before 4.0, formerly backported to the Rust LLVM fork.
// ignore-tidy-linelength
// ignore-windows
// ignore-macos
// min-llvm-version 3.8
// min-llvm-version 4.0
// compile-flags: -g -C no-prepopulate-passes

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.
//
// no-system-llvm
// compile-flags: -O
#![crate_type="lib"]
pub enum Three { A, B, C }
pub enum Four { A, B, C, D }
#[no_mangle]
pub fn three_valued(x: Three) -> Three {
// CHECK-LABEL: @three_valued
// CHECK-NEXT: {{^.*:$}}
// CHECK-NEXT: ret i8 %0
match x {
Three::A => Three::A,
Three::B => Three::B,
Three::C => Three::C,
}
}
#[no_mangle]
pub fn four_valued(x: Four) -> Four {
// CHECK-LABEL: @four_valued
// CHECK-NEXT: {{^.*:$}}
// CHECK-NEXT: ret i8 %0
match x {
Four::A => Four::A,
Four::B => Four::B,
Four::C => Four::C,
Four::D => Four::D,
}
}

View file

@ -21,12 +21,15 @@ pub enum E {
#[no_mangle]
pub fn exhaustive_match(e: E) {
// CHECK: switch{{.*}}, label %[[OTHERWISE:[a-zA-Z0-9_]+]] [
// CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[TRUE:[a-zA-Z0-9_]+]]
// CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[A:[a-zA-Z0-9_]+]]
// CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[B:[a-zA-Z0-9_]+]]
// CHECK-NEXT: ]
// CHECK: [[TRUE]]:
// CHECK: [[A]]:
// CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]]
// CHECK: [[B]]:
// CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]]
// CHECK: [[OTHERWISE]]:
// CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]]
// CHECK-NEXT: unreachable
match e {
E::A => (),
E::B => (),

View file

@ -19,7 +19,7 @@ struct Zst { phantom: PhantomData<Zst> }
// CHECK-LABEL: @mir
// CHECK-NOT: store{{.*}}undef
#[no_mangle]
fn mir() {
pub fn mir() {
let x = Zst { phantom: PhantomData };
let y = (x, 0);
drop(y);

View file

@ -24,6 +24,6 @@ pub struct Big {
// CHECK-LABEL: @test_mvi
#[no_mangle]
pub unsafe fn test_mvi(target: *mut Big, make_big: fn() -> Big) {
// CHECK: call void %1(%Big*{{[^%]*}} %0)
// CHECK: call void %make_big(%Big*{{[^%]*}} %target)
move_val_init(target, make_big());
}

View file

@ -16,10 +16,10 @@
#![feature(naked_functions)]
// CHECK: Function Attrs: naked uwtable
// CHECK-NEXT: define internal void @naked_empty()
// CHECK-NEXT: define void @naked_empty()
#[no_mangle]
#[naked]
fn naked_empty() {
pub fn naked_empty() {
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: ret void
}
@ -27,8 +27,8 @@ fn naked_empty() {
// CHECK: Function Attrs: naked uwtable
#[no_mangle]
#[naked]
// CHECK-NEXT: define internal void @naked_with_args(i{{[0-9]+}})
fn naked_with_args(a: isize) {
// CHECK-NEXT: define void @naked_with_args(i{{[0-9]+}})
pub fn naked_with_args(a: isize) {
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: %a = alloca i{{[0-9]+}}
&a; // keep variable in an alloca
@ -36,20 +36,20 @@ fn naked_with_args(a: isize) {
}
// CHECK: Function Attrs: naked uwtable
// CHECK-NEXT: define internal i{{[0-9]+}} @naked_with_return()
// CHECK-NEXT: define i{{[0-9]+}} @naked_with_return()
#[no_mangle]
#[naked]
fn naked_with_return() -> isize {
pub fn naked_with_return() -> isize {
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: ret i{{[0-9]+}} 0
0
}
// CHECK: Function Attrs: naked uwtable
// CHECK-NEXT: define internal i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}})
// CHECK-NEXT: define i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}})
#[no_mangle]
#[naked]
fn naked_with_args_and_return(a: isize) -> isize {
pub fn naked_with_args_and_return(a: isize) -> isize {
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: %a = alloca i{{[0-9]+}}
&a; // keep variable in an alloca
@ -58,10 +58,10 @@ fn naked_with_args_and_return(a: isize) -> isize {
}
// CHECK: Function Attrs: naked uwtable
// CHECK-NEXT: define internal void @naked_recursive()
// CHECK-NEXT: define void @naked_recursive()
#[no_mangle]
#[naked]
fn naked_recursive() {
pub fn naked_recursive() {
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: call void @naked_empty()

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.
// compile-flags: -O
#![feature(core_intrinsics)]
#![crate_type = "lib"]
#[no_mangle]
pub fn a(a: &mut u32, b: u32) {
// CHECK-LABEL: define void @a
// CHECK: store i32 %b, i32* %a, align 4, !nontemporal
unsafe {
std::intrinsics::nontemporal_store(a, b);
}
}

View 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.
// aux-build:nounwind.rs
// compile-flags: -C no-prepopulate-passes -C panic=abort -C metadata=a
// ignore-windows
#![crate_type = "lib"]
extern crate nounwind;
#[no_mangle]
pub fn foo() {
nounwind::bar();
// CHECK: @foo() unnamed_addr #0
// CHECK: @bar() unnamed_addr #0
// CHECK: attributes #0 = { {{.*}}nounwind{{.*}} }
}

View file

@ -54,9 +54,17 @@ pub struct PackedPair(u8, u32);
// CHECK-LABEL: @pkd_pair
#[no_mangle]
pub fn pkd_pair(pair1: &mut PackedPair, pair2: &mut PackedPair) {
// CHECK: [[V1:%[a-z0-9]+]] = load i8, i8* %{{.*}}, align 1
// CHECK: [[V2:%[a-z0-9]+]] = load i32, i32* %{{.*}}, align 1
// CHECK: store i8 [[V1]], i8* {{.*}}, align 1
// CHECK: store i32 [[V2]], i32* {{.*}}, align 1
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{.*}}, i8* %{{.*}}, i{{[0-9]+}} 5, i32 1, i1 false)
*pair2 = *pair1;
}
#[repr(packed)]
#[derive(Copy, Clone)]
pub struct PackedNestedPair((u32, u32));
// CHECK-LABEL: @pkd_nested_pair
#[no_mangle]
pub fn pkd_nested_pair(pair1: &mut PackedNestedPair, pair2: &mut PackedNestedPair) {
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{.*}}, i8* %{{.*}}, i{{[0-9]+}} 8, i32 1, i1 false)
*pair2 = *pair1;
}

View file

@ -28,7 +28,7 @@
#![crate_type = "lib"]
// CHECK: Function Attrs: uwtable
// CHECK: Function Attrs: nounwind uwtable
// CHECK-NEXT: define void @normal_uwtable()
#[no_mangle]
pub fn normal_uwtable() {

View file

@ -9,13 +9,14 @@
// except according to those terms.
// compile-flags: -C no-prepopulate-passes
// ignore-tidy-linelength
#![crate_type = "lib"]
// Hack to get the correct size for the length part in slices
// CHECK: @helper([[USIZE:i[0-9]+]])
// CHECK: @helper([[USIZE:i[0-9]+]] %arg0)
#[no_mangle]
fn helper(_: usize) {
pub fn helper(_: usize) {
}
// CHECK-LABEL: @ref_dst
@ -23,10 +24,10 @@ fn helper(_: usize) {
pub fn ref_dst(s: &[u8]) {
// We used to generate an extra alloca and memcpy to ref the dst, so check that we copy
// directly to the alloca for "x"
// CHECK: [[X0:%[0-9]+]] = getelementptr {{.*}} { i8*, [[USIZE]] }* %x, i32 0, i32 0
// CHECK: store i8* %0, i8** [[X0]]
// CHECK: [[X1:%[0-9]+]] = getelementptr {{.*}} { i8*, [[USIZE]] }* %x, i32 0, i32 1
// CHECK: store [[USIZE]] %1, [[USIZE]]* [[X1]]
// CHECK: [[X0:%[0-9]+]] = getelementptr {{.*}} { [0 x i8]*, [[USIZE]] }* %x, i32 0, i32 0
// CHECK: store [0 x i8]* %s.0, [0 x i8]** [[X0]]
// CHECK: [[X1:%[0-9]+]] = getelementptr {{.*}} { [0 x i8]*, [[USIZE]] }* %x, i32 0, i32 1
// CHECK: store [[USIZE]] %s.1, [[USIZE]]* [[X1]]
let x = &*s;
&x; // keep variable in an alloca

View file

@ -0,0 +1,16 @@
// 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-test: this is not a test
#[inline]
pub fn some_aux_mod_function() -> i32 {
1234
}

View file

@ -16,12 +16,19 @@
extern crate remap_path_prefix_aux;
// Here we check that submodules and include files are found using the path without
// remapping. This test requires that rustc is called with an absolute path.
mod aux_mod;
include!("aux_mod.rs");
// Here we check that the expansion of the file!() macro is mapped.
// CHECK: internal constant [34 x i8] c"/the/src/remap_path_prefix/main.rs"
pub static FILE_PATH: &'static str = file!();
fn main() {
remap_path_prefix_aux::some_aux_function();
aux_mod::some_aux_mod_function();
some_aux_mod_function();
}
// Here we check that local debuginfo is mapped correctly.

View file

@ -15,7 +15,7 @@
// CHECK-LABEL: @zero_sized_elem
#[no_mangle]
pub fn zero_sized_elem() {
// CHECK-NOT: br label %slice_loop_header{{.*}}
// CHECK-NOT: br label %repeat_loop_header{{.*}}
// CHECK-NOT: call void @llvm.memset.p0i8
let x = [(); 4];
drop(&x);
@ -24,7 +24,7 @@ pub fn zero_sized_elem() {
// CHECK-LABEL: @zero_len_array
#[no_mangle]
pub fn zero_len_array() {
// CHECK-NOT: br label %slice_loop_header{{.*}}
// CHECK-NOT: br label %repeat_loop_header{{.*}}
// CHECK-NOT: call void @llvm.memset.p0i8
let x = [4; 0];
drop(&x);
@ -34,7 +34,7 @@ pub fn zero_len_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{{.*}}
// CHECK-NOT: br label %repeat_loop_header{{.*}}
let x = [7u8; 4];
drop(&x);
}
@ -50,7 +50,7 @@ enum Init {
#[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{{.*}}
// CHECK-NOT: br label %repeat_loop_header{{.*}}
let x = [Init::Memset; 4];
drop(&x);
}
@ -59,7 +59,7 @@ pub fn byte_enum_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{{.*}}
// CHECK-NOT: br label %repeat_loop_header{{.*}}
let x = [0u32; 4];
drop(&x);
}
@ -67,7 +67,7 @@ pub fn zeroed_integer_array() {
// CHECK-LABEL: @nonzero_integer_array
#[no_mangle]
pub fn nonzero_integer_array() {
// CHECK: br label %slice_loop_header{{.*}}
// CHECK: br label %repeat_loop_header{{.*}}
// CHECK-NOT: call void @llvm.memset.p0i8
let x = [0x1a_2b_3c_4d_u32; 4];
drop(&x);

View file

@ -25,9 +25,9 @@ pub struct Bytes {
#[no_mangle]
pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) {
// CHECK: [[TMP:%.+]] = alloca i32
// CHECK: %arg1 = alloca [4 x i8]
// CHECK: store i32 %1, i32* [[TMP]]
// CHECK: [[Y8:%[0-9]+]] = bitcast [4 x i8]* %arg1 to i8*
// CHECK: %y = alloca [4 x i8]
// CHECK: store i32 %0, i32* [[TMP]]
// CHECK: [[Y8:%[0-9]+]] = bitcast [4 x i8]* %y to i8*
// CHECK: [[TMP8:%[0-9]+]] = bitcast i32* [[TMP]] to i8*
// CHECK: call void @llvm.memcpy.{{.*}}(i8* [[Y8]], i8* [[TMP8]], i{{[0-9]+}} 4, i32 1, i1 false)
*x = y;
@ -39,9 +39,9 @@ pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) {
#[no_mangle]
pub fn small_struct_alignment(x: &mut Bytes, y: Bytes) {
// CHECK: [[TMP:%.+]] = alloca i32
// CHECK: %arg1 = alloca %Bytes
// CHECK: store i32 %1, i32* [[TMP]]
// CHECK: [[Y8:%[0-9]+]] = bitcast %Bytes* %arg1 to i8*
// CHECK: %y = alloca %Bytes
// CHECK: store i32 %0, i32* [[TMP]]
// CHECK: [[Y8:%[0-9]+]] = bitcast %Bytes* %y to i8*
// CHECK: [[TMP8:%[0-9]+]] = bitcast i32* [[TMP]] to i8*
// CHECK: call void @llvm.memcpy.{{.*}}(i8* [[Y8]], i8* [[TMP8]], i{{[0-9]+}} 4, i32 1, i1 false)
*x = y;

View file

@ -0,0 +1,46 @@
// 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
// This file tests that we don't generate any code for saturation if
// -Z saturating-float-casts is not enabled.
#![crate_type = "lib"]
#![feature(i128_type)]
// CHECK-LABEL: @f32_to_u32
#[no_mangle]
pub fn f32_to_u32(x: f32) -> u32 {
// CHECK: fptoui
// CHECK-NOT: fcmp
// CHECK-NOT: icmp
// CHECK-NOT: select
x as u32
}
// CHECK-LABEL: @f32_to_i32
#[no_mangle]
pub fn f32_to_i32(x: f32) -> i32 {
// CHECK: fptosi
// CHECK-NOT: fcmp
// CHECK-NOT: icmp
// CHECK-NOT: select
x as i32
}
#[no_mangle]
pub fn f64_to_u16(x: f64) -> u16 {
// CHECK: fptoui
// CHECK-NOT: fcmp
// CHECK-NOT: icmp
// CHECK-NOT: select
x as u16
}

View file

@ -0,0 +1,33 @@
// 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.
// This test depends on a patch that was committed to upstream LLVM
// after 5.0, then backported to the Rust LLVM fork.
// ignore-tidy-linelength
// ignore-windows
// ignore-macos
// min-system-llvm-version 5.1
// compile-flags: -g -C no-prepopulate-passes
// CHECK-LABEL: @main
// CHECK: {{.*}}DICompositeType{{.*}}name: "vtable",{{.*}}vtableHolder:{{.*}}
pub trait T {
}
impl T for f64 {
}
pub fn main() {
let d = 23.0f64;
let td = &d as &T;
}

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.
// ignore-arm
// ignore-aarch64
// ignore-emscripten
// compile-flags: -O
#![feature(repr_simd)]
#![crate_type="lib"]
#[repr(simd)]
#[derive(Clone, Copy)]
pub struct i8x8(u64);
#[no_mangle]
pub fn a(a: &mut i8x8, b: i8x8) -> i8x8 {
// CHECK-LABEL: define x86_mmx @a(x86_mmx*{{.*}}, x86_mmx{{.*}})
// CHECK: store x86_mmx %b, x86_mmx* %a
// CHECK: ret x86_mmx %b
*a = b;
return b
}

View file

@ -12,6 +12,7 @@
#![feature(plugin_registrar, rustc_private)]
#![feature(box_syntax)]
#![feature(macro_vis_matcher)]
#[macro_use] extern crate rustc;
extern crate rustc_plugin;

View file

@ -12,6 +12,7 @@
#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]
#![feature(macro_vis_matcher)]
// Load rustc as a plugin to get macros
#[macro_use]

View file

@ -12,6 +12,7 @@
#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]
#![feature(macro_vis_matcher)]
extern crate syntax;

View file

@ -17,7 +17,6 @@
// for the error message we see here.)
#![feature(rustc_private)]
#![feature(const_atomic_usize_new)]
extern crate arena;

View file

@ -17,7 +17,8 @@ extern crate derive_bad;
#[derive(
A
)]
//~^^ ERROR: proc-macro derive produced unparseable tokens
//~^^ ERROR proc-macro derive produced unparseable tokens
//~| ERROR expected `:`, found `}`
struct A;
fn main() {}

View file

@ -23,5 +23,5 @@ fn main() {
bang_proc_macro2!();
//~^ ERROR cannot find value `foobar2` in this scope
//~^^ did you mean `foobar`?
println!("{}", x);
println!("{}", x); //~ ERROR cannot find value `x` in this scope
}

View file

@ -13,15 +13,9 @@ const C: i32 = 2;
const CR: &'static mut i32 = &mut C; //~ ERROR E0017
//~| NOTE constants require immutable values
//~| ERROR E0017
//~| NOTE constants require immutable values
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
//~| NOTE statics require immutable values
//~| ERROR E0017
//~| NOTE statics require immutable values
//~| ERROR cannot borrow
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
//~| NOTE statics require immutable values
//~| ERROR E0017
//~| NOTE statics require immutable values
fn main() {}

View file

@ -17,6 +17,7 @@ fn main() {
//~| NOTE ranges require char or numeric types
//~| NOTE start type: &'static str
//~| NOTE end type: &'static str
//~| ERROR non-reference pattern used to match a reference
_ => {}
}
}

View file

@ -10,7 +10,9 @@
enum Enum {
X = (1 << 500), //~ ERROR E0080
//~| WARNING shift left with overflow
Y = (1 / 0) //~ ERROR E0080
//~| WARNING divide by zero
}
fn main() {

View file

@ -8,10 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[repr(i32)]
enum Foo {}
//~^ ERROR E0084
//~| unsupported enum representation
#[repr(i32)] //~ ERROR: E0084
enum Foo {} //~ NOTE: zero-variant enum
fn main() {
}

View file

@ -10,6 +10,6 @@
fn main() {
let _: Box<std::io::Read + std::io::Write>;
//~^ ERROR only Send/Sync traits can be used as additional traits in a trait object [E0225]
//~| NOTE non-Send/Sync additional trait
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
//~| NOTE non-auto additional trait
}

View file

@ -18,5 +18,6 @@ extern crate libc as alloc;
//~^ ERROR E0259
//~| NOTE `alloc` reimported here
//~| NOTE `alloc` must be defined only once in the type namespace of this module
//~| NOTE You can use `as` to change the binding name of the import
fn main() {}

View file

@ -12,11 +12,8 @@ static X: i32 = 1;
const C: i32 = 2;
const CR: &'static mut i32 = &mut C; //~ ERROR E0017
//~| ERROR E0017
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
//~| ERROR E0017
//~| ERROR cannot borrow
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
//~| ERROR E0017
fn main() {}

View file

@ -9,7 +9,7 @@
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
//[mir]compile-flags: -Z borrowck=mir
struct FancyNum {
num: u8,
@ -19,8 +19,7 @@ fn main() {
let mut fancy_num = FancyNum { num: 5 };
let fancy_ref = &fancy_num;
fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
//[mir]~^ ERROR (Mir) [E0506]
//[mir]~| ERROR (Ast) [E0506]
//[mir]~^ ERROR [E0506]
println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
}

View file

@ -8,9 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
struct NonCopy;
fn main() {
let array = [NonCopy; 1];
let _value = array[0]; //~ ERROR E0508
let _value = array[0]; //[ast]~ ERROR [E0508]
//[mir]~^ ERROR [E0508]
}

View file

@ -8,21 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[repr(C)] //~ ERROR E0517
//~| requires a struct, enum or union
type Foo = u8;
#[repr(C)] //~ ERROR: E0517
type Foo = u8; //~ NOTE: not a struct, enum or union
#[repr(packed)] //~ ERROR E0517
//~| requires a struct
enum Foo2 {Bar, Baz}
#[repr(packed)] //~ ERROR: E0517
enum Foo2 {Bar, Baz} //~ NOTE: not a struct
#[repr(u8)] //~ ERROR E0517
//~| requires an enum
struct Foo3 {bar: bool, baz: bool}
#[repr(u8)] //~ ERROR: E0517
struct Foo3 {bar: bool, baz: bool} //~ NOTE: not an enum
#[repr(C)] //~ ERROR E0517
//~| requires a struct, enum or union
impl Foo3 {
#[repr(C)] //~ ERROR: E0517
impl Foo3 { //~ NOTE: not a struct, enum or union
}
fn main() {

View file

@ -8,13 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[inline(always)] //~ ERROR E0518
//~| requires a function
struct Foo;
#[inline(always)] //~ ERROR: E0518
struct Foo; //~ NOTE: not a function
#[inline(never)] //~ ERROR E0518
//~| requires a function
impl Foo {
#[inline(never)] //~ ERROR: E0518
impl Foo { //~ NOTE: not a function
}
fn main() {

View file

@ -11,4 +11,6 @@
#[inline()] //~ ERROR E0534
pub fn something() {}
fn main() {}
fn main() {
something();
}

View file

@ -0,0 +1,19 @@
// 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.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
static NUM: i32 = 18;
fn main() {
NUM = 20; //[ast]~ ERROR E0594
//[mir]~^ ERROR cannot assign to immutable item `NUM`
}

View file

@ -8,7 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
fn main() {
let x = 1;
let y = &mut x; //~ ERROR E0596
let y = &mut x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR [E0596]
}

View file

@ -0,0 +1,36 @@
// 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)]
#![feature(conservative_impl_trait)]
trait Id<T> {}
trait Lt<'a> {}
impl<'a> Lt<'a> for () {}
impl<T> Id<T> for T {}
fn free_fn_capture_hrtb_in_impl_trait()
-> impl for<'a> Id<impl Lt<'a>>
//~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level [E0657]
{
()
}
struct Foo;
impl Foo {
fn impl_fn_capture_hrtb_in_impl_trait()
-> impl for<'a> Id<impl Lt<'a>>
//~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level
{
()
}
}
fn main() {}

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.
#![feature(use_nested_groups)]
#![allow(unused_imports)]
mod foo {}
use foo::{
::bar, //~ ERROR crate root in paths can only be used in start position
super::bar, //~ ERROR `super` in paths can only be used in start position
self::bar, //~ ERROR `self` in paths can only be used in start position
};
fn main() {}

View file

@ -0,0 +1,55 @@
// 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(arbitrary_self_types)]
use std::rc::Rc;
trait Foo {
fn foo(self: Rc<Self>) -> usize;
}
trait Bar {
fn foo(self: Rc<Self>) -> usize where Self: Sized;
fn bar(self: Box<Self>) -> usize;
}
impl Foo for usize {
fn foo(self: Rc<Self>) -> usize {
*self
}
}
impl Bar for usize {
fn foo(self: Rc<Self>) -> usize {
*self
}
fn bar(self: Box<Self>) -> usize {
*self
}
}
fn make_foo() {
let x = Box::new(5usize) as Box<Foo>;
//~^ ERROR E0038
//~| NOTE method `foo` has a non-standard `self` type
//~| NOTE the trait `Foo` cannot be made into an object
//~| ERROR E0038
//~| NOTE method `foo` has a non-standard `self` type
//~| NOTE the trait `Foo` cannot be made into an object
//~| NOTE requirements on the impl of `std::ops::CoerceUnsized<std::boxed::Box<Foo>>`
}
fn make_bar() {
let x = Box::new(5usize) as Box<Bar>;
x.bar();
}
fn main() {}

View file

@ -27,8 +27,8 @@ pub fn main() {
foo(x);
unsafe {
asm!("mov $1, $0" : "=r"(x) : "r"(5));
//~^ ERROR re-assignment of immutable variable `x`
//~| NOTE re-assignment of immutable
//~^ ERROR cannot assign twice to immutable variable `x`
//~| NOTE cannot assign twice to immutable
}
foo(x);
}

View file

@ -8,12 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Zborrowck=mir
fn test() {
let v: isize;
v = 1; //~ NOTE first assignment
v = 1; //[ast]~ NOTE first assignment
//[mir]~^ NOTE first assignment
println!("v={}", v);
v = 2; //~ ERROR re-assignment of immutable variable
//~| NOTE re-assignment of immutable
v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
//[mir]~^ ERROR cannot assign twice to immutable variable `v`
//[ast]~| NOTE cannot assign twice to immutable
//[mir]~| NOTE cannot assign twice to immutable
println!("v={}", v);
}

View file

@ -30,7 +30,7 @@ fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
{
// x and y here have two distinct lifetimes:
let z: I::A = if cond { x } else { y };
//~^ ERROR cannot infer
//~^ ERROR lifetime mismatch
}
pub fn main() {}

View file

@ -50,9 +50,10 @@ fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
#[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)
let a = bar(foo, y);
let b = bar(foo, x);
(a, b) //[krisskross]~ ERROR 55:5: 55:6: lifetime mismatch [E0623]
//[krisskross]~^ ERROR 55:8: 55:9: lifetime mismatch [E0623]
}
#[rustc_error]

View file

@ -45,8 +45,8 @@ fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'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);
let a = bar(f, x);
let b = bar(f, y); //[oneuse]~ ERROR 49:19: 49:20: lifetime mismatch [E0623]
(a, b)
}
@ -60,9 +60,9 @@ fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
#[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)
let a = bar(foo, y); //[krisskross]~ ERROR E0623
let b = bar(foo, x);
(a, b) //[krisskross]~ ERROR E0623
}
#[rustc_error]

View file

@ -0,0 +1,16 @@
// 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(optin_builtin_traits)]
trait Foo {}
impl Foo for .. {}
//~^ ERROR The form `impl Foo for .. {}` will be removed, please use `auto trait Foo {}`
//~^^ WARN this was previously accepted by the compiler

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.
#![feature(optin_builtin_traits)]
auto trait Generic<T> {}
//~^ ERROR auto traits cannot have generics
//~^^ traits with auto impls (`e.g. impl Trait for ..`) can not have type parameters
auto trait Bound : Copy {}
//~^ ERROR auto traits cannot have super traits
//~^^ traits with auto impls (`e.g. impl Trait for ..`) cannot have predicates
auto trait MyTrait { fn foo() {} }
//~^ ERROR auto traits cannot contain items
//~^^ traits with default impls (`e.g. impl Trait for ..`) must have no methods or associated items
fn main() {}

View file

@ -52,6 +52,24 @@ pub enum Enum {
#[deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedTupleStruct(pub isize);
pub mod nested {
#[deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedStruct {
pub i: isize
}
#[deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedUnitStruct;
pub enum Enum {
#[deprecated(since = "1.0.0", note = "text")]
DeprecatedVariant,
}
#[deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedTupleStruct(pub isize);
}
pub struct Stable {
#[deprecated(since = "1.0.0", note = "text")]
pub override2: u8,

View file

@ -8,10 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(libc)]
extern crate libc;
extern "C" {
pub fn rand() -> libc::c_int;
pub fn rand() -> u32;
}

View file

@ -12,6 +12,7 @@
#![crate_type = "rlib"]
pub trait DefaultedTrait { }
#[allow(auto_impl)]
impl DefaultedTrait for .. { }
pub struct Something<T> { t: T }

View file

@ -10,6 +10,7 @@
#![feature(repr_simd, platform_intrinsics, core_intrinsics)]
#![allow(warnings)]
#![crate_type = "rlib"]
// Bad monomorphizations could previously cause LLVM asserts even though the
// error was caught in the compiler.
@ -21,21 +22,19 @@ extern "platform-intrinsic" {
use std::intrinsics;
#[derive(Copy, Clone)]
struct Foo(i64);
pub struct Foo(i64);
unsafe fn test_cttz(v: Foo) -> Foo {
pub unsafe fn test_cttz(v: Foo) -> Foo {
intrinsics::cttz(v)
//~^ ERROR `cttz` intrinsic: expected basic integer type, found `Foo`
}
unsafe fn test_fadd_fast(a: Foo, b: Foo) -> Foo {
pub unsafe fn test_fadd_fast(a: Foo, b: Foo) -> Foo {
intrinsics::fadd_fast(a, b)
//~^ ERROR `fadd_fast` intrinsic: expected basic float type, found `Foo`
}
unsafe fn test_simd_add(a: Foo, b: Foo) -> Foo {
pub unsafe fn test_simd_add(a: Foo, b: Foo) -> Foo {
simd_add(a, b)
//~^ ERROR `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo`
}
fn main() {}

View file

@ -12,7 +12,7 @@ trait Trait {}
pub fn main() {
let x: Vec<Trait + Sized> = Vec::new();
//~^ ERROR only Send/Sync traits can be used as additional traits in a trait object
//~^ ERROR only auto traits can be used as additional traits in a trait object
//~| ERROR the trait bound `Trait: std::marker::Sized` is not satisfied
//~| ERROR the trait bound `Trait: std::marker::Sized` is not satisfied
}

View file

@ -12,6 +12,6 @@ mod foo { pub struct bar; }
fn main() {
let bar = 5;
//~^ ERROR let bindings cannot shadow unit structs
//~^ ERROR mismatched types
use foo::bar;
}

View file

@ -10,11 +10,14 @@
enum color { rgb(isize, isize, isize), rgba(isize, isize, isize, isize), }
//~^ NOTE variant `hsl` not found here
fn main() {
let red: color = color::rgb(255, 0, 0);
match red {
color::rgb(r, g, b) => { println!("rgb"); }
color::hsl(h, s, l) => { println!("hsl"); } //~ ERROR no function
color::hsl(h, s, l) => { println!("hsl"); }
//~^ ERROR no variant
//~| NOTE variant not found in `color`
}
}

View file

@ -0,0 +1,70 @@
// 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.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
static static_x : i32 = 1;
static mut static_x_mut : i32 = 1;
fn main() {
let x = 1;
let mut x_mut = 1;
{ // borrow of local
let _y1 = &mut x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR [E0596]
let _y2 = &mut x_mut; // No error
}
{ // borrow of static
let _y1 = &mut static_x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR [E0596]
unsafe { let _y2 = &mut static_x_mut; } // No error
}
{ // borrow of deref to box
let box_x = Box::new(1);
let mut box_x_mut = Box::new(1);
let _y1 = &mut *box_x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR [E0596]
let _y2 = &mut *box_x_mut; // No error
}
{ // borrow of deref to reference
let ref_x = &x;
let ref_x_mut = &mut x_mut;
let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR [E0596]
let _y2 = &mut *ref_x_mut; // No error
}
{ // borrow of deref to pointer
let ptr_x : *const _ = &x;
let ptr_mut_x : *mut _ = &mut x_mut;
unsafe {
let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR [E0596]
let _y2 = &mut *ptr_mut_x; // No error
}
}
{ // borrowing mutably through an immutable reference
struct Foo<'a> { f: &'a mut i32, g: &'a i32 };
let mut foo = Foo { f: &mut x_mut, g: &x };
let foo_ref = &foo;
let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389]
//[mir]~^ ERROR [E0596]
// FIXME: Wrong error in MIR
}
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
//[mir]compile-flags: -Z borrowck=mir
struct point { x: isize, y: isize }
@ -21,8 +21,7 @@ fn a() {
// inherently mutable; since `p` was made immutable, `p.x` is now
// immutable. Otherwise the type of &_q.x (&isize) would be wrong.
p.x = 5; //[ast]~ ERROR cannot assign to `p.x`
//[mir]~^ ERROR cannot assign to `p.x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `p.0` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `p.x` because it is borrowed
q.x;
}
@ -33,8 +32,7 @@ fn c() {
let mut p = point {x: 3, y: 4};
let q = &p.y;
p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p`
//[mir]~^ ERROR cannot assign to `p` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `p` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `p` because it is borrowed
p.x; // silence warning
*q; // stretch loan
}
@ -46,8 +44,7 @@ fn d() {
let mut p = point {x: 3, y: 4};
let q = &p.y;
p.y = 5; //[ast]~ ERROR cannot assign to `p.y`
//[mir]~^ ERROR cannot assign to `p.y` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `p.1` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `p.y` because it is borrowed
*q;
}

View file

@ -8,9 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
static foo: isize = 5;
fn main() {
// assigning to various global constants
foo = 6; //~ ERROR cannot assign to immutable static item
foo = 6; //[ast]~ ERROR cannot assign to immutable static item
//[mir]~^ ERROR cannot assign to immutable item `foo`
}

View file

@ -13,7 +13,7 @@
// ignore-tidy-linelength
// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
//[mir]compile-flags: -Z borrowck=mir
#![feature(box_syntax)]
@ -29,48 +29,42 @@ fn a() {
let mut x = 3;
let c1 = || x = 4;
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
}
fn b() {
let mut x = 3;
let c1 = || set(&mut x);
let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x`
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
}
fn c() {
let mut x = 3;
let c1 = || set(&mut x);
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
}
fn d() {
let mut x = 3;
let c2 = || x * 5;
x = 5; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
}
fn e() {
let mut x = 3;
let c1 = || get(&x);
x = 5; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
}
fn f() {
let mut x: Box<_> = box 3;
let c1 = || get(&*x);
*x = 5; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `*x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `(*x)` because it is borrowed (Mir)
*x = 5; //[ast]~ ERROR cannot assign to `*x`
//[mir]~^ ERROR cannot assign to `*x` because it is borrowed
}
fn g() {
@ -81,8 +75,7 @@ fn g() {
let mut x: Box<_> = box Foo { f: box 3 };
let c1 = || get(&*x.f);
*x.f = 5; //[ast]~ ERROR cannot assign to `*x.f`
//[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `(*(*x).0)` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed
}
fn h() {
@ -93,8 +86,7 @@ fn h() {
let mut x: Box<_> = box Foo { f: box 3 };
let c1 = || get(&*x.f);
let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable
//[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable (Ast)
//[mir]~| ERROR cannot borrow `x` as mutable because it is also borrowed as immutable (Mir)
//[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
}
fn main() {

View file

@ -0,0 +1,305 @@
// 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.
// ignore-tidy-linelength
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
#![feature(slice_patterns)]
#![feature(advanced_slice_patterns)]
pub struct Foo {
x: u32
}
pub struct Bar(u32);
pub enum Baz {
X(u32)
}
union U {
a: u8,
b: u64,
}
impl Foo {
fn x(&mut self) -> &mut u32 { &mut self.x }
}
impl Bar {
fn x(&mut self) -> &mut u32 { &mut self.0 }
}
impl Baz {
fn x(&mut self) -> &mut u32 {
match *self {
Baz::X(ref mut value) => value
}
}
}
fn main() {
// Local and field from struct
{
let mut f = Foo { x: 22 };
let _x = f.x();
f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed
}
// Local and field from tuple-struct
{
let mut g = Bar(22);
let _0 = g.x();
g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed
//[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed
}
// Local and field from tuple
{
let mut h = (22, 23);
let _0 = &mut h.0;
h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed
//[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed
}
// Local and field from enum
{
let mut e = Baz::X(2);
let _e0 = e.x();
match e {
Baz::X(value) => value
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed
};
}
// Local and field from union
unsafe {
let mut u = U { b: 0 };
let _ra = &mut u.a;
u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed
}
// Deref and field from struct
{
let mut f = Box::new(Foo { x: 22 });
let _x = f.x();
f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed
}
// Deref and field from tuple-struct
{
let mut g = Box::new(Bar(22));
let _0 = g.x();
g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed
//[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed
}
// Deref and field from tuple
{
let mut h = Box::new((22, 23));
let _0 = &mut h.0;
h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed
//[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed
}
// Deref and field from enum
{
let mut e = Box::new(Baz::X(3));
let _e0 = e.x();
match *e {
Baz::X(value) => value
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed
};
}
// Deref and field from union
unsafe {
let mut u = Box::new(U { b: 0 });
let _ra = &mut u.a;
u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed
}
// Constant index
{
let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let _v = &mut v;
match v {
&[x, _, .., _, _] => println!("{}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
match v {
&[_, x, .., _, _] => println!("{}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
match v {
&[_, _, .., x, _] => println!("{}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
match v {
&[_, _, .., _, x] => println!("{}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
}
// Subslices
{
let mut v = &[1, 2, 3, 4, 5];
let _v = &mut v;
match v {
&[x..] => println!("{:?}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
match v {
&[_, x..] => println!("{:?}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
match v {
&[x.., _] => println!("{:?}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
match v {
&[_, x.., _] => println!("{:?}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
}
// Downcasted field
{
enum E<X> { A(X), B { x: X } }
let mut e = E::A(3);
let _e = &mut e;
match e {
E::A(ref ax) =>
//[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable
//[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable
//[mir]~| ERROR cannot use `e` because it was mutably borrowed
println!("e.ax: {:?}", ax),
E::B { x: ref bx } =>
//[ast]~^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable
//[mir]~^^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable
println!("e.bx: {:?}", bx),
}
}
// Field in field
{
struct F { x: u32, y: u32 };
struct S { x: F, y: (u32, u32), };
let mut s = S { x: F { x: 1, y: 2}, y: (999, 998) };
let _s = &mut s;
match s {
S { y: (ref y0, _), .. } =>
//[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable
//[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable
println!("y0: {:?}", y0),
_ => panic!("other case"),
}
match s {
S { x: F { y: ref x0, .. }, .. } =>
//[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable
//[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable
println!("x0: {:?}", x0),
_ => panic!("other case"),
}
}
// Field of ref
{
struct Block<'a> {
current: &'a u8,
unrelated: &'a u8,
};
fn bump<'a>(mut block: &mut Block<'a>) {
let x = &mut block;
let p: &'a u8 = &*block.current;
//[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable
// No errors in AST because of issue rust#38899
}
}
// Field of ptr
{
struct Block2 {
current: *const u8,
unrelated: *const u8,
}
unsafe fn bump2(mut block: *mut Block2) {
let x = &mut block;
let p : *const u8 = &*(*block).current;
//[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable
// No errors in AST because of issue rust#38899
}
}
// Field of index
{
struct F {x: u32, y: u32};
let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}];
let _v = &mut v;
v[0].y;
//[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..].y` because it was mutably borrowed
//[mir]~| ERROR cannot use `*v` because it was mutably borrowed
}
// Field of constant index
{
struct F {x: u32, y: u32};
let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}];
let _v = &mut v;
match v {
&[_, F {x: ref xf, ..}] => println!("{}", xf),
//[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable
// No errors in AST
_ => panic!("other case")
}
}
// Field from upvar
{
let mut x = 0;
|| {
let y = &mut x;
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
//[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time
*y = 1;
};
}
// Field from upvar nested
{
let mut x = 0;
|| {
|| {
let y = &mut x;
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
//[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time
*y = 1;
}
};
}
{
fn foo(x: Vec<i32>) {
let c = || {
drop(x);
drop(x); //[ast]~ ERROR use of moved value: `x`
//[mir]~^ ERROR use of moved value: `x`
};
c();
}
}
}

View file

@ -0,0 +1,24 @@
// Copyright 2012 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: -Z borrowck=mir
fn foo(_:String) {}
fn main()
{
let my_str = "hello".to_owned();
match Some(42) {
Some(_) if { drop(my_str); false } => {}
Some(_) => {}
None => { foo(my_str); } //~ ERROR [E0382]
}
}

View file

@ -8,12 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
// Check that we check fns appearing in constant declarations.
// Issue #22382.
const MOVE: fn(&String) -> String = {
fn broken(x: &String) -> String {
return *x //~ ERROR cannot move
return *x //[ast]~ ERROR cannot move out of borrowed content [E0507]
//[mir]~^ ERROR [E0507]
}
broken
};

View file

@ -9,7 +9,7 @@
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
//[mir]compile-flags: -Z borrowck=mir
fn main() {
let mut _a = 3;
@ -17,7 +17,6 @@ fn main() {
{
let _c = &*_b;
_a = 4; //[ast]~ ERROR cannot assign to `_a`
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `_a` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed
}
}

View file

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
#[derive(Clone)]
struct point {
x: isize,
@ -16,6 +19,8 @@ struct point {
fn main() {
let mut origin: point;
origin = point {x: 10,.. origin}; //~ ERROR use of possibly uninitialized variable: `origin.y`
origin = point {x: 10,.. origin};
//[ast]~^ ERROR use of possibly uninitialized variable: `origin.y` [E0381]
//[mir]~^^ ERROR [E0381]
origin.clone();
}

View file

@ -14,6 +14,9 @@
// Also includes tests of the errors reported when the Box in question
// is immutable (#14270).
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
#![feature(box_syntax)]
struct A { a: isize }
@ -23,7 +26,8 @@ fn indirect_write_to_imm_box() {
let mut x: isize = 1;
let y: Box<_> = box &mut x;
let p = &y;
***p = 2; //~ ERROR cannot assign to data in a `&` reference
***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference
//[mir]~^ ERROR cannot assign to immutable item `***p`
drop(p);
}
@ -32,7 +36,8 @@ fn borrow_in_var_from_var() {
let mut y: Box<_> = box &mut x;
let p = &y;
let q = &***p;
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
**y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed
//[mir]~^ ERROR cannot assign to `**y` because it is borrowed
drop(p);
drop(q);
}
@ -42,7 +47,8 @@ fn borrow_in_var_from_var_via_imm_box() {
let y: Box<_> = box &mut x;
let p = &y;
let q = &***p;
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
**y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed
//[mir]~^ ERROR cannot assign to `**y` because it is borrowed
drop(p);
drop(q);
}
@ -52,7 +58,8 @@ fn borrow_in_var_from_field() {
let mut y: Box<_> = box &mut x.a;
let p = &y;
let q = &***p;
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
**y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed
//[mir]~^ ERROR cannot assign to `**y` because it is borrowed
drop(p);
drop(q);
}
@ -62,7 +69,8 @@ fn borrow_in_var_from_field_via_imm_box() {
let y: Box<_> = box &mut x.a;
let p = &y;
let q = &***p;
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
**y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed
//[mir]~^ ERROR cannot assign to `**y` because it is borrowed
drop(p);
drop(q);
}
@ -72,7 +80,8 @@ fn borrow_in_field_from_var() {
let mut y = B { a: box &mut x };
let p = &y.a;
let q = &***p;
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
**y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed
//[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed
drop(p);
drop(q);
}
@ -82,7 +91,8 @@ fn borrow_in_field_from_var_via_imm_box() {
let y = B { a: box &mut x };
let p = &y.a;
let q = &***p;
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
**y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed
//[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed
drop(p);
drop(q);
}
@ -92,7 +102,8 @@ fn borrow_in_field_from_field() {
let mut y = B { a: box &mut x.a };
let p = &y.a;
let q = &***p;
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
**y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed
//[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed
drop(p);
drop(q);
}
@ -102,7 +113,8 @@ fn borrow_in_field_from_field_via_imm_box() {
let y = B { a: box &mut x.a };
let p = &y.a;
let q = &***p;
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
**y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed
//[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed
drop(p);
drop(q);
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
//[mir]compile-flags: -Z borrowck=mir
#![allow(unused_variables)]
#![allow(unused_assignments)]
@ -26,8 +26,7 @@ fn separate_arms() {
}
Some(ref __isize) => {
x = Some(1); //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
}
}
x.clone(); // just to prevent liveness warnings

View file

@ -0,0 +1,19 @@
// 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.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
fn cplusplus_mode(x: isize) -> &'static isize {
&x //[ast]~ ERROR `x` does not live long enough
//[mir]~^ ERROR borrowed value does not live long enough
}
fn main() {}

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.
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) {
let mut z = (0, 0);
*x = Some(&mut z.1); //[ast]~ ERROR [E0597]
//[mir]~^ ERROR [E0597]
panic!("catch me for a dangling pointer!")
}
fn main() {
cplusplus_mode_exceptionally_unsafe(&mut None);
}

Some files were not shown because too many files have changed in this diff Show more