From 5d79e8c4c97388dd1201135b8d6cfadccfd3c8e3 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sat, 13 Jul 2019 18:02:00 +0300 Subject: [PATCH 01/30] reserve `impl From for T` this is necessary for never-type stabilization --- src/libcore/convert.rs | 6 +++++ src/librustc/traits/select.rs | 21 ++++++++++++--- src/librustc/ty/mod.rs | 28 +++++++++++++------- src/librustc_typeck/check/wfcheck.rs | 29 ++++++++++++--------- src/libsyntax/feature_gate/builtin_attrs.rs | 4 +++ src/libsyntax_pos/symbol.rs | 1 + src/test/ui/never-impl-is-reserved.rs | 12 +++++++++ src/test/ui/never-impl-is-reserved.stderr | 12 +++++++++ 8 files changed, 87 insertions(+), 26 deletions(-) create mode 100644 src/test/ui/never-impl-is-reserved.rs create mode 100644 src/test/ui/never-impl-is-reserved.stderr diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 06f2b7bab12eb..82c20efa9f0d6 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -554,6 +554,12 @@ impl From for T { fn from(t: T) -> T { t } } +#[stable(feature = "convert_infallible", since = "1.34.0")] +#[cfg(not(boostrap_stdarch_ignore_this))] +#[rustc_reservation_impl] +impl From for T { + fn from(t: !) -> T { t } +} // TryFrom implies TryInto #[stable(feature = "try_from", since = "1.34.0")] diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index a54bc05f16961..debd946d7164f 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -50,6 +50,8 @@ use std::iter; use std::rc::Rc; use crate::util::nodemap::{FxHashMap, FxHashSet}; +use syntax::symbol::sym; + pub struct SelectionContext<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, @@ -1326,8 +1328,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { (result, dep_node) } - // Treat negative impls as unimplemented - fn filter_negative_impls( + // Treat negative impls as unimplemented, and reservation impls as Ok(None) + fn filter_negative_and_reservation_impls( &self, candidate: SelectionCandidate<'tcx>, ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> { @@ -1337,6 +1339,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { { return Err(Unimplemented); } + + if self.tcx().has_attr(def_id, sym::rustc_reservation_impl) { + return Ok(None); + } } Ok(Some(candidate)) } @@ -1453,7 +1459,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Instead, we select the right impl now but report `Bar does // not implement Clone`. if candidates.len() == 1 { - return self.filter_negative_impls(candidates.pop().unwrap()); + return self.filter_negative_and_reservation_impls(candidates.pop().unwrap()); } // Winnow, but record the exact outcome of evaluation, which @@ -1528,7 +1534,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } // Just one candidate left. - self.filter_negative_impls(candidates.pop().unwrap().candidate) + self.filter_negative_and_reservation_impls(candidates.pop().unwrap().candidate) } fn is_knowable<'o>(&mut self, stack: &TraitObligationStack<'o, 'tcx>) -> Option { @@ -3728,6 +3734,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { return Err(()); } + if self.intercrate.is_none() && + self.tcx().has_attr(impl_def_id, sym::rustc_reservation_impl) + { + debug!("match_impl: reservation impls only apply in intercrate mode"); + return Err(()); + } + debug!("match_impl: success impl_substs={:?}", impl_substs); Ok(Normalized { value: impl_substs, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 8bb9648e031ef..c5cbe0d0dabe7 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2911,7 +2911,13 @@ impl<'tcx> TyCtxt<'tcx> { return Some(ImplOverlapKind::Permitted); } - let is_legit = if self.features().overlapping_marker_traits { + if self.impl_polarity(def_id1) != self.impl_polarity(def_id2) { + debug!("impls_are_allowed_to_overlap({:?}, {:?}) - different polarities, None", + def_id1, def_id2); + return None; + } + + let is_marker_overlap = if self.features().overlapping_marker_traits { let trait1_is_empty = self.impl_trait_ref(def_id1) .map_or(false, |trait_ref| { self.associated_item_def_ids(trait_ref.def_id).is_empty() @@ -2920,22 +2926,24 @@ impl<'tcx> TyCtxt<'tcx> { .map_or(false, |trait_ref| { self.associated_item_def_ids(trait_ref.def_id).is_empty() }); - self.impl_polarity(def_id1) == self.impl_polarity(def_id2) - && trait1_is_empty - && trait2_is_empty + trait1_is_empty && trait2_is_empty } else { let is_marker_impl = |def_id: DefId| -> bool { let trait_ref = self.impl_trait_ref(def_id); trait_ref.map_or(false, |tr| self.trait_def(tr.def_id).is_marker) }; - self.impl_polarity(def_id1) == self.impl_polarity(def_id2) - && is_marker_impl(def_id1) - && is_marker_impl(def_id2) + is_marker_impl(def_id1) && is_marker_impl(def_id2) }; - if is_legit { - debug!("impls_are_allowed_to_overlap({:?}, {:?}) = Some(Permitted)", - def_id1, def_id2); + // `#[rustc_reservation_impl]` impls don't overlap with anything + let is_reserve_overlap = { + self.has_attr(def_id1, sym::rustc_reservation_impl) || + self.has_attr(def_id2, sym::rustc_reservation_impl) + }; + + if is_marker_overlap || is_reserve_overlap { + debug!("impls_are_allowed_to_overlap({:?}, {:?}) = Some(Permitted) ({:?}/{:?})", + def_id1, def_id2, is_marker_overlap, is_reserve_overlap); Some(ImplOverlapKind::Permitted) } else { if let Some(self_ty1) = self.issue33140_self_ty(def_id1) { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index b0e886a2aa2eb..87c34d62bde0a 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -398,18 +398,23 @@ fn check_impl<'tcx>( match *ast_trait_ref { Some(ref ast_trait_ref) => { - let trait_ref = fcx.tcx.impl_trait_ref(item_def_id).unwrap(); - let trait_ref = - fcx.normalize_associated_types_in( - ast_trait_ref.path.span, &trait_ref); - let obligations = - ty::wf::trait_obligations(fcx, - fcx.param_env, - fcx.body_id, - &trait_ref, - ast_trait_ref.path.span); - for obligation in obligations { - fcx.register_predicate(obligation); + // `#[rustc_reservation_impl]` impls are not real impls and + // therefore don't need to be WF (the trait's `Self: Trait` predicate + // won't hold). + if !fcx.tcx.has_attr(item_def_id, sym::rustc_reservation_impl) { + let trait_ref = fcx.tcx.impl_trait_ref(item_def_id).unwrap(); + let trait_ref = + fcx.normalize_associated_types_in( + ast_trait_ref.path.span, &trait_ref); + let obligations = + ty::wf::trait_obligations(fcx, + fcx.param_env, + fcx.body_id, + &trait_ref, + ast_trait_ref.path.span); + for obligation in obligations { + fcx.register_predicate(obligation); + } } } None => { diff --git a/src/libsyntax/feature_gate/builtin_attrs.rs b/src/libsyntax/feature_gate/builtin_attrs.rs index b6e13200f32af..d38489a2f0db9 100644 --- a/src/libsyntax/feature_gate/builtin_attrs.rs +++ b/src/libsyntax/feature_gate/builtin_attrs.rs @@ -498,6 +498,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ overflow checking behavior of several libcore functions that are inlined \ across crates and will never be stable", ), + rustc_attr!(rustc_reservation_impl, Normal, template!(Word), + "the `#[rustc_reservation_impl]` attribute is internally used \ + for reserving for `for From for T` impl" + ), rustc_attr!( rustc_test_marker, Normal, template!(Word), "the `#[rustc_test_marker]` attribute is used internally to track tests", diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 597ae83572cee..32af930ffb884 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -606,6 +606,7 @@ symbols! { rustc_std_internal_symbol, rustc_symbol_name, rustc_synthetic, + rustc_reservation_impl, rustc_test_marker, rustc_then_this_would_need, rustc_variance, diff --git a/src/test/ui/never-impl-is-reserved.rs b/src/test/ui/never-impl-is-reserved.rs new file mode 100644 index 0000000000000..9d16015bdc129 --- /dev/null +++ b/src/test/ui/never-impl-is-reserved.rs @@ -0,0 +1,12 @@ +// check that the `for T: From` impl is reserved + +#![feature(never_type)] + +pub struct MyFoo; +pub trait MyTrait {} + +impl MyTrait for MyFoo {} +// This will conflict with the first impl if we impl `for T: From`. +impl MyTrait for T where T: From {} //~ ERROR conflicting implementation + +fn main() {} diff --git a/src/test/ui/never-impl-is-reserved.stderr b/src/test/ui/never-impl-is-reserved.stderr new file mode 100644 index 0000000000000..09116eb4f7faf --- /dev/null +++ b/src/test/ui/never-impl-is-reserved.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyFoo`: + --> $DIR/never-impl-is-reserved.rs:10:1 + | +LL | impl MyTrait for MyFoo {} + | ---------------------- first implementation here +LL | // This will conflict with the first impl if we impl `for T: From`. +LL | impl MyTrait for T where T: From {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyFoo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. From 9a94ecde04306986dac1b7ca88b4b327b67ea499 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sat, 13 Jul 2019 22:52:57 +0300 Subject: [PATCH 02/30] improve and add tests --- ...rved.rs => never-from-impl-is-reserved.rs} | 0 ...err => never-from-impl-is-reserved.stderr} | 2 +- .../reservation-impl-coherence-conflict.rs | 16 +++++++++++ ...reservation-impl-coherence-conflict.stderr | 11 ++++++++ .../reservation-impl-no-use.rs | 14 ++++++++++ .../reservation-impl-no-use.stderr | 15 ++++++++++ .../reservation-impls/reservation-impl-ok.rs | 28 +++++++++++++++++++ 7 files changed, 85 insertions(+), 1 deletion(-) rename src/test/ui/{never-impl-is-reserved.rs => never-from-impl-is-reserved.rs} (100%) rename src/test/ui/{never-impl-is-reserved.stderr => never-from-impl-is-reserved.stderr} (91%) create mode 100644 src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs create mode 100644 src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr create mode 100644 src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs create mode 100644 src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr create mode 100644 src/test/ui/traits/reservation-impls/reservation-impl-ok.rs diff --git a/src/test/ui/never-impl-is-reserved.rs b/src/test/ui/never-from-impl-is-reserved.rs similarity index 100% rename from src/test/ui/never-impl-is-reserved.rs rename to src/test/ui/never-from-impl-is-reserved.rs diff --git a/src/test/ui/never-impl-is-reserved.stderr b/src/test/ui/never-from-impl-is-reserved.stderr similarity index 91% rename from src/test/ui/never-impl-is-reserved.stderr rename to src/test/ui/never-from-impl-is-reserved.stderr index 09116eb4f7faf..7e9b21a542933 100644 --- a/src/test/ui/never-impl-is-reserved.stderr +++ b/src/test/ui/never-from-impl-is-reserved.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyFoo`: - --> $DIR/never-impl-is-reserved.rs:10:1 + --> $DIR/never-from-impl-is-reserved.rs:10:1 | LL | impl MyTrait for MyFoo {} | ---------------------- first implementation here diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs new file mode 100644 index 0000000000000..1a5266f5583d6 --- /dev/null +++ b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs @@ -0,0 +1,16 @@ +// compile-fail + +// check that reservation impls are accounted for in negative reasoning. + +#![feature(rustc_attrs)] + +trait MyTrait {} +#[rustc_reservation_impl] +impl MyTrait for () {} + +trait OtherTrait {} +impl OtherTrait for () {} +impl OtherTrait for T {} +//~^ ERROR conflicting implementations + +fn main() {} diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr new file mode 100644 index 0000000000000..7b88d2b42db1b --- /dev/null +++ b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `OtherTrait` for type `()`: + --> $DIR/reservation-impl-coherence-conflict.rs:13:1 + | +LL | impl OtherTrait for () {} + | ---------------------- first implementation here +LL | impl OtherTrait for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs new file mode 100644 index 0000000000000..f08338bdc1c91 --- /dev/null +++ b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs @@ -0,0 +1,14 @@ +// compile-fail + +// check that reservation impls can't be used as normal impls in positive reasoning. + +#![feature(rustc_attrs)] + +trait MyTrait { fn foo(&self); } +#[rustc_reservation_impl] +impl MyTrait for () { fn foo(&self) {} } + +fn main() { + <() as MyTrait>::foo(&()); + //~^ ERROR the trait bound `(): MyTrait` is not satisfied +} diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr new file mode 100644 index 0000000000000..8a86f53086dd5 --- /dev/null +++ b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `(): MyTrait` is not satisfied + --> $DIR/reservation-impl-no-use.rs:12:5 + | +LL | trait MyTrait { fn foo(&self); } + | -------------- required by `MyTrait::foo` +... +LL | <() as MyTrait>::foo(&()); + | ^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `()` + | + = help: the following implementations were found: + <() as MyTrait> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs b/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs new file mode 100644 index 0000000000000..febd14b792297 --- /dev/null +++ b/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs @@ -0,0 +1,28 @@ +// run-pass + +// rpass test for reservation impls. Not 100% required because `From` uses them, +// but still. + +#![feature(rustc_attrs)] + +use std::mem; + +trait MyTrait { + fn foo(&self, s: S) -> usize; +} + +#[rustc_reservation_impl] +impl MyTrait for T { + fn foo(&self, _x: u64) -> usize { 0 } +} + +// reservation impls don't create coherence conflicts, even with +// non-chain overlap. +impl MyTrait for u32 { + fn foo(&self, _x: S) -> usize { mem::size_of::() } +} + +fn main() { + // ...and the non-reservation impl gets picked.XS + assert_eq!(0u32.foo(0u64), mem::size_of::()); +} From 1ec7ae14fa5b4b29f56d7085f632dd6301ad4815 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sun, 14 Jul 2019 00:09:46 +0300 Subject: [PATCH 03/30] resolve the rustc_reservation_impl attribute in 1 place --- src/librustc/query/mod.rs | 2 +- src/librustc/traits/auto_trait.rs | 2 +- src/librustc/traits/select.rs | 24 ++++++------- src/librustc/ty/mod.rs | 46 ++++++++++++++++-------- src/librustc_metadata/decoder.rs | 2 +- src/librustc_metadata/encoder.rs | 3 +- src/librustc_metadata/schema.rs | 2 +- src/librustc_traits/lowering/mod.rs | 5 +-- src/librustc_typeck/check/wfcheck.rs | 53 +++++++++++++++------------- src/librustc_typeck/collect.rs | 26 ++++++++++++-- src/librustdoc/clean/mod.rs | 13 ++++--- 11 files changed, 112 insertions(+), 66 deletions(-) diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index c7260945295a6..b937d1a30409a 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -286,7 +286,7 @@ rustc_queries! { query associated_item(_: DefId) -> ty::AssocItem {} query impl_trait_ref(_: DefId) -> Option> {} - query impl_polarity(_: DefId) -> hir::ImplPolarity {} + query impl_polarity(_: DefId) -> ty::ImplPolarity {} query issue33140_self_ty(_: DefId) -> Option> {} } diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index d89cf8eb3e843..c481943e25e37 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -321,7 +321,7 @@ impl AutoTraitFinder<'tcx> { match vtable { Vtable::VtableImpl(VtableImplData { impl_def_id, .. }) => { // Blame tidy for the weird bracket placement - if infcx.tcx.impl_polarity(*impl_def_id) == hir::ImplPolarity::Negative + if infcx.tcx.impl_polarity(*impl_def_id) == ty::ImplPolarity::Negative { debug!("evaluate_nested_obligations: Found explicit negative impl\ {:?}, bailing out", impl_def_id); diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index debd946d7164f..61bb53dd334fa 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -50,8 +50,6 @@ use std::iter; use std::rc::Rc; use crate::util::nodemap::{FxHashMap, FxHashSet}; -use syntax::symbol::sym; - pub struct SelectionContext<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, @@ -1334,15 +1332,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidate: SelectionCandidate<'tcx>, ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> { if let ImplCandidate(def_id) = candidate { - if !self.allow_negative_impls - && self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative - { - return Err(Unimplemented); - } - - if self.tcx().has_attr(def_id, sym::rustc_reservation_impl) { - return Ok(None); - } + match self.tcx().impl_polarity(def_id) { + ty::ImplPolarity::Negative if !self.allow_negative_impls => { + return Err(Unimplemented); + } + ty::ImplPolarity::Reservation => { + return Ok(None); + } + _ => {} + }; } Ok(Some(candidate)) } @@ -3734,8 +3732,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { return Err(()); } - if self.intercrate.is_none() && - self.tcx().has_attr(impl_def_id, sym::rustc_reservation_impl) + if self.intercrate.is_none() + && self.tcx().impl_polarity(impl_def_id) == ty::ImplPolarity::Reservation { debug!("match_impl: reservation impls only apply in intercrate mode"); return Err(()); diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index c5cbe0d0dabe7..b546a24534666 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -167,6 +167,16 @@ pub struct ImplHeader<'tcx> { pub predicates: Vec>, } +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)] +pub enum ImplPolarity { + /// `impl Trait for Type` + Positive, + /// `impl !Trait for Type` + Negative, + /// `#[rustc_reservation_impl] impl Trait for Type` + Reservation, +} + #[derive(Copy, Clone, Debug, PartialEq, HashStable)] pub struct AssocItem { pub def_id: DefId, @@ -2911,11 +2921,24 @@ impl<'tcx> TyCtxt<'tcx> { return Some(ImplOverlapKind::Permitted); } - if self.impl_polarity(def_id1) != self.impl_polarity(def_id2) { - debug!("impls_are_allowed_to_overlap({:?}, {:?}) - different polarities, None", - def_id1, def_id2); - return None; - } + match (self.impl_polarity(def_id1), self.impl_polarity(def_id2)) { + (ImplPolarity::Reservation, _) | + (_, ImplPolarity::Reservation) => { + // `#[rustc_reservation_impl]` impls don't overlap with anything + debug!("impls_are_allowed_to_overlap({:?}, {:?}) = Some(Permitted) (reservations)", + def_id1, def_id2); + return Some(ImplOverlapKind::Permitted); + } + (ImplPolarity::Positive, ImplPolarity::Negative) | + (ImplPolarity::Negative, ImplPolarity::Positive) => { + // FIXME: when can this happen? + debug!("impls_are_allowed_to_overlap({:?}, {:?}) - None (differing polarities)", + def_id1, def_id2); + return None; + } + (ImplPolarity::Positive, ImplPolarity::Positive) | + (ImplPolarity::Negative, ImplPolarity::Negative) => {} + }; let is_marker_overlap = if self.features().overlapping_marker_traits { let trait1_is_empty = self.impl_trait_ref(def_id1) @@ -2935,15 +2958,10 @@ impl<'tcx> TyCtxt<'tcx> { is_marker_impl(def_id1) && is_marker_impl(def_id2) }; - // `#[rustc_reservation_impl]` impls don't overlap with anything - let is_reserve_overlap = { - self.has_attr(def_id1, sym::rustc_reservation_impl) || - self.has_attr(def_id2, sym::rustc_reservation_impl) - }; - if is_marker_overlap || is_reserve_overlap { - debug!("impls_are_allowed_to_overlap({:?}, {:?}) = Some(Permitted) ({:?}/{:?})", - def_id1, def_id2, is_marker_overlap, is_reserve_overlap); + if is_marker_overlap { + debug!("impls_are_allowed_to_overlap({:?}, {:?}) = Some(Permitted) (marker overlap)", + def_id1, def_id2); Some(ImplOverlapKind::Permitted) } else { if let Some(self_ty1) = self.issue33140_self_ty(def_id1) { @@ -3325,7 +3343,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { debug!("issue33140_self_ty({:?}), trait-ref={:?}", def_id, trait_ref); let is_marker_like = - tcx.impl_polarity(def_id) == hir::ImplPolarity::Positive && + tcx.impl_polarity(def_id) == ty::ImplPolarity::Positive && tcx.associated_item_def_ids(trait_ref.def_id).is_empty(); // Check whether these impls would be ok for a marker trait. diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 34c84b1d79d4b..9785b69eaf09e 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -722,7 +722,7 @@ impl<'a, 'tcx> CrateMetadata { self.get_impl_data(id).parent_impl } - pub fn get_impl_polarity(&self, id: DefIndex) -> hir::ImplPolarity { + pub fn get_impl_polarity(&self, id: DefIndex) -> ty::ImplPolarity { self.get_impl_data(id).polarity } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index f430f01542efe..9bf0eefd9fe70 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1172,8 +1172,9 @@ impl EncodeContext<'tcx> { ctor_sig: None, }), repr_options) } - hir::ItemKind::Impl(_, polarity, defaultness, ..) => { + hir::ItemKind::Impl(_, _, defaultness, ..) => { let trait_ref = tcx.impl_trait_ref(def_id); + let polarity = tcx.impl_polarity(def_id); let parent = if let Some(trait_ref) = trait_ref { let trait_def = tcx.trait_def(trait_ref.def_id); trait_def.ancestors(tcx, def_id).nth(1).and_then(|node| { diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 1a5f0e17ba7ce..90967c7933323 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -327,7 +327,7 @@ pub struct TraitAliasData<'tcx> { #[derive(RustcEncodable, RustcDecodable)] pub struct ImplData<'tcx> { - pub polarity: hir::ImplPolarity, + pub polarity: ty::ImplPolarity, pub defaultness: hir::Defaultness, pub parent_impl: Option, diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 1558ce1bced52..51d49f0d59ae7 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -4,7 +4,7 @@ use rustc::hir::def::DefKind; use rustc::hir::def_id::DefId; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::map::definitions::DefPathData; -use rustc::hir::{self, ImplPolarity}; +use rustc::hir; use rustc::traits::{ Clause, Clauses, @@ -295,7 +295,8 @@ fn program_clauses_for_trait(tcx: TyCtxt<'_>, def_id: DefId) -> Clauses<'_> { } fn program_clauses_for_impl(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> { - if let ImplPolarity::Negative = tcx.impl_polarity(def_id) { + // FIXME: implement reservation impls. + if let ty::ImplPolarity::Negative = tcx.impl_polarity(def_id) { return List::empty(); } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 87c34d62bde0a..e0e878ffdcc47 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -94,20 +94,27 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: DefId) { // // won't be allowed unless there's an *explicit* implementation of `Send` // for `T` - hir::ItemKind::Impl(_, polarity, defaultness, _, ref trait_ref, ref self_ty, _) => { + hir::ItemKind::Impl(_, _, defaultness, _, ref trait_ref, ref self_ty, _) => { let is_auto = tcx.impl_trait_ref(tcx.hir().local_def_id(item.hir_id)) - .map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id)); + .map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id)); + let polarity = tcx.impl_polarity(def_id); if let (hir::Defaultness::Default { .. }, true) = (defaultness, is_auto) { tcx.sess.span_err(item.span, "impls of auto traits cannot be default"); } - if polarity == hir::ImplPolarity::Positive { - check_impl(tcx, item, self_ty, trait_ref); - } else { - // FIXME(#27579): what amount of WF checking do we need for neg impls? - if trait_ref.is_some() && !is_auto { - span_err!(tcx.sess, item.span, E0192, - "negative impls are only allowed for \ - auto traits (e.g., `Send` and `Sync`)") + match polarity { + ty::ImplPolarity::Positive => { + check_impl(tcx, item, self_ty, trait_ref); + } + ty::ImplPolarity::Negative => { + // FIXME(#27579): what amount of WF checking do we need for neg impls? + if trait_ref.is_some() && !is_auto { + span_err!(tcx.sess, item.span, E0192, + "negative impls are only allowed for \ + auto traits (e.g., `Send` and `Sync`)") + } + } + ty::ImplPolarity::Reservation => { + // FIXME: what amount of WF checking do we need for reservation impls? } } } @@ -401,20 +408,18 @@ fn check_impl<'tcx>( // `#[rustc_reservation_impl]` impls are not real impls and // therefore don't need to be WF (the trait's `Self: Trait` predicate // won't hold). - if !fcx.tcx.has_attr(item_def_id, sym::rustc_reservation_impl) { - let trait_ref = fcx.tcx.impl_trait_ref(item_def_id).unwrap(); - let trait_ref = - fcx.normalize_associated_types_in( - ast_trait_ref.path.span, &trait_ref); - let obligations = - ty::wf::trait_obligations(fcx, - fcx.param_env, - fcx.body_id, - &trait_ref, - ast_trait_ref.path.span); - for obligation in obligations { - fcx.register_predicate(obligation); - } + let trait_ref = fcx.tcx.impl_trait_ref(item_def_id).unwrap(); + let trait_ref = + fcx.normalize_associated_types_in( + ast_trait_ref.path.span, &trait_ref); + let obligations = + ty::wf::trait_obligations(fcx, + fcx.param_env, + fcx.body_id, + &trait_ref, + ast_trait_ref.path.span); + for obligation in obligations { + fcx.register_predicate(obligation); } } None => { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index d2e9203779cc8..4503bb264a5f7 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1866,10 +1866,30 @@ fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { } } -fn impl_polarity(tcx: TyCtxt<'_>, def_id: DefId) -> hir::ImplPolarity { +fn impl_polarity(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ImplPolarity { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); - match tcx.hir().expect_item(hir_id).node { - hir::ItemKind::Impl(_, polarity, ..) => polarity, + let is_rustc_reservation = tcx.has_attr(def_id, sym::rustc_reservation_impl); + let item = tcx.hir().expect_item(hir_id); + match &item.node { + hir::ItemKind::Impl(_, hir::ImplPolarity::Negative, ..) => { + if is_rustc_reservation { + tcx.sess.span_err(item.span, "reservation impls can't be negative"); + } + ty::ImplPolarity::Negative + } + hir::ItemKind::Impl(_, hir::ImplPolarity::Positive, _, _, None, _, _) => { + if is_rustc_reservation { + tcx.sess.span_err(item.span, "reservation impls can't be inherent"); + } + ty::ImplPolarity::Positive + } + hir::ItemKind::Impl(_, hir::ImplPolarity::Positive, _, _, Some(_tr), _, _) => { + if is_rustc_reservation { + ty::ImplPolarity::Reservation + } else { + ty::ImplPolarity::Positive + } + } ref item => bug!("impl_polarity: {:?} not an impl", item), } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ae70fdc530be6..15ada0952c8a3 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3864,11 +3864,13 @@ pub enum ImplPolarity { Negative, } -impl Clean for hir::ImplPolarity { +impl Clean for ty::ImplPolarity { fn clean(&self, _: &DocContext<'_>) -> ImplPolarity { match self { - &hir::ImplPolarity::Positive => ImplPolarity::Positive, - &hir::ImplPolarity::Negative => ImplPolarity::Negative, + &ty::ImplPolarity::Positive | + // FIXME: do we want to do something else here? + &ty::ImplPolarity::Reservation => ImplPolarity::Positive, + &ty::ImplPolarity::Negative => ImplPolarity::Negative, } } } @@ -3900,6 +3902,7 @@ impl Clean> for doctree::Impl<'_> { let mut ret = Vec::new(); let trait_ = self.trait_.clean(cx); let items = self.items.iter().map(|ii| ii.clean(cx)).collect::>(); + let def_id = cx.tcx.hir().local_def_id(self.id); // If this impl block is an implementation of the Deref trait, then we // need to try inlining the target's inherent impl blocks as well. @@ -3918,7 +3921,7 @@ impl Clean> for doctree::Impl<'_> { name: None, attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.hir().local_def_id(self.id), + def_id, visibility: self.vis.clean(cx), stability: cx.stability(self.id).clean(cx), deprecation: cx.deprecation(self.id).clean(cx), @@ -3929,7 +3932,7 @@ impl Clean> for doctree::Impl<'_> { trait_, for_: self.for_.clean(cx), items, - polarity: Some(self.polarity.clean(cx)), + polarity: Some(cx.tcx.impl_polarity(def_id).clean(cx)), synthetic: false, blanket_impl: None, }) From b5665e811ba4eca0f778efb65bd3e4a69f4c3ca6 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sat, 27 Jul 2019 20:44:14 +0300 Subject: [PATCH 04/30] improve comments --- src/librustc/traits/select.rs | 2 +- src/librustc/ty/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 61bb53dd334fa..de1c71a1ba31f 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -1326,7 +1326,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { (result, dep_node) } - // Treat negative impls as unimplemented, and reservation impls as Ok(None) + // Treat negative impls as unimplemented, and reservation impls as ambiguity. fn filter_negative_and_reservation_impls( &self, candidate: SelectionCandidate<'tcx>, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index b546a24534666..6a9d7eb0750ba 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2931,7 +2931,7 @@ impl<'tcx> TyCtxt<'tcx> { } (ImplPolarity::Positive, ImplPolarity::Negative) | (ImplPolarity::Negative, ImplPolarity::Positive) => { - // FIXME: when can this happen? + // `impl AutoTrait for Type` + `impl !AutoTrait for Type` debug!("impls_are_allowed_to_overlap({:?}, {:?}) - None (differing polarities)", def_id1, def_id2); return None; From 9196b2d0c89b8af853f8f41b5854655932491758 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sat, 27 Jul 2019 22:18:34 +0300 Subject: [PATCH 05/30] add error message for case --- src/libcore/convert.rs | 7 ++++- src/librustc/traits/select.rs | 31 +++++++++++++++++-- src/libsyntax/feature_gate/builtin_attrs.rs | 3 +- .../ui/never-from-impl-is-reserved.stderr | 2 ++ .../reservation-impl-coherence-conflict.rs | 2 +- ...reservation-impl-coherence-conflict.stderr | 2 ++ .../reservation-impl-no-use.rs | 2 +- .../reservation-impls/reservation-impl-ok.rs | 2 +- 8 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 82c20efa9f0d6..6edd56f749290 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -556,7 +556,12 @@ impl From for T { #[stable(feature = "convert_infallible", since = "1.34.0")] #[cfg(not(boostrap_stdarch_ignore_this))] -#[rustc_reservation_impl] +#[rustc_reservation_impl="a future version of Rust might implement `From` for \ + all types. \ + However, it is OK to implement `From` for types you own - \ + when the blanket impl will be added, coherence will be changed \ + to make these impls not be an error." +] impl From for T { fn from(t: !) -> T { t } } diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index de1c71a1ba31f..c91ee1b9caa93 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -43,6 +43,8 @@ use crate::hir; use rustc_data_structures::bit_set::GrowableBitSet; use rustc_data_structures::sync::Lock; use rustc_target::spec::abi::Abi; +use syntax::attr; +use syntax::symbol::sym; use std::cell::{Cell, RefCell}; use std::cmp; use std::fmt::{self, Display}; @@ -99,6 +101,9 @@ pub enum IntercrateAmbiguityCause { trait_desc: String, self_desc: Option, }, + ReservationImpl { + message: String + }, } impl IntercrateAmbiguityCause { @@ -139,6 +144,11 @@ impl IntercrateAmbiguityCause { trait_desc, self_desc ) } + &IntercrateAmbiguityCause::ReservationImpl { + ref message + } => { + message.clone() + } } } } @@ -1328,15 +1338,32 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Treat negative impls as unimplemented, and reservation impls as ambiguity. fn filter_negative_and_reservation_impls( - &self, + &mut self, candidate: SelectionCandidate<'tcx>, ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> { if let ImplCandidate(def_id) = candidate { - match self.tcx().impl_polarity(def_id) { + let tcx = self.tcx(); + match tcx.impl_polarity(def_id) { ty::ImplPolarity::Negative if !self.allow_negative_impls => { return Err(Unimplemented); } ty::ImplPolarity::Reservation => { + if let Some(intercrate_ambiguity_clauses) + = &mut self.intercrate_ambiguity_causes + { + let attrs = tcx.get_attrs(def_id); + let attr = attr::find_by_name(&attrs, sym::rustc_reservation_impl); + let value = attr.and_then(|a| a.value_str()); + if let Some(value) = value { + debug!("filter_negative_and_reservation_impls: \ + reservation impl ambiguity on {:?}", def_id); + intercrate_ambiguity_clauses.push( + IntercrateAmbiguityCause::ReservationImpl { + message: value.to_string() + } + ); + } + } return Ok(None); } _ => {} diff --git a/src/libsyntax/feature_gate/builtin_attrs.rs b/src/libsyntax/feature_gate/builtin_attrs.rs index d38489a2f0db9..d14afc6deaa69 100644 --- a/src/libsyntax/feature_gate/builtin_attrs.rs +++ b/src/libsyntax/feature_gate/builtin_attrs.rs @@ -457,7 +457,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // ========================================================================== // Internal attributes, Misc: // ========================================================================== - gated!( lang, Normal, template!(NameValueStr: "name"), lang_items, "language items are subject to change", @@ -498,7 +497,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ overflow checking behavior of several libcore functions that are inlined \ across crates and will never be stable", ), - rustc_attr!(rustc_reservation_impl, Normal, template!(Word), + rustc_attr!(rustc_reservation_impl, Normal, template!(NameValueStr: "reservation message"), "the `#[rustc_reservation_impl]` attribute is internally used \ for reserving for `for From for T` impl" ), diff --git a/src/test/ui/never-from-impl-is-reserved.stderr b/src/test/ui/never-from-impl-is-reserved.stderr index 7e9b21a542933..352fed7ca4515 100644 --- a/src/test/ui/never-from-impl-is-reserved.stderr +++ b/src/test/ui/never-from-impl-is-reserved.stderr @@ -6,6 +6,8 @@ LL | impl MyTrait for MyFoo {} LL | // This will conflict with the first impl if we impl `for T: From`. LL | impl MyTrait for T where T: From {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyFoo` + | + = note: a future version of Rust might implement `From` for all types. However, it is OK to implement `From` for types you own - when the blanket impl will be added, coherence will be changed to make these impls not be an error. error: aborting due to previous error diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs index 1a5266f5583d6..775278c30cd4c 100644 --- a/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs +++ b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs @@ -5,7 +5,7 @@ #![feature(rustc_attrs)] trait MyTrait {} -#[rustc_reservation_impl] +#[rustc_reservation_impl="this impl is reserved"] impl MyTrait for () {} trait OtherTrait {} diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr index 7b88d2b42db1b..47e141bd048eb 100644 --- a/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr +++ b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr @@ -5,6 +5,8 @@ LL | impl OtherTrait for () {} | ---------------------- first implementation here LL | impl OtherTrait for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()` + | + = note: this impl is reserved error: aborting due to previous error diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs index f08338bdc1c91..3391daaabe975 100644 --- a/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs +++ b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs @@ -5,7 +5,7 @@ #![feature(rustc_attrs)] trait MyTrait { fn foo(&self); } -#[rustc_reservation_impl] +#[rustc_reservation_impl = "foo"] impl MyTrait for () { fn foo(&self) {} } fn main() { diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs b/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs index febd14b792297..611c8d8841323 100644 --- a/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs +++ b/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs @@ -11,7 +11,7 @@ trait MyTrait { fn foo(&self, s: S) -> usize; } -#[rustc_reservation_impl] +#[rustc_reservation_impl = "foo"] impl MyTrait for T { fn foo(&self, _x: u64) -> usize { 0 } } From d7eb5620804540ce5f48d49fadcf0930d9d24000 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sat, 14 Sep 2019 15:34:42 +0300 Subject: [PATCH 06/30] add test for lattice specialization --- .../reservation-impl-non-lattice-ok.rs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs new file mode 100644 index 0000000000000..2517052b5e4d7 --- /dev/null +++ b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs @@ -0,0 +1,56 @@ +// build-pass + +// Check that a reservation impl does not force other impls to follow +// a lattice discipline. + +// Why did we ever want to do this? +// +// We want to eventually add a `impl From for T` impl. That impl conflicts +// with existing impls - at least the `impl From for T` impl. There are +// 2 ways we thought of for dealing with that conflict: +// +// 1. Using specialization and doing some handling for the overlap. The current +// thought is for something like "lattice specialization", which means providing +// an (higher-priority) impl for the intersection of every 2 conflicting impls +// that determines what happens in the intersection case. That's the first +// thing we thought about - see e.g. +// https://github.com/rust-lang/rust/issues/57012#issuecomment-452150775 +// +// 2. The other way is to notice that `impl From for T` is basically a marker +// trait, as you say since its only method is uninhabited, and allow for "marker +// trait overlap", where the conflict "doesn't matter" as there is nothing that +// can cause a conflict. +// +// Now it turned out lattice specialization doesn't work it, because an +// `impl From for Smaht` would require a `impl From for Smaht`, +// breaking backwards-compatibility in a fairly painful way. So if we want to +// go with a known approach, we should go with a "marker trait overlap"-style +// approach. + +#![feature(rustc_attrs, never_type)] + +trait MyTrait {} + +impl MyTrait for ! {} + +trait MyFrom { + fn my_from(x: T) -> Self; +} + +// Given the "normal" impls for From +#[rustc_reservation_impl="this impl is reserved"] +impl MyFrom for T { + fn my_from(x: !) -> Self { match x {} } +} + +impl MyFrom for T { + fn my_from(x: T) -> Self { x } +} + +// ... we *do* want to allow this common pattern, of `From for MySmaht` +struct MySmaht(T); +impl MyFrom for MySmaht { + fn my_from(x: T) -> Self { MySmaht(x) } +} + +fn main() {} From 5de1fafb1569ad12f039562ca86f14730d970a3b Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 18 Sep 2019 19:37:26 +0300 Subject: [PATCH 07/30] improve comment --- .../reservation-impls/reservation-impl-non-lattice-ok.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs index 2517052b5e4d7..ae1556cb4dc88 100644 --- a/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs +++ b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs @@ -16,10 +16,10 @@ // thing we thought about - see e.g. // https://github.com/rust-lang/rust/issues/57012#issuecomment-452150775 // -// 2. The other way is to notice that `impl From for T` is basically a marker -// trait, as you say since its only method is uninhabited, and allow for "marker -// trait overlap", where the conflict "doesn't matter" as there is nothing that -// can cause a conflict. +// 2. The other way is to notice that `impl From for T` is basically a +// marker trait since its only method is uninhabited, and allow for "marker +// trait overlap", where the conflict "doesn't matter" because it can't +// actually cause any ambiguity. // // Now it turned out lattice specialization doesn't work it, because an // `impl From for Smaht` would require a `impl From for Smaht`, From 68fd593a22c98246857726f576a14651d9ecb997 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 23 Sep 2019 13:51:59 -0400 Subject: [PATCH 08/30] cite reservation impls tracking issue --- src/librustc/ty/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 6a9d7eb0750ba..5a436b28fbcf3 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -174,6 +174,9 @@ pub enum ImplPolarity { /// `impl !Trait for Type` Negative, /// `#[rustc_reservation_impl] impl Trait for Type` + /// + /// This is a "stability hack", not a real Rust feature. + /// See #64631 for details. Reservation, } From b40a64da4fb1f2012bd925100b4cff2a38a72b30 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 23 Sep 2019 13:52:16 -0400 Subject: [PATCH 09/30] remove outdated fixme --- src/librustc_traits/lowering/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 51d49f0d59ae7..4c30227150fb1 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -295,7 +295,6 @@ fn program_clauses_for_trait(tcx: TyCtxt<'_>, def_id: DefId) -> Clauses<'_> { } fn program_clauses_for_impl(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> { - // FIXME: implement reservation impls. if let ty::ImplPolarity::Negative = tcx.impl_polarity(def_id) { return List::empty(); } From da60c53fa7fb74d314d3ad4f33ea55479884313a Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 23 Sep 2019 13:52:24 -0400 Subject: [PATCH 10/30] nit: update text to avoid "lattice specialization" term --- .../reservation-impl-non-lattice-ok.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs index ae1556cb4dc88..f14589ccf846d 100644 --- a/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs +++ b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs @@ -9,11 +9,12 @@ // with existing impls - at least the `impl From for T` impl. There are // 2 ways we thought of for dealing with that conflict: // -// 1. Using specialization and doing some handling for the overlap. The current -// thought is for something like "lattice specialization", which means providing -// an (higher-priority) impl for the intersection of every 2 conflicting impls -// that determines what happens in the intersection case. That's the first -// thing we thought about - see e.g. +// 1. Using specialization and doing some handling for the +// overlap. The current thought is to require ["intersection +// impls"][ii], specialization", which means providing an +// (higher-priority) impl for the intersection of every 2 conflicting +// impls that determines what happens in the intersection case. That's +// the first thing we thought about - see e.g. // https://github.com/rust-lang/rust/issues/57012#issuecomment-452150775 // // 2. The other way is to notice that `impl From for T` is basically a @@ -26,6 +27,8 @@ // breaking backwards-compatibility in a fairly painful way. So if we want to // go with a known approach, we should go with a "marker trait overlap"-style // approach. +// +// [ii]: http://smallcultfollowing.com/babysteps/blog/2016/09/24/intersection-impls/ #![feature(rustc_attrs, never_type)] From 167ab0439eb9f2d7b199f846fe07061b31185e09 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 23 Sep 2019 14:27:34 -0400 Subject: [PATCH 11/30] nit: update error text to cite tracking issue --- src/libcore/convert.rs | 8 ++------ src/test/ui/never-from-impl-is-reserved.stderr | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 6edd56f749290..71edea561b8bb 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -556,12 +556,8 @@ impl From for T { #[stable(feature = "convert_infallible", since = "1.34.0")] #[cfg(not(boostrap_stdarch_ignore_this))] -#[rustc_reservation_impl="a future version of Rust might implement `From` for \ - all types. \ - However, it is OK to implement `From` for types you own - \ - when the blanket impl will be added, coherence will be changed \ - to make these impls not be an error." -] +#[rustc_reservation_impl="permitting this impl would forbid us from adding \ +`impl From for T` later; see rust-lang/rust#64715 for details"] impl From for T { fn from(t: !) -> T { t } } diff --git a/src/test/ui/never-from-impl-is-reserved.stderr b/src/test/ui/never-from-impl-is-reserved.stderr index 352fed7ca4515..8b8d0f4ea73be 100644 --- a/src/test/ui/never-from-impl-is-reserved.stderr +++ b/src/test/ui/never-from-impl-is-reserved.stderr @@ -7,7 +7,7 @@ LL | // This will conflict with the first impl if we impl `for T: From`. LL | impl MyTrait for T where T: From {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyFoo` | - = note: a future version of Rust might implement `From` for all types. However, it is OK to implement `From` for types you own - when the blanket impl will be added, coherence will be changed to make these impls not be an error. + = note: permitting this impl would forbid us from adding `impl From for T` later; see rust-lang/rust#64715 for details error: aborting due to previous error From 99dc545552c40212b9d062512cd391af076b51c9 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 24 Sep 2019 11:10:42 -0400 Subject: [PATCH 12/30] add a rustdoc comment to the reservation impl --- src/libcore/convert.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 71edea561b8bb..f639309db8791 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -554,6 +554,11 @@ impl From for T { fn from(t: T) -> T { t } } +/// **Stability note:** This impl does not yet exist, but we are +/// "reserving space" to add it in the future. See +/// [rust-lang/rust#64715][#64715] for details. +/// +/// [#64715]: https://github.com/rust-lang/rust/issues/64715 #[stable(feature = "convert_infallible", since = "1.34.0")] #[cfg(not(boostrap_stdarch_ignore_this))] #[rustc_reservation_impl="permitting this impl would forbid us from adding \ From 40fad7446ea0e25f8cb3f01a98318261e6c5fde1 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 25 Sep 2019 15:36:14 -0400 Subject: [PATCH 13/30] Remove global_tcx from TyCtxt The non-global context was removed; there's only one context now. This is a noop method that only serves to confuse readers -- remove it. --- src/librustc/dep_graph/graph.rs | 2 +- src/librustc/infer/mod.rs | 2 +- src/librustc/infer/opaque_types/mod.rs | 6 ++---- src/librustc/middle/intrinsicck.rs | 2 +- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc/traits/chalk_fulfill.rs | 2 +- src/librustc/traits/error_reporting.rs | 7 +++---- src/librustc/traits/fulfill.rs | 2 +- src/librustc/traits/query/dropck_outlives.rs | 3 +-- .../traits/query/evaluate_obligation.rs | 2 +- src/librustc/traits/query/normalize.rs | 4 ++-- src/librustc/traits/query/outlives_bounds.rs | 2 +- src/librustc/traits/select.rs | 2 +- .../traits/specialize/specialization_graph.rs | 1 - src/librustc/traits/util.rs | 3 +-- src/librustc/ty/context.rs | 18 +++++------------- src/librustc/ty/instance.rs | 2 +- src/librustc/ty/layout.rs | 6 +++--- src/librustc/ty/mod.rs | 8 ++++---- src/librustc/ty/query/plumbing.rs | 16 ++++++++-------- src/librustc_macros/src/query.rs | 4 ++-- src/librustc_mir/borrow_check/mod.rs | 6 +++--- .../borrow_check/nll/type_check/mod.rs | 3 +-- .../borrow_check/nll/universal_regions.rs | 5 ++--- src/librustc_mir/dataflow/drop_flag_effects.rs | 3 +-- src/librustc_mir/hair/cx/expr.rs | 4 ++-- src/librustc_mir/hair/cx/mod.rs | 9 ++++----- src/librustc_mir/shim.rs | 2 +- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/expr.rs | 4 ++-- src/librustc_typeck/check/wfcheck.rs | 2 +- 31 files changed, 59 insertions(+), 77 deletions(-) diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index e76a70350b33e..acfdc91523f70 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -590,7 +590,7 @@ impl DepGraph { // mark it as green by recursively marking all of its // dependencies green. self.try_mark_previous_green( - tcx.global_tcx(), + tcx, data, prev_index, &dep_node diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 5d556485c15f3..cbc81d35b7188 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -1460,7 +1460,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // type-checking closure types are in local tables only. if !self.in_progress_tables.is_some() || !ty.has_closure_types() { if !(param_env, ty).has_local_value() { - return ty.is_copy_modulo_regions(self.tcx.global_tcx(), param_env, span); + return ty.is_copy_modulo_regions(self.tcx, param_env, span); } } diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 129cfc8bcb23f..742a760c175ae 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -561,15 +561,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { def_id, instantiated_ty ); - let gcx = self.tcx.global_tcx(); - // Use substs to build up a reverse map from regions to their // identity mappings. This is necessary because of `impl // Trait` lifetimes are computed by replacing existing // lifetimes with 'static and remapping only those used in the // `impl Trait` return type, resulting in the parameters // shifting. - let id_substs = InternalSubsts::identity_for_item(gcx, def_id); + let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id); let map: FxHashMap, Kind<'tcx>> = opaque_defn .substs .iter() @@ -851,7 +849,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { ) .emit(); - self.tcx().global_tcx().mk_region(ty::ReStatic) + self.tcx().mk_region(ty::ReStatic) }, } } diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 1cc96c549e724..1ed0a6e70e994 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -82,7 +82,7 @@ impl ExprVisitor<'tcx> { // Special-case transmutting from `typeof(function)` and // `Option` to present a clearer error. - let from = unpack_option_like(self.tcx.global_tcx(), from); + let from = unpack_option_like(self.tcx, from); if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) { if size_to == Pointer.size(&self.tcx) { struct_span_err!(self.tcx.sess, span, E0591, diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 73ca981bbe868..1a462070b67dc 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -749,7 +749,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { .unwrap_or(ty::ClosureKind::LATTICE_BOTTOM), None => - closure_substs.closure_kind(closure_def_id, self.tcx.global_tcx()), + closure_substs.closure_kind(closure_def_id, self.tcx), } } _ => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", ty), diff --git a/src/librustc/traits/chalk_fulfill.rs b/src/librustc/traits/chalk_fulfill.rs index a7e1f2a6a73a7..d9e83df7ddda6 100644 --- a/src/librustc/traits/chalk_fulfill.rs +++ b/src/librustc/traits/chalk_fulfill.rs @@ -108,7 +108,7 @@ impl TraitEngine<'tcx> for FulfillmentContext<'tcx> { goal: obligation.goal.predicate, }, &mut orig_values); - match infcx.tcx.global_tcx().evaluate_goal(canonical_goal) { + match infcx.tcx.evaluate_goal(canonical_goal) { Ok(response) => { if response.is_proven() { making_progress = true; diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 08fea75739978..f4859b5a93703 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -497,7 +497,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { 4 }; - let normalize = |candidate| self.tcx.global_tcx().infer_ctxt().enter(|ref infcx| { + let normalize = |candidate| self.tcx.infer_ctxt().enter(|ref infcx| { let normalized = infcx .at(&ObligationCause::dummy(), ty::ParamEnv::empty()) .normalize(candidate) @@ -783,8 +783,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } ty::Predicate::ObjectSafe(trait_def_id) => { - let violations = self.tcx.global_tcx() - .object_safety_violations(trait_def_id); + let violations = self.tcx.object_safety_violations(trait_def_id); if let Some(err) = self.tcx.report_object_safety_error( span, trait_def_id, @@ -920,7 +919,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } TraitNotObjectSafe(did) => { - let violations = self.tcx.global_tcx().object_safety_violations(did); + let violations = self.tcx.object_safety_violations(did); if let Some(err) = self.tcx.report_object_safety_error(span, did, violations) { err } else { diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 6c421e9df6800..8c712384f0d2d 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -495,7 +495,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { } else { if !substs.has_local_value() { let instance = ty::Instance::resolve( - self.selcx.tcx().global_tcx(), + self.selcx.tcx(), obligation.param_env, def_id, substs, diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 46403a38c99bd..11fc4491e8941 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -40,12 +40,11 @@ impl<'cx, 'tcx> At<'cx, 'tcx> { }; } - let gcx = tcx.global_tcx(); let mut orig_values = OriginalQueryValues::default(); let c_ty = self.infcx.canonicalize_query(&self.param_env.and(ty), &mut orig_values); let span = self.cause.span; debug!("c_ty = {:?}", c_ty); - if let Ok(result) = &gcx.dropck_outlives(c_ty) { + if let Ok(result) = &tcx.dropck_outlives(c_ty) { if result.is_proven() { if let Ok(InferOk { value, obligations }) = self.infcx.instantiate_query_response_and_region_obligations( diff --git a/src/librustc/traits/query/evaluate_obligation.rs b/src/librustc/traits/query/evaluate_obligation.rs index b9557ceaa6d9f..17684df7e9b8e 100644 --- a/src/librustc/traits/query/evaluate_obligation.rs +++ b/src/librustc/traits/query/evaluate_obligation.rs @@ -50,7 +50,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { // Run canonical query. If overflow occurs, rerun from scratch but this time // in standard trait query mode so that overflow is handled appropriately // within `SelectionContext`. - self.tcx.global_tcx().evaluate_obligation(c_pred) + self.tcx.evaluate_obligation(c_pred) } // Helper function that canonicalizes and runs the query. If an diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index c31ff3ab1b55d..04ab9342dca1b 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -141,7 +141,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { // binder). It would be better to normalize in a // binding-aware fashion. - let gcx = self.infcx.tcx.global_tcx(); + let tcx = self.infcx.tcx; let mut orig_values = OriginalQueryValues::default(); // HACK(matthewjasper) `'static` is special-cased in selection, @@ -150,7 +150,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { &self.param_env.and(*data), &mut orig_values); debug!("QueryNormalizer: c_data = {:#?}", c_data); debug!("QueryNormalizer: orig_values = {:#?}", orig_values); - match gcx.normalize_projection_ty(c_data) { + match tcx.normalize_projection_ty(c_data) { Ok(result) => { // We don't expect ambiguity. if result.is_ambiguous() { diff --git a/src/librustc/traits/query/outlives_bounds.rs b/src/librustc/traits/query/outlives_bounds.rs index 40bd18738b528..f5808b6b5faaf 100644 --- a/src/librustc/traits/query/outlives_bounds.rs +++ b/src/librustc/traits/query/outlives_bounds.rs @@ -97,7 +97,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { let mut orig_values = OriginalQueryValues::default(); let key = self.canonicalize_query(¶m_env.and(ty), &mut orig_values); - let result = match self.tcx.global_tcx().implied_outlives_bounds(key) { + let result = match self.tcx.implied_outlives_bounds(key) { Ok(r) => r, Err(NoSolution) => { self.tcx.sess.delay_span_bug( diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 386a5677f5f17..605c883d5411e 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -2460,7 +2460,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { if other.evaluation.must_apply_modulo_regions() { match victim.candidate { ImplCandidate(victim_def) => { - let tcx = self.tcx().global_tcx(); + let tcx = self.tcx(); return tcx.specializes((other_def, victim_def)) || tcx.impls_are_allowed_to_overlap( other_def, victim_def).is_some(); diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index c9a40db41dfde..096466be2023c 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -162,7 +162,6 @@ impl<'tcx> Children { } }; - let tcx = tcx.global_tcx(); let (le, ge) = traits::overlapping_impls( tcx, possible_sibling, diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 3e5520dd46557..aa771d65ebd5d 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -661,8 +661,7 @@ impl<'tcx> TyCtxt<'tcx> { } } None => { - self.global_tcx() - .impl_defaultness(node_item_def_id) + self.impl_defaultness(node_item_def_id) .is_default() } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index a25ef21d6978f..8f9439485cced 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1076,14 +1076,6 @@ pub struct GlobalCtxt<'tcx> { } impl<'tcx> TyCtxt<'tcx> { - /// Gets the global `TyCtxt`. - #[inline] - pub fn global_tcx(self) -> TyCtxt<'tcx> { - TyCtxt { - gcx: self.gcx, - } - } - #[inline(always)] pub fn hir(self) -> &'tcx hir_map::Map<'tcx> { &self.hir_map @@ -1167,7 +1159,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Like lift, but only tries in the global tcx. pub fn lift_to_global>(self, value: &T) -> Option { - value.lift_to_tcx(self.global_tcx()) + value.lift_to_tcx(self) } /// Creates a type context and call the closure with a `TyCtxt` reference @@ -1443,7 +1435,7 @@ impl<'tcx> TyCtxt<'tcx> { -> Result<(), E::Error> where E: ty::codec::TyEncoder { - self.queries.on_disk_cache.serialize(self.global_tcx(), encoder) + self.queries.on_disk_cache.serialize(self, encoder) } /// If `true`, we should use the AST-based borrowck (we may *also* use @@ -1617,7 +1609,7 @@ impl<'tcx> GlobalCtxt<'tcx> { let tcx = TyCtxt { gcx: self, }; - ty::tls::with_related_context(tcx.global_tcx(), |icx| { + ty::tls::with_related_context(tcx, |icx| { let new_icx = ty::tls::ImplicitCtxt { tcx, query: icx.query.clone(), @@ -2442,7 +2434,7 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> { - self.mk_ty(Array(ty, ty::Const::from_usize(self.global_tcx(), n))) + self.mk_ty(Array(ty, ty::Const::from_usize(self, n))) } #[inline] @@ -2657,7 +2649,7 @@ impl<'tcx> TyCtxt<'tcx> { if ts.len() == 0 { List::empty() } else { - self.global_tcx()._intern_canonical_var_infos(ts) + self._intern_canonical_var_infos(ts) } } diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index a26fa72f33041..d2451d85d0fc9 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -210,7 +210,7 @@ impl<'tcx> Instance<'tcx> { } pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> { - Instance::new(def_id, tcx.global_tcx().empty_substs_for_def_id(def_id)) + Instance::new(def_id, tcx.empty_substs_for_def_id(def_id)) } #[inline] diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index e52feea1624c1..5636c02a7cb74 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1883,7 +1883,7 @@ impl<'tcx> HasDataLayout for TyCtxt<'tcx> { impl<'tcx> HasTyCtxt<'tcx> for TyCtxt<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { - self.global_tcx() + *self } } @@ -2003,7 +2003,7 @@ impl TyCtxt<'tcx> { pub fn layout_of(self, param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> Result, LayoutError<'tcx>> { let cx = LayoutCx { - tcx: self.global_tcx(), + tcx: self, param_env: param_env_and_ty.param_env }; cx.layout_of(param_env_and_ty.value) @@ -2017,7 +2017,7 @@ impl ty::query::TyCtxtAt<'tcx> { pub fn layout_of(self, param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> Result, LayoutError<'tcx>> { let cx = LayoutCx { - tcx: self.global_tcx().at(self.span), + tcx: self.at(self.span), param_env: param_env_and_ty.param_env }; cx.layout_of(param_env_and_ty.value) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 61483fa8a498e..940bcc7c221b3 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2365,7 +2365,7 @@ impl<'tcx> AdtDef { pub fn eval_explicit_discr(&self, tcx: TyCtxt<'tcx>, expr_did: DefId) -> Option> { let param_env = tcx.param_env(expr_did); let repr_type = self.repr.discr_type(); - let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), expr_did); + let substs = InternalSubsts::identity_for_item(tcx, expr_did); let instance = ty::Instance::new(expr_did, substs); let cid = GlobalId { instance, @@ -2374,7 +2374,7 @@ impl<'tcx> AdtDef { match tcx.const_eval(param_env.and(cid)) { Ok(val) => { // FIXME: Find the right type and use it instead of `val.ty` here - if let Some(b) = val.try_eval_bits(tcx.global_tcx(), param_env, val.ty) { + if let Some(b) = val.try_eval_bits(tcx, param_env, val.ty) { trace!("discriminants: {} ({:?})", b, repr_type); Some(Discr { val: b, @@ -2410,7 +2410,7 @@ impl<'tcx> AdtDef { tcx: TyCtxt<'tcx>, ) -> impl Iterator)> + Captures<'tcx> { let repr_type = self.repr.discr_type(); - let initial = repr_type.initial_discriminant(tcx.global_tcx()); + let initial = repr_type.initial_discriminant(tcx); let mut prev_discr = None::>; self.variants.iter_enumerated().map(move |(i, v)| { let mut discr = prev_discr.map_or(initial, |d| d.wrap_incr(tcx)); @@ -2444,7 +2444,7 @@ impl<'tcx> AdtDef { let (val, offset) = self.discriminant_def_for_variant(variant_index); let explicit_value = val .and_then(|expr_did| self.eval_explicit_discr(tcx, expr_did)) - .unwrap_or_else(|| self.repr.discr_type().initial_discriminant(tcx.global_tcx())); + .unwrap_or_else(|| self.repr.discr_type().initial_discriminant(tcx)); explicit_value.checked_add(tcx, offset as u128).0 } diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index a1828bb5ab7a7..d247c0f9f69f3 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -265,7 +265,7 @@ impl<'tcx> TyCtxt<'tcx> { tls::with_related_context(self, move |current_icx| { // Update the `ImplicitCtxt` to point to our new query job. let new_icx = tls::ImplicitCtxt { - tcx: self.global_tcx(), + tcx: self, query: Some(job), diagnostics, layout_depth: current_icx.layout_depth, @@ -274,7 +274,7 @@ impl<'tcx> TyCtxt<'tcx> { // Use the `ImplicitCtxt` while we execute the query. tls::enter_context(&new_icx, |_| { - compute(self.global_tcx()) + compute(self) }) }) } @@ -384,7 +384,7 @@ impl<'tcx> TyCtxt<'tcx> { let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| { self.start_query(job.job.clone(), diagnostics, |tcx| { tcx.dep_graph.with_anon_task(Q::dep_kind(), || { - Q::compute(tcx.global_tcx(), key) + Q::compute(tcx, key) }) }) }); @@ -445,10 +445,10 @@ impl<'tcx> TyCtxt<'tcx> { debug_assert!(self.dep_graph.is_green(dep_node)); // First we try to load the result from the on-disk cache. - let result = if Q::cache_on_disk(self.global_tcx(), key.clone(), None) && + let result = if Q::cache_on_disk(self, key.clone(), None) && self.sess.opts.debugging_opts.incremental_queries { self.sess.profiler(|p| p.incremental_load_result_start(Q::NAME)); - let result = Q::try_load_from_disk(self.global_tcx(), prev_dep_node_index); + let result = Q::try_load_from_disk(self, prev_dep_node_index); self.sess.profiler(|p| p.incremental_load_result_end(Q::NAME)); // We always expect to find a cached result for things that @@ -643,7 +643,7 @@ impl<'tcx> TyCtxt<'tcx> { macro_rules! handle_cycle_error { ([][$tcx: expr, $error:expr]) => {{ $tcx.report_cycle($error).emit(); - Value::from_cycle_error($tcx.global_tcx()) + Value::from_cycle_error($tcx) }}; ([fatal_cycle$(, $modifiers:ident)*][$tcx:expr, $error:expr]) => {{ $tcx.report_cycle($error).emit(); @@ -652,7 +652,7 @@ macro_rules! handle_cycle_error { }}; ([cycle_delay_bug$(, $modifiers:ident)*][$tcx:expr, $error:expr]) => {{ $tcx.report_cycle($error).delay_as_bug(); - Value::from_cycle_error($tcx.global_tcx()) + Value::from_cycle_error($tcx) }}; ([$other:ident$(, $modifiers:ident)*][$($args:tt)*]) => { handle_cycle_error!([$($modifiers),*][$($args)*]) @@ -999,7 +999,7 @@ macro_rules! define_queries_inner { // would be missing appropriate entries in `providers`. .unwrap_or(&tcx.queries.fallback_extern_providers) .$name; - provider(tcx.global_tcx(), key) + provider(tcx, key) }) } diff --git a/src/librustc_macros/src/query.rs b/src/librustc_macros/src/query.rs index a8df7e197a8c9..9a68dd0f5e3ce 100644 --- a/src/librustc_macros/src/query.rs +++ b/src/librustc_macros/src/query.rs @@ -442,8 +442,8 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { .map(|c| c.is_green()) .unwrap_or(false)); - let key = RecoverKey::recover(tcx.global_tcx(), self).unwrap(); - if queries::#name::cache_on_disk(tcx.global_tcx(), key, None) { + let key = RecoverKey::recover(tcx, self).unwrap(); + if queries::#name::cache_on_disk(tcx, key, None) { let _ = tcx.#name(key); } } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 32c6dd67a4b5a..1c60adae4f259 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -671,7 +671,7 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx target: _, unwind: _, } => { - let gcx = self.infcx.tcx.global_tcx(); + let tcx = self.infcx.tcx; // Compute the type with accurate region information. let drop_place_ty = drop_place.ty(self.body, self.infcx.tcx); @@ -679,10 +679,10 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx // Erase the regions. let drop_place_ty = self.infcx.tcx.erase_regions(&drop_place_ty).ty; - // "Lift" into the gcx -- once regions are erased, this type should be in the + // "Lift" into the tcx -- once regions are erased, this type should be in the // global arenas; this "lift" operation basically just asserts that is true, but // that is useful later. - gcx.lift_to_global(&drop_place_ty).unwrap(); + tcx.lift_to_global(&drop_place_ty).unwrap(); debug!("visit_terminator_drop \ loc: {:?} term: {:?} drop_place: {:?} drop_place_ty: {:?} span: {:?}", diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 6a764b19c4ddf..4a9366371b392 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -1894,9 +1894,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // Erase the regions from `ty` to get a global type. The // `Sized` bound in no way depends on precise regions, so this // shouldn't affect `is_sized`. - let gcx = tcx.global_tcx(); let erased_ty = tcx.erase_regions(&ty); - if !erased_ty.is_sized(gcx.at(span), self.param_env) { + if !erased_ty.is_sized(tcx.at(span), self.param_env) { // in current MIR construction, all non-control-flow rvalue // expressions evaluate through `as_temp` or `into` a return // slot or local, so to find all unsized rvalues it is enough diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index 3e090aed52270..81d4814012af9 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -521,9 +521,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { defining_ty: DefiningTy<'tcx>, ) -> UniversalRegionIndices<'tcx> { let tcx = self.infcx.tcx; - let gcx = tcx.global_tcx(); let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id); - let identity_substs = InternalSubsts::identity_for_item(gcx, closure_base_def_id); + let identity_substs = InternalSubsts::identity_for_item(tcx, closure_base_def_id); let fr_substs = match defining_ty { DefiningTy::Closure(_, ClosureSubsts { ref substs }) | DefiningTy::Generator(_, GeneratorSubsts { ref substs }, _) => { @@ -542,7 +541,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { DefiningTy::FnDef(_, substs) | DefiningTy::Const(_, substs) => substs, }; - let global_mapping = iter::once((gcx.lifetimes.re_static, fr_static)); + let global_mapping = iter::once((tcx.lifetimes.re_static, fr_static)); let subst_mapping = identity_substs .regions() .zip(fr_substs.regions().map(|r| r.to_region_vid())); diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index 444cc008ae785..e3631c6ecfd94 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -148,9 +148,8 @@ pub(crate) fn on_all_drop_children_bits<'tcx, F>( let ty = place.ty(body, tcx).ty; debug!("on_all_drop_children_bits({:?}, {:?} : {:?})", path, place, ty); - let gcx = tcx.global_tcx(); let erased_ty = tcx.erase_regions(&ty); - if erased_ty.needs_drop(gcx, ctxt.param_env) { + if erased_ty.needs_drop(tcx, ctxt.param_env) { each_child(child); } else { debug!("on_all_drop_children_bits - skipping") diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index bdfcacd0f4629..fc675f730c433 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -543,9 +543,9 @@ fn make_mirror_unadjusted<'a, 'tcx>( // Now comes the rote stuff: hir::ExprKind::Repeat(ref v, ref count) => { let def_id = cx.tcx.hir().local_def_id(count.hir_id); - let substs = InternalSubsts::identity_for_item(cx.tcx.global_tcx(), def_id); + let substs = InternalSubsts::identity_for_item(cx.tcx, def_id); let instance = ty::Instance::resolve( - cx.tcx.global_tcx(), + cx.tcx, cx.param_env, def_id, substs, diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 740dc2011cab1..d0447ad278e5a 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -83,7 +83,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> { infcx, root_lint_level: src_id, param_env: tcx.param_env(src_def_id), - identity_substs: InternalSubsts::identity_for_item(tcx.global_tcx(), src_def_id), + identity_substs: InternalSubsts::identity_for_item(tcx, src_def_id), region_scope_tree: tcx.region_scope_tree(src_def_id), tables, constness, @@ -154,12 +154,11 @@ impl<'a, 'tcx> Cx<'a, 'tcx> { } pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> { - let tcx = self.tcx.global_tcx(); - let p = match tcx.hir().get(p.hir_id) { + let p = match self.tcx.hir().get(p.hir_id) { Node::Pat(p) | Node::Binding(p) => p, node => bug!("pattern became {:?}", node) }; - Pattern::from_hir(tcx, + Pattern::from_hir(self.tcx, self.param_env.and(self.identity_substs), self.tables(), p) @@ -190,7 +189,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> { } pub fn needs_drop(&mut self, ty: Ty<'tcx>) -> bool { - ty.needs_drop(self.tcx.global_tcx(), self.param_env) + ty.needs_drop(self.tcx, self.param_env) } pub fn tcx(&self) -> TyCtxt<'tcx> { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 6daca5e261431..c61732b3793a1 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -79,7 +79,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx } ty::InstanceDef::ClosureOnceShim { call_once } => { let fn_mut = tcx.lang_items().fn_mut_trait().unwrap(); - let call_mut = tcx.global_tcx() + let call_mut = tcx .associated_items(fn_mut) .find(|it| it.kind == ty::AssocKind::Method) .unwrap().def_id; diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 718d12484f741..8d5c44e1404ae 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1268,7 +1268,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // to avoid ICEs. for item in ®ular_traits { let object_safety_violations = - tcx.global_tcx().astconv_object_safety_violations(item.trait_ref().def_id()); + tcx.astconv_object_safety_violations(item.trait_ref().def_id()); if !object_safety_violations.is_empty() { tcx.report_object_safety_error( span, diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index 6b694bfc8da25..a56c3d0e686aa 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -932,9 +932,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(self.to_const(count, tcx.type_of(count_def_id))) } else { let param_env = ty::ParamEnv::empty(); - let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), count_def_id); + let substs = InternalSubsts::identity_for_item(tcx, count_def_id); let instance = ty::Instance::resolve( - tcx.global_tcx(), + tcx, param_env, count_def_id, substs, diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 265d0676fa8d1..27270d584e839 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -48,7 +48,7 @@ impl<'tcx> CheckWfFcxBuilder<'tcx> { // empty `param_env`. check_false_global_bounds(&fcx, span, id); } - let wf_tys = f(&fcx, fcx.tcx.global_tcx()); + let wf_tys = f(&fcx, fcx.tcx); fcx.select_all_obligations_or_error(); fcx.regionck_item(id, span, &wf_tys); }); From 5cebfa53ba2e8c11b26762c19b69a3ddddd73519 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 25 Sep 2019 15:40:21 -0400 Subject: [PATCH 14/30] Remove lift_to_global --- src/librustc/mir/mod.rs | 2 +- src/librustc/ty/context.rs | 5 ----- src/librustc/ty/error.rs | 2 +- src/librustc/ty/print/pretty.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 2 +- src/librustc_traits/chalk_context/mod.rs | 2 +- 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 967d16fa0d902..cf82184ab032c 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1504,7 +1504,7 @@ impl<'tcx> TerminatorKind<'tcx> { Goto { .. } => vec!["".into()], SwitchInt { ref values, switch_ty, .. } => ty::tls::with(|tcx| { let param_env = ty::ParamEnv::empty(); - let switch_ty = tcx.lift_to_global(&switch_ty).unwrap(); + let switch_ty = tcx.lift(&switch_ty).unwrap(); let size = tcx.layout_of(param_env.and(switch_ty)).unwrap().size; values .iter() diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 8f9439485cced..0b2938a35e74c 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1157,11 +1157,6 @@ impl<'tcx> TyCtxt<'tcx> { value.lift_to_tcx(self) } - /// Like lift, but only tries in the global tcx. - pub fn lift_to_global>(self, value: &T) -> Option { - value.lift_to_tcx(self) - } - /// Creates a type context and call the closure with a `TyCtxt` reference /// to the context. The closure enforces that the type context and any interned /// value (types, substs, etc.) can only be used while `ty::tls` has a valid diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 125c48f5f31d7..7582495aafcce 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -193,7 +193,7 @@ impl<'tcx> ty::TyS<'tcx> { ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.def_path_str(def.did)).into(), ty::Foreign(def_id) => format!("extern type `{}`", tcx.def_path_str(def_id)).into(), ty::Array(_, n) => { - let n = tcx.lift_to_global(&n).unwrap(); + let n = tcx.lift(&n).unwrap(); match n.try_eval_usize(tcx, ty::ParamEnv::empty()) { Some(n) => { format!("array of {} element{}", n, pluralise!(n)).into() diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index d99580116e4ae..ff9f9e6970162 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -917,7 +917,7 @@ pub trait PrettyPrinter<'tcx>: let min = 1u128 << (bit_size - 1); let max = min - 1; - let ty = self.tcx().lift_to_global(&ct.ty).unwrap(); + let ty = self.tcx().lift(&ct.ty).unwrap(); let size = self.tcx().layout_of(ty::ParamEnv::empty().and(ty)) .unwrap() .size; diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 1c60adae4f259..165268274e624 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -682,7 +682,7 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx // "Lift" into the tcx -- once regions are erased, this type should be in the // global arenas; this "lift" operation basically just asserts that is true, but // that is useful later. - tcx.lift_to_global(&drop_place_ty).unwrap(); + tcx.lift(&drop_place_ty).unwrap(); debug!("visit_terminator_drop \ loc: {:?} term: {:?} drop_place: {:?} drop_place_ty: {:?} span: {:?}", diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index 5c23ad4a4edfb..a071d7c8c13e0 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -474,7 +474,7 @@ impl context::UnificationOps, ChalkArenas<'tcx>> &self, value: DelayedLiteral>, ) -> DelayedLiteral> { - match self.infcx.tcx.lift_to_global(&value) { + match self.infcx.tcx.lift(&value) { Some(literal) => literal, None => bug!("cannot lift {:?}", value), } From e70724c23bd2bd5cfbbac784d103f2a61a40284f Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 24 Sep 2019 21:16:09 +0300 Subject: [PATCH 15/30] address rebase damage --- src/libcore/convert.rs | 2 +- .../traits/reservation-impls/reservation-impl-no-use.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index f639309db8791..3cd2337ee59a5 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -560,7 +560,7 @@ impl From for T { /// /// [#64715]: https://github.com/rust-lang/rust/issues/64715 #[stable(feature = "convert_infallible", since = "1.34.0")] -#[cfg(not(boostrap_stdarch_ignore_this))] +#[cfg(not(bootstrap))] #[rustc_reservation_impl="permitting this impl would forbid us from adding \ `impl From for T` later; see rust-lang/rust#64715 for details"] impl From for T { diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr index 8a86f53086dd5..0cd56b978f10c 100644 --- a/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr +++ b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `(): MyTrait` is not satisfied - --> $DIR/reservation-impl-no-use.rs:12:5 + --> $DIR/reservation-impl-no-use.rs:12:26 | LL | trait MyTrait { fn foo(&self); } | -------------- required by `MyTrait::foo` ... LL | <() as MyTrait>::foo(&()); - | ^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `()` + | ^^^ the trait `MyTrait` is not implemented for `()` | = help: the following implementations were found: <() as MyTrait> From 9f63a3a2d671b2d4c14ff518e52b48d143d7d389 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 25 Sep 2019 16:35:19 -0400 Subject: [PATCH 16/30] Remove stray uses of gcx name --- src/librustc/traits/query/type_op/mod.rs | 2 +- src/librustc_typeck/check/wfcheck.rs | 4 +- src/librustc_typeck/coherence/builtin.rs | 48 ++++++++++++------------ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index e2a5cd9670e0c..989c4aeea0964 100644 --- a/src/librustc/traits/query/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -66,7 +66,7 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx { canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, ) -> Fallible>; - /// Casts a lifted query result (which is in the gcx lifetime) + /// Casts a lifted query result (which is in the tcx lifetime) /// into the tcx lifetime. This is always just an identity cast, /// but the generic code doesn't realize it -- put another way, in /// the generic code, we have a `Lifted<'tcx, Self::QueryResponse>` diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 27270d584e839..31edea5b4f842 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -359,8 +359,8 @@ fn check_item_type( ) { debug!("check_item_type: {:?}", item_id); - for_id(tcx, item_id, ty_span).with_fcx(|fcx, gcx| { - let ty = gcx.type_of(gcx.hir().local_def_id(item_id)); + for_id(tcx, item_id, ty_span).with_fcx(|fcx, tcx| { + let ty = tcx.type_of(tcx.hir().local_def_id(item_id)); let item_ty = fcx.normalize_associated_types_in(ty_span, &ty); let mut forbid_unsized = true; diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index a95b9a03dcf77..2df07540d7fcd 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -322,29 +322,29 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: DefId) { } } -pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo { +pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo { debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did); - let coerce_unsized_trait = gcx.lang_items().coerce_unsized_trait().unwrap(); + let coerce_unsized_trait = tcx.lang_items().coerce_unsized_trait().unwrap(); - let unsize_trait = gcx.lang_items().require(UnsizeTraitLangItem).unwrap_or_else(|err| { - gcx.sess.fatal(&format!("`CoerceUnsized` implementation {}", err)); + let unsize_trait = tcx.lang_items().require(UnsizeTraitLangItem).unwrap_or_else(|err| { + tcx.sess.fatal(&format!("`CoerceUnsized` implementation {}", err)); }); // this provider should only get invoked for local def-ids - let impl_hir_id = gcx.hir().as_local_hir_id(impl_did).unwrap_or_else(|| { + let impl_hir_id = tcx.hir().as_local_hir_id(impl_did).unwrap_or_else(|| { bug!("coerce_unsized_info: invoked for non-local def-id {:?}", impl_did) }); - let source = gcx.type_of(impl_did); - let trait_ref = gcx.impl_trait_ref(impl_did).unwrap(); + let source = tcx.type_of(impl_did); + let trait_ref = tcx.impl_trait_ref(impl_did).unwrap(); assert_eq!(trait_ref.def_id, coerce_unsized_trait); let target = trait_ref.substs.type_at(1); debug!("visit_implementation_of_coerce_unsized: {:?} -> {:?} (bound)", source, target); - let span = gcx.hir().span(impl_hir_id); - let param_env = gcx.param_env(impl_did); + let span = tcx.hir().span(impl_hir_id); + let param_env = tcx.param_env(impl_did); assert!(!source.has_escaping_bound_vars()); let err_info = CoerceUnsizedInfo { custom_kind: None }; @@ -353,7 +353,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn source, target); - gcx.infer_ctxt().enter(|infcx| { + tcx.infer_ctxt().enter(|infcx| { let cause = ObligationCause::misc(span, impl_hir_id); let check_mutbl = |mt_a: ty::TypeAndMut<'tcx>, mt_b: ty::TypeAndMut<'tcx>, @@ -372,24 +372,24 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a); let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a }; let mt_b = ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b }; - check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ref(r_b, ty)) + check_mutbl(mt_a, mt_b, &|ty| tcx.mk_imm_ref(r_b, ty)) } (&ty::Ref(_, ty_a, mutbl_a), &ty::RawPtr(mt_b)) => { let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a }; - check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ptr(ty)) + check_mutbl(mt_a, mt_b, &|ty| tcx.mk_imm_ptr(ty)) } (&ty::RawPtr(mt_a), &ty::RawPtr(mt_b)) => { - check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ptr(ty)) + check_mutbl(mt_a, mt_b, &|ty| tcx.mk_imm_ptr(ty)) } (&ty::Adt(def_a, substs_a), &ty::Adt(def_b, substs_b)) if def_a.is_struct() && def_b.is_struct() => { if def_a != def_b { - let source_path = gcx.def_path_str(def_a.did); - let target_path = gcx.def_path_str(def_b.did); - span_err!(gcx.sess, + let source_path = tcx.def_path_str(def_a.did); + let target_path = tcx.def_path_str(def_b.did); + span_err!(tcx.sess, span, E0377, "the trait `CoerceUnsized` may only be implemented \ @@ -443,9 +443,9 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn let diff_fields = fields.iter() .enumerate() .filter_map(|(i, f)| { - let (a, b) = (f.ty(gcx, substs_a), f.ty(gcx, substs_b)); + let (a, b) = (f.ty(tcx, substs_a), f.ty(tcx, substs_b)); - if gcx.type_of(f.did).is_phantom_data() { + if tcx.type_of(f.did).is_phantom_data() { // Ignore PhantomData fields return None; } @@ -472,7 +472,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn .collect::>(); if diff_fields.is_empty() { - span_err!(gcx.sess, + span_err!(tcx.sess, span, E0374, "the trait `CoerceUnsized` may only be implemented \ @@ -480,14 +480,14 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn being coerced, none found"); return err_info; } else if diff_fields.len() > 1 { - let item = gcx.hir().expect_item(impl_hir_id); + let item = tcx.hir().expect_item(impl_hir_id); let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.node { t.path.span } else { - gcx.hir().span(impl_hir_id) + tcx.hir().span(impl_hir_id) }; - let mut err = struct_span_err!(gcx.sess, + let mut err = struct_span_err!(tcx.sess, span, E0375, "implementing the trait \ @@ -514,7 +514,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn } _ => { - span_err!(gcx.sess, + span_err!(tcx.sess, span, E0376, "the trait `CoerceUnsized` may only be implemented \ @@ -527,7 +527,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn // Register an obligation for `A: Trait`. let cause = traits::ObligationCause::misc(span, impl_hir_id); - let predicate = gcx.predicate_for_trait_def(param_env, + let predicate = tcx.predicate_for_trait_def(param_env, cause, trait_def_id, 0, From 4469bddaad6b797af06950c85e270e0172f5aa53 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 25 Sep 2019 16:40:24 -0400 Subject: [PATCH 17/30] Remove shrink_to_tcx_lifetime There's no longer two distinct gcx and tcx lifetimes which made this necessary (or, at least, the code compiles -- it's possible we got better at normalizing, but that seems unlikely). --- .../traits/query/type_op/ascribe_user_type.rs | 8 +--- src/librustc/traits/query/type_op/eq.rs | 8 +--- .../query/type_op/implied_outlives_bounds.rs | 8 +--- src/librustc/traits/query/type_op/mod.rs | 21 +--------- .../traits/query/type_op/normalize.rs | 38 +------------------ src/librustc/traits/query/type_op/outlives.rs | 8 +--- .../traits/query/type_op/prove_predicate.rs | 8 +--- src/librustc/traits/query/type_op/subtype.rs | 8 +--- 8 files changed, 9 insertions(+), 98 deletions(-) diff --git a/src/librustc/traits/query/type_op/ascribe_user_type.rs b/src/librustc/traits/query/type_op/ascribe_user_type.rs index 05a4d4336a7c2..34aa4ee78da30 100644 --- a/src/librustc/traits/query/type_op/ascribe_user_type.rs +++ b/src/librustc/traits/query/type_op/ascribe_user_type.rs @@ -1,4 +1,4 @@ -use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse}; use crate::traits::query::Fallible; use crate::hir::def_id::DefId; use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; @@ -37,12 +37,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> { ) -> Fallible> { tcx.type_op_ascribe_user_type(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, ()>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { - v - } } BraceStructTypeFoldableImpl! { diff --git a/src/librustc/traits/query/type_op/eq.rs b/src/librustc/traits/query/type_op/eq.rs index e8ec304f918a3..3653f9268dcde 100644 --- a/src/librustc/traits/query/type_op/eq.rs +++ b/src/librustc/traits/query/type_op/eq.rs @@ -1,4 +1,4 @@ -use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse}; use crate::traits::query::Fallible; use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; @@ -34,12 +34,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for Eq<'tcx> { ) -> Fallible> { tcx.type_op_eq(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, ()>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { - v - } } BraceStructTypeFoldableImpl! { diff --git a/src/librustc/traits/query/type_op/implied_outlives_bounds.rs b/src/librustc/traits/query/type_op/implied_outlives_bounds.rs index 3beb4d64656c5..12a834fbda6bd 100644 --- a/src/librustc/traits/query/type_op/implied_outlives_bounds.rs +++ b/src/librustc/traits/query/type_op/implied_outlives_bounds.rs @@ -1,4 +1,4 @@ -use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse}; use crate::traits::query::outlives_bounds::OutlivesBound; use crate::traits::query::Fallible; use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; @@ -38,12 +38,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> { tcx.implied_outlives_bounds(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> { - v - } } BraceStructTypeFoldableImpl! { diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index 989c4aeea0964..98e535234b630 100644 --- a/src/librustc/traits/query/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -1,6 +1,6 @@ use crate::infer::canonical::{ - Canonical, Canonicalized, CanonicalizedQueryResponse, OriginalQueryValues, - QueryRegionConstraints, QueryResponse, + Canonicalized, CanonicalizedQueryResponse, OriginalQueryValues, + QueryRegionConstraints, }; use crate::infer::{InferCtxt, InferOk}; use std::fmt; @@ -66,22 +66,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx { canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, ) -> Fallible>; - /// Casts a lifted query result (which is in the tcx lifetime) - /// into the tcx lifetime. This is always just an identity cast, - /// but the generic code doesn't realize it -- put another way, in - /// the generic code, we have a `Lifted<'tcx, Self::QueryResponse>` - /// and we want to convert that to a `Self::QueryResponse`. This is - /// not a priori valid, so we can't do it -- but in practice, it - /// is always a no-op (e.g., the lifted form of a type, - /// `Ty<'tcx>`, is a subtype of `Ty<'tcx>`). So we have to push - /// the operation into the impls that know more specifically what - /// `QueryResponse` is. This operation would (maybe) be nicer with - /// something like HKTs or GATs, since then we could make - /// `QueryResponse` parametric and `'tcx` and `'tcx` etc. - fn shrink_to_tcx_lifetime( - lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>>; - fn fully_perform_into( query_key: ParamEnvAnd<'tcx, Self>, infcx: &InferCtxt<'_, 'tcx>, @@ -99,7 +83,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx { let canonical_self = infcx.canonicalize_hr_query_hack(&query_key, &mut canonical_var_values); let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?; - let canonical_result = Self::shrink_to_tcx_lifetime(&canonical_result); let param_env = query_key.param_env; diff --git a/src/librustc/traits/query/type_op/normalize.rs b/src/librustc/traits/query/type_op/normalize.rs index 3fe85d8d83eb9..2138f792d45bb 100644 --- a/src/librustc/traits/query/type_op/normalize.rs +++ b/src/librustc/traits/query/type_op/normalize.rs @@ -1,4 +1,4 @@ -use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse}; use std::fmt; use crate::traits::query::Fallible; use crate::ty::fold::TypeFoldable; @@ -38,12 +38,6 @@ where ) -> Fallible> { T::type_op_method(tcx, canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, T>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, T>> { - T::shrink_to_tcx_lifetime(v) - } } pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Copy { @@ -51,12 +45,6 @@ pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Cop tcx: TyCtxt<'tcx>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, ) -> Fallible>; - - /// Converts from the `'tcx` (lifted) form of `Self` into the `tcx` - /// form of `Self`. - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, Self>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>>; } impl Normalizable<'tcx> for Ty<'tcx> { @@ -66,12 +54,6 @@ impl Normalizable<'tcx> for Ty<'tcx> { ) -> Fallible> { tcx.type_op_normalize_ty(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, Self>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { - v - } } impl Normalizable<'tcx> for ty::Predicate<'tcx> { @@ -81,12 +63,6 @@ impl Normalizable<'tcx> for ty::Predicate<'tcx> { ) -> Fallible> { tcx.type_op_normalize_predicate(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, Self>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { - v - } } impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> { @@ -96,12 +72,6 @@ impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> { ) -> Fallible> { tcx.type_op_normalize_poly_fn_sig(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, Self>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { - v - } } impl Normalizable<'tcx> for ty::FnSig<'tcx> { @@ -111,12 +81,6 @@ impl Normalizable<'tcx> for ty::FnSig<'tcx> { ) -> Fallible> { tcx.type_op_normalize_fn_sig(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, Self>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { - v - } } BraceStructTypeFoldableImpl! { diff --git a/src/librustc/traits/query/type_op/outlives.rs b/src/librustc/traits/query/type_op/outlives.rs index d4b36356ffb06..9b956f3e55408 100644 --- a/src/librustc/traits/query/type_op/outlives.rs +++ b/src/librustc/traits/query/type_op/outlives.rs @@ -1,4 +1,4 @@ -use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse}; use crate::traits::query::dropck_outlives::trivial_dropck_outlives; use crate::traits::query::dropck_outlives::DropckOutlivesResult; use crate::traits::query::Fallible; @@ -53,12 +53,6 @@ impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> { tcx.dropck_outlives(canonicalized) } - - fn shrink_to_tcx_lifetime( - lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> { - lifted_query_result - } } BraceStructTypeFoldableImpl! { diff --git a/src/librustc/traits/query/type_op/prove_predicate.rs b/src/librustc/traits/query/type_op/prove_predicate.rs index 1efe66326d724..2a908d0f66e5b 100644 --- a/src/librustc/traits/query/type_op/prove_predicate.rs +++ b/src/librustc/traits/query/type_op/prove_predicate.rs @@ -1,4 +1,4 @@ -use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse}; use crate::traits::query::Fallible; use crate::ty::{ParamEnvAnd, Predicate, TyCtxt}; @@ -43,12 +43,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> { ) -> Fallible> { tcx.type_op_prove_predicate(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, ()>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { - v - } } BraceStructTypeFoldableImpl! { diff --git a/src/librustc/traits/query/type_op/subtype.rs b/src/librustc/traits/query/type_op/subtype.rs index 71c74999c2762..c89a55daa095e 100644 --- a/src/librustc/traits/query/type_op/subtype.rs +++ b/src/librustc/traits/query/type_op/subtype.rs @@ -1,4 +1,4 @@ -use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse}; use crate::traits::query::Fallible; use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; @@ -34,12 +34,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for Subtype<'tcx> { ) -> Fallible> { tcx.type_op_subtype(canonicalized) } - - fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'tcx, ()>, - ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { - v - } } BraceStructTypeFoldableImpl! { From 80db06d6daa290fbc722fbae6dbfa0728ca259b5 Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Tue, 24 Sep 2019 21:34:44 -0700 Subject: [PATCH 18/30] Fix ExitStatus on Fuchsia Fuchsia exit codes don't follow the convention of libc::WEXITSTATUS et al, and they are 64 bits instead of 32 bits. This gives Fuchsia its own representation of ExitStatus. Additionally, the zircon syscall structs were out of date, causing us to see bogus return codes. --- src/libstd/sys/unix/process/mod.rs | 4 +- src/libstd/sys/unix/process/process_common.rs | 51 ------------------ .../sys/unix/process/process_fuchsia.rs | 38 ++++++++++++-- src/libstd/sys/unix/process/process_unix.rs | 52 +++++++++++++++++++ src/libstd/sys/unix/process/zircon.rs | 23 ++------ 5 files changed, 93 insertions(+), 75 deletions(-) diff --git a/src/libstd/sys/unix/process/mod.rs b/src/libstd/sys/unix/process/mod.rs index 056a20345f404..553e980f08e97 100644 --- a/src/libstd/sys/unix/process/mod.rs +++ b/src/libstd/sys/unix/process/mod.rs @@ -1,5 +1,5 @@ -pub use self::process_common::{Command, ExitStatus, ExitCode, Stdio, StdioPipes}; -pub use self::process_inner::Process; +pub use self::process_common::{Command, ExitCode, Stdio, StdioPipes}; +pub use self::process_inner::{ExitStatus, Process}; pub use crate::ffi::OsString as EnvKey; mod process_common; diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 713d308555956..4edd2ebf8c598 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -393,57 +393,6 @@ impl fmt::Debug for Command { } } -/// Unix exit statuses -#[derive(PartialEq, Eq, Clone, Copy, Debug)] -pub struct ExitStatus(c_int); - -impl ExitStatus { - pub fn new(status: c_int) -> ExitStatus { - ExitStatus(status) - } - - fn exited(&self) -> bool { - unsafe { libc::WIFEXITED(self.0) } - } - - pub fn success(&self) -> bool { - self.code() == Some(0) - } - - pub fn code(&self) -> Option { - if self.exited() { - Some(unsafe { libc::WEXITSTATUS(self.0) }) - } else { - None - } - } - - pub fn signal(&self) -> Option { - if !self.exited() { - Some(unsafe { libc::WTERMSIG(self.0) }) - } else { - None - } - } -} - -impl From for ExitStatus { - fn from(a: c_int) -> ExitStatus { - ExitStatus(a) - } -} - -impl fmt::Display for ExitStatus { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if let Some(code) = self.code() { - write!(f, "exit code: {}", code) - } else { - let signal = self.signal().unwrap(); - write!(f, "signal: {}", signal) - } - } -} - #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub struct ExitCode(u8); diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index fff9fc6b3bbc8..2b1a3ecfd70f5 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -1,11 +1,13 @@ +use crate::convert::TryInto; use crate::io; +use crate::fmt; use crate::mem; use crate::ptr; use crate::sys::process::zircon::{Handle, zx_handle_t}; use crate::sys::process::process_common::*; -use libc::size_t; +use libc::{c_int, size_t}; //////////////////////////////////////////////////////////////////////////////// // Command @@ -160,7 +162,7 @@ impl Process { return Err(io::Error::new(io::ErrorKind::InvalidData, "Failed to get exit status of process")); } - Ok(ExitStatus::new(proc_info.rec.return_code)) + Ok(ExitStatus(proc_info.return_code)) } pub fn try_wait(&mut self) -> io::Result> { @@ -190,6 +192,36 @@ impl Process { return Err(io::Error::new(io::ErrorKind::InvalidData, "Failed to get exit status of process")); } - Ok(Some(ExitStatus::new(proc_info.rec.return_code))) + Ok(Some(ExitStatus(proc_info.return_code))) + } +} + +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub struct ExitStatus(i64); + +impl ExitStatus { + pub fn success(&self) -> bool { + self.code() == Some(0) + } + + pub fn code(&self) -> Option { + // FIXME: support extracting return code as an i64 + self.0.try_into().ok() + } + + pub fn signal(&self) -> Option { + None + } +} + +impl From for ExitStatus { + fn from(a: c_int) -> ExitStatus { + ExitStatus(a as i64) + } +} + +impl fmt::Display for ExitStatus { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "exit code: {}", self.0) } } diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index e6a742bd45d0b..507dc6892613a 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -1,3 +1,4 @@ +use crate::fmt; use crate::io::{self, Error, ErrorKind}; use crate::ptr; use crate::sys::cvt; @@ -441,3 +442,54 @@ impl Process { } } } + +/// Unix exit statuses +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub struct ExitStatus(c_int); + +impl ExitStatus { + pub fn new(status: c_int) -> ExitStatus { + ExitStatus(status) + } + + fn exited(&self) -> bool { + unsafe { libc::WIFEXITED(self.0) } + } + + pub fn success(&self) -> bool { + self.code() == Some(0) + } + + pub fn code(&self) -> Option { + if self.exited() { + Some(unsafe { libc::WEXITSTATUS(self.0) }) + } else { + None + } + } + + pub fn signal(&self) -> Option { + if !self.exited() { + Some(unsafe { libc::WTERMSIG(self.0) }) + } else { + None + } + } +} + +impl From for ExitStatus { + fn from(a: c_int) -> ExitStatus { + ExitStatus(a) + } +} + +impl fmt::Display for ExitStatus { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Some(code) = self.code() { + write!(f, "exit code: {}", code) + } else { + let signal = self.signal().unwrap(); + write!(f, "signal: {}", signal) + } + } +} diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs index 1ba48de3c0785..188a6b5f2da4a 100644 --- a/src/libstd/sys/unix/process/zircon.rs +++ b/src/libstd/sys/unix/process/zircon.rs @@ -65,29 +65,14 @@ impl Drop for Handle { } } -// Common ZX_INFO header -#[derive(Default)] -#[repr(C)] -pub struct zx_info_header_t { - pub topic: u32, // identifies the info struct - pub avail_topic_size: u16, // “native” size of the struct - pub topic_size: u16, // size of the returned struct (<=topic_size) - pub avail_count: u32, // number of records the kernel has - pub count: u32, // number of records returned (limited by buffer size) -} - -#[derive(Default)] -#[repr(C)] -pub struct zx_record_process_t { - pub return_code: c_int, -} - // Returned for topic ZX_INFO_PROCESS #[derive(Default)] #[repr(C)] pub struct zx_info_process_t { - pub hdr: zx_info_header_t, - pub rec: zx_record_process_t, + pub return_code: i64, + pub started: bool, + pub exited: bool, + pub debugger_attached: bool, } extern { From ece6f833dfe99db87d17c02efeaa8aac88ad302b Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 6 Sep 2019 11:41:57 +0200 Subject: [PATCH 19/30] Refuse downgrading NLL errors on Rust 2015. --- src/librustc_mir/borrow_check/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 32c6dd67a4b5a..241a398a08cda 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -259,10 +259,8 @@ fn do_mir_borrowck<'a, 'tcx>( move_error_reported: BTreeMap::new(), uninitialized_error_reported: Default::default(), errors_buffer, - // Only downgrade errors on Rust 2015 and refuse to do so on Rust 2018. - // FIXME(Centril): In Rust 1.40.0, refuse doing so on 2015 as well and - // proceed to throwing out the migration infrastructure. - disable_error_downgrading: body.span.rust_2018(), + // FIXME(Centril): throw out the migration infrastructure. + disable_error_downgrading: true, nonlexical_regioncx: regioncx, used_mut: Default::default(), used_mut_upvars: SmallVec::new(), From aff9c833e5a82307b79302c48ce2d245d56c3031 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 6 Sep 2019 11:54:50 +0200 Subject: [PATCH 20/30] rustc_mir: remove dead code for downgrading errors. --- .../borrow_check/conflict_errors.rs | 3 - src/librustc_mir/borrow_check/mod.rs | 56 +------------------ 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index 599a0ad0d0c52..b828317c57ba8 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -105,9 +105,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()), ); - // This error should not be downgraded to a warning, - // even in migrate mode. - self.disable_error_downgrading(); err.buffer(&mut self.errors_buffer); } else { if let Some((reported_place, _)) = self.move_error_reported.get(&move_out_indices) { diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 241a398a08cda..1c842eac474f9 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -7,7 +7,6 @@ use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; use rustc::lint::builtin::UNUSED_MUT; use rustc::lint::builtin::{MUTABLE_BORROW_RESERVATION_CONFLICT}; -use rustc::middle::borrowck::SignalledError; use rustc::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind}; use rustc::mir::{ ClearCrossCrate, Local, Location, Body, Mutability, Operand, Place, PlaceBase, PlaceElem, @@ -18,7 +17,7 @@ use rustc::mir::{Terminator, TerminatorKind}; use rustc::ty::query::Providers; use rustc::ty::{self, TyCtxt}; -use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, Level}; +use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder}; use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::graph::dominators::Dominators; @@ -259,8 +258,6 @@ fn do_mir_borrowck<'a, 'tcx>( move_error_reported: BTreeMap::new(), uninitialized_error_reported: Default::default(), errors_buffer, - // FIXME(Centril): throw out the migration infrastructure. - disable_error_downgrading: true, nonlexical_regioncx: regioncx, used_mut: Default::default(), used_mut_upvars: SmallVec::new(), @@ -372,33 +369,6 @@ fn do_mir_borrowck<'a, 'tcx>( if !mbcx.errors_buffer.is_empty() { mbcx.errors_buffer.sort_by_key(|diag| diag.span.primary_span()); - if !mbcx.disable_error_downgrading && tcx.migrate_borrowck() { - // When borrowck=migrate, check if AST-borrowck would - // error on the given code. - - // rust-lang/rust#55492, rust-lang/rust#58776 check the base def id - // for errors. AST borrowck is responsible for aggregating - // `signalled_any_error` from all of the nested closures here. - let base_def_id = tcx.closure_base_def_id(def_id); - - match tcx.borrowck(base_def_id).signalled_any_error { - SignalledError::NoErrorsSeen => { - // if AST-borrowck signalled no errors, then - // downgrade all the buffered MIR-borrowck errors - // to warnings. - - for err in mbcx.errors_buffer.iter_mut() { - downgrade_if_error(err); - } - } - SignalledError::SawSomeError => { - // if AST-borrowck signalled a (cancelled) error, - // then we will just emit the buffered - // MIR-borrowck errors as normal. - } - } - } - for diag in mbcx.errors_buffer.drain(..) { mbcx.infcx.tcx.sess.diagnostic().emit_diagnostic(&diag); } @@ -414,21 +384,6 @@ fn do_mir_borrowck<'a, 'tcx>( result } -fn downgrade_if_error(diag: &mut Diagnostic) { - if diag.is_error() { - diag.level = Level::Warning; - diag.warn( - "this error has been downgraded to a warning for backwards \ - compatibility with previous releases", - ).warn( - "this represents potential undefined behavior in your code and \ - this warning will become a hard error in the future", - ).note( - "for more information, try `rustc --explain E0729`" - ); - } -} - crate struct MirBorrowckCtxt<'cx, 'tcx> { crate infcx: &'cx InferCtxt<'cx, 'tcx>, body: &'cx Body<'tcx>, @@ -489,9 +444,6 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> { uninitialized_error_reported: FxHashSet>, /// Errors to be reported buffer errors_buffer: Vec, - /// If there are no errors reported by the HIR borrow checker, we downgrade - /// all NLL errors to warnings. Setting this flag disables downgrading. - disable_error_downgrading: bool, /// This field keeps track of all the local variables that are declared mut and are mutated. /// Used for the warning issued by an unused mutable local variable. used_mut: FxHashSet, @@ -932,12 +884,6 @@ impl InitializationRequiringAction { } impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { - /// If there are no errors reported by the HIR borrow checker, we downgrade - /// all NLL errors to warnings. Calling this disables downgrading. - crate fn disable_error_downgrading(&mut self) { - self.disable_error_downgrading = true; - } - /// Checks an access to the given place to see if it is allowed. Examines the set of borrows /// that are in scope, as well as which paths have been initialized, to ensure that (a) the /// place is initialized and (b) it is not borrowed in some way that would prevent this From 6ec9b3a0b6510fcac75bd60e5a317de7f29310ef Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 6 Sep 2019 15:47:50 +0200 Subject: [PATCH 21/30] Adjust & --bless tests due to no longer downgrading NLL errors on 2015. --- .../borrowck-anon-fields-variant.nll.stderr | 40 -- .../borrowck/borrowck-anon-fields-variant.rs | 4 +- .../borrowck-anon-fields-variant.stderr | 12 +- .../borrowck-describe-lvalue.nll.stderr | 366 ------------------ .../ui/borrowck/borrowck-describe-lvalue.rs | 12 +- .../borrowck/borrowck-describe-lvalue.stderr | 30 +- .../borrowck-migrate-to-nll.edition.stderr | 14 - .../ui/borrowck/borrowck-migrate-to-nll.rs | 36 -- .../borrowck-migrate-to-nll.zflag.stderr | 15 - .../min_const_fn/min_const_fn.nll.stderr | 328 ---------------- .../ui/consts/min_const_fn/min_const_fn.rs | 4 +- .../consts/min_const_fn/min_const_fn.stderr | 14 +- .../min_const_fn/min_const_fn_dyn.nll.stderr | 31 -- .../consts/min_const_fn/min_const_fn_dyn.rs | 4 +- .../min_const_fn/min_const_fn_dyn.stderr | 8 +- src/test/ui/feature-gates/feature-gate-nll.rs | 14 +- .../ui/feature-gates/feature-gate-nll.stderr | 20 +- .../ui/issues/issue-40510-1.migrate.stderr | 11 +- src/test/ui/issues/issue-40510-1.nll.stderr | 2 +- src/test/ui/issues/issue-40510-1.rs | 11 +- ...igrate.nll.stderr => issue-40510-1.stderr} | 2 +- .../ui/issues/issue-40510-3.migrate.stderr | 11 +- src/test/ui/issues/issue-40510-3.nll.stderr | 2 +- src/test/ui/issues/issue-40510-3.rs | 11 +- ...igrate.nll.stderr => issue-40510-3.stderr} | 2 +- ...96-scribble-on-boxed-borrow.migrate.stderr | 32 +- .../issue-45696-scribble-on-boxed-borrow.rs | 43 +- ...ssue-45696-scribble-on-boxed-borrow.stderr | 33 ++ src/test/ui/issues/issue-49824.nll.stderr | 18 - src/test/ui/issues/issue-49824.rs | 10 +- src/test/ui/issues/issue-49824.stderr | 21 +- .../ui/nll/borrowed-referent-issue-38899.rs | 2 - .../nll/borrowed-referent-issue-38899.stderr | 2 +- .../pattern-bindings-after-at.nll.stderr | 22 -- .../ui/pattern/pattern-bindings-after-at.rs | 4 +- .../pattern/pattern-bindings-after-at.stderr | 8 +- src/test/ui/thread-local-in-ctfe.nll.stderr | 49 --- src/test/ui/thread-local-in-ctfe.rs | 8 +- src/test/ui/thread-local-in-ctfe.stderr | 22 +- 39 files changed, 104 insertions(+), 1174 deletions(-) delete mode 100644 src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr delete mode 100644 src/test/ui/borrowck/borrowck-describe-lvalue.nll.stderr delete mode 100644 src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr delete mode 100644 src/test/ui/borrowck/borrowck-migrate-to-nll.rs delete mode 100644 src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr delete mode 100644 src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr delete mode 100644 src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr rename src/test/ui/issues/{issue-40510-1.migrate.nll.stderr => issue-40510-1.stderr} (93%) rename src/test/ui/issues/{issue-40510-3.migrate.nll.stderr => issue-40510-3.stderr} (94%) create mode 100644 src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.stderr delete mode 100644 src/test/ui/issues/issue-49824.nll.stderr delete mode 100644 src/test/ui/pattern/pattern-bindings-after-at.nll.stderr delete mode 100644 src/test/ui/thread-local-in-ctfe.nll.stderr diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr deleted file mode 100644 index f66994b3f100a..0000000000000 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0503]: cannot use `y` because it was mutably borrowed - --> $DIR/borrowck-anon-fields-variant.rs:17:7 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- borrow of `y.0` occurs here -... -LL | Foo::Y(_, ref mut b) => b, - | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` -... -LL | *a += 1; - | ------- borrow later used here - -error[E0503]: cannot use `y` because it was mutably borrowed - --> $DIR/borrowck-anon-fields-variant.rs:37:7 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- borrow of `y.0` occurs here -... -LL | Foo::Y(ref mut b, _) => b, - | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` -... -LL | *a += 1; - | ------- borrow later used here - -error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-variant.rs:37:14 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- first mutable borrow occurs here -... -LL | Foo::Y(ref mut b, _) => b, - | ^^^^^^^^^ second mutable borrow occurs here -... -LL | *a += 1; - | ------- first borrow later used here - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0499, E0503. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.rs b/src/test/ui/borrowck/borrowck-anon-fields-variant.rs index 695809f58c551..cecc278e1931c 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.rs +++ b/src/test/ui/borrowck/borrowck-anon-fields-variant.rs @@ -15,9 +15,7 @@ fn distinct_variant() { // reference. let b = match y { Foo::Y(_, ref mut b) => b, - //~^ WARNING cannot use `y` - //~| WARNING this error has been downgraded to a warning - //~| WARNING this warning will become a hard error in the future + //~^ ERROR cannot use `y` Foo::X => panic!() }; diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr b/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr index e2d3e417ac3ac..2caeed1bd44ea 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr @@ -1,4 +1,4 @@ -warning[E0503]: cannot use `y` because it was mutably borrowed +error[E0503]: cannot use `y` because it was mutably borrowed --> $DIR/borrowck-anon-fields-variant.rs:17:7 | LL | Foo::Y(ref mut a, _) => a, @@ -9,13 +9,9 @@ LL | Foo::Y(_, ref mut b) => b, ... LL | *a += 1; | ------- borrow later used here - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` error[E0503]: cannot use `y` because it was mutably borrowed - --> $DIR/borrowck-anon-fields-variant.rs:37:7 + --> $DIR/borrowck-anon-fields-variant.rs:35:7 | LL | Foo::Y(ref mut a, _) => a, | --------- borrow of `y.0` occurs here @@ -27,7 +23,7 @@ LL | *a += 1; | ------- borrow later used here error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-variant.rs:37:14 + --> $DIR/borrowck-anon-fields-variant.rs:35:14 | LL | Foo::Y(ref mut a, _) => a, | --------- first mutable borrow occurs here @@ -38,7 +34,7 @@ LL | Foo::Y(ref mut b, _) => b, LL | *a += 1; | ------- first borrow later used here -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0499, E0503. For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.nll.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.nll.stderr deleted file mode 100644 index 20f05353d4633..0000000000000 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.nll.stderr +++ /dev/null @@ -1,366 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:262:13 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | &mut x; - | ^^^^^^ second mutable borrow occurs here -LL | *y = 1; - | ------ first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:272:20 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | &mut x; - | ^^^^^^ second mutable borrow occurs here -LL | *y = 1; - | ------ first borrow later used here - -error: captured variable cannot escape `FnMut` closure body - --> $DIR/borrowck-describe-lvalue.rs:270:16 - | -LL | || { - | - inferred to be a `FnMut` closure -LL | / || { -LL | | let y = &mut x; -LL | | &mut x; -LL | | *y = 1; -LL | | drop(y); -LL | | } - | |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body - | - = note: `FnMut` closures only have access to their captured variables while they are executing... - = note: ...therefore, they cannot allow references to captured variables to escape - -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:41:9 - | -LL | let x = f.x(); - | - borrow of `f` occurs here -LL | f.x; - | ^^^ use of borrowed `f` -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:48:9 - | -LL | let x = g.x(); - | - borrow of `g` occurs here -LL | g.0; - | ^^^ use of borrowed `g` -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:55:9 - | -LL | let x = &mut h.0; - | -------- borrow of `h.0` occurs here -LL | h.0; - | ^^^ use of borrowed `h.0` -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:63:20 - | -LL | let x = e.x(); - | - borrow of `e` occurs here -LL | match e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `e` -LL | }; -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:71:9 - | -LL | let x = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a; - | ^^^ use of borrowed `u.a` -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:78:9 - | -LL | let x = f.x(); - | - borrow of `*f` occurs here -LL | f.x; - | ^^^ use of borrowed `*f` -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:85:9 - | -LL | let x = g.x(); - | - borrow of `*g` occurs here -LL | g.0; - | ^^^ use of borrowed `*g` -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:92:9 - | -LL | let x = &mut h.0; - | -------- borrow of `h.0` occurs here -LL | h.0; - | ^^^ use of borrowed `h.0` -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:100:20 - | -LL | let x = e.x(); - | - borrow of `*e` occurs here -LL | match *e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `*e` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:109:9 - | -LL | let x = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a; - | ^^^ use of borrowed `u.a` -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:117:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { -LL | &[x, _, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:122:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:127:25 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, _, .., x, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:132:28 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, _, .., _, x] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:143:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { -LL | &[x @ ..] => println!("{:?}", x), - | ^^^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:148:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x @ ..] => println!("{:?}", x), - | ^^^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:153:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[x @ .., _] => println!("{:?}", x), - | ^^^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:158:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x @ .., _] => println!("{:?}", x), - | ^^^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:171:13 - | -LL | let x = &mut e; - | ------ borrow of `e` occurs here -LL | match e { -LL | E::A(ref ax) => - | ^^^^^^^^^^^^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - -error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:171:18 - | -LL | let x = &mut e; - | ------ mutable borrow occurs here -LL | match e { -LL | E::A(ref ax) => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:175:23 - | -LL | let x = &mut e; - | ------ mutable borrow occurs here -... -LL | E::B { x: ref bx } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:188:22 - | -LL | let x = &mut s; - | ------ mutable borrow occurs here -LL | match s { -LL | S { y: (ref y0, _), .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:194:28 - | -LL | let x = &mut s; - | ------ mutable borrow occurs here -... -LL | S { x: F { y: ref x0, .. }, .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0503]: cannot use `*v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:240:9 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | v[0].y; - | ^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[_].y` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:240:9 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | v[0].y; - | ^^^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:251:24 - | -LL | let x = &mut v; - | ------ mutable borrow occurs here -LL | match v { -LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:210:29 - | -LL | let x = &mut block; - | ---------- mutable borrow occurs here -LL | let p: &'a u8 = &*block.current; - | ^^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:227:33 - | -LL | let x = &mut block; - | ---------- mutable borrow occurs here -LL | let p : *const u8 = &*(*block).current; - | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-describe-lvalue.rs:282:22 - | -LL | drop(x); - | - value moved here -LL | drop(x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait - -error: aborting due to 32 previous errors - -Some errors have detailed explanations: E0382, E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.rs b/src/test/ui/borrowck/borrowck-describe-lvalue.rs index c27d9519dc798..8425960aa8600 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.rs +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.rs @@ -208,10 +208,8 @@ fn main() { fn bump<'a>(mut block: &mut Block<'a>) { let x = &mut block; let p: &'a u8 = &*block.current; - //~^ WARNING cannot borrow `*block.current` as immutable because it is also borrowed as mutable - //~| this error has been downgraded - //~| this warning will become a hard error in the future - // Warning because of issue rust#38899 + //~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable + // See issue rust#38899 drop(x); } } @@ -225,10 +223,8 @@ fn main() { unsafe fn bump2(mut block: *mut Block2) { let x = &mut block; let p : *const u8 = &*(*block).current; - //~^ WARNING cannot borrow `*block.current` as immutable because it is also borrowed as mutable - //~| this error has been downgraded - //~| this warning will become a hard error in the future - // Warning because of issue rust#38899 + //~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable + // See issue rust#38899 drop(x); } } diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.stderr index 38d847a90ff95..4213523d2fa4b 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.stderr +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:262:13 + --> $DIR/borrowck-describe-lvalue.rs:258:13 | LL | let y = &mut x; | ------ first mutable borrow occurs here @@ -9,7 +9,7 @@ LL | *y = 1; | ------ first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:272:20 + --> $DIR/borrowck-describe-lvalue.rs:268:20 | LL | let y = &mut x; | ------ first mutable borrow occurs here @@ -19,7 +19,7 @@ LL | *y = 1; | ------ first borrow later used here error: captured variable cannot escape `FnMut` closure body - --> $DIR/borrowck-describe-lvalue.rs:270:16 + --> $DIR/borrowck-describe-lvalue.rs:266:16 | LL | || { | - inferred to be a `FnMut` closure @@ -295,7 +295,7 @@ LL | drop(x); | - mutable borrow later used here error[E0503]: cannot use `*v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:240:9 + --> $DIR/borrowck-describe-lvalue.rs:236:9 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -306,7 +306,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[_].y` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:240:9 + --> $DIR/borrowck-describe-lvalue.rs:236:9 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -317,7 +317,7 @@ LL | drop(x); | - borrow later used here error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:251:24 + --> $DIR/borrowck-describe-lvalue.rs:247:24 | LL | let x = &mut v; | ------ mutable borrow occurs here @@ -328,7 +328,7 @@ LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), LL | drop(x); | - mutable borrow later used here -warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable +error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:210:29 | LL | let x = &mut block; @@ -338,13 +338,9 @@ LL | let p: &'a u8 = &*block.current; ... LL | drop(x); | - mutable borrow later used here - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` -warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:227:33 +error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:225:33 | LL | let x = &mut block; | ---------- mutable borrow occurs here @@ -353,13 +349,9 @@ LL | let p : *const u8 = &*(*block).current; ... LL | drop(x); | - mutable borrow later used here - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` error[E0382]: use of moved value: `x` - --> $DIR/borrowck-describe-lvalue.rs:282:22 + --> $DIR/borrowck-describe-lvalue.rs:278:22 | LL | drop(x); | - value moved here @@ -368,7 +360,7 @@ LL | drop(x); | = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 30 previous errors +error: aborting due to 32 previous errors Some errors have detailed explanations: E0382, E0499, E0502, E0503. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr b/src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr deleted file mode 100644 index 58f2cadcc6573..0000000000000 --- a/src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-migrate-to-nll.rs:29:21 - | -LL | let x = &mut block; - | ---------- mutable borrow occurs here -LL | let p: &'a u8 = &*block.current; - | ^^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.rs b/src/test/ui/borrowck/borrowck-migrate-to-nll.rs deleted file mode 100644 index 6587dfdbc03f3..0000000000000 --- a/src/test/ui/borrowck/borrowck-migrate-to-nll.rs +++ /dev/null @@ -1,36 +0,0 @@ -// This is a test of the borrowck migrate mode. It leverages #38899, a -// bug that is fixed by NLL: this code is (unsoundly) accepted by -// AST-borrowck, but is correctly rejected by the NLL borrowck. -// -// Therefore, for backwards-compatiblity, under borrowck=migrate the -// NLL checks will be emitted as *warnings*. -// -// In Rust 2018, no errors will be downgraded to warnings. - -// NLL mode makes this compile-fail; we cannot currently encode a -// test that is run-pass or compile-fail based on compare-mode. So -// just ignore it instead: - -// ignore-compare-mode-nll -// ignore-compare-mode-polonius - -// revisions: zflag edition -//[zflag]compile-flags: -Z borrowck=migrate -//[edition]edition:2018 -//[zflag] check-pass - -pub 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; - //[edition]~^ ERROR cannot borrow `*block.current` as immutable - // (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes) - drop(x); - drop(p); -} - -fn main() {} diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr b/src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr deleted file mode 100644 index ace336a3bf32a..0000000000000 --- a/src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-migrate-to-nll.rs:29:21 - | -LL | let x = &mut block; - | ---------- mutable borrow occurs here -LL | let p: &'a u8 = &*block.current; - | ^^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` - diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr deleted file mode 100644 index 4b43a0d0a1a1b..0000000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr +++ /dev/null @@ -1,328 +0,0 @@ -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:37:25 - | -LL | const fn into_inner(self) -> T { self.0 } - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:39:36 - | -LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:44:28 - | -LL | const fn into_inner_lt(self) -> T { self.0 } - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:46:42 - | -LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:51:27 - | -LL | const fn into_inner_s(self) -> T { self.0 } - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:53:38 - | -LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:58:39 - | -LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:76:16 - | -LL | const fn foo11(t: T) -> T { t } - | ^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:78:18 - | -LL | const fn foo11_2(t: T) -> T { t } - | ^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:80:33 - | -LL | const fn foo19(f: f32) -> f32 { f * 2.0 } - | ^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:82:35 - | -LL | const fn foo19_2(f: f32) -> f32 { 2.0 - f } - | ^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: only int and `bool` operations are stable in const fn - --> $DIR/min_const_fn.rs:84:35 - | -LL | const fn foo19_3(f: f32) -> f32 { -f } - | ^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:86:43 - | -LL | const fn foo19_4(f: f32, g: f32) -> f32 { f / g } - | ^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: cannot access `static` items in const fn - --> $DIR/min_const_fn.rs:90:27 - | -LL | const fn foo25() -> u32 { BAR } - | ^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: cannot access `static` items in const fn - --> $DIR/min_const_fn.rs:91:36 - | -LL | const fn foo26() -> &'static u32 { &BAR } - | ^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn - --> $DIR/min_const_fn.rs:92:42 - | -LL | const fn foo30(x: *const u32) -> usize { x as usize } - | ^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn - --> $DIR/min_const_fn.rs:94:63 - | -LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } } - | ^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn - --> $DIR/min_const_fn.rs:96:42 - | -LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } - | ^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn - --> $DIR/min_const_fn.rs:98:63 - | -LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } } - | ^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/min_const_fn.rs:100:38 - | -LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } } - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: loops are not allowed in const fn - --> $DIR/min_const_fn.rs:102:29 - | -LL | const fn foo30_5(b: bool) { while b { } } - | ^^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/min_const_fn.rs:105:44 - | -LL | const fn foo36(a: bool, b: bool) -> bool { a && b } - | ^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/min_const_fn.rs:107:44 - | -LL | const fn foo37(a: bool, b: bool) -> bool { a || b } - | ^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:109:14 - | -LL | const fn inc(x: &mut i32) { *x += 1 } - | ^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:114:6 - | -LL | impl Foo { - | ^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:119:6 - | -LL | impl Foo { - | ^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:124:6 - | -LL | impl Foo { - | ^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: `impl Trait` in const fn is unstable - --> $DIR/min_const_fn.rs:130:24 - | -LL | const fn no_rpit2() -> AlanTuring { AlanTuring(0) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:132:34 - | -LL | const fn no_apit2(_x: AlanTuring) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:134:22 - | -LL | const fn no_apit(_x: impl std::fmt::Debug) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: `impl Trait` in const fn is unstable - --> $DIR/min_const_fn.rs:135:23 - | -LL | const fn no_rpit() -> impl std::fmt::Debug {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:136:23 - | -LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} - | ^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:137:32 - | -LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0515]: cannot return reference to temporary value - --> $DIR/min_const_fn.rs:137:63 - | -LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^-- - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:145:41 - | -LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: function pointers in const fn are unstable - --> $DIR/min_const_fn.rs:148:21 - | -LL | const fn no_fn_ptrs(_x: fn()) {} - | ^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: function pointers in const fn are unstable - --> $DIR/min_const_fn.rs:150:27 - | -LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } - | ^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error: aborting due to 37 previous errors - -Some errors have detailed explanations: E0515, E0723. -For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index 8b423da788292..d0f63b148ff2b 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -136,9 +136,7 @@ const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } //~^ ERROR trait bounds other than `Sized` -//~| WARNING cannot return reference to temporary value -//~| WARNING this error has been downgraded to a warning -//~| WARNING this warning will become a hard error in the future +//~| ERROR cannot return reference to temporary value const fn no_unsafe() { unsafe {} } diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index 211902b687b1b..7919cfe987cfc 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -286,7 +286,7 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = help: add `#![feature(const_fn)]` to the crate attributes to enable -warning[E0515]: cannot return reference to temporary value +error[E0515]: cannot return reference to temporary value --> $DIR/min_const_fn.rs:137:63 | LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } @@ -294,13 +294,9 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } | || | |temporary value created here | returns a reference to data owned by the current function - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:145:41 + --> $DIR/min_const_fn.rs:143:41 | LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -309,7 +305,7 @@ LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 = help: add `#![feature(const_fn)]` to the crate attributes to enable error[E0723]: function pointers in const fn are unstable - --> $DIR/min_const_fn.rs:148:21 + --> $DIR/min_const_fn.rs:146:21 | LL | const fn no_fn_ptrs(_x: fn()) {} | ^^ @@ -318,7 +314,7 @@ LL | const fn no_fn_ptrs(_x: fn()) {} = help: add `#![feature(const_fn)]` to the crate attributes to enable error[E0723]: function pointers in const fn are unstable - --> $DIR/min_const_fn.rs:150:27 + --> $DIR/min_const_fn.rs:148:27 | LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } | ^^^^ @@ -326,7 +322,7 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = help: add `#![feature(const_fn)]` to the crate attributes to enable -error: aborting due to 36 previous errors +error: aborting due to 37 previous errors Some errors have detailed explanations: E0515, E0723. For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr deleted file mode 100644 index 0ea950d678f87..0000000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn_dyn.rs:9:5 - | -LL | x.0.field; - | ^^^^^^^^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn_dyn.rs:12:66 - | -LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } - | ^^ - | - = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0716]: temporary value dropped while borrowed - --> $DIR/min_const_fn_dyn.rs:12:67 - | -LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } - | -^ - temporary value is freed at the end of this statement - | || - | |creates a temporary which is freed while still in use - | cast requires that borrow lasts for `'static` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0716, E0723. -For more information about an error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs index 75b67192f0081..3833510c0b3b5 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs @@ -11,8 +11,6 @@ const fn no_inner_dyn_trait2(x: Hide) { } const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } //~^ ERROR trait bounds other than `Sized` -//~| WARNING temporary value dropped while borrowed -//~| WARNING this error has been downgraded to a warning -//~| WARNING this warning will become a hard error in the future +//~| ERROR temporary value dropped while borrowed fn main() {} diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr index 02ddb0395296c..0ea950d678f87 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr @@ -16,7 +16,7 @@ LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = help: add `#![feature(const_fn)]` to the crate attributes to enable -warning[E0716]: temporary value dropped while borrowed +error[E0716]: temporary value dropped while borrowed --> $DIR/min_const_fn_dyn.rs:12:67 | LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } @@ -24,12 +24,8 @@ LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } | || | |creates a temporary which is freed while still in use | cast requires that borrow lasts for `'static` - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0716, E0723. For more information about an error, try `rustc --explain E0716`. diff --git a/src/test/ui/feature-gates/feature-gate-nll.rs b/src/test/ui/feature-gates/feature-gate-nll.rs index 8ec752409ab00..fd6c5b67ef69e 100644 --- a/src/test/ui/feature-gates/feature-gate-nll.rs +++ b/src/test/ui/feature-gates/feature-gate-nll.rs @@ -1,20 +1,18 @@ // There isn't a great way to test feature(nll), since it just disables migrate -// mode and changes some error messages. We just test for migrate mode. +// mode and changes some error messages. + +// FIXME(Centril): This test is probably obsolete now and `nll` should become +// `accepted`. // Don't use compare-mode=nll, since that turns on NLL. // ignore-compare-mode-nll // ignore-compare-mode-polonius -#![feature(rustc_attrs)] - -#[rustc_error] -fn main() { //~ ERROR compilation successful +fn main() { let mut x = (33, &0); let m = &mut x; let p = &*x.1; - //~^ WARNING cannot borrow - //~| WARNING this error has been downgraded to a warning - //~| WARNING this warning will become a hard error in the future + //~^ ERROR cannot borrow m; } diff --git a/src/test/ui/feature-gates/feature-gate-nll.stderr b/src/test/ui/feature-gates/feature-gate-nll.stderr index e5b28bbfa2477..edfc22c32c936 100644 --- a/src/test/ui/feature-gates/feature-gate-nll.stderr +++ b/src/test/ui/feature-gates/feature-gate-nll.stderr @@ -1,29 +1,13 @@ -warning[E0502]: cannot borrow `*x.1` as immutable because it is also borrowed as mutable +error[E0502]: cannot borrow `*x.1` as immutable because it is also borrowed as mutable --> $DIR/feature-gate-nll.rs:15:13 | LL | let m = &mut x; | ------ mutable borrow occurs here LL | let p = &*x.1; | ^^^^^ immutable borrow occurs here -... +LL | LL | m; | - mutable borrow later used here - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` - -error: compilation successful - --> $DIR/feature-gate-nll.rs:11:1 - | -LL | / fn main() { -LL | | let mut x = (33, &0); -LL | | -LL | | let m = &mut x; -... | -LL | | m; -LL | | } - | |_^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40510-1.migrate.stderr b/src/test/ui/issues/issue-40510-1.migrate.stderr index 28aaa2a797e05..776a724d3106a 100644 --- a/src/test/ui/issues/issue-40510-1.migrate.stderr +++ b/src/test/ui/issues/issue-40510-1.migrate.stderr @@ -1,4 +1,4 @@ -warning: captured variable cannot escape `FnMut` closure body +error: captured variable cannot escape `FnMut` closure body --> $DIR/issue-40510-1.rs:11:9 | LL | || { @@ -8,15 +8,6 @@ LL | &mut x | = note: `FnMut` closures only have access to their captured variables while they are executing... = note: ...therefore, they cannot allow references to captured variables to escape - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` - -error: compilation successful - --> $DIR/issue-40510-1.rs:20:1 - | -LL | fn main() {} - | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40510-1.nll.stderr b/src/test/ui/issues/issue-40510-1.nll.stderr index 776a724d3106a..f4fda0abc2049 100644 --- a/src/test/ui/issues/issue-40510-1.nll.stderr +++ b/src/test/ui/issues/issue-40510-1.nll.stderr @@ -1,5 +1,5 @@ error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-40510-1.rs:11:9 + --> $DIR/issue-40510-1.rs:7:9 | LL | || { | - inferred to be a `FnMut` closure diff --git a/src/test/ui/issues/issue-40510-1.rs b/src/test/ui/issues/issue-40510-1.rs index 6ecbeefd88115..ca53dcd9b41fa 100644 --- a/src/test/ui/issues/issue-40510-1.rs +++ b/src/test/ui/issues/issue-40510-1.rs @@ -1,21 +1,12 @@ -#![feature(rustc_attrs)] #![allow(unused)] -// revisions: migrate nll -#![cfg_attr(nll, feature(nll))] - fn f() { let mut x: Box<()> = Box::new(()); || { &mut x }; - //[migrate]~^^ WARNING captured variable cannot escape `FnMut` closure body - //[migrate]~| WARNING this error has been downgraded to a warning - //[migrate]~| WARNING this warning will become a hard error in the future - //[nll]~^^^^^ ERROR captured variable cannot escape `FnMut` closure body + //~^^ ERROR captured variable cannot escape `FnMut` closure body } -#[rustc_error] fn main() {} -//[migrate]~^ ERROR diff --git a/src/test/ui/issues/issue-40510-1.migrate.nll.stderr b/src/test/ui/issues/issue-40510-1.stderr similarity index 93% rename from src/test/ui/issues/issue-40510-1.migrate.nll.stderr rename to src/test/ui/issues/issue-40510-1.stderr index 776a724d3106a..f4fda0abc2049 100644 --- a/src/test/ui/issues/issue-40510-1.migrate.nll.stderr +++ b/src/test/ui/issues/issue-40510-1.stderr @@ -1,5 +1,5 @@ error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-40510-1.rs:11:9 + --> $DIR/issue-40510-1.rs:7:9 | LL | || { | - inferred to be a `FnMut` closure diff --git a/src/test/ui/issues/issue-40510-3.migrate.stderr b/src/test/ui/issues/issue-40510-3.migrate.stderr index f00690efc312c..a49475a8570a1 100644 --- a/src/test/ui/issues/issue-40510-3.migrate.stderr +++ b/src/test/ui/issues/issue-40510-3.migrate.stderr @@ -1,4 +1,4 @@ -warning: captured variable cannot escape `FnMut` closure body +error: captured variable cannot escape `FnMut` closure body --> $DIR/issue-40510-3.rs:11:9 | LL | || { @@ -10,15 +10,6 @@ LL | | } | = note: `FnMut` closures only have access to their captured variables while they are executing... = note: ...therefore, they cannot allow references to captured variables to escape - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` - -error: compilation successful - --> $DIR/issue-40510-3.rs:22:1 - | -LL | fn main() {} - | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40510-3.nll.stderr b/src/test/ui/issues/issue-40510-3.nll.stderr index a49475a8570a1..4bc7d0f5deac5 100644 --- a/src/test/ui/issues/issue-40510-3.nll.stderr +++ b/src/test/ui/issues/issue-40510-3.nll.stderr @@ -1,5 +1,5 @@ error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-40510-3.rs:11:9 + --> $DIR/issue-40510-3.rs:7:9 | LL | || { | - inferred to be a `FnMut` closure diff --git a/src/test/ui/issues/issue-40510-3.rs b/src/test/ui/issues/issue-40510-3.rs index 205d982363128..181263adcbfa8 100644 --- a/src/test/ui/issues/issue-40510-3.rs +++ b/src/test/ui/issues/issue-40510-3.rs @@ -1,9 +1,5 @@ -#![feature(rustc_attrs)] #![allow(unused)] -// revisions: migrate nll -#![cfg_attr(nll, feature(nll))] - fn f() { let mut x: Vec<()> = Vec::new(); @@ -11,13 +7,8 @@ fn f() { || { x.push(()) } - //[migrate]~^^^ WARNING captured variable cannot escape `FnMut` closure body - //[migrate]~| WARNING this error has been downgraded to a warning - //[migrate]~| WARNING this warning will become a hard error in the future - //[nll]~^^^^^^ ERROR captured variable cannot escape `FnMut` closure body + //~^^^ ERROR captured variable cannot escape `FnMut` closure body }; } -#[rustc_error] fn main() {} -//[migrate]~^ ERROR diff --git a/src/test/ui/issues/issue-40510-3.migrate.nll.stderr b/src/test/ui/issues/issue-40510-3.stderr similarity index 94% rename from src/test/ui/issues/issue-40510-3.migrate.nll.stderr rename to src/test/ui/issues/issue-40510-3.stderr index a49475a8570a1..4bc7d0f5deac5 100644 --- a/src/test/ui/issues/issue-40510-3.migrate.nll.stderr +++ b/src/test/ui/issues/issue-40510-3.stderr @@ -1,5 +1,5 @@ error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-40510-3.rs:11:9 + --> $DIR/issue-40510-3.rs:7:9 | LL | || { | - inferred to be a `FnMut` closure diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr index 2e99572d01828..45b22511d27d6 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr @@ -1,4 +1,4 @@ -warning[E0713]: borrow may still be in use when destructor runs +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:52:5 | LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { @@ -8,12 +8,8 @@ LL | &mut *s.0 ... LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` -warning[E0713]: borrow may still be in use when destructor runs +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:63:5 | LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { @@ -23,12 +19,8 @@ LL | &mut *(*s).0 ... LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` -warning[E0713]: borrow may still be in use when destructor runs +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:74:5 | LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { @@ -38,23 +30,7 @@ LL | &mut *(**s).0 ... LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` - -error: compilation successful - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:81:1 - | -LL | / fn main() { -LL | | let mut x = 1; -LL | | { -LL | | let mut long_lived = Scribble(&mut x); -... | -LL | | *boxed_boxed_scribbled(Box::new(Box::new(Scribble(&mut x)))) += 10; -LL | | } - | |_^ -error: aborting due to previous error +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0713`. diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs index 9f261884f3d2d..b73637efe6e99 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs @@ -2,27 +2,16 @@ // mutable borrows that would be scribbled over by destructors before // the return occurs. // -// We will explicitly test NLL, and migration modes; -// thus we will also skip the automated compare-mode=nll. +// We will explicitly test NLL; thus we will also skip the automated compare-mode=nll. -// revisions: nll migrate // ignore-compare-mode-nll // ignore-compare-mode-polonius -// This test is going to pass in the migrate revision, because the AST-borrowck -// accepted this code in the past (see notes below). So we use `#[rustc_error]` -// to keep the outcome as an error in all scenarios, and rely on the stderr -// files to show what the actual behavior is. (See rust-lang/rust#49855.) -#![feature(rustc_attrs)] - -#![cfg_attr(nll, feature(nll))] - struct Scribble<'a>(&'a mut u32); impl<'a> Drop for Scribble<'a> { fn drop(&mut self) { *self.0 = 42; } } -// this is okay, in both AST-borrowck and NLL: The `Scribble` here *has* -// to strictly outlive `'a` +// this is okay: The `Scribble` here *has* to strictly outlive `'a` fn borrowed_scribble<'a>(s: &'a mut Scribble) -> &'a mut u32 { &mut *s.0 } @@ -44,41 +33,21 @@ fn boxed_boxed_borrowed_scribble<'a>(s: Box>) -> &'a mut u // * (Maybe in the future the two-phase borrows system will be // extended to support this case. But for now, it is an error in // NLL, even with two-phase borrows.) -// -// In any case, the AST-borrowck was not smart enough to know that -// this should be an error. (Which is perhaps the essence of why -// rust-lang/rust#45696 arose in the first place.) fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { - &mut *s.0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] - //[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713] - //[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility - //[migrate]~| WARNING this represents potential undefined behavior in your code + &mut *s.0 //~ ERROR borrow may still be in use when destructor runs [E0713] } // This, by analogy to previous case, is *also* not okay. -// -// (But again, AST-borrowck was not smart enogh to know that this -// should be an error.) fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { - &mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] - //[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713] - //[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility - //[migrate]~| WARNING this represents potential undefined behavior in your code + &mut *(*s).0 //~ ERROR borrow may still be in use when destructor runs [E0713] } // This, by analogy to previous case, is *also* not okay. -// -// (But again, AST-borrowck was not smart enogh to know that this -// should be an error.) fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { - &mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] - //[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713] - //[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility - //[migrate]~| WARNING this represents potential undefined behavior in your code + &mut *(**s).0 //~ ERROR borrow may still be in use when destructor runs [E0713] } -#[rustc_error] -fn main() { //[migrate]~ ERROR compilation successful +fn main() { let mut x = 1; { let mut long_lived = Scribble(&mut x); diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.stderr new file mode 100644 index 0000000000000..d1fdc289cd68e --- /dev/null +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.stderr @@ -0,0 +1,33 @@ +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:37:5 + | +LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *s.0 + | ^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` +LL | } + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait + +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:42:5 + | +LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *(*s).0 + | ^^^^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` +LL | } + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait + +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:47:5 + | +LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *(**s).0 + | ^^^^^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` +LL | } + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0713`. diff --git a/src/test/ui/issues/issue-49824.nll.stderr b/src/test/ui/issues/issue-49824.nll.stderr deleted file mode 100644 index 9c6f8d4532a70..0000000000000 --- a/src/test/ui/issues/issue-49824.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-49824.rs:10:9 - | -LL | || { - | - inferred to be a `FnMut` closure -LL | / || { -LL | | -LL | | -LL | | -LL | | let _y = &mut x; -LL | | } - | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body - | - = note: `FnMut` closures only have access to their captured variables while they are executing... - = note: ...therefore, they cannot allow references to captured variables to escape - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-49824.rs b/src/test/ui/issues/issue-49824.rs index b0d01b3d98d51..bc1cd6856bc92 100644 --- a/src/test/ui/issues/issue-49824.rs +++ b/src/test/ui/issues/issue-49824.rs @@ -1,16 +1,8 @@ -#![feature(rustc_attrs)] - -// This test checks that a warning occurs with migrate mode. - -#[rustc_error] fn main() { - //~^ ERROR compilation successful let mut x = 0; || { || { - //~^ WARNING captured variable cannot escape `FnMut` closure body - //~| WARNING this error has been downgraded to a warning - //~| WARNING this warning will become a hard error in the future + //~^ ERROR captured variable cannot escape `FnMut` closure body let _y = &mut x; } }; diff --git a/src/test/ui/issues/issue-49824.stderr b/src/test/ui/issues/issue-49824.stderr index d5f1af88e133a..6b486aafcdf40 100644 --- a/src/test/ui/issues/issue-49824.stderr +++ b/src/test/ui/issues/issue-49824.stderr @@ -1,33 +1,16 @@ -warning: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-49824.rs:10:9 +error: captured variable cannot escape `FnMut` closure body + --> $DIR/issue-49824.rs:4:9 | LL | || { | - inferred to be a `FnMut` closure LL | / || { LL | | -LL | | -LL | | LL | | let _y = &mut x; LL | | } | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body | = note: `FnMut` closures only have access to their captured variables while they are executing... = note: ...therefore, they cannot allow references to captured variables to escape - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` - -error: compilation successful - --> $DIR/issue-49824.rs:6:1 - | -LL | / fn main() { -LL | | -LL | | let mut x = 0; -LL | | || { -... | -LL | | }; -LL | | } - | |_^ error: aborting due to previous error diff --git a/src/test/ui/nll/borrowed-referent-issue-38899.rs b/src/test/ui/nll/borrowed-referent-issue-38899.rs index d4b05fb793160..1fe1332832a14 100644 --- a/src/test/ui/nll/borrowed-referent-issue-38899.rs +++ b/src/test/ui/nll/borrowed-referent-issue-38899.rs @@ -1,7 +1,5 @@ // Regression test for issue #38899 -#![feature(nll)] - pub struct Block<'a> { current: &'a u8, unrelated: &'a u8, diff --git a/src/test/ui/nll/borrowed-referent-issue-38899.stderr b/src/test/ui/nll/borrowed-referent-issue-38899.stderr index 38a6e27a0e560..16588cbcfb285 100644 --- a/src/test/ui/nll/borrowed-referent-issue-38899.stderr +++ b/src/test/ui/nll/borrowed-referent-issue-38899.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowed-referent-issue-38899.rs:13:21 + --> $DIR/borrowed-referent-issue-38899.rs:11:21 | LL | let x = &mut block; | ---------- mutable borrow occurs here diff --git a/src/test/ui/pattern/pattern-bindings-after-at.nll.stderr b/src/test/ui/pattern/pattern-bindings-after-at.nll.stderr deleted file mode 100644 index 35ee7877f2f78..0000000000000 --- a/src/test/ui/pattern/pattern-bindings-after-at.nll.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0303]: pattern bindings are not allowed after an `@` - --> $DIR/pattern-bindings-after-at.rs:8:31 - | -LL | ref mut z @ &mut Some(ref a) => { - | ^^^^^ not allowed after `@` - -error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable - --> $DIR/pattern-bindings-after-at.rs:8:31 - | -LL | ref mut z @ &mut Some(ref a) => { - | ----------------------^^^^^- - | | | - | | immutable borrow occurs here - | mutable borrow occurs here -... -LL | **z = None; - | ---------- mutable borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0303, E0502. -For more information about an error, try `rustc --explain E0303`. diff --git a/src/test/ui/pattern/pattern-bindings-after-at.rs b/src/test/ui/pattern/pattern-bindings-after-at.rs index 20a1d017cdd18..aff7264752de2 100644 --- a/src/test/ui/pattern/pattern-bindings-after-at.rs +++ b/src/test/ui/pattern/pattern-bindings-after-at.rs @@ -7,9 +7,7 @@ fn main() { match &mut Some(1) { ref mut z @ &mut Some(ref a) => { //~^ ERROR pattern bindings are not allowed after an `@` - //~| WARN cannot borrow `_` as immutable because it is also borrowed as mutable - //~| WARN this error has been downgraded to a warning for backwards compatibility - //~| WARN this represents potential undefined behavior in your code and this warning will + //~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable **z = None; println!("{}", *a); } diff --git a/src/test/ui/pattern/pattern-bindings-after-at.stderr b/src/test/ui/pattern/pattern-bindings-after-at.stderr index 70452a930ee70..35ee7877f2f78 100644 --- a/src/test/ui/pattern/pattern-bindings-after-at.stderr +++ b/src/test/ui/pattern/pattern-bindings-after-at.stderr @@ -4,7 +4,7 @@ error[E0303]: pattern bindings are not allowed after an `@` LL | ref mut z @ &mut Some(ref a) => { | ^^^^^ not allowed after `@` -warning[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable +error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable --> $DIR/pattern-bindings-after-at.rs:8:31 | LL | ref mut z @ &mut Some(ref a) => { @@ -15,12 +15,8 @@ LL | ref mut z @ &mut Some(ref a) => { ... LL | **z = None; | ---------- mutable borrow later used here - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` -error: aborting due to previous error +error: aborting due to 2 previous errors Some errors have detailed explanations: E0303, E0502. For more information about an error, try `rustc --explain E0303`. diff --git a/src/test/ui/thread-local-in-ctfe.nll.stderr b/src/test/ui/thread-local-in-ctfe.nll.stderr deleted file mode 100644 index 18d01b1879018..0000000000000 --- a/src/test/ui/thread-local-in-ctfe.nll.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:6:17 - | -LL | static B: u32 = A; - | ^ - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:9:18 - | -LL | static C: &u32 = &A; - | ^^ - -error[E0712]: thread-local variable borrowed past end of function - --> $DIR/thread-local-in-ctfe.rs:9:18 - | -LL | static C: &u32 = &A; - | ^^- end of enclosing function is here - | | - | thread-local variables cannot be borrowed beyond the end of the function - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:15:16 - | -LL | const D: u32 = A; - | ^ - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:18:17 - | -LL | const E: &u32 = &A; - | ^^ - -error[E0712]: thread-local variable borrowed past end of function - --> $DIR/thread-local-in-ctfe.rs:18:17 - | -LL | const E: &u32 = &A; - | ^^- end of enclosing function is here - | | - | thread-local variables cannot be borrowed beyond the end of the function - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:25:5 - | -LL | A - | ^ - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0712`. diff --git a/src/test/ui/thread-local-in-ctfe.rs b/src/test/ui/thread-local-in-ctfe.rs index 7ca1a2e7e90c2..722c3883fdda4 100644 --- a/src/test/ui/thread-local-in-ctfe.rs +++ b/src/test/ui/thread-local-in-ctfe.rs @@ -8,18 +8,14 @@ static B: u32 = A; static C: &u32 = &A; //~^ ERROR thread-local statics cannot be accessed at compile-time -//~| WARNING thread-local variable borrowed past end of function -//~| WARNING this error has been downgraded to a warning -//~| WARNING this warning will become a hard error in the future +//~| ERROR thread-local variable borrowed past end of function const D: u32 = A; //~^ ERROR thread-local statics cannot be accessed at compile-time const E: &u32 = &A; //~^ ERROR thread-local statics cannot be accessed at compile-time -//~| WARNING thread-local variable borrowed past end of function -//~| WARNING this error has been downgraded to a warning -//~| WARNING this warning will become a hard error in the future +//~| ERROR thread-local variable borrowed past end of function const fn f() -> u32 { A diff --git a/src/test/ui/thread-local-in-ctfe.stderr b/src/test/ui/thread-local-in-ctfe.stderr index 6869109e67fc0..2983ac3f60cf2 100644 --- a/src/test/ui/thread-local-in-ctfe.stderr +++ b/src/test/ui/thread-local-in-ctfe.stderr @@ -10,48 +10,40 @@ error[E0625]: thread-local statics cannot be accessed at compile-time LL | static C: &u32 = &A; | ^^ -warning[E0712]: thread-local variable borrowed past end of function +error[E0712]: thread-local variable borrowed past end of function --> $DIR/thread-local-in-ctfe.rs:9:18 | LL | static C: &u32 = &A; | ^^- end of enclosing function is here | | | thread-local variables cannot be borrowed beyond the end of the function - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:15:16 + --> $DIR/thread-local-in-ctfe.rs:13:16 | LL | const D: u32 = A; | ^ error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:18:17 + --> $DIR/thread-local-in-ctfe.rs:16:17 | LL | const E: &u32 = &A; | ^^ -warning[E0712]: thread-local variable borrowed past end of function - --> $DIR/thread-local-in-ctfe.rs:18:17 +error[E0712]: thread-local variable borrowed past end of function + --> $DIR/thread-local-in-ctfe.rs:16:17 | LL | const E: &u32 = &A; | ^^- end of enclosing function is here | | | thread-local variables cannot be borrowed beyond the end of the function - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - = note: for more information, try `rustc --explain E0729` error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:25:5 + --> $DIR/thread-local-in-ctfe.rs:21:5 | LL | A | ^ -error: aborting due to 5 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0712`. From 487f8ab732beebb44c1d6d3530d49a9af1c31c4b Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 6 Sep 2019 15:52:48 +0200 Subject: [PATCH 22/30] add test for #53432. --- ...3432-nested-closure-outlives-borrowed-value.rs | 7 +++++++ ...-nested-closure-outlives-borrowed-value.stderr | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.rs create mode 100644 src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr diff --git a/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.rs b/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.rs new file mode 100644 index 0000000000000..f1fd1b507c71e --- /dev/null +++ b/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.rs @@ -0,0 +1,7 @@ +fn main() { + let f = move || {}; + let _action = move || { + || f() // The `nested` closure + //~^ ERROR lifetime may not live long enough + }; +} diff --git a/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr b/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr new file mode 100644 index 0000000000000..3781691ff41dc --- /dev/null +++ b/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr @@ -0,0 +1,15 @@ +error: lifetime may not live long enough + --> $DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9 + | +LL | let _action = move || { + | ------- + | | | + | | return type of closure is [closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:15 f:&'2 [closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:2:13: 2:23]] + | lifetime `'1` represents this closure's body +LL | || f() // The `nested` closure + | ^^^^^^ returning this value requires that `'1` must outlive `'2` + | + = note: closure implements `Fn`, so references to captured variables can't escape the closure + +error: aborting due to previous error + From 2fb0bba5b5152489b0ce93d52572634a3a4d7ac0 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 6 Sep 2019 15:58:39 +0200 Subject: [PATCH 23/30] remove feature(nll) from #45157 test. --- src/test/ui/issues/issue-40510-1.nll.stderr | 13 ------------- src/test/ui/issues/issue-40510-3.nll.stderr | 15 --------------- src/test/ui/issues/issue-45157.rs | 1 - src/test/ui/issues/issue-45157.stderr | 2 +- 4 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 src/test/ui/issues/issue-40510-1.nll.stderr delete mode 100644 src/test/ui/issues/issue-40510-3.nll.stderr diff --git a/src/test/ui/issues/issue-40510-1.nll.stderr b/src/test/ui/issues/issue-40510-1.nll.stderr deleted file mode 100644 index f4fda0abc2049..0000000000000 --- a/src/test/ui/issues/issue-40510-1.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-40510-1.rs:7:9 - | -LL | || { - | - inferred to be a `FnMut` closure -LL | &mut x - | ^^^^^^ returns a reference to a captured variable which escapes the closure body - | - = note: `FnMut` closures only have access to their captured variables while they are executing... - = note: ...therefore, they cannot allow references to captured variables to escape - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-40510-3.nll.stderr b/src/test/ui/issues/issue-40510-3.nll.stderr deleted file mode 100644 index 4bc7d0f5deac5..0000000000000 --- a/src/test/ui/issues/issue-40510-3.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-40510-3.rs:7:9 - | -LL | || { - | - inferred to be a `FnMut` closure -LL | / || { -LL | | x.push(()) -LL | | } - | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body - | - = note: `FnMut` closures only have access to their captured variables while they are executing... - = note: ...therefore, they cannot allow references to captured variables to escape - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-45157.rs b/src/test/ui/issues/issue-45157.rs index 22ea254a769e8..bd18784289fe2 100644 --- a/src/test/ui/issues/issue-45157.rs +++ b/src/test/ui/issues/issue-45157.rs @@ -1,5 +1,4 @@ #![allow(unused)] -#![feature(nll)] // ignore-tidy-linelength diff --git a/src/test/ui/issues/issue-45157.stderr b/src/test/ui/issues/issue-45157.stderr index fbfa1d199566e..1b879e0b48c87 100644 --- a/src/test/ui/issues/issue-45157.stderr +++ b/src/test/ui/issues/issue-45157.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `u` (via `u.z.c`) as immutable because it is also borrowed as mutable (via `u.s.a`) - --> $DIR/issue-45157.rs:29:20 + --> $DIR/issue-45157.rs:28:20 | LL | let mref = &mut u.s.a; | ---------- mutable borrow occurs here (via `u.s.a`) From 1256613ac7ad60e4bde735b740fe546d6dc3a784 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 6 Sep 2019 16:02:04 +0200 Subject: [PATCH 24/30] remove feature(nll) from #31567 test. --- src/test/ui/nll/issue-31567.rs | 2 -- src/test/ui/nll/issue-31567.stderr | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/ui/nll/issue-31567.rs b/src/test/ui/nll/issue-31567.rs index c57a07a54d58a..623954e6d5b94 100644 --- a/src/test/ui/nll/issue-31567.rs +++ b/src/test/ui/nll/issue-31567.rs @@ -2,8 +2,6 @@ // causing region relations not to be enforced at all the places where // they have to be enforced. -#![feature(nll)] - struct VecWrapper<'a>(&'a mut S); struct S(Box); diff --git a/src/test/ui/nll/issue-31567.stderr b/src/test/ui/nll/issue-31567.stderr index d098ff82d34f0..7d43383e89fd7 100644 --- a/src/test/ui/nll/issue-31567.stderr +++ b/src/test/ui/nll/issue-31567.stderr @@ -1,5 +1,5 @@ error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-31567.rs:12:26 + --> $DIR/issue-31567.rs:10:26 | LL | fn get_dangling<'a>(v: VecWrapper<'a>) -> &'a u32 { | -- lifetime `'a` defined here From b638aa1f5b8043a16af67ca52e0645c2c1352ee3 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 6 Sep 2019 16:04:26 +0200 Subject: [PATCH 25/30] remove feature(nll) from #27868 test. --- src/test/ui/nll/issue-27868.rs | 2 -- src/test/ui/nll/issue-27868.stderr | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/ui/nll/issue-27868.rs b/src/test/ui/nll/issue-27868.rs index b5cf20bc9f965..e436b22dbaad4 100644 --- a/src/test/ui/nll/issue-27868.rs +++ b/src/test/ui/nll/issue-27868.rs @@ -1,7 +1,5 @@ // Regression test for issue #27868 -#![feature(nll)] - use std::ops::AddAssign; struct MyVec(Vec); diff --git a/src/test/ui/nll/issue-27868.stderr b/src/test/ui/nll/issue-27868.stderr index c83cb0b300b25..e0b3b5494d0a5 100644 --- a/src/test/ui/nll/issue-27868.stderr +++ b/src/test/ui/nll/issue-27868.stderr @@ -1,5 +1,5 @@ error[E0506]: cannot assign to `vecvec` because it is borrowed - --> $DIR/issue-27868.rs:26:9 + --> $DIR/issue-27868.rs:24:9 | LL | vecvec[0] += { | ------ From 2b80ed99db8097d3d0e45d03561b81ede6b443b2 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 6 Sep 2019 16:23:00 +0200 Subject: [PATCH 26/30] remove feature(nll) in more cases. --- ...issue-27282-move-match-input-into-guard.rs | 2 - ...e-27282-move-match-input-into-guard.stderr | 2 +- .../issue-27282-move-ref-mut-into-guard.rs | 5 -- ...issue-27282-move-ref-mut-into-guard.stderr | 2 +- ...sue-27282-mutate-before-diverging-arm-1.rs | 2 - ...27282-mutate-before-diverging-arm-1.stderr | 2 +- ...sue-27282-mutate-before-diverging-arm-2.rs | 2 - ...27282-mutate-before-diverging-arm-2.stderr | 2 +- ...sue-27282-mutate-before-diverging-arm-3.rs | 2 +- src/test/ui/issues/issue-29723.rs | 2 - src/test/ui/issues/issue-29723.stderr | 2 +- src/test/ui/nll/borrowed-match-issue-45045.rs | 2 - .../ui/nll/borrowed-match-issue-45045.stderr | 2 +- .../do-not-ignore-lifetime-bounds-in-copy.rs | 2 - ...-not-ignore-lifetime-bounds-in-copy.stderr | 2 +- src/test/ui/nll/enum-drop-access.rs | 2 - src/test/ui/nll/enum-drop-access.stderr | 4 +- .../nll/issue-21232-partial-init-and-use.rs | 2 - .../issue-21232-partial-init-and-use.stderr | 46 +++++++++---------- src/test/ui/nll/issue-48238.rs | 2 - src/test/ui/nll/issue-48238.stderr | 2 +- ...59-report-when-borrow-and-drop-conflict.rs | 2 - ...eport-when-borrow-and-drop-conflict.stderr | 8 ++-- src/test/ui/nll/issue-53040.rs | 2 - src/test/ui/nll/issue-53040.stderr | 2 +- src/test/ui/nll/issue-53773.rs | 2 - src/test/ui/nll/issue-53773.stderr | 2 +- src/test/ui/nll/issue-57100.rs | 1 - src/test/ui/nll/issue-57100.stderr | 4 +- src/test/ui/nll/match-guards-always-borrow.rs | 2 - .../ui/nll/match-guards-always-borrow.stderr | 2 +- src/test/ui/nll/match-on-borrowed.rs | 2 - src/test/ui/nll/match-on-borrowed.stderr | 8 ++-- 33 files changed, 47 insertions(+), 81 deletions(-) diff --git a/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs b/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs index 0721b051bcbd8..71f1f15654b55 100644 --- a/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs +++ b/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs @@ -7,8 +7,6 @@ // reaches the panic code when executed, despite the compiler warning // about that match arm being unreachable. -#![feature(nll)] - fn main() { let b = &mut true; match b { diff --git a/src/test/ui/issues/issue-27282-move-match-input-into-guard.stderr b/src/test/ui/issues/issue-27282-move-match-input-into-guard.stderr index 6993419326c8e..51f9b464d7660 100644 --- a/src/test/ui/issues/issue-27282-move-match-input-into-guard.stderr +++ b/src/test/ui/issues/issue-27282-move-match-input-into-guard.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `b` - --> $DIR/issue-27282-move-match-input-into-guard.rs:18:14 + --> $DIR/issue-27282-move-match-input-into-guard.rs:16:14 | LL | let b = &mut true; | - move occurs because `b` has type `&mut bool`, which does not implement the `Copy` trait diff --git a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs b/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs index e570b04a2bead..afa0ba780de46 100644 --- a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs +++ b/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs @@ -1,11 +1,6 @@ // Issue 27282: Example 1: This sidesteps the AST checks disallowing // mutable borrows in match guards by hiding the mutable borrow in a // guard behind a move (of the ref mut pattern id) within a closure. -// -// This example is not rejected by AST borrowck (and then reliably -// segfaults when executed). - -#![feature(nll)] fn main() { match Some(&4) { diff --git a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr b/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr index c5a9dd98a1596..30cf0d66afaff 100644 --- a/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr +++ b/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/issue-27282-move-ref-mut-into-guard.rs:14:19 + --> $DIR/issue-27282-move-ref-mut-into-guard.rs:9:19 | LL | if { (|| { let bar = foo; bar.take() })(); false } => {}, | ^^ --- diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs index 3fb13d66ccb32..d17d6f07f6870 100644 --- a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs +++ b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs @@ -9,8 +9,6 @@ // diverges, and therefore a single final fake-read at the very end // after the final match arm would not suffice. -#![feature(nll)] - struct ForceFnOnce; fn main() { diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr index 199407ad77463..188f0b25c3084 100644 --- a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr +++ b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr @@ -1,5 +1,5 @@ error[E0510]: cannot mutably borrow `x` in match guard - --> $DIR/issue-27282-mutate-before-diverging-arm-1.rs:23:14 + --> $DIR/issue-27282-mutate-before-diverging-arm-1.rs:21:14 | LL | match x { | - value is immutable in match guard diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.rs b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.rs index f5eaae925db01..9c3e7e9978ec7 100644 --- a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.rs +++ b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.rs @@ -13,8 +13,6 @@ // occurs in the pattern-match itself, and not in the guard // expression. -#![feature(nll)] - struct ForceFnOnce; fn main() { diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.stderr b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.stderr index 3c72cb02015a0..f0a3151f4e12f 100644 --- a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.stderr +++ b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.stderr @@ -1,5 +1,5 @@ error[E0510]: cannot mutably borrow `x` in match guard - --> $DIR/issue-27282-mutate-before-diverging-arm-2.rs:28:18 + --> $DIR/issue-27282-mutate-before-diverging-arm-2.rs:26:18 | LL | match x { | - value is immutable in match guard diff --git a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs index 4cf5bcd6b4f68..cff9e963e2725 100644 --- a/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs +++ b/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs @@ -8,7 +8,7 @@ // This case is interesting because a borrow of **x is untracked, because **x is // immutable. However, for matches we care that **x refers to the same value // until we have chosen a match arm. -#![feature(nll)] + struct ForceFnOnce; fn main() { let mut x = &mut &Some(&2); diff --git a/src/test/ui/issues/issue-29723.rs b/src/test/ui/issues/issue-29723.rs index 41db52a1fadac..ce91022f093d4 100644 --- a/src/test/ui/issues/issue-29723.rs +++ b/src/test/ui/issues/issue-29723.rs @@ -1,5 +1,3 @@ -#![feature(nll)] - // test for https://github.com/rust-lang/rust/issues/29723 fn main() { diff --git a/src/test/ui/issues/issue-29723.stderr b/src/test/ui/issues/issue-29723.stderr index 7928af5d5a5cd..04915ab5f9510 100644 --- a/src/test/ui/issues/issue-29723.stderr +++ b/src/test/ui/issues/issue-29723.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `s` - --> $DIR/issue-29723.rs:12:13 + --> $DIR/issue-29723.rs:10:13 | LL | let s = String::new(); | - move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait diff --git a/src/test/ui/nll/borrowed-match-issue-45045.rs b/src/test/ui/nll/borrowed-match-issue-45045.rs index 59516d8b444d1..0cd8e956d309f 100644 --- a/src/test/ui/nll/borrowed-match-issue-45045.rs +++ b/src/test/ui/nll/borrowed-match-issue-45045.rs @@ -1,7 +1,5 @@ // Regression test for issue #45045 -#![feature(nll)] - enum Xyz { A, B, diff --git a/src/test/ui/nll/borrowed-match-issue-45045.stderr b/src/test/ui/nll/borrowed-match-issue-45045.stderr index f8d4d56621deb..1607304e6716b 100644 --- a/src/test/ui/nll/borrowed-match-issue-45045.stderr +++ b/src/test/ui/nll/borrowed-match-issue-45045.stderr @@ -1,5 +1,5 @@ error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowed-match-issue-45045.rs:15:9 + --> $DIR/borrowed-match-issue-45045.rs:13:9 | LL | let f = &mut e; | ------ borrow of `e` occurs here diff --git a/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.rs b/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.rs index 2a1321c25510f..99922cc51b0d1 100644 --- a/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.rs +++ b/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.rs @@ -1,7 +1,5 @@ // Test that the 'static bound from the Copy impl is respected. Regression test for #29149. -#![feature(nll)] - #[derive(Clone)] struct Foo<'a>(&'a u32); impl Copy for Foo<'static> {} diff --git a/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr b/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr index bf5c571b455b3..b811ba4fd0cd2 100644 --- a/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr +++ b/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr @@ -1,5 +1,5 @@ error[E0597]: `s` does not live long enough - --> $DIR/do-not-ignore-lifetime-bounds-in-copy.rs:10:17 + --> $DIR/do-not-ignore-lifetime-bounds-in-copy.rs:8:17 | LL | let a = Foo(&s); | ^^ borrowed value does not live long enough diff --git a/src/test/ui/nll/enum-drop-access.rs b/src/test/ui/nll/enum-drop-access.rs index dc436d20fd857..5ef0c3fe73dbf 100644 --- a/src/test/ui/nll/enum-drop-access.rs +++ b/src/test/ui/nll/enum-drop-access.rs @@ -1,5 +1,3 @@ -#![feature(nll)] - enum DropOption { Some(T), None, diff --git a/src/test/ui/nll/enum-drop-access.stderr b/src/test/ui/nll/enum-drop-access.stderr index 699179fd52fd4..a532ae121a6ef 100644 --- a/src/test/ui/nll/enum-drop-access.stderr +++ b/src/test/ui/nll/enum-drop-access.stderr @@ -1,5 +1,5 @@ error[E0713]: borrow may still be in use when destructor runs - --> $DIR/enum-drop-access.rs:15:31 + --> $DIR/enum-drop-access.rs:13:31 | LL | fn drop_enum(opt: DropOption<&mut i32>) -> Option<&mut i32> { | - let's call the lifetime of this reference `'1` @@ -13,7 +13,7 @@ LL | } | - here, drop of `opt` needs exclusive access to `*opt.0`, because the type `DropOption<&mut i32>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/enum-drop-access.rs:24:36 + --> $DIR/enum-drop-access.rs:22:36 | LL | fn optional_drop_enum(opt: Option>) -> Option<&mut i32> { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/nll/issue-21232-partial-init-and-use.rs b/src/test/ui/nll/issue-21232-partial-init-and-use.rs index 7da47c85f5450..1836f766cc7ef 100644 --- a/src/test/ui/nll/issue-21232-partial-init-and-use.rs +++ b/src/test/ui/nll/issue-21232-partial-init-and-use.rs @@ -12,8 +12,6 @@ // tests that are meant to continue failing to compile once // rust-lang/rust#54987 is implemented. -#![feature(nll)] - struct S { x: u32, diff --git a/src/test/ui/nll/issue-21232-partial-init-and-use.stderr b/src/test/ui/nll/issue-21232-partial-init-and-use.stderr index 32147898320c0..9e69262b38900 100644 --- a/src/test/ui/nll/issue-21232-partial-init-and-use.stderr +++ b/src/test/ui/nll/issue-21232-partial-init-and-use.stderr @@ -1,17 +1,17 @@ error[E0381]: assign to part of possibly-uninitialized variable: `s` - --> $DIR/issue-21232-partial-init-and-use.rs:99:5 + --> $DIR/issue-21232-partial-init-and-use.rs:97:5 | LL | s.x = 10; s.y = Box::new(20); | ^^^^^^^^ use of possibly-uninitialized `s` error[E0381]: assign to part of possibly-uninitialized variable: `t` - --> $DIR/issue-21232-partial-init-and-use.rs:106:5 + --> $DIR/issue-21232-partial-init-and-use.rs:104:5 | LL | t.0 = 10; t.1 = Box::new(20); | ^^^^^^^^ use of possibly-uninitialized `t` error[E0382]: assign to part of moved value: `s` - --> $DIR/issue-21232-partial-init-and-use.rs:113:5 + --> $DIR/issue-21232-partial-init-and-use.rs:111:5 | LL | let mut s: S = S::new(); drop(s); | ----- - value moved here @@ -21,7 +21,7 @@ LL | s.x = 10; s.y = Box::new(20); | ^^^^^^^^ value partially assigned here after move error[E0382]: assign to part of moved value: `t` - --> $DIR/issue-21232-partial-init-and-use.rs:120:5 + --> $DIR/issue-21232-partial-init-and-use.rs:118:5 | LL | let mut t: T = (0, Box::new(0)); drop(t); | ----- - value moved here @@ -31,19 +31,19 @@ LL | t.0 = 10; t.1 = Box::new(20); | ^^^^^^^^ value partially assigned here after move error[E0381]: assign to part of possibly-uninitialized variable: `s` - --> $DIR/issue-21232-partial-init-and-use.rs:127:5 + --> $DIR/issue-21232-partial-init-and-use.rs:125:5 | LL | s.x = 10; | ^^^^^^^^ use of possibly-uninitialized `s` error[E0381]: assign to part of possibly-uninitialized variable: `t` - --> $DIR/issue-21232-partial-init-and-use.rs:134:5 + --> $DIR/issue-21232-partial-init-and-use.rs:132:5 | LL | t.0 = 10; | ^^^^^^^^ use of possibly-uninitialized `t` error[E0382]: assign to part of moved value: `s` - --> $DIR/issue-21232-partial-init-and-use.rs:141:5 + --> $DIR/issue-21232-partial-init-and-use.rs:139:5 | LL | let mut s: S = S::new(); drop(s); | ----- - value moved here @@ -53,7 +53,7 @@ LL | s.x = 10; | ^^^^^^^^ value partially assigned here after move error[E0382]: assign to part of moved value: `t` - --> $DIR/issue-21232-partial-init-and-use.rs:148:5 + --> $DIR/issue-21232-partial-init-and-use.rs:146:5 | LL | let mut t: T = (0, Box::new(0)); drop(t); | ----- - value moved here @@ -63,31 +63,31 @@ LL | t.0 = 10; | ^^^^^^^^ value partially assigned here after move error[E0381]: assign to part of possibly-uninitialized variable: `s` - --> $DIR/issue-21232-partial-init-and-use.rs:155:5 + --> $DIR/issue-21232-partial-init-and-use.rs:153:5 | LL | s.x = 10; | ^^^^^^^^ use of possibly-uninitialized `s` error[E0381]: assign to part of possibly-uninitialized variable: `t` - --> $DIR/issue-21232-partial-init-and-use.rs:162:5 + --> $DIR/issue-21232-partial-init-and-use.rs:160:5 | LL | t.0 = 10; | ^^^^^^^^ use of possibly-uninitialized `t` error[E0381]: assign to part of possibly-uninitialized variable: `q` - --> $DIR/issue-21232-partial-init-and-use.rs:178:5 + --> $DIR/issue-21232-partial-init-and-use.rs:176:5 | LL | q.r.f.x = 10; q.r.f.y = Box::new(20); | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f` error[E0381]: assign to part of possibly-uninitialized variable: `q` - --> $DIR/issue-21232-partial-init-and-use.rs:185:5 + --> $DIR/issue-21232-partial-init-and-use.rs:183:5 | LL | q.r.f.0 = 10; q.r.f.1 = Box::new(20); | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f` error[E0382]: assign to part of moved value: `q.r` - --> $DIR/issue-21232-partial-init-and-use.rs:192:5 + --> $DIR/issue-21232-partial-init-and-use.rs:190:5 | LL | let mut q: Q> = Q::new(S::new()); drop(q.r); | --- value moved here @@ -97,7 +97,7 @@ LL | q.r.f.x = 10; q.r.f.y = Box::new(20); = note: move occurs because `q.r` has type `R>>`, which does not implement the `Copy` trait error[E0382]: assign to part of moved value: `q.r` - --> $DIR/issue-21232-partial-init-and-use.rs:199:5 + --> $DIR/issue-21232-partial-init-and-use.rs:197:5 | LL | let mut q: Q = Q::new((0, Box::new(0))); drop(q.r); | --- value moved here @@ -107,19 +107,19 @@ LL | q.r.f.0 = 10; q.r.f.1 = Box::new(20); = note: move occurs because `q.r` has type `R<(u32, std::boxed::Box)>`, which does not implement the `Copy` trait error[E0381]: assign to part of possibly-uninitialized variable: `q` - --> $DIR/issue-21232-partial-init-and-use.rs:206:5 + --> $DIR/issue-21232-partial-init-and-use.rs:204:5 | LL | q.r.f.x = 10; | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f` error[E0381]: assign to part of possibly-uninitialized variable: `q` - --> $DIR/issue-21232-partial-init-and-use.rs:213:5 + --> $DIR/issue-21232-partial-init-and-use.rs:211:5 | LL | q.r.f.0 = 10; | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f` error[E0382]: assign to part of moved value: `q.r` - --> $DIR/issue-21232-partial-init-and-use.rs:220:5 + --> $DIR/issue-21232-partial-init-and-use.rs:218:5 | LL | let mut q: Q> = Q::new(S::new()); drop(q.r); | --- value moved here @@ -129,7 +129,7 @@ LL | q.r.f.x = 10; = note: move occurs because `q.r` has type `R>>`, which does not implement the `Copy` trait error[E0382]: assign to part of moved value: `q.r` - --> $DIR/issue-21232-partial-init-and-use.rs:227:5 + --> $DIR/issue-21232-partial-init-and-use.rs:225:5 | LL | let mut q: Q = Q::new((0, Box::new(0))); drop(q.r); | --- value moved here @@ -139,19 +139,19 @@ LL | q.r.f.0 = 10; = note: move occurs because `q.r` has type `R<(u32, std::boxed::Box)>`, which does not implement the `Copy` trait error[E0381]: assign to part of possibly-uninitialized variable: `q` - --> $DIR/issue-21232-partial-init-and-use.rs:234:5 + --> $DIR/issue-21232-partial-init-and-use.rs:232:5 | LL | q.r.f.x = 10; | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f` error[E0381]: assign to part of possibly-uninitialized variable: `q` - --> $DIR/issue-21232-partial-init-and-use.rs:241:5 + --> $DIR/issue-21232-partial-init-and-use.rs:239:5 | LL | q.r.f.0 = 10; | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f` error[E0382]: assign to part of moved value: `c` - --> $DIR/issue-21232-partial-init-and-use.rs:259:13 + --> $DIR/issue-21232-partial-init-and-use.rs:257:13 | LL | let mut c = (1, "".to_owned()); | ----- move occurs because `c` has type `(i32, std::string::String)`, which does not implement the `Copy` trait @@ -162,7 +162,7 @@ LL | c.0 = 2; | ^^^^^^^ value partially assigned here after move error[E0382]: assign to part of moved value: `c` - --> $DIR/issue-21232-partial-init-and-use.rs:269:13 + --> $DIR/issue-21232-partial-init-and-use.rs:267:13 | LL | let mut c = (1, (1, "".to_owned())); | ----- move occurs because `c` has type `(i32, (i32, std::string::String))`, which does not implement the `Copy` trait @@ -173,7 +173,7 @@ LL | (c.1).0 = 2; | ^^^^^^^^^^^ value partially assigned here after move error[E0382]: assign to part of moved value: `c.1` - --> $DIR/issue-21232-partial-init-and-use.rs:277:13 + --> $DIR/issue-21232-partial-init-and-use.rs:275:13 | LL | c2 => { | -- value moved here diff --git a/src/test/ui/nll/issue-48238.rs b/src/test/ui/nll/issue-48238.rs index 2e64ea72db28b..d2e9285fa4137 100644 --- a/src/test/ui/nll/issue-48238.rs +++ b/src/test/ui/nll/issue-48238.rs @@ -1,7 +1,5 @@ // Regression test for issue #48238 -#![feature(nll)] - fn use_val<'a>(val: &'a u8) -> &'a u8 { val } diff --git a/src/test/ui/nll/issue-48238.stderr b/src/test/ui/nll/issue-48238.stderr index 05a90eec05c3f..0aa1eedad9fd9 100644 --- a/src/test/ui/nll/issue-48238.stderr +++ b/src/test/ui/nll/issue-48238.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-48238.rs:11:13 + --> $DIR/issue-48238.rs:9:13 | LL | move || use_val(&orig); | ------- ^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` diff --git a/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs b/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs index 58416c31edde7..7ea1c445d143e 100644 --- a/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs +++ b/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs @@ -3,8 +3,6 @@ // one of its fields, it is useful to be reminded of the significance // of the fact that the type implements Drop. -#![feature(nll)] - pub struct S<'a> { url: &'a mut String } impl<'a> Drop for S<'a> { fn drop(&mut self) { } } diff --git a/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr b/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr index ce48457abe7ec..1a1250ff9353f 100644 --- a/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr +++ b/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr @@ -1,5 +1,5 @@ error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:13:5 + --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:11:5 | LL | fn finish_1(s: S) -> &mut String { | - has type `S<'1>` @@ -9,7 +9,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:18:13 + --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:16:13 | LL | fn finish_2(s: S) -> &mut String { | - has type `S<'1>` @@ -19,7 +19,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:23:21 + --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:21:21 | LL | fn finish_3(s: S) -> &mut String { | - has type `S<'1>` @@ -29,7 +29,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait error[E0509]: cannot move out of type `S<'_>`, which implements the `Drop` trait - --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:28:13 + --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:26:13 | LL | let p = s.url; p | ^^^^^ diff --git a/src/test/ui/nll/issue-53040.rs b/src/test/ui/nll/issue-53040.rs index 8ce24c8ede9ac..e4ee6e913f683 100644 --- a/src/test/ui/nll/issue-53040.rs +++ b/src/test/ui/nll/issue-53040.rs @@ -1,5 +1,3 @@ -#![feature(nll)] - fn main() { let mut v: Vec<()> = Vec::new(); || &mut v; diff --git a/src/test/ui/nll/issue-53040.stderr b/src/test/ui/nll/issue-53040.stderr index 9e7e63af87db1..7cba32c67432c 100644 --- a/src/test/ui/nll/issue-53040.stderr +++ b/src/test/ui/nll/issue-53040.stderr @@ -1,5 +1,5 @@ error: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-53040.rs:5:8 + --> $DIR/issue-53040.rs:3:8 | LL | || &mut v; | - ^^^^^^ returns a reference to a captured variable which escapes the closure body diff --git a/src/test/ui/nll/issue-53773.rs b/src/test/ui/nll/issue-53773.rs index 62e1631dcf36f..ed971b6ce0e1b 100644 --- a/src/test/ui/nll/issue-53773.rs +++ b/src/test/ui/nll/issue-53773.rs @@ -1,5 +1,3 @@ -#![feature(nll)] - struct Archive; struct ArchiveIterator<'a> { x: &'a Archive, diff --git a/src/test/ui/nll/issue-53773.stderr b/src/test/ui/nll/issue-53773.stderr index 1933ef7a2dbc7..45831460e5238 100644 --- a/src/test/ui/nll/issue-53773.stderr +++ b/src/test/ui/nll/issue-53773.stderr @@ -1,5 +1,5 @@ error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-53773.rs:43:22 + --> $DIR/issue-53773.rs:41:22 | LL | members.push(child.raw); | ^^^^^^^^^ diff --git a/src/test/ui/nll/issue-57100.rs b/src/test/ui/nll/issue-57100.rs index f669fe00956ef..c7f3e9d730367 100644 --- a/src/test/ui/nll/issue-57100.rs +++ b/src/test/ui/nll/issue-57100.rs @@ -1,5 +1,4 @@ #![allow(unused)] -#![feature(nll)] // ignore-tidy-linelength diff --git a/src/test/ui/nll/issue-57100.stderr b/src/test/ui/nll/issue-57100.stderr index 5d5c86c34875c..5f733c14036b0 100644 --- a/src/test/ui/nll/issue-57100.stderr +++ b/src/test/ui/nll/issue-57100.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `r.r2_union.f3_union` (via `r.r2_union.f3_union.s2_leaf.l1_u8`) as immutable because it is also borrowed as mutable (via `r.r2_union.f3_union.s1_leaf.l1_u8`) - --> $DIR/issue-57100.rs:44:20 + --> $DIR/issue-57100.rs:43:20 | LL | let mref = &mut r.r2_union.f3_union.s1_leaf.l1_u8; | -------------------------------------- mutable borrow occurs here (via `r.r2_union.f3_union.s1_leaf.l1_u8`) @@ -13,7 +13,7 @@ LL | println!("{} {}", mref, nref) = note: `r.r2_union.f3_union.s2_leaf.l1_u8` is a field of the union `Second`, so it overlaps the field `r.r2_union.f3_union.s1_leaf.l1_u8` error[E0502]: cannot borrow `r.r2_union` (via `r.r2_union.f1_leaf.l1_u8`) as immutable because it is also borrowed as mutable (via `r.r2_union.f2_leaf.l1_u8`) - --> $DIR/issue-57100.rs:62:20 + --> $DIR/issue-57100.rs:61:20 | LL | let mref = &mut r.r2_union.f2_leaf.l1_u8; | ----------------------------- mutable borrow occurs here (via `r.r2_union.f2_leaf.l1_u8`) diff --git a/src/test/ui/nll/match-guards-always-borrow.rs b/src/test/ui/nll/match-guards-always-borrow.rs index d423730bdbc35..87dba187ba2c2 100644 --- a/src/test/ui/nll/match-guards-always-borrow.rs +++ b/src/test/ui/nll/match-guards-always-borrow.rs @@ -1,5 +1,3 @@ -#![feature(nll)] - // Here is arielb1's basic example from rust-lang/rust#27282 // that AST borrowck is flummoxed by: diff --git a/src/test/ui/nll/match-guards-always-borrow.stderr b/src/test/ui/nll/match-guards-always-borrow.stderr index 5b49db45a52ec..15f94043b430f 100644 --- a/src/test/ui/nll/match-guards-always-borrow.stderr +++ b/src/test/ui/nll/match-guards-always-borrow.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/match-guards-always-borrow.rs:10:14 + --> $DIR/match-guards-always-borrow.rs:8:14 | LL | (|| { let bar = foo; bar.take() })(); | ^^ --- diff --git a/src/test/ui/nll/match-on-borrowed.rs b/src/test/ui/nll/match-on-borrowed.rs index edce2b185df34..aba0a7f71f5c1 100644 --- a/src/test/ui/nll/match-on-borrowed.rs +++ b/src/test/ui/nll/match-on-borrowed.rs @@ -5,8 +5,6 @@ // Test that we don't allow mutating the value being matched on in a way that // changes which patterns it matches, until we have chosen an arm. -#![feature(nll)] - struct A(i32, i32); fn struct_example(mut a: A) { diff --git a/src/test/ui/nll/match-on-borrowed.stderr b/src/test/ui/nll/match-on-borrowed.stderr index 284a910a01b8a..f9c9a84632212 100644 --- a/src/test/ui/nll/match-on-borrowed.stderr +++ b/src/test/ui/nll/match-on-borrowed.stderr @@ -1,5 +1,5 @@ error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/match-on-borrowed.rs:51:9 + --> $DIR/match-on-borrowed.rs:49:9 | LL | E::V(ref mut x, _) => x, | --------- borrow of `e.0` occurs here @@ -11,7 +11,7 @@ LL | x; | - borrow later used here error[E0503]: cannot use `*f` because it was mutably borrowed - --> $DIR/match-on-borrowed.rs:64:9 + --> $DIR/match-on-borrowed.rs:62:9 | LL | E::V(ref mut x, _) => x, | --------- borrow of `f.0` occurs here @@ -23,7 +23,7 @@ LL | x; | - borrow later used here error[E0503]: cannot use `t` because it was mutably borrowed - --> $DIR/match-on-borrowed.rs:82:9 + --> $DIR/match-on-borrowed.rs:80:9 | LL | let x = &mut t; | ------ borrow of `t` occurs here @@ -35,7 +35,7 @@ LL | x; | - borrow later used here error[E0381]: use of possibly-uninitialized variable: `n` - --> $DIR/match-on-borrowed.rs:92:11 + --> $DIR/match-on-borrowed.rs:90:11 | LL | match n {} | ^ use of possibly-uninitialized `n` From dfdd4d79d4ae0055ef6ef4a35a3d1413ea503057 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 25 Sep 2019 22:08:10 +0200 Subject: [PATCH 27/30] rm "src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr" --- ...96-scribble-on-boxed-borrow.migrate.stderr | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr deleted file mode 100644 index 45b22511d27d6..0000000000000 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:52:5 - | -LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { - | -- lifetime `'a` defined here -LL | &mut *s.0 - | ^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` -... -LL | } - | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait - -error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:63:5 - | -LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { - | -- lifetime `'a` defined here -LL | &mut *(*s).0 - | ^^^^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` -... -LL | } - | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait - -error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:74:5 - | -LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { - | -- lifetime `'a` defined here -LL | &mut *(**s).0 - | ^^^^^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` -... -LL | } - | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0713`. From ce8c5d2749e68b2bade9df0133c1c3d9ee390d4b Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 25 Sep 2019 22:09:09 +0200 Subject: [PATCH 28/30] issue-#45696-scribble...: remove outdated comment. --- src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs | 2 -- .../ui/issues/issue-45696-scribble-on-boxed-borrow.stderr | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs index b73637efe6e99..e9daf39262c2b 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs @@ -1,8 +1,6 @@ // rust-lang/rust#45696: This test is checking that we *cannot* return // mutable borrows that would be scribbled over by destructors before // the return occurs. -// -// We will explicitly test NLL; thus we will also skip the automated compare-mode=nll. // ignore-compare-mode-nll // ignore-compare-mode-polonius diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.stderr index d1fdc289cd68e..18aa38899cb8e 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.stderr +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.stderr @@ -1,5 +1,5 @@ error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:37:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:35:5 | LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -9,7 +9,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:42:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:40:5 | LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -19,7 +19,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:47:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:45:5 | LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { | -- lifetime `'a` defined here From f8af7666bdaeefce8692a962ee93b94040e37c0d Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 26 Sep 2019 06:44:50 +0200 Subject: [PATCH 29/30] cargotest: bump webrender --- src/tools/cargotest/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 1a42e0cac3ccc..30dee9bebc004 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -61,7 +61,7 @@ const TEST_REPOS: &'static [Test] = &[ Test { name: "webrender", repo: "https://github.com/servo/webrender", - sha: "cdadd068f4c7218bd983d856981d561e605270ab", + sha: "a3d6e6894c5a601fa547c6273eb963ca1321c2bb", lock: None, packages: &[], }, From 9a2cc54e11e919acf83827609ed0fb0d07bf0778 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 26 Sep 2019 07:50:39 +0200 Subject: [PATCH 30/30] cargotest: bump iron --- src/tools/cargotest/lockfiles/iron-Cargo.lock | 457 ------------------ src/tools/cargotest/main.rs | 4 +- 2 files changed, 2 insertions(+), 459 deletions(-) delete mode 100644 src/tools/cargotest/lockfiles/iron-Cargo.lock diff --git a/src/tools/cargotest/lockfiles/iron-Cargo.lock b/src/tools/cargotest/lockfiles/iron-Cargo.lock deleted file mode 100644 index 3aa3883b701d1..0000000000000 --- a/src/tools/cargotest/lockfiles/iron-Cargo.lock +++ /dev/null @@ -1,457 +0,0 @@ -[root] -name = "iron" -version = "0.5.1" -dependencies = [ - "conduit-mime-types 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper-native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "advapi32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "antidote" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "conduit-mime-types" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "core-foundation" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "core-foundation-sys" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crypt32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foreign-types" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "gcc" -version = "0.3.45" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "gdi32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "httparse" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "hyper" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hyper-native-tls" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "idna" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "language-tags" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "matches" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "mime" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "modifier" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "native-tls" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "openssl 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", - "schannel 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num_cpus" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl-sys" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", - "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pkg-config" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "plugin" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redox_syscall" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc-serialize" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc_version" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "schannel" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crypt32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "secur32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "secur32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "security-framework" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "security-framework-sys" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "tempdir" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "time" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "traitobject" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "typeable" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "typemap" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unsafe-any 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicase" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-bidi" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unsafe-any" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "url" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "user32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e06588080cb19d0acb6739808aafa5f26bfb2ca015b2b6370028b44cf7cb8a9a" -"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" -"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum conduit-mime-types 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "95ca30253581af809925ef68c2641cc140d6183f43e12e0af4992d53768bd7b8" -"checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" -"checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" -"checksum crypt32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e34988f7e069e0b2f3bfc064295161e489b2d4e04a2e4248fb94360cdf00b4ec" -"checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d" -"checksum gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "40899336fb50db0c78710f53e87afc54d8c7266fb76262fecc78ca1a7f09deae" -"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" -"checksum httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a6e7a63e511f9edffbab707141fbb8707d1a3098615fb2adbd5769cdfcc9b17d" -"checksum hyper 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)" = "43a15e3273b2133aaac0150478ab443fb89f15c3de41d8d93d8f3bb14bf560f6" -"checksum hyper-native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "afe68f772f0497a7205e751626bb8e1718568b58534b6108c73a74ef80483409" -"checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" -"checksum lazy_static 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4732c563b9a21a406565c4747daa7b46742f082911ae4753f390dc9ec7ee1a97" -"checksum libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "88ee81885f9f04bff991e306fea7c1c60a5f0f9e409e99f6b40e3311a3363135" -"checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad" -"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" -"checksum mime 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5514f038123342d01ee5f95129e4ef1e0470c93bc29edf058a46f9ee3ba6737e" -"checksum modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58" -"checksum native-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b805ee0e8fa268f67a4e5c7f4f80adb8af1fc4428ea0ce5b0ecab1430ef17ec0" -"checksum num_cpus 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a18c392466409c50b87369414a2680c93e739aedeb498eb2bff7d7eb569744e2" -"checksum openssl 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8aa0eb7aad44f0da6f7dda13ddb4559d91a0f40cfab150b1f76ad5b39ec523f" -"checksum openssl-sys 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)" = "14f5bfd12054d764510b887152d564ba11d99ae24ea7d740781778f646620576" -"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" -"checksum plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a6a0dc3910bc8db877ffed8e457763b317cf880df4ae19109b9f77d277cf6e0" -"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d" -"checksum redox_syscall 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "29dbdfd4b9df8ab31dec47c6087b7b13cbf4a776f335e4de8efba8288dda075b" -"checksum rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "684ce48436d6465300c9ea783b6b14c4361d6b8dcbb1375b486a69cc19e2dfb0" -"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" -"checksum schannel 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b291854e37196c2b67249e09d6bdeff410b19e1acf05558168e9c4413b4e95" -"checksum secur32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f412dfa83308d893101dd59c10d6fda8283465976c28c287c5c855bf8d216bc" -"checksum security-framework 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2a8396fe671bb1f80fa3f4ff2aae0e968de16ef18d37a4e5e514771a1f07726e" -"checksum security-framework-sys 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "573b031c5f672b298cca566fac71aceea00e41bc925e75b5ec7b44dc7237180a" -"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" -"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" -"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade" -"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" -"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" -"checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" -"checksum unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a5906ca2b98c799f4b1ab4557b76367ebd6ae5ef14930ec841c74aed5f3764" -"checksum unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a078ebdd62c0e71a709c3d53d2af693fe09fe93fbff8344aebe289b78f9032" -"checksum unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e28fa37426fceeb5cf8f41ee273faa7c82c47dc8fba5853402841e665fcd86ff" -"checksum unsafe-any 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b351086021ebc264aea3ab4f94d61d889d98e5e9ec2d985d993f50133537fd3a" -"checksum url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5ba8a749fb4479b043733416c244fa9d1d3af3d7c23804944651c8a448cb87e" -"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 30dee9bebc004..bdbc544d4fc3b 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -17,8 +17,8 @@ const TEST_REPOS: &'static [Test] = &[ Test { name: "iron", repo: "https://github.com/iron/iron", - sha: "21c7dae29c3c214c08533c2a55ac649b418f2fe3", - lock: Some(include_str!("lockfiles/iron-Cargo.lock")), + sha: "cf056ea5e8052c1feea6141e40ab0306715a2c33", + lock: None, packages: &[], }, Test {