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

This commit is contained in:
Alex Crichton 2017-08-11 09:55:13 -07:00
commit 3971a3d55c
64 changed files with 544 additions and 167 deletions

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:attribute-with-error.rs
// ignore-stage1
#![feature(proc_macro)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:attributes-included.rs
// ignore-stage1
#![feature(proc_macro, rustc_attrs)]
#![warn(unused)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:derive-bad.rs
// ignore-stage1
#[macro_use]
extern crate derive_bad;

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:derive-unstable-2.rs
// ignore-stage1
#![allow(warnings)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:derive-unstable.rs
// ignore-stage1
#![allow(warnings)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:issue_38586.rs
// ignore-stage1
#![feature(proc_macro)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:derive-b.rs
// ignore-stage1
#![allow(warnings)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:bang_proc_macro2.rs
// ignore-stage1
#![feature(proc_macro)]
#![allow(unused_macros)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:derive-b.rs
// ignore-stage1
#![allow(warnings)]

View file

@ -0,0 +1,17 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo() -> bool {
break true; //~ ERROR E0268
}
fn main() {
break {}; //~ ERROR E0268
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags: -Z verbose -Z mir-emit-validate=1
// compile-flags: -Z verbose -Z mir-emit-validate=1 -Z span_free_formats
struct Test(i32);
@ -20,16 +20,13 @@ impl Test {
fn main() {
let mut x = 0;
Test(0).foo(&mut x);
Test(0).foo(&mut x); // just making sure we do not panic when there is a tuple struct ctor
// 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: {
@ -57,3 +54,24 @@ fn main() {
// }
// }
// END rustc.node23.EraseRegions.after.mir
// START rustc.node50.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_1/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_1/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3);
// _3 = _2;
// StorageLive(_4);
// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 }))), [(*_3): i32]);
// _4 = &ReErased (*_3);
// Validate(Acquire, [(*_4): i32/ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 })) (imm)]);
// StorageLive(_5);
// _5 = (*_4);
// _0 = _5;
// StorageDead(_5);
// StorageDead(_4);
// EndRegion(ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 })));
// StorageDead(_3);
// return;
// }
// }
// END rustc.node50.EraseRegions.after.mir

View file

@ -9,7 +9,7 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags: -Z verbose -Z mir-emit-validate=1
// compile-flags: -Z verbose -Z mir-emit-validate=1 -Z span_free_formats
// Make sure unsafe fns and fns with an unsafe block only get restricted validation.
@ -45,6 +45,19 @@ fn main() {
// }
// }
// END rustc.node4.EraseRegions.after.mir
// START rustc.node22.EraseRegions.after.mir
// fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483659) => validate_4/8cd878b::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483659) => validate_4/8cd878b::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]);
// StorageLive(_3);
// _3 = _2;
// (*_3) = const 23i32;
// StorageDead(_3);
// return;
// }
// }
// END rustc.node22.EraseRegions.after.mir
// START rustc.node31.EraseRegions.after.mir
// fn test(_1: &ReErased mut i32) -> () {
// bb0: {
@ -58,3 +71,13 @@ fn main() {
// }
// }
// END rustc.node31.EraseRegions.after.mir
// START rustc.node60.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3);
// _0 = const write_42(_4) -> bb1;
// }
// }
// END rustc.node60.EraseRegions.after.mir

View file

@ -9,9 +9,9 @@
// except according to those terms.
// ignore-tidy-linelength
// compile-flags: -Z verbose -Z mir-emit-validate=2
// compile-flags: -Z verbose -Z mir-emit-validate=2 -Z span_free_formats
// Make sure unsafe fns and fns with an unsafe block only get full validation.
// Make sure unsafe fns and fns with an unsafe block still get full validation.
unsafe fn write_42(x: *mut i32) -> bool {
*x = 42;
@ -26,12 +26,12 @@ fn main() {
test(&mut 0);
let test_closure = unsafe { |x: &mut i32| write_42(x) };
// Note that validation will fail if this is executed: The closure keeps the lock on
// x, so the write in write_42 fails. This test just checks code generation,
// so the UB doesn't matter.
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) -> () {
@ -42,3 +42,22 @@ fn main() {
// }
// }
// END rustc.node17.EraseRegions.after.mir
// START rustc.node46.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483660) => validate_5/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483660) => validate_5/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3);
// _3 = _2;
// StorageLive(_4);
// StorageLive(_5);
// Validate(Suspend(ReScope(Misc(NodeId(44)))), [(*_3): i32]);
// _5 = &ReErased mut (*_3);
// Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(44)))]);
// _4 = _5 as *mut i32 (Misc);
// StorageDead(_5);
// EndRegion(ReScope(Misc(NodeId(44))));
// Validate(Release, [_0: bool, _4: *mut i32]);
// _0 = const write_42(_4) -> bb1;
// }
// }
// END rustc.node46.EraseRegions.after.mir

View file

@ -1,6 +1,12 @@
-include ../tools.mk
ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1)
# ignore stage1
all:
else
all:
$(RUSTC) a.rs && $(RUSTC) b.rs
$(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \
--out-dir=$(TMPDIR)
endif

View file

@ -1,4 +1,10 @@
-include ../tools.mk
ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1)
# ignore stage1
all:
else
all:
$(RUSTC) a.rs && $(RUSTC) b.rs && $(RUSTC) c.rs
endif

View file

@ -1,5 +1,11 @@
-include ../tools.mk
ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1)
# ignore stage1
all:
else
all:
$(RUSTC) foo.rs; $(RUSTC) bar.rs
$(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR)
endif

View file

@ -1,5 +1,10 @@
-include ../tools.mk
ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1)
# ignore stage1
all:
else
# Windows doesn't correctly handle include statements with escaping paths,
# so this test will not get run on Windows.
ifdef IS_WINDOWS
@ -15,3 +20,5 @@ $(TMPDIR)/libllvm-function-pass.o:
$(TMPDIR)/libllvm-module-pass.o:
$(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o
endif
endif

View file

@ -1,6 +1,12 @@
-include ../tools.mk
ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1)
# ignore stage1
all:
else
all:
$(RUSTC) foo.rs
$(RUSTC) bar.rs --emit dep-info
grep "proc-macro source" $(TMPDIR)/bar.d && exit 1 || exit 0
endif

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:custom_derive_plugin.rs
// ignore-stage1
#![feature(plugin, custom_derive)]
#![plugin(custom_derive_plugin)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:add-impl.rs
// ignore-stage1
#[macro_use]
extern crate add_impl;

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:append-impl.rs
// ignore-stage1
#![allow(warnings)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:attr-args.rs
// ignore-stage1
#![allow(warnings)]
#![feature(proc_macro)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:bang-macro.rs
// ignore-stage1
#![feature(proc_macro)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:count_compound_ops.rs
// ignore-stage1
#![feature(proc_macro)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:double.rs
// ignore-stage1
#![allow(unused)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:derive-same-struct.rs
// ignore-stage1
#[macro_use]
extern crate derive_same_struct;

View file

@ -10,6 +10,7 @@
// aux-build:hygiene_example_codegen.rs
// aux-build:hygiene_example.rs
// ignore-stage1
#![feature(proc_macro)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:issue-39889.rs
// ignore-stage1
#![feature(proc_macro)]
#![allow(unused)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
// aux-build:issue-40001-plugin.rs
// ignore-stage1
#![feature(proc_macro, plugin)]
#![plugin(issue_40001_plugin)]

View file

@ -10,6 +10,7 @@
// aux-build:derive-atob.rs
// aux-build:derive-ctod.rs
// ignore-stage1
#[macro_use]
extern crate derive_atob;

View file

@ -10,6 +10,7 @@
// aux-build:derive-a.rs
// aux-build:derive-reexport.rs
// ignore-stage1
#[macro_use]
extern crate derive_reexport;

View file

@ -137,4 +137,10 @@ pub fn main() {
panic!("from outer");
};
assert_eq!(break_from_while_to_outer, 567);
let rust = true;
let value = loop {
break rust;
};
assert!(value);
}

View file

@ -45,6 +45,11 @@ fn main() {
assert!(g != h);
assert!(g != i);
assert!(h != i);
// Make sure lifetime anonymization handles nesting correctly
let j = TypeId::of::<fn(for<'a> fn(&'a isize) -> &'a usize)>();
let k = TypeId::of::<fn(for<'b> fn(&'b isize) -> &'b usize)>();
assert_eq!(j, k);
}
// Boxed unboxed closures
{

View file

@ -107,6 +107,10 @@ fn fishy() {
String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>());
}
fn union() {
union union<'union> { union: &'union union<'union>, }
}
pub fn main() {
strange();
funny();
@ -119,4 +123,5 @@ pub fn main() {
dots();
you_eight();
fishy();
union();
}