]> git.lizzy.rs Git - rust.git/commitdiff
Merge remote-tracking branch 'origin/master' into gen
authorAlex Crichton <alex@alexcrichton.com>
Fri, 11 Aug 2017 16:55:13 +0000 (09:55 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 11 Aug 2017 16:55:13 +0000 (09:55 -0700)
64 files changed:
src/liballoc/arc.rs
src/liballoc/string.rs
src/librustc/ich/impls_mir.rs
src/librustc/ich/impls_ty.rs
src/librustc/macros.rs
src/librustc/mir/visit.rs
src/librustc/ty/layout.rs
src/librustc/ty/mod.rs
src/librustc/ty/util.rs
src/librustc_driver/driver.rs
src/librustc_metadata/encoder.rs
src/librustc_mir/shim.rs
src/librustc_mir/transform/add_call_guards.rs
src/librustc_mir/transform/nll.rs
src/librustc_trans/back/symbol_export.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/diagnostics.rs
src/librustdoc/html/render.rs
src/librustdoc/html/static/rustdoc.css
src/libstd/fs.rs
src/libstd/io/error.rs
src/libstd/io/mod.rs
src/libstd/lib.rs
src/libstd/net/ip.rs
src/libstd/sys/unix/ext/net.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/expand.rs
src/libsyntax/parse/lexer/unicode_chars.rs
src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs
src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs
src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs
src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs
src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs
src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs
src/test/compile-fail-fulldeps/proc-macro/item-error.rs
src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs
src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs
src/test/compile-fail/issue-43162.rs [new file with mode: 0644]
src/test/mir-opt/validate_1.rs
src/test/mir-opt/validate_4.rs
src/test/mir-opt/validate_5.rs
src/test/run-make/issue-37839/Makefile
src/test/run-make/issue-37893/Makefile
src/test/run-make/issue-38237/Makefile
src/test/run-make/llvm-pass/Makefile
src/test/run-make/rustc-macro-dep-files/Makefile
src/test/run-pass-fulldeps/issue-40663.rs
src/test/run-pass-fulldeps/proc-macro/add-impl.rs
src/test/run-pass-fulldeps/proc-macro/append-impl.rs
src/test/run-pass-fulldeps/proc-macro/attr-args.rs
src/test/run-pass-fulldeps/proc-macro/bang-macro.rs
src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs
src/test/run-pass-fulldeps/proc-macro/crate-var.rs
src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs
src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs
src/test/run-pass-fulldeps/proc-macro/issue-39889.rs
src/test/run-pass-fulldeps/proc-macro/issue-40001.rs
src/test/run-pass-fulldeps/proc-macro/load-two.rs
src/test/run-pass-fulldeps/proc-macro/use-reexport.rs
src/test/run-pass/loop-break-value.rs
src/test/run-pass/type-id-higher-rank.rs
src/test/run-pass/weird-exprs.rs
src/tools/tidy/src/pal.rs
src/tools/tidy/src/style.rs

index 9e3142519341777cca7803f8e663bdca417ef00c..daf556795fa6b2b9bdb71d7b9193cc36ba769f9d 100644 (file)
@@ -95,7 +95,7 @@
 /// # Cloning references
 ///
 /// Creating a new reference from an existing reference counted pointer is done using the
-/// `Clone` trait implemented for [`Arc<T>`][`arc`] and [`Weak<T>`][`weak`].
+/// `Clone` trait implemented for [`Arc<T>`][arc] and [`Weak<T>`][weak].
 ///
 /// ```
 /// use std::sync::Arc;
index 622cc68964bf7061cc49d3832a69bbc63186c81c..322b137e99f0e9b6856d5171384aab0b3f482a87 100644 (file)
 /// # Deref
 ///
 /// `String`s implement [`Deref`]`<Target=str>`, and so inherit all of [`str`]'s
-/// methods. In addition, this means that you can pass a `String` to any
+/// methods. In addition, this means that you can pass a `String` to a
 /// function which takes a [`&str`] by using an ampersand (`&`):
 ///
 /// ```
 ///
 /// This will create a [`&str`] from the `String` and pass it in. This
 /// conversion is very inexpensive, and so generally, functions will accept
-/// [`&str`]s as arguments unless they need a `String` for some specific reason.
+/// [`&str`]s as arguments unless they need a `String` for some specific
+/// reason.
 ///
+/// In certain cases Rust doesn't have enough information to make this
+/// conversion, known as `Deref` coercion. In the following example a string
+/// slice `&'a str` implements the trait `TraitExample`, and the function
+/// `example_func` takes anything that implements the trait. In this case Rust
+/// would need to make two implicit conversions, which Rust doesn't have the
+/// means to do. For that reason, the following example will not compile.
+///
+/// ```compile_fail,E0277
+/// trait TraitExample {}
+///
+/// impl<'a> TraitExample for &'a str {}
+///
+/// fn example_func<A: TraitExample>(example_arg: A) {}
+///
+/// fn main() {
+///     let example_string = String::from("example_string");
+///     example_func(&example_string);
+/// }
+/// ```
+///
+/// There are two options that would work instead. The first would be to
+/// change the line `example_func(&example_string);` to
+/// `example_func(example_string.as_str());`, using the method `as_str()`
+/// to explicitly extract the string slice containing the string. The second
+/// way changes `example_func(&example_string);` to
+/// `example_func(&*example_string);`. In this case we are dereferencing a
+/// `String` to a `str`, then referencing the `str` back to `&str`. The
+/// second way is more idiomatic, however both work to do the conversion
+/// explicitly rather than relying on the implicit conversion.
 ///
 /// # Representation
 ///
index 3d5de5579f0f910d0c5fafbf6e1981433d0990fc..7ee2cc3b650c5c59a9bc069b9c40ba390e23c803 100644 (file)
@@ -34,7 +34,7 @@
 impl_stable_hash_for!(struct mir::BasicBlockData<'tcx> { statements, terminator, is_cleanup });
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for mir::Terminator<'tcx> {
+for mir::Terminator<'gcx> {
     #[inline]
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
@@ -128,7 +128,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for mir::TerminatorKind<'tcx> {
+for mir::TerminatorKind<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -197,7 +197,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for mir::AssertMessage<'tcx> {
+for mir::AssertMessage<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -220,7 +220,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 impl_stable_hash_for!(struct mir::Statement<'tcx> { source_info, kind });
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for mir::StatementKind<'tcx> {
+for mir::StatementKind<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -257,7 +257,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl<'a, 'gcx, 'tcx, T> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-    for mir::ValidationOperand<'tcx, T>
+    for mir::ValidationOperand<'gcx, T>
     where T: HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
 {
     fn hash_stable<W: StableHasherResult>(&self,
@@ -273,7 +273,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 
 impl_stable_hash_for!(enum mir::ValidationOp { Acquire, Release, Suspend(extent) });
 
-impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Lvalue<'tcx> {
+impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Lvalue<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -293,7 +293,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl<'a, 'gcx, 'tcx, B, V, T> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for mir::Projection<'tcx, B, V, T>
+for mir::Projection<'gcx, B, V, T>
     where B: HashStable<StableHashingContext<'a, 'gcx, 'tcx>>,
           V: HashStable<StableHashingContext<'a, 'gcx, 'tcx>>,
           T: HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
@@ -312,7 +312,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl<'a, 'gcx, 'tcx, V, T> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for mir::ProjectionElem<'tcx, V, T>
+for mir::ProjectionElem<'gcx, V, T>
     where V: HashStable<StableHashingContext<'a, 'gcx, 'tcx>>,
           T: HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
 {
@@ -348,7 +348,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 
 impl_stable_hash_for!(struct mir::VisibilityScopeData { span, parent_scope });
 
-impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Operand<'tcx> {
+impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Operand<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -365,7 +365,7 @@ fn hash_stable<W: StableHasherResult>(&self,
     }
 }
 
-impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Rvalue<'tcx> {
+impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Rvalue<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -426,7 +426,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for mir::AggregateKind<'tcx> {
+for mir::AggregateKind<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -487,7 +487,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 
 impl_stable_hash_for!(struct mir::Constant<'tcx> { span, ty, literal });
 
-impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Literal<'tcx> {
+impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Literal<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
index 352d25dad659c0447aae9d72c7da8ca14d6371a3..22364c2c43a366812dfffac7511afbfe205ba2a2 100644 (file)
@@ -20,7 +20,7 @@
 use ty;
 
 impl<'a, 'gcx, 'tcx, T> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for &'tcx ty::Slice<T>
+for &'gcx ty::Slice<T>
     where T: HashStable<StableHashingContext<'a, 'gcx, 'tcx>> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
@@ -30,7 +30,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for ty::subst::Kind<'tcx> {
+for ty::subst::Kind<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -55,6 +55,11 @@ fn hash_stable<W: StableHasherResult>(&self,
                 db.depth.hash_stable(hcx, hasher);
                 i.hash_stable(hcx, hasher);
             }
+            ty::ReLateBound(db, ty::BrNamed(def_id, name)) => {
+                db.depth.hash_stable(hcx, hasher);
+                def_id.hash_stable(hcx, hasher);
+                name.hash_stable(hcx, hasher);
+            }
             ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, index, name }) => {
                 def_id.hash_stable(hcx, hasher);
                 index.hash_stable(hcx, hasher);
@@ -76,7 +81,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for ty::adjustment::AutoBorrow<'tcx> {
+for ty::adjustment::AutoBorrow<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -94,7 +99,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for ty::adjustment::Adjust<'tcx> {
+for ty::adjustment::Adjust<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -128,7 +133,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for ty::UpvarCapture<'tcx> {
+for ty::UpvarCapture<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -155,12 +160,13 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl<'a, 'gcx, 'tcx, T> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::Binder<T>
-    where T: HashStable<StableHashingContext<'a, 'gcx, 'tcx>> + ty::fold::TypeFoldable<'tcx>
+    where T: HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
 {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
-        hcx.tcx().anonymize_late_bound_regions(self).0.hash_stable(hcx, hasher);
+        let ty::Binder(ref inner) = *self;
+        inner.hash_stable(hcx, hasher);
     }
 }
 
@@ -195,7 +201,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 impl_stable_hash_for!(struct ty::ProjectionTy<'tcx> { substs, item_def_id });
 
 
-impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::Predicate<'tcx> {
+impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::Predicate<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -261,7 +267,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for ::middle::const_val::ConstVal<'tcx> {
+for ::middle::const_val::ConstVal<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -490,7 +496,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for ty::TypeVariants<'tcx>
+for ty::TypeVariants<'gcx>
 {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
@@ -587,7 +593,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for ty::ExistentialPredicate<'tcx>
+for ty::ExistentialPredicate<'gcx>
 {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
@@ -620,7 +626,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 
 
 impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
-for ty::TypeckTables<'tcx> {
+for ty::TypeckTables<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
@@ -705,7 +711,7 @@ fn hash_stable<W: StableHasherResult>(&self,
     substs
 });
 
-impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::InstanceDef<'tcx> {
+impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::InstanceDef<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
index f814f941b06f1aed2dd35a0a18b8c3214e8c3e28..f3d66b49de5a89000c00ec4597a4e68bebd9313b 100644 (file)
@@ -73,10 +73,10 @@ macro_rules! __impl_stable_hash_field {
 #[macro_export]
 macro_rules! impl_stable_hash_for {
     (enum $enum_name:path { $( $variant:ident $( ( $($arg:ident),* ) )* ),* }) => {
-        impl<'a, 'gcx, 'tcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a, 'gcx, 'tcx>> for $enum_name {
+        impl<'a, 'tcx, 'lcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a, 'tcx, 'lcx>> for $enum_name {
             #[inline]
             fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&self,
-                                                  __ctx: &mut $crate::ich::StableHashingContext<'a, 'gcx, 'tcx>,
+                                                  __ctx: &mut $crate::ich::StableHashingContext<'a, 'tcx, 'lcx>,
                                                   __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher<W>) {
                 use $enum_name::*;
                 ::std::mem::discriminant(self).hash_stable(__ctx, __hasher);
@@ -92,10 +92,10 @@ fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&s
         }
     };
     (struct $struct_name:path { $($field:ident),* }) => {
-        impl<'a, 'gcx, 'tcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a, 'gcx, 'tcx>> for $struct_name {
+        impl<'a, 'tcx, 'lcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a, 'tcx, 'lcx>> for $struct_name {
             #[inline]
             fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&self,
-                                                  __ctx: &mut $crate::ich::StableHashingContext<'a, 'gcx, 'tcx>,
+                                                  __ctx: &mut $crate::ich::StableHashingContext<'a, 'tcx, 'lcx>,
                                                   __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher<W>) {
                 let $struct_name {
                     $(ref $field),*
@@ -106,10 +106,10 @@ fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&s
         }
     };
     (tuple_struct $struct_name:path { $($field:ident),* }) => {
-        impl<'a, 'gcx, 'tcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a, 'gcx, 'tcx>> for $struct_name {
+        impl<'a, 'tcx, 'lcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a, 'tcx, 'lcx>> for $struct_name {
             #[inline]
             fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&self,
-                                                  __ctx: &mut $crate::ich::StableHashingContext<'a, 'gcx, 'tcx>,
+                                                  __ctx: &mut $crate::ich::StableHashingContext<'a, 'tcx, 'lcx>,
                                                   __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher<W>) {
                 let $struct_name (
                     $(ref $field),*
@@ -125,11 +125,11 @@ fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&s
 macro_rules! impl_stable_hash_for_spanned {
     ($T:path) => (
 
-        impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ::syntax::codemap::Spanned<$T>
+        impl<'a, 'tcx, 'lcx> HashStable<StableHashingContext<'a, 'tcx, 'lcx>> for ::syntax::codemap::Spanned<$T>
         {
             #[inline]
             fn hash_stable<W: StableHasherResult>(&self,
-                                                  hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
+                                                  hcx: &mut StableHashingContext<'a, 'tcx, 'lcx>,
                                                   hasher: &mut StableHasher<W>) {
                 self.node.hash_stable(hcx, hasher);
                 self.span.hash_stable(hcx, hasher);
index 30ffa73019c960b3ee6e8b2ae753177b9d228d33..6589e824187fd5b730c11b12166d249ef5aae044 100644 (file)
@@ -788,6 +788,7 @@ fn visit_location(&mut self, mir: & $($mutability)* Mir<'tcx>, location: Locatio
 make_mir_visitor!(Visitor,);
 make_mir_visitor!(MutVisitor,mut);
 
+#[derive(Copy, Clone, Debug)]
 pub enum Lookup {
     Loc(Location),
     Src(SourceInfo),
index 54e15ed01f074b7d548899e3eede6d9009ca31ff..cf21a66d51538f9d66147b9185783030d17e7cfe 100644 (file)
@@ -2207,8 +2207,8 @@ pub fn field_type<C: LayoutTyper<'tcx>>(&self, cx: C, i: usize) -> Ty<'tcx> {
         let tcx = cx.tcx();
 
         let ptr_field_type = |pointee: Ty<'tcx>| {
+            assert!(i < 2);
             let slice = |element: Ty<'tcx>| {
-                assert!(i < 2);
                 if i == 0 {
                     tcx.mk_mut_ptr(element)
                 } else {
index b5aea7e33d61fa7935827a1126691d69a1f02bf0..0a3c4d5d8fa5a4114fc345e3204545dfcf1d6494 100644 (file)
@@ -501,7 +501,7 @@ pub fn is_suggestable(&self) -> bool {
     }
 }
 
-impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::TyS<'tcx> {
+impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::TyS<'gcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
                                           hasher: &mut StableHasher<W>) {
index 2d29a288a260831e780c4eb7b4d1d9a0c37e6463..82810b7aae1bb1a70b93af6f6c5399ed8c6929be 100644 (file)
@@ -215,6 +215,11 @@ pub fn type_id_hash(self, ty: Ty<'tcx>) -> u64 {
         let mut hasher = StableHasher::new();
         let mut hcx = StableHashingContext::new(self);
 
+        // We want the type_id be independent of the types free regions, so we
+        // erase them. The erase_regions() call will also anonymize bound
+        // regions, which is desirable too.
+        let ty = self.erase_regions(&ty);
+
         hcx.while_hashing_spans(false, |hcx| {
             hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
                 ty.hash_stable(hcx, &mut hasher);
index e331d6c6ae05ae60ac2e3235597c616cf5aa9002..da22f1e411dba5a2cf2cdefead97c30a5d69ae83 100644 (file)
@@ -949,15 +949,16 @@ macro_rules! try_with_f {
 
     // These next passes must be executed together
     passes.push_pass(MIR_OPTIMIZED, mir::transform::no_landing_pads::NoLandingPads);
-    passes.push_pass(MIR_OPTIMIZED, mir::transform::add_call_guards::AddCallGuards);
+    passes.push_pass(MIR_OPTIMIZED, mir::transform::add_call_guards::CriticalCallEdges);
     passes.push_pass(MIR_OPTIMIZED, mir::transform::elaborate_drops::ElaborateDrops);
     passes.push_pass(MIR_OPTIMIZED, mir::transform::no_landing_pads::NoLandingPads);
+    // AddValidation needs to run after ElaborateDrops and before EraseRegions, and it needs
+    // an AllCallEdges pass right before it.
+    passes.push_pass(MIR_OPTIMIZED, mir::transform::add_call_guards::AllCallEdges);
+    passes.push_pass(MIR_OPTIMIZED, mir::transform::add_validation::AddValidation);
     passes.push_pass(MIR_OPTIMIZED, mir::transform::simplify::SimplifyCfg::new("elaborate-drops"));
     // No lifetime analysis based on borrowing can be done from here on out.
 
-    // AddValidation needs to run after ElaborateDrops and before EraseRegions.
-    passes.push_pass(MIR_OPTIMIZED, mir::transform::add_validation::AddValidation);
-
     // From here on out, regions are gone.
     passes.push_pass(MIR_OPTIMIZED, mir::transform::erase_regions::EraseRegions);
 
@@ -969,9 +970,7 @@ macro_rules! try_with_f {
     passes.push_pass(MIR_OPTIMIZED, mir::transform::simplify::SimplifyLocals);
 
     passes.push_pass(MIR_OPTIMIZED, mir::transform::generator::StateTransform);
-    passes.push_pass(MIR_OPTIMIZED, mir::transform::no_landing_pads::NoLandingPads);
-
-    passes.push_pass(MIR_OPTIMIZED, mir::transform::add_call_guards::AddCallGuards);
+    passes.push_pass(MIR_OPTIMIZED, mir::transform::add_call_guards::CriticalCallEdges);
     passes.push_pass(MIR_OPTIMIZED, mir::transform::dump_mir::Marker("PreTrans"));
 
     TyCtxt::create_and_enter(sess,
index 1d8feb6b636e5fe6d52b8512155f88173a04de44..7f14b2bc1056723fb867035d9ad7016b42138a9e 100644 (file)
@@ -563,7 +563,7 @@ fn encode_info_for_mod(&mut self,
         Entry {
             kind: EntryKind::Mod(self.lazy(&data)),
             visibility: self.lazy(&ty::Visibility::from_hir(vis, id, tcx)),
-            span: self.lazy(&md.inner),
+            span: self.lazy(&tcx.def_span(def_id)),
             attributes: self.encode_attributes(attrs),
             children: self.lazy_seq(md.item_ids.iter().map(|item_id| {
                 tcx.hir.local_def_id(item_id.id).index
index fee9ff854cd31314c9fa690355727a5b81007979..177211e9372595343d92b4155246b05909b22b18 100644 (file)
@@ -105,7 +105,7 @@ fn make_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
         debug!("make_shim({:?}) = untransformed {:?}", instance, result);
         no_landing_pads::no_landing_pads(tcx, &mut result);
         simplify::simplify_cfg(&mut result);
-        add_call_guards::add_call_guards(&mut result);
+        add_call_guards::CriticalCallEdges.add_call_guards(&mut result);
     debug!("make_shim({:?}) = {:?}", instance, result);
 
     tcx.alloc_mir(result)
index b7c7a1774dd356f3ab2aac43decccb7002904a36..23a9c4c57ca6a39b107b2fef139c8540e3145457 100644 (file)
 use rustc::mir::transform::{MirPass, MirSource};
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 
-pub struct AddCallGuards;
+#[derive(PartialEq)]
+pub enum AddCallGuards {
+    AllCallEdges,
+    CriticalCallEdges,
+}
+pub use self::AddCallGuards::*;
 
 /**
  * Breaks outgoing critical edges for call terminators in the MIR.
@@ -40,48 +45,52 @@ fn run_pass<'a, 'tcx>(&self,
                           _tcx: TyCtxt<'a, 'tcx, 'tcx>,
                           _src: MirSource,
                           mir: &mut Mir<'tcx>) {
-        add_call_guards(mir);
+        self.add_call_guards(mir);
     }
 }
 
-pub fn add_call_guards(mir: &mut Mir) {
-    let pred_count: IndexVec<_, _> =
-        mir.predecessors().iter().map(|ps| ps.len()).collect();
+impl AddCallGuards {
+    pub fn add_call_guards(&self, mir: &mut Mir) {
+        let pred_count: IndexVec<_, _> =
+            mir.predecessors().iter().map(|ps| ps.len()).collect();
 
-    // We need a place to store the new blocks generated
-    let mut new_blocks = Vec::new();
+        // We need a place to store the new blocks generated
+        let mut new_blocks = Vec::new();
 
-    let cur_len = mir.basic_blocks().len();
+        let cur_len = mir.basic_blocks().len();
 
-    for block in mir.basic_blocks_mut() {
-        match block.terminator {
-            Some(Terminator {
-                kind: TerminatorKind::Call {
-                    destination: Some((_, ref mut destination)),
-                    cleanup: Some(_),
-                    ..
-                }, source_info
-            }) if pred_count[*destination] > 1 => {
-                // It's a critical edge, break it
-                let call_guard = BasicBlockData {
-                    statements: vec![],
-                    is_cleanup: block.is_cleanup,
-                    terminator: Some(Terminator {
-                        source_info: source_info,
-                        kind: TerminatorKind::Goto { target: *destination }
-                    })
-                };
+        for block in mir.basic_blocks_mut() {
+            match block.terminator {
+                Some(Terminator {
+                    kind: TerminatorKind::Call {
+                        destination: Some((_, ref mut destination)),
+                        cleanup,
+                        ..
+                    }, source_info
+                }) if pred_count[*destination] > 1 &&
+                      (cleanup.is_some() || self == &AllCallEdges) =>
+                {
+                    // It's a critical edge, break it
+                    let call_guard = BasicBlockData {
+                        statements: vec![],
+                        is_cleanup: block.is_cleanup,
+                        terminator: Some(Terminator {
+                            source_info: source_info,
+                            kind: TerminatorKind::Goto { target: *destination }
+                        })
+                    };
 
-                // Get the index it will be when inserted into the MIR
-                let idx = cur_len + new_blocks.len();
-                new_blocks.push(call_guard);
-                *destination = BasicBlock::new(idx);
+                    // Get the index it will be when inserted into the MIR
+                    let idx = cur_len + new_blocks.len();
+                    new_blocks.push(call_guard);
+                    *destination = BasicBlock::new(idx);
+                }
+                _ => {}
             }
-            _ => {}
         }
-    }
 
-    debug!("Broke {} N edges", new_blocks.len());
+        debug!("Broke {} N edges", new_blocks.len());
 
-    mir.basic_blocks_mut().extend(new_blocks);
+        mir.basic_blocks_mut().extend(new_blocks);
+    }
 }
index 3273b4ff347e562d224844c70954cef3f799d13d..fb4764c4962682bef62e135f33050ff536f09465 100644 (file)
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use rustc::ty::TyCtxt;
-use rustc::mir::Mir;
-use rustc::mir::visit::MutVisitor;
+use rustc::ty::TypeFoldable;
+use rustc::ty::subst::{Kind, Substs};
+use rustc::ty::{Ty, TyCtxt, ClosureSubsts, RegionVid, RegionKind};
+use rustc::mir::{Mir, Location, Rvalue, BasicBlock, Statement, StatementKind};
+use rustc::mir::visit::{MutVisitor, Lookup};
 use rustc::mir::transform::{MirPass, MirSource};
+use rustc::infer::{self, InferCtxt};
+use syntax_pos::DUMMY_SP;
+use std::collections::HashMap;
 
 #[allow(dead_code)]
-struct NLLVisitor<'a, 'tcx: 'a> {
-    tcx: TyCtxt<'a, 'tcx, 'tcx>,
+struct NLLVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
+    lookup_map: HashMap<RegionVid, Lookup>,
+    infcx: InferCtxt<'a, 'gcx, 'tcx>,
 }
 
-impl<'a, 'tcx> NLLVisitor<'a, 'tcx> {
-    pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
+impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> {
+    pub fn new(infcx: InferCtxt<'a, 'gcx, 'tcx>) -> Self {
         NLLVisitor {
-            tcx: tcx
+            infcx: infcx,
+            lookup_map: HashMap::new(),
+        }
+    }
+
+    pub fn into_results(self) -> HashMap<RegionVid, Lookup> {
+        self.lookup_map
+    }
+
+    fn renumber_regions<T>(&self, value: &T) -> T where T: TypeFoldable<'tcx> {
+        self.infcx.tcx.fold_regions(value, &mut false, |_region, _depth| {
+            self.infcx.next_region_var(infer::MiscVariable(DUMMY_SP))
+        })
+    }
+
+    fn store_region(&mut self, region: &RegionKind, lookup: Lookup) {
+        if let RegionKind::ReVar(rid) = *region {
+            self.lookup_map.entry(rid).or_insert(lookup);
+        }
+    }
+
+    fn store_ty_regions(&mut self, ty: &Ty<'tcx>, lookup: Lookup) {
+        for region in ty.regions() {
+            self.store_region(region, lookup);
+        }
+    }
+
+    fn store_kind_regions(&mut self, kind: &'tcx Kind, lookup: Lookup) {
+        if let Some(ty) = kind.as_type() {
+            self.store_ty_regions(&ty, lookup);
+        } else if let Some(region) = kind.as_region() {
+            self.store_region(region, lookup);
         }
     }
 }
 
-impl<'a, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'tcx> {
-    // FIXME: Nashenas88: implement me!
+impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
+    fn visit_ty(&mut self, ty: &mut Ty<'tcx>, lookup: Lookup) {
+        let old_ty = *ty;
+        *ty = self.renumber_regions(&old_ty);
+        self.store_ty_regions(ty, lookup);
+    }
+
+    fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, location: Location) {
+        *substs = self.renumber_regions(&{*substs});
+        let lookup = Lookup::Loc(location);
+        for kind in *substs {
+            self.store_kind_regions(kind, lookup);
+        }
+    }
+
+    fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, location: Location) {
+        match *rvalue {
+            Rvalue::Ref(ref mut r, _, _) => {
+                let old_r = *r;
+                *r = self.renumber_regions(&old_r);
+                let lookup = Lookup::Loc(location);
+                self.store_region(r, lookup);
+            }
+            Rvalue::Use(..) |
+            Rvalue::Repeat(..) |
+            Rvalue::Len(..) |
+            Rvalue::Cast(..) |
+            Rvalue::BinaryOp(..) |
+            Rvalue::CheckedBinaryOp(..) |
+            Rvalue::UnaryOp(..) |
+            Rvalue::Discriminant(..) |
+            Rvalue::NullaryOp(..) |
+            Rvalue::Aggregate(..) => {
+                // These variants don't contain regions.
+            }
+        }
+        self.super_rvalue(rvalue, location);
+    }
+
+    fn visit_closure_substs(&mut self,
+                            substs: &mut ClosureSubsts<'tcx>,
+                            location: Location) {
+        *substs = self.renumber_regions(substs);
+        let lookup = Lookup::Loc(location);
+        for kind in substs.substs {
+            self.store_kind_regions(kind, lookup);
+        }
+    }
+
+    fn visit_statement(&mut self,
+                       block: BasicBlock,
+                       statement: &mut Statement<'tcx>,
+                       location: Location) {
+        if let StatementKind::EndRegion(_) = statement.kind {
+            statement.kind = StatementKind::Nop;
+        }
+        self.super_statement(block, statement, location);
+    }
 }
 
 // MIR Pass for non-lexical lifetimes
@@ -38,10 +131,16 @@ fn run_pass<'a, 'tcx>(&self,
                           tcx: TyCtxt<'a, 'tcx, 'tcx>,
                           _: MirSource,
                           mir: &mut Mir<'tcx>) {
-        if tcx.sess.opts.debugging_opts.nll {
-            // Clone mir so we can mutate it without disturbing the rest
-            // of the compiler
-            NLLVisitor::new(tcx).visit_mir(&mut mir.clone());
+        if !tcx.sess.opts.debugging_opts.nll {
+            return;
         }
+
+        tcx.infer_ctxt().enter(|infcx| {
+            // Clone mir so we can mutate it without disturbing the rest of the compiler
+            let mut renumbered_mir = mir.clone();
+            let mut visitor = NLLVisitor::new(infcx);
+            visitor.visit_mir(&mut renumbered_mir);
+            let _results = visitor.into_results();
+        })
     }
 }
\ No newline at end of file
index 72071f8cec99006793a4a5df09d9c7f246fa95d7..971483e91b6f341d13743ffd901e87385775d549 100644 (file)
@@ -13,6 +13,7 @@
 use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE, INVALID_CRATE, CRATE_DEF_INDEX};
 use rustc::session::config;
 use rustc::ty::TyCtxt;
+use rustc_allocator::ALLOCATOR_METHODS;
 use syntax::attr;
 
 /// The SymbolExportLevel of a symbols specifies from which kinds of crates
@@ -83,6 +84,14 @@ pub fn compute<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                               SymbolExportLevel::C));
         }
 
+        if tcx.sess.allocator_kind.get().is_some() {
+            for method in ALLOCATOR_METHODS {
+                local_crate.push((format!("__rust_{}", method.name),
+                                  INVALID_DEF_ID,
+                                  SymbolExportLevel::Rust));
+            }
+        }
+
         if let Some(id) = tcx.sess.derive_registrar_fn.get() {
             let def_id = tcx.hir.local_def_id(id);
             let idx = def_id.index;
index d2176b245be11838a1a76d19d3682068958b0747..b22cb0bafe824e32a2b2b27313e797423208869b 100644 (file)
@@ -3700,6 +3700,20 @@ fn check_expr_kind(&self,
                   // inside a loop at all, which is caught by the
                   // loop-checking pass.
                   assert!(self.tcx.sess.err_count() > 0);
+
+                  // We still need to assign a type to the inner expression to
+                  // prevent the ICE in #43162.
+                  if let Some(ref e) = *expr_opt {
+                      self.check_expr_with_hint(e, tcx.types.err);
+
+                      // ... except when we try to 'break rust;'.
+                      // ICE this expression in particular (see #43162).
+                      if let hir::ExprPath(hir::QPath::Resolved(_, ref path)) = e.node {
+                          if path.segments.len() == 1 && path.segments[0].name == "rust" {
+                              fatally_break_rust(self.tcx.sess);
+                          }
+                      }
+                  }
               }
 
               // the type of a `break` is always `!`, since it diverges
@@ -4937,3 +4951,20 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         }
     }
 }
+
+fn fatally_break_rust(sess: &Session) {
+    let handler = sess.diagnostic();
+    handler.span_bug_no_panic(
+        MultiSpan::new(),
+        "It looks like you're trying to break rust; would you like some ICE?",
+    );
+    handler.note_without_error("the compiler expectedly panicked. this is a feature.");
+    handler.note_without_error(
+        "we would appreciate a joke overview: \
+        https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675"
+    );
+    handler.note_without_error(&format!("rustc {} running on {}",
+        option_env!("CFG_VERSION").unwrap_or("unknown_version"),
+        ::session::config::host_triple(),
+    ));
+}
index 4c608249ee95a4139e4e38e8bdb546d4d60e2ee5..f5ecedcebb49389738486d44631be6abaf63010c 100644 (file)
@@ -1525,9 +1525,9 @@ fn foo() -> _ { 5 } // error, explicitly write out the return type instead
 "##,
 
 E0122: r##"
-An attempt was made to add a generic constraint to a type alias. While Rust will
-allow this with a warning, it will not currently enforce the constraint.
-Consider the example below:
+An attempt was made to add a generic constraint to a type alias. This constraint
+is entirely ignored. For backwards compatibility, Rust still allows this with a
+warning. Consider the example below:
 
 ```
 trait Foo{}
index fc0adef70baa1da01307f902724ac1e8650132ba..563c5618759b721a11fa64c2975764d0acd8f194 100644 (file)
@@ -2141,8 +2141,8 @@ fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::
 
     if !types.is_empty() {
         write!(w, "
-            <h2 id='associated-types' class='section-header'>
-              <a href='#associated-types'>Associated Types</a>
+            <h2 id='associated-types' class='small-section-header'>
+              Associated Types<a href='#associated-types' class='anchor'></a>
             </h2>
             <div class='methods'>
         ")?;
@@ -2154,8 +2154,8 @@ fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::
 
     if !consts.is_empty() {
         write!(w, "
-            <h2 id='associated-const' class='section-header'>
-              <a href='#associated-const'>Associated Constants</a>
+            <h2 id='associated-const' class='small-section-header'>
+              Associated Constants<a href='#associated-const' class='anchor'></a>
             </h2>
             <div class='methods'>
         ")?;
@@ -2168,8 +2168,8 @@ fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::
     // Output the documentation for each function individually
     if !required.is_empty() {
         write!(w, "
-            <h2 id='required-methods' class='section-header'>
-              <a href='#required-methods'>Required Methods</a>
+            <h2 id='required-methods' class='small-section-header'>
+              Required Methods<a href='#required-methods' class='anchor'></a>
             </h2>
             <div class='methods'>
         ")?;
@@ -2180,8 +2180,8 @@ fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::
     }
     if !provided.is_empty() {
         write!(w, "
-            <h2 id='provided-methods' class='section-header'>
-              <a href='#provided-methods'>Provided Methods</a>
+            <h2 id='provided-methods' class='small-section-header'>
+              Provided Methods<a href='#provided-methods' class='anchor'></a>
             </h2>
             <div class='methods'>
         ")?;
@@ -2196,8 +2196,8 @@ fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::
 
     let cache = cache();
     write!(w, "
-        <h2 id='implementors' class='section-header'>
-          <a href='#implementors'>Implementors</a>
+        <h2 id='implementors' class='small-section-header'>
+          Implementors<a href='#implementors' class='anchor'></a>
         </h2>
         <ul class='item-list' id='implementors-list'>
     ")?;
@@ -2436,8 +2436,8 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
     }).peekable();
     if let doctree::Plain = s.struct_type {
         if fields.peek().is_some() {
-            write!(w, "<h2 id='fields' class='fields section-header'>
-                       <a href='#fields'>Fields</a></h2>")?;
+            write!(w, "<h2 id='fields' class='fields small-section-header'>
+                       Fields<a href='#fields' class='anchor'></a></h2>")?;
             for (field, ty) in fields {
                 let id = derive_id(format!("{}.{}",
                                            ItemType::StructField,
@@ -2485,8 +2485,8 @@ fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
         }
     }).peekable();
     if fields.peek().is_some() {
-        write!(w, "<h2 id='fields' class='fields section-header'>
-                   <a href='#fields'>Fields</a></h2>")?;
+        write!(w, "<h2 id='fields' class='fields small-section-header'>
+                   Fields<a href='#fields' class='anchor'></a></h2>")?;
         for (field, ty) in fields {
             write!(w, "<span id='{shortty}.{name}' class=\"{shortty}\"><code>{name}: {ty}</code>
                        </span>",
@@ -2558,8 +2558,8 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
 
     document(w, cx, it)?;
     if !e.variants.is_empty() {
-        write!(w, "<h2 id='variants' class='variants section-header'>
-                   <a href='#variants'>Variants</a></h2>\n")?;
+        write!(w, "<h2 id='variants' class='variants small-section-header'>
+                   Variants<a href='#variants' class='anchor'></a></h2>\n")?;
         for variant in &e.variants {
             let id = derive_id(format!("{}.{}",
                                        ItemType::Variant,
@@ -2831,16 +2831,16 @@ fn render_assoc_items(w: &mut fmt::Formatter,
         let render_mode = match what {
             AssocItemRender::All => {
                 write!(w, "
-                    <h2 id='methods' class='section-header'>
-                      <a href='#methods'>Methods</a>
+                    <h2 id='methods' class='small-section-header'>
+                      Methods<a href='#methods' class='anchor'></a>
                     </h2>
                 ")?;
                 RenderMode::Normal
             }
             AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => {
                 write!(w, "
-                    <h2 id='deref-methods' class='section-header'>
-                      <a href='#deref-methods'>Methods from {}&lt;Target = {}&gt;</a>
+                    <h2 id='deref-methods' class='small-section-header'>
+                      Methods from {}&lt;Target = {}&gt;<a href='#deref-methods' class='anchor'></a>
                     </h2>
                 ", trait_, type_)?;
                 RenderMode::ForDeref { mut_: deref_mut_ }
@@ -2865,8 +2865,8 @@ fn render_assoc_items(w: &mut fmt::Formatter,
             render_deref_methods(w, cx, impl_, containing_item, has_deref_mut)?;
         }
         write!(w, "
-            <h2 id='implementations' class='section-header'>
-              <a href='#implementations'>Trait Implementations</a>
+            <h2 id='implementations' class='small-section-header'>
+              Trait Implementations<a href='#implementations' class='anchor'></a>
             </h2>
         ")?;
         for i in &traits {
index 51465bafc42e23f10b4ab947ed366c0163e145df..ee94f0baeb9a39bdf9cf590adc1b4c88878ab00b 100644 (file)
@@ -438,6 +438,16 @@ a {
        background: transparent;
 }
 
+.small-section-header:hover > .anchor {
+       display: initial;
+}
+.anchor {
+       display: none;
+}
+.anchor:after {
+       content: '\2002\00a7\2002';
+}
+
 .docblock a:hover, .docblock-short a:hover, .stability a {
        text-decoration: underline;
 }
@@ -677,6 +687,10 @@ span.since {
        left: 0;
 }
 
+.variant + .toggle-wrapper + .docblock > p {
+       margin-top: 5px;
+}
+
 .variant + .toggle-wrapper > a {
        margin-top: 5px;
 }
@@ -695,7 +709,7 @@ span.since {
        margin-bottom: 25px;
 }
 
-.enum .variant, .struct .structfield, .union .structfield {
+#main > .variant, #main > .structfield {
        display: block;
 }
 
index 38d3312b4e7dd6a7569cdd5381de742edc8e538e..062186ef70866fec67ef4d4676950b5bc3dc02e1 100644 (file)
@@ -28,7 +28,7 @@
 /// A reference to an open file on the filesystem.
 ///
 /// An instance of a `File` can be read and/or written depending on what options
-/// it was opened with. Files also implement `Seek` to alter the logical cursor
+/// it was opened with. Files also implement [`Seek`] to alter the logical cursor
 /// that the file contains internally.
 ///
 /// Files are automatically closed when they go out of scope.
@@ -48,7 +48,7 @@
 /// # }
 /// ```
 ///
-/// Read the contents of a file into a `String`:
+/// Read the contents of a file into a [`String`]:
 ///
 /// ```no_run
 /// use std::fs::File;
@@ -81,6 +81,8 @@
 /// # }
 /// ```
 ///
+/// [`Seek`]: ../io/trait.Seek.html
+/// [`String`]: ../string/struct.String.html
 /// [`Read`]: ../io/trait.Read.html
 /// [`BufReader<R>`]: ../io/struct.BufReader.html
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -104,19 +106,19 @@ pub struct File {
 /// Iterator over the entries in a directory.
 ///
 /// This iterator is returned from the [`read_dir`] function of this module and
-/// will yield instances of `io::Result<DirEntry>`. Through a [`DirEntry`]
+/// will yield instances of [`io::Result`]`<`[`DirEntry`]`>`. Through a [`DirEntry`]
 /// information like the entry's path and possibly other metadata can be
 /// learned.
 ///
-/// [`read_dir`]: fn.read_dir.html
-/// [`DirEntry`]: struct.DirEntry.html
-///
 /// # Errors
 ///
-/// This [`io::Result`] will be an `Err` if there's some sort of intermittent
+/// This [`io::Result`] will be an [`Err`] if there's some sort of intermittent
 /// IO error during iteration.
 ///
+/// [`read_dir`]: fn.read_dir.html
+/// [`DirEntry`]: struct.DirEntry.html
 /// [`io::Result`]: ../io/type.Result.html
+/// [`Err`]: ../result/enum.Result.html#variant.Err
 #[stable(feature = "rust1", since = "1.0.0")]
 #[derive(Debug)]
 pub struct ReadDir(fs_imp::ReadDir);
index 0a5804a774411c0b078d8070bc5b944283461dc2..68f55221a6c985f1fb7ee84718afcd9e9d97c52b 100644 (file)
 /// A specialized [`Result`](../result/enum.Result.html) type for I/O
 /// operations.
 ///
-/// This type is broadly used across `std::io` for any operation which may
+/// This type is broadly used across [`std::io`] for any operation which may
 /// produce an error.
 ///
-/// This typedef is generally used to avoid writing out `io::Error` directly and
-/// is otherwise a direct mapping to `Result`.
+/// This typedef is generally used to avoid writing out [`io::Error`] directly and
+/// is otherwise a direct mapping to [`Result`].
 ///
-/// While usual Rust style is to import types directly, aliases of `Result`
-/// often are not, to make it easier to distinguish between them. `Result` is
-/// generally assumed to be `std::result::Result`, and so users of this alias
+/// While usual Rust style is to import types directly, aliases of [`Result`]
+/// often are not, to make it easier to distinguish between them. [`Result`] is
+/// generally assumed to be [`std::result::Result`][`Result`], and so users of this alias
 /// will generally use `io::Result` instead of shadowing the prelude's import
-/// of `std::result::Result`.
+/// of [`std::result::Result`][`Result`].
+///
+/// [`std::io`]: ../io/index.html
+/// [`io::Error`]: ../io/struct.Error.html
+/// [`Result`]: ../result/enum.Result.html
 ///
 /// # Examples
 ///
 #[stable(feature = "rust1", since = "1.0.0")]
 pub type Result<T> = result::Result<T, Error>;
 
-/// The error type for I/O operations of the `Read`, `Write`, `Seek`, and
+/// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and
 /// associated traits.
 ///
 /// Errors mostly originate from the underlying OS, but custom instances of
 /// `Error` can be created with crafted error messages and a particular value of
 /// [`ErrorKind`].
 ///
+/// [`Read`]: ../io/trait.Read.html
+/// [`Write`]: ../io/trait.Write.html
+/// [`Seek`]: ../io/trait.Seek.html
 /// [`ErrorKind`]: enum.ErrorKind.html
 #[derive(Debug)]
 #[stable(feature = "rust1", since = "1.0.0")]
index 9a3036f753ed314e155321dea34d8acfdaea0a92..f486493f98b4c275f6ac3d37ebe612c494f703db 100644 (file)
@@ -22,7 +22,7 @@
 //! you'll see a few different types of I/O throughout the documentation in
 //! this module: [`File`]s, [`TcpStream`]s, and sometimes even [`Vec<T>`]s. For
 //! example, [`Read`] adds a [`read`][`Read::read`] method, which we can use on
-//! `File`s:
+//! [`File`]s:
 //!
 //! ```
 //! use std::io;
 //! # }
 //! ```
 //!
-//! Note that you cannot use the `?` operator in functions that do not return
-//! a `Result<T, E>` (e.g. `main`). Instead, you can call `.unwrap()` or `match`
-//! on the return value to catch any possible errors:
+//! Note that you cannot use the [`?` operator] in functions that do not return
+//! a [`Result<T, E>`][`Result`] (e.g. `main`). Instead, you can call [`.unwrap()`]
+//! or `match` on the return value to catch any possible errors:
 //!
 //! ```
 //! use std::io;
 //! [`io::Result`]: type.Result.html
 //! [`?` operator]: ../../book/first-edition/syntax-index.html
 //! [`Read::read`]: trait.Read.html#tymethod.read
+//! [`Result`]: ../result/enum.Result.html
+//! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
index bd9c9c747848921fee9f6d089edf9670060ef4f0..f7748aa3f041f43a51a0f20002e331b00626b71e 100644 (file)
 
 #![default_lib_allocator]
 
+// Always use alloc_system during stage0 since we don't know if the alloc_*
+// crate the stage0 compiler will pick by default is enabled (e.g.
+// if the user has disabled jemalloc in `./configure`).
+// `force_alloc_system` is *only* intended as a workaround for local rebuilds
+// with a rustc without jemalloc.
+// The not(stage0+msvc) gates will only last until the next stage0 bump
+#![cfg_attr(all(
+        not(all(stage0, target_env = "msvc")),
+        any(stage0, feature = "force_alloc_system")),
+    feature(global_allocator))]
+#[cfg(all(
+    not(all(stage0, target_env = "msvc")),
+    any(stage0, feature = "force_alloc_system")))]
+#[global_allocator]
+static ALLOC: alloc_system::System = alloc_system::System;
+
 // Explicitly import the prelude. The compiler uses this same unstable attribute
 // to import the prelude implicitly when building crates that depend on std.
 #[prelude_import]
index 1e5368896af9100ff44819bb3f8d34c4ffc84920..0abf8179cc971ff1fdc9092636c87e0a72fa00e5 100644 (file)
@@ -466,7 +466,7 @@ pub fn is_link_local(&self) -> bool {
     /// - test addresses used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
     /// - the unspecified address (0.0.0.0)
     ///
-    /// [ipv4-sr]: http://goo.gl/RaZ7lg
+    /// [ipv4-sr]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
     /// [`true`]: ../../std/primitive.bool.html
     ///
     /// # Examples
index 94b87a6bff4908bbef10994688bdd9146fd52624..7701ae25b418f792bd1e124891927931c967db25 100644 (file)
@@ -655,7 +655,7 @@ fn inner(path: &Path) -> io::Result<UnixListener> {
     /// Accepts a new incoming connection to this listener.
     ///
     /// This function will block the calling thread until a new Unix connection
-    /// is established. When established, the corersponding [`UnixStream`] and
+    /// is established. When established, the corresponding [`UnixStream`] and
     /// the remote peer's address will be returned.
     ///
     /// [`UnixStream`]: ../../../../std/os/unix/net/struct.UnixStream.html
index 7eeafa72c682966ce6687772389c6399e3023f7b..194d30e25d41082e9f8bf5dc12c88b694af38d68 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-pub use self::SyntaxExtension::{MultiDecorator, MultiModifier, NormalTT, IdentTT};
+pub use self::SyntaxExtension::*;
 
 use ast::{self, Attribute, Name, PatKind, MetaItem};
 use attr::HasAttrs;
index 16c264e0f941028e4cb59d636d58caed8500f09b..4843a66a750fab71473d1f297eb8fb2a9bb231a4 100644 (file)
@@ -294,7 +294,7 @@ fn expand(&mut self, expansion: Expansion) -> Expansion {
                         let item = match self.cx.resolver.resolve_macro(
                                 Mark::root(), path, MacroKind::Derive, false) {
                             Ok(ext) => match *ext {
-                                SyntaxExtension::BuiltinDerive(..) => item_with_markers.clone(),
+                                BuiltinDerive(..) => item_with_markers.clone(),
                                 _ => item.clone(),
                             },
                             _ => item.clone(),
@@ -427,7 +427,7 @@ fn expand_attr_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) ->
                 items.push(item);
                 kind.expect_from_annotatables(items)
             }
-            SyntaxExtension::AttrProcMacro(ref mac) => {
+            AttrProcMacro(ref mac) => {
                 let item_tok = TokenTree::Token(DUMMY_SP, Token::interpolated(match item {
                     Annotatable::Item(item) => token::NtItem(item),
                     Annotatable::TraitItem(item) => token::NtTraitItem(item.unwrap()),
@@ -436,7 +436,7 @@ fn expand_attr_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) ->
                 let tok_result = mac.expand(self.cx, attr.span, attr.tokens, item_tok);
                 self.parse_expansion(tok_result, kind, &attr.path, attr.span)
             }
-            SyntaxExtension::ProcMacroDerive(..) | SyntaxExtension::BuiltinDerive(..) => {
+            ProcMacroDerive(..) | BuiltinDerive(..) => {
                 self.cx.span_err(attr.span, &format!("`{}` is a derive mode", attr.path));
                 kind.dummy(attr.span)
             }
@@ -474,7 +474,7 @@ fn expand_bang_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) ->
         };
 
         let opt_expanded = match *ext {
-            SyntaxExtension::DeclMacro(ref expand, def_span) => {
+            DeclMacro(ref expand, def_span) => {
                 if let Err(msg) = validate_and_set_expn_info(def_span.map(|(_, s)| s),
                                                              false) {
                     self.cx.span_err(path.span, &msg);
@@ -512,18 +512,18 @@ fn expand_bang_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) ->
                 kind.make_from(expander.expand(self.cx, span, ident, input))
             }
 
-            MultiDecorator(..) | MultiModifier(..) | SyntaxExtension::AttrProcMacro(..) => {
+            MultiDecorator(..) | MultiModifier(..) | AttrProcMacro(..) => {
                 self.cx.span_err(path.span,
                                  &format!("`{}` can only be used in attributes", path));
                 return kind.dummy(span);
             }
 
-            SyntaxExtension::ProcMacroDerive(..) | SyntaxExtension::BuiltinDerive(..) => {
+            ProcMacroDerive(..) | BuiltinDerive(..) => {
                 self.cx.span_err(path.span, &format!("`{}` is a derive mode", path));
                 return kind.dummy(span);
             }
 
-            SyntaxExtension::ProcMacro(ref expandfun) => {
+            ProcMacro(ref expandfun) => {
                 if ident.name != keywords::Invalid.name() {
                     let msg =
                         format!("macro {}! expects no ident argument, given '{}'", path, ident);
@@ -582,7 +582,7 @@ fn expand_derive_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) -
         };
 
         match *ext {
-            SyntaxExtension::ProcMacroDerive(ref ext, _) => {
+            ProcMacroDerive(ref ext, _) => {
                 invoc.expansion_data.mark.set_expn_info(expn_info);
                 let span = Span { ctxt: self.cx.backtrace(), ..span };
                 let dummy = ast::MetaItem { // FIXME(jseyfried) avoid this
@@ -592,7 +592,7 @@ fn expand_derive_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) -
                 };
                 kind.expect_from_annotatables(ext.expand(self.cx, span, &dummy, item))
             }
-            SyntaxExtension::BuiltinDerive(func) => {
+            BuiltinDerive(func) => {
                 expn_info.callee.allow_internal_unstable = true;
                 invoc.expansion_data.mark.set_expn_info(expn_info);
                 let span = Span { ctxt: self.cx.backtrace(), ..span };
index 85df4eee9134440c3222dcb59378fe94f1779d90..c36fdef2d4c1dd9f9117a11f560654eb2b1a1b45 100644 (file)
@@ -82,7 +82,7 @@
     ('։', "Armenian Full Stop", ':'),
     ('܃', "Syriac Supralinear Colon", ':'),
     ('܄', "Syriac Sublinear Colon", ':'),
-    ('᛬', "Runic Multiple Ponctuation", ':'),
+    ('᛬', "Runic Multiple Punctuation", ':'),
     ('︰', "Presentation Form For Vertical Two Dot Leader", ':'),
     ('᠃', "Mongolian Full Stop", ':'),
     ('᠉', "Mongolian Manchu Full Stop", ':'),
     ('ꝸ', "Latin Small Letter Um", '&'),
     ('&', "Fullwidth Ampersand", '&'),
 
-    ('᛭', "Runic Cros Punctuation", '+'),
+    ('᛭', "Runic Cross Punctuation", '+'),
     ('➕', "Heavy Plus Sign", '+'),
     ('𐊛', "Lycian Letter H", '+'),
     ('﬩', "Hebrew Letter Alternative Plus Sign", '+'),
index 65f4b6350c4eed4f578d9d78bc61949360b66a4f..00a27818327f6692afb55eb9f74003319ecdba99 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:attribute-with-error.rs
+// ignore-stage1
 
 #![feature(proc_macro)]
 
index f42d1006bf5c1c18a3bdfe4539ce84879b54e68c..2adbee1d3fbd5b7c23bf58667d33f00e893c1c54 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:attributes-included.rs
+// ignore-stage1
 
 #![feature(proc_macro, rustc_attrs)]
 #![warn(unused)]
index 42fad803bfa68ae345d5643ff0ae3b0e99fbdadb..b03409c9c285e69b1b34db4e5c594a86e695bec7 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:derive-bad.rs
+// ignore-stage1
 
 #[macro_use]
 extern crate derive_bad;
index e4fcbb117a5057c0dd55eb757713496102a08bad..6f254dcbdb11a361f602bbc989ac3f38e645aa03 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:derive-unstable-2.rs
+// ignore-stage1
 
 #![allow(warnings)]
 
index 836e336fc22f013e86983a5c0530a0ebac944719..ca0f0e382ed0c2af76d303ca4eef7fefb0cf7e48 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:derive-unstable.rs
+// ignore-stage1
 
 #![allow(warnings)]
 
index 42475e6de90c982178efac63a4c3cde5685f6edd..1d645a7ec510fe420509ea39d600d30c06544218 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:issue_38586.rs
+// ignore-stage1
 
 #![feature(proc_macro)]
 
index 4133e75e3a62d8f33ca7d1c80a1db23e020b544a..c0d4d71a6ec8be6356729db5b5dee4c835b7f398 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:derive-b.rs
+// ignore-stage1
 
 #![allow(warnings)]
 
index 93dead1a156851ca0a69b4861540b0f3e86f6e91..b1fb7d42d8683b064f1b88bafa85fa093fc70a5e 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:bang_proc_macro2.rs
+// ignore-stage1
 
 #![feature(proc_macro)]
 #![allow(unused_macros)]
index df881bedec1bbf5202dfd618eefe913c658c13fc..153e4dd05717a42f6ae0933ccc31ec88a938af7c 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:derive-b.rs
+// ignore-stage1
 
 #![allow(warnings)]
 
diff --git a/src/test/compile-fail/issue-43162.rs b/src/test/compile-fail/issue-43162.rs
new file mode 100644 (file)
index 0000000..8f46612
--- /dev/null
@@ -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
+}
index 9ac76a5f4ea614fd2af8480ff4b6ad1ffc316286..677c92ea71b7a78a64241da9c9fe7cd7afe13c39 100644 (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 @@ fn foo(&self, _x: &mut i32) {}
 
 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
index 591de975740f9fd572883f2156ad82ff75987706..2ee459d6809c55d771eccf02872a0631b5f5286f 100644 (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
index e9919af9fd3a6fec243a75c3979d7002836d6073..0182e6e2964452c5627f49503ace6d7b5eff7498 100644 (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
index f17ce537fb813dacf340d0cc9762262076421924..8b3355b96226aa8e5d1f9fbf550cf00f9c365b81 100644 (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
index 27b69baf97787b794b246d27c0df5c4e4db99f50..c7732cc2682b1a044ee1cdd247f1aeb08b85e59f 100644 (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
index 0a681401b1afbdd4eff22b4e5968c25e22d84832..855d958b344a9531a3aa998ff1e89a04bd869e0a 100644 (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
index aab6e895f22609fb87dd8951c46b0d191a259b97..0d31d2c823500ab64d6d9412b77de4300d71db1d 100644 (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
index e3a6776c8080b5426e1af2ffb476e8c4a34a11cd..1ab27397e3146bbafa134862eca203a4763c2a35 100644 (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
index d030eab64e564026301e6996e34b55d8e6775681..8cb9dc4a1b6ec5ca2aab7dc2c9cb1c1a781874c4 100644 (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)]
index 7ea7ceafc28766d6a12f0263aa324c950ff8da9e..5175fe174a9e743230b9b4bb887a91b9da128c88 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:add-impl.rs
+// ignore-stage1
 
 #[macro_use]
 extern crate add_impl;
index 591f3331d28c00382f421852d34df791cf43c583..37aef7ef1318c4dd6b6f520e205070e7d6348d65 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:append-impl.rs
+// ignore-stage1
 
 #![allow(warnings)]
 
index 8a9fdd7536770dc07fdd3357f63e0893e08654c9..2968cc7871d7e1ac04691b19e98401ec3772ada4 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:attr-args.rs
+// ignore-stage1
 
 #![allow(warnings)]
 #![feature(proc_macro)]
index 531bd0dd3569d9b0a191c3330950d60599a8173d..ffa4731f1e6371b0153a9929298a8aebc8cdab89 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:bang-macro.rs
+// ignore-stage1
 
 #![feature(proc_macro)]
 
index 1a2b144e4717bae285eeb833986f12c6c5f13d30..00ad0e76ed014c10c2bf8bcf2f1bf9b538d2fcfe 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:count_compound_ops.rs
+// ignore-stage1
 
 #![feature(proc_macro)]
 
index ba1417ecb56e408cf96d2db98c384b32fa4c96f2..b6acb0faab2a531d1aef4faef0bbf434f173a38d 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:double.rs
+// ignore-stage1
 
 #![allow(unused)]
 
index ce3ba60b0ecf4b264b17523a8c209cf675416f86..ba5a639a759cb826f156524c92730897f7420119 100644 (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;
index 51198db5aa76d137fdc81d1da315c29ed7ae0113..4cac7d19b4de8f2472d9fd78d4359bfbce414d61 100644 (file)
@@ -10,6 +10,7 @@
 
 // aux-build:hygiene_example_codegen.rs
 // aux-build:hygiene_example.rs
+// ignore-stage1
 
 #![feature(proc_macro)]
 
index 05610116ad6bff88c260bb5607242612fcef1f8b..87130242c0f04035331fda007066e1f0ee9af507 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:issue-39889.rs
+// ignore-stage1
 
 #![feature(proc_macro)]
 #![allow(unused)]
index 54e84b7f6189fd9be35f9e8c657bdd4b10e8bd85..b7826edd8b4e5215c82aba9325d639a82cf2935e 100644 (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)]
index d15a83a2cbe432afc4fb8a17261e10ce24876fac..67c12377814704d84d2abcc32464ab60d8e2996a 100644 (file)
@@ -10,6 +10,7 @@
 
 // aux-build:derive-atob.rs
 // aux-build:derive-ctod.rs
+// ignore-stage1
 
 #[macro_use]
 extern crate derive_atob;
index f0a1bfe652857989c9b5dfacf4a74b79f08ea12b..03dfeb1f5c9a5ce99edcd0f506352d5df154bd97 100644 (file)
@@ -10,6 +10,7 @@
 
 // aux-build:derive-a.rs
 // aux-build:derive-reexport.rs
+// ignore-stage1
 
 #[macro_use]
 extern crate derive_reexport;
index 1d5c83bc20d9554c3244eaa3d7513d1982d7f255..39053769b24b59d9aff3ffb37128675726c760f0 100644 (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);
 }
index 827b05c0801e1eb39b5650defc365315f411b3d3..2865b5d04e5be61d4bdaf6ca522d5dac1c7be7ea 100644 (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
     {
index 20f58301d45244adfa7c0ded2515b3234bce9be2..64fd9e0a7721b833de1877fd4abb12964d6b01f2 100644 (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();
 }
index 1065749a6961ce5c19fcfcde01fbabccfc5517b7..10c99713820460eb869c88688b6ee7196849e3e4 100644 (file)
@@ -69,6 +69,7 @@
     "src/libstd/path.rs",
     "src/libstd/f32.rs",
     "src/libstd/f64.rs",
+    "src/libstd/lib.rs", // Until next stage0 snapshot bump
     "src/libstd/sys_common/mod.rs",
     "src/libstd/sys_common/net.rs",
     "src/libterm", // Not sure how to make this crate portable, but test needs it
index b42beb37821cef09e09f52073161ad62b2cd0eda..a689d8a8be4119d2808ed086b6a83cc81cfb4aa1 100644 (file)
@@ -83,7 +83,7 @@ fn line_is_url(line: &str) -> bool {
                 => state = EXP_END,
 
             (EXP_URL, w)
-                if w.starts_with("http://") || w.starts_with("https://")
+                if w.starts_with("http://") || w.starts_with("https://") || w.starts_with("../")
                 => state = EXP_END,
 
             (_, _) => return false,