diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000000000..df230cde9b713 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,6 @@ +# Currently, most of the code in the compiler uses historical style. +# +# For new code, consider running rustfmt with this config (it should +# be picked up automatically). +version = "Two" +use_small_heuristics = "Max" diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index 78de85398594e..7f1352095d936 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -92,10 +92,12 @@ impl<'a> DefCollector<'a> { visit::walk_generics(this, generics); // Walk the generated arguments for the `async fn`. - for a in arguments { + for (i, a) in arguments.iter().enumerate() { use visit::Visitor; if let Some(arg) = &a.arg { this.visit_ty(&arg.ty); + } else { + this.visit_ty(&decl.inputs[i].ty); } } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index a8f39e441309a..2044e5ddae90e 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -97,9 +97,8 @@ impl SuppressRegionErrors { // If we're on Migrate mode, report AST region errors BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, - // If we're on MIR or Compare mode, don't report AST region errors as they should - // be reported by NLL - BorrowckMode::Compare | BorrowckMode::Mir => SuppressRegionErrors { suppressed: true }, + // If we're on MIR, don't report AST region errors as they should be reported by NLL + BorrowckMode::Mir => SuppressRegionErrors { suppressed: true }, } } } diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 6d8558211818b..f85fd524a5d9b 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -1,13 +1,14 @@ +use rustc_data_structures::fx::FxHashMap; +use syntax_pos::Span; + use crate::hir::def_id::DefId; use crate::hir; use crate::hir::Node; use crate::infer::{self, InferCtxt, InferOk, TypeVariableOrigin}; use crate::infer::outlives::free_region_map::FreeRegionRelations; -use rustc_data_structures::fx::FxHashMap; use crate::traits::{self, PredicateObligation}; use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind}; -use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; -use crate::ty::outlives::Component; +use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor}; use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind}; use crate::util::nodemap::DefIdMap; @@ -373,58 +374,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let least_region = least_region.unwrap_or(self.tcx.lifetimes.re_static); debug!("constrain_opaque_types: least_region={:?}", least_region); - // Require that the type `concrete_ty` outlives - // `least_region`, modulo any type parameters that appear - // in the type, which we ignore. This is because impl - // trait values are assumed to capture all the in-scope - // type parameters. This little loop here just invokes - // `outlives` repeatedly, draining all the nested - // obligations that result. - let mut types = vec![concrete_ty]; - let bound_region = |r| self.sub_regions(infer::CallReturn(span), least_region, r); - while let Some(ty) = types.pop() { - let mut components = smallvec![]; - self.tcx.push_outlives_components(ty, &mut components); - while let Some(component) = components.pop() { - match component { - Component::Region(r) => { - bound_region(r); - } - - Component::Param(_) => { - // ignore type parameters like `T`, they are captured - // implicitly by the `impl Trait` - } - - Component::UnresolvedInferenceVariable(_) => { - // we should get an error that more type - // annotations are needed in this case - self.tcx - .sess - .delay_span_bug(span, "unresolved inf var in opaque"); - } - - Component::Projection(ty::ProjectionTy { - substs, - item_def_id: _, - }) => { - for k in substs { - match k.unpack() { - UnpackedKind::Lifetime(lt) => bound_region(lt), - UnpackedKind::Type(ty) => types.push(ty), - UnpackedKind::Const(_) => { - // Const parameters don't impose constraints. - } - } - } - } - - Component::EscapingProjection(more_components) => { - components.extend(more_components); - } - } - } - } + concrete_ty.visit_with(&mut OpaqueTypeOutlivesVisitor { + infcx: self, + least_region, + span, + }); } /// Given the fully resolved, instantiated type for an opaque @@ -502,6 +456,80 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } +// Visitor that requires that (almost) all regions in the type visited outlive +// `least_region`. We cannot use `push_outlives_components` because regions in +// closure signatures are not included in their outlives components. We need to +// ensure all regions outlive the given bound so that we don't end up with, +// say, `ReScope` appearing in a return type and causing ICEs when other +// functions end up with region constraints involving regions from other +// functions. +// +// We also cannot use `for_each_free_region` because for closures it includes +// the regions parameters from the enclosing item. +// +// We ignore any type parameters because impl trait values are assumed to +// capture all the in-scope type parameters. +struct OpaqueTypeOutlivesVisitor<'a, 'gcx, 'tcx> { + infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, + least_region: ty::Region<'tcx>, + span: Span, +} + +impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx> +{ + fn visit_binder>(&mut self, t: &ty::Binder) -> bool { + t.skip_binder().visit_with(self); + false // keep visiting + } + + fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { + match *r { + // ignore bound regions, keep visiting + ty::ReLateBound(_, _) => false, + _ => { + self.infcx.sub_regions(infer::CallReturn(self.span), self.least_region, r); + false + } + } + } + + fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { + // We're only interested in types involving regions + if !ty.flags.intersects(ty::TypeFlags::HAS_FREE_REGIONS) { + return false; // keep visiting + } + + match ty.sty { + ty::Closure(def_id, ref substs) => { + // Skip lifetime parameters of the enclosing item(s) + + for upvar_ty in substs.upvar_tys(def_id, self.infcx.tcx) { + upvar_ty.visit_with(self); + } + + substs.closure_sig_ty(def_id, self.infcx.tcx).visit_with(self); + } + + ty::Generator(def_id, ref substs, _) => { + // Skip lifetime parameters of the enclosing item(s) + // Also skip the witness type, because that has no free regions. + + for upvar_ty in substs.upvar_tys(def_id, self.infcx.tcx) { + upvar_ty.visit_with(self); + } + + substs.return_ty(def_id, self.infcx.tcx).visit_with(self); + substs.yield_ty(def_id, self.infcx.tcx).visit_with(self); + } + _ => { + ty.super_visit_with(self); + } + } + + false + } +} + struct ReverseMapper<'cx, 'gcx: 'tcx, 'tcx: 'cx> { tcx: TyCtxt<'cx, 'gcx, 'tcx>, @@ -563,8 +591,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx> // ignore `'static`, as that can appear anywhere ty::ReStatic | - // ignore `ReScope`, as that can appear anywhere - // See `src/test/run-pass/issue-49556.rs` for example. + // ignore `ReScope`, which may appear in impl Trait in bindings. ty::ReScope(..) => return r, _ => { } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 82a28716f5cab..09e2b523fae83 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2059,10 +2059,13 @@ impl<'tcx> Place<'tcx> { /// Finds the innermost `Local` from this `Place`. pub fn base_local(&self) -> Option { - match self { - Place::Base(PlaceBase::Local(local)) => Some(*local), - Place::Projection(box Projection { base, elem: _ }) => base.base_local(), - Place::Base(PlaceBase::Static(..)) => None, + let mut place = self; + loop { + match place { + Place::Projection(proj) => place = &proj.base, + Place::Base(PlaceBase::Static(_)) => return None, + Place::Base(PlaceBase::Local(local)) => return Some(*local), + } } } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4682eb547836b..ad80e5d74bd2a 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -462,7 +462,6 @@ pub enum PrintRequest { #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum BorrowckMode { Mir, - Compare, Migrate, } @@ -471,7 +470,6 @@ impl BorrowckMode { /// on the AST borrow check if the MIR-based one errors. pub fn migrate(self) -> bool { match self { - BorrowckMode::Compare => false, BorrowckMode::Mir => false, BorrowckMode::Migrate => true, } @@ -480,7 +478,6 @@ impl BorrowckMode { /// Should we emit the AST-based borrow checker errors? pub fn use_ast(self) -> bool { match self { - BorrowckMode::Compare => true, BorrowckMode::Mir => false, BorrowckMode::Migrate => false, } @@ -1214,7 +1211,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, identify_regions: bool = (false, parse_bool, [UNTRACKED], "make unnamed regions display as '# (where # is some non-ident unique id)"), borrowck: Option = (None, parse_opt_string, [UNTRACKED], - "select which borrowck is used (`ast`, `mir`, `migrate`, or `compare`)"), + "select which borrowck is used (`mir` or `migrate`)"), time_passes: bool = (false, parse_bool, [UNTRACKED], "measure time of each rustc pass"), time: bool = (false, parse_bool, [UNTRACKED], @@ -2315,7 +2312,6 @@ pub fn build_session_options_and_crate_config( let borrowck_mode = match debugging_opts.borrowck.as_ref().map(|s| &s[..]) { None | Some("migrate") => BorrowckMode::Migrate, Some("mir") => BorrowckMode::Mir, - Some("compare") => BorrowckMode::Compare, Some(m) => early_error(error_format, &format!("unknown borrowck mode `{}`", m)), }; diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index 56dacf20edcb8..5ced497baa1fd 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -210,7 +210,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> { self.insert_as_pending_if_two_phase(location, &assigned_place, kind, idx); - if let Some(local) = borrowed_place.root_local() { + if let Some(local) = borrowed_place.base_local() { self.local_map.entry(local).or_default().insert(idx); } } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 1d65a018dd62d..fc1f5eb5d5a7a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1831,7 +1831,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } place = base; - continue; } } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs index 960e75048fa16..58a164b38f911 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs @@ -47,11 +47,10 @@ pub(super) fn generate<'gcx, 'tcx>( mir.local_decls.indices().collect() } else { let free_regions = { - let borrowck_context = typeck.borrowck_context.as_ref().unwrap(); regions_that_outlive_free_regions( typeck.infcx.num_region_vars(), - &borrowck_context.universal_regions, - &borrowck_context.constraints.outlives_constraints, + &typeck.borrowck_context.universal_regions, + &typeck.borrowck_context.constraints.outlives_constraints, ) }; compute_live_locals(typeck.tcx(), &free_regions, mir) diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs index 4c4b4c0431927..87e9a704fac1e 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs @@ -517,16 +517,15 @@ impl LivenessContext<'_, '_, '_, '_, 'tcx> { let tcx = typeck.tcx(); tcx.for_each_free_region(&value, |live_region| { - let borrowck_context = typeck.borrowck_context.as_mut().unwrap(); - let live_region_vid = borrowck_context + let live_region_vid = typeck.borrowck_context .universal_regions .to_region_vid(live_region); - borrowck_context + typeck.borrowck_context .constraints .liveness_constraints .add_elements(live_region_vid, live_at); - if let Some(facts) = borrowck_context.all_facts { + if let Some(facts) = typeck.borrowck_context.all_facts { for point in live_at.iter() { let loc = elements.to_location(point); facts.region_live_at.push((live_region_vid, location_table.start_index(loc))); 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 1d62b9f764a19..4589e4ef036a4 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -20,7 +20,6 @@ use crate::borrow_check::nll::ToRegionVid; use crate::dataflow::move_paths::MoveData; use crate::dataflow::FlowAtLocation; use crate::dataflow::MaybeInitializedPlaces; -use crate::transform::{MirPass, MirSource}; use either::Either; use rustc::hir; use rustc::hir::def_id::DefId; @@ -159,16 +158,14 @@ pub(crate) fn type_check<'gcx, 'tcx>( param_env, mir, ®ion_bound_pairs, - Some(implicit_region_bound), - Some(&mut borrowck_context), - Some(&universal_region_relations), - |cx| { + implicit_region_bound, + &mut borrowck_context, + &universal_region_relations, + |mut cx| { cx.equate_inputs_and_outputs(mir, universal_regions, &normalized_inputs_and_output); - liveness::generate(cx, mir, elements, flow_inits, move_data, location_table); + liveness::generate(&mut cx, mir, elements, flow_inits, move_data, location_table); - cx.borrowck_context - .as_mut() - .map(|bcx| translate_outlives_facts(bcx)); + translate_outlives_facts(cx.borrowck_context); }, ); @@ -184,9 +181,9 @@ fn type_check_internal<'a, 'gcx, 'tcx, R>( param_env: ty::ParamEnv<'gcx>, mir: &'a Mir<'tcx>, region_bound_pairs: &'a RegionBoundPairs<'tcx>, - implicit_region_bound: Option>, - borrowck_context: Option<&'a mut BorrowCheckContext<'a, 'tcx>>, - universal_region_relations: Option<&'a UniversalRegionRelations<'tcx>>, + implicit_region_bound: ty::Region<'tcx>, + borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>, + universal_region_relations: &'a UniversalRegionRelations<'tcx>, mut extra: impl FnMut(&mut TypeChecker<'a, 'gcx, 'tcx>) -> R, ) -> R where { let mut checker = TypeChecker::new( @@ -548,15 +545,19 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { let all_facts = &mut None; let mut constraints = Default::default(); let mut closure_bounds = Default::default(); - if let Some(ref mut bcx) = self.cx.borrowck_context { - // Don't try to add borrow_region facts for the promoted MIR - mem::swap(bcx.all_facts, all_facts); - - // Use a new sets of constraints and closure bounds so that we can - // modify their locations. - mem::swap(&mut bcx.constraints.outlives_constraints, &mut constraints); - mem::swap(&mut bcx.constraints.closure_bounds_mapping, &mut closure_bounds); - }; + // Don't try to add borrow_region facts for the promoted MIR + mem::swap(self.cx.borrowck_context.all_facts, all_facts); + + // Use a new sets of constraints and closure bounds so that we can + // modify their locations. + mem::swap( + &mut self.cx.borrowck_context.constraints.outlives_constraints, + &mut constraints + ); + mem::swap( + &mut self.cx.borrowck_context.constraints.closure_bounds_mapping, + &mut closure_bounds + ); self.visit_mir(promoted_mir); @@ -567,40 +568,44 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { self.mir = parent_mir; // Merge the outlives constraints back in, at the given location. - if let Some(ref mut base_bcx) = self.cx.borrowck_context { - mem::swap(base_bcx.all_facts, all_facts); - mem::swap(&mut base_bcx.constraints.outlives_constraints, &mut constraints); - mem::swap(&mut base_bcx.constraints.closure_bounds_mapping, &mut closure_bounds); - - let locations = location.to_locations(); - for constraint in constraints.iter() { - let mut constraint = *constraint; - constraint.locations = locations; - if let ConstraintCategory::Return - | ConstraintCategory::UseAsConst - | ConstraintCategory::UseAsStatic = constraint.category - { - // "Returning" from a promoted is an assigment to a - // temporary from the user's point of view. - constraint.category = ConstraintCategory::Boring; - } - base_bcx.constraints.outlives_constraints.push(constraint) - } + mem::swap(self.cx.borrowck_context.all_facts, all_facts); + mem::swap( + &mut self.cx.borrowck_context.constraints.outlives_constraints, + &mut constraints + ); + mem::swap( + &mut self.cx.borrowck_context.constraints.closure_bounds_mapping, + &mut closure_bounds + ); - if !closure_bounds.is_empty() { - let combined_bounds_mapping = closure_bounds - .into_iter() - .flat_map(|(_, value)| value) - .collect(); - let existing = base_bcx - .constraints - .closure_bounds_mapping - .insert(location, combined_bounds_mapping); - assert!( - existing.is_none(), - "Multiple promoteds/closures at the same location." - ); + let locations = location.to_locations(); + for constraint in constraints.iter() { + let mut constraint = *constraint; + constraint.locations = locations; + if let ConstraintCategory::Return + | ConstraintCategory::UseAsConst + | ConstraintCategory::UseAsStatic = constraint.category + { + // "Returning" from a promoted is an assigment to a + // temporary from the user's point of view. + constraint.category = ConstraintCategory::Boring; } + self.cx.borrowck_context.constraints.outlives_constraints.push(constraint) + } + + if !closure_bounds.is_empty() { + let combined_bounds_mapping = closure_bounds + .into_iter() + .flat_map(|(_, value)| value) + .collect(); + let existing = self.cx.borrowck_context + .constraints + .closure_bounds_mapping + .insert(location, combined_bounds_mapping); + assert!( + existing.is_none(), + "Multiple promoteds/closures at the same location." + ); } } @@ -831,10 +836,10 @@ struct TypeChecker<'a, 'gcx: 'tcx, 'tcx: 'a> { user_type_annotations: &'a CanonicalUserTypeAnnotations<'tcx>, mir_def_id: DefId, region_bound_pairs: &'a RegionBoundPairs<'tcx>, - implicit_region_bound: Option>, + implicit_region_bound: ty::Region<'tcx>, reported_errors: FxHashSet<(Ty<'tcx>, Span)>, - borrowck_context: Option<&'a mut BorrowCheckContext<'a, 'tcx>>, - universal_region_relations: Option<&'a UniversalRegionRelations<'tcx>>, + borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>, + universal_region_relations: &'a UniversalRegionRelations<'tcx>, } struct BorrowCheckContext<'a, 'tcx: 'a> { @@ -976,9 +981,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { mir_def_id: DefId, param_env: ty::ParamEnv<'gcx>, region_bound_pairs: &'a RegionBoundPairs<'tcx>, - implicit_region_bound: Option>, - borrowck_context: Option<&'a mut BorrowCheckContext<'a, 'tcx>>, - universal_region_relations: Option<&'a UniversalRegionRelations<'tcx>>, + implicit_region_bound: ty::Region<'tcx>, + borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>, + universal_region_relations: &'a UniversalRegionRelations<'tcx>, ) -> Self { let mut checker = Self { infcx, @@ -1092,18 +1097,16 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { locations, data ); - if let Some(ref mut borrowck_context) = self.borrowck_context { - constraint_conversion::ConstraintConversion::new( - self.infcx, - borrowck_context.universal_regions, - self.region_bound_pairs, - self.implicit_region_bound, - self.param_env, - locations, - category, - &mut borrowck_context.constraints, - ).convert_all(&data); - } + constraint_conversion::ConstraintConversion::new( + self.infcx, + self.borrowck_context.universal_regions, + self.region_bound_pairs, + Some(self.implicit_region_bound), + self.param_env, + locations, + category, + &mut self.borrowck_context.constraints, + ).convert_all(&data); } /// Convenient wrapper around `relate_tys::relate_types` -- see @@ -1123,7 +1126,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { b, locations, category, - self.borrowck_context.as_mut().map(|x| &mut **x), + Some(self.borrowck_context), ) } @@ -1276,10 +1279,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { ), )?; - let universal_region_relations = match self.universal_region_relations { - Some(rel) => rel, - None => return Ok(()), - }; + let universal_region_relations = self.universal_region_relations; // Finally, if we instantiated the anon types successfully, we // have to solve any bounds (e.g., `-> impl Iterator` needs to @@ -1324,14 +1324,14 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { // of lowering. Assignments to other sorts of places *are* interesting // though. let category = match *place { - Place::Base(PlaceBase::Local(RETURN_PLACE)) => if let Some(BorrowCheckContext { + Place::Base(PlaceBase::Local(RETURN_PLACE)) => if let BorrowCheckContext { universal_regions: UniversalRegions { defining_ty: DefiningTy::Const(def_id, _), .. }, .. - }) = self.borrowck_context + } = self.borrowck_context { if tcx.is_static(*def_id) { ConstraintCategory::UseAsStatic @@ -1559,15 +1559,13 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { // output) types in the signature must be live, since // all the inputs that fed into it were live. for &late_bound_region in map.values() { - if let Some(ref mut borrowck_context) = self.borrowck_context { - let region_vid = borrowck_context - .universal_regions - .to_region_vid(late_bound_region); - borrowck_context - .constraints - .liveness_constraints - .add_element(region_vid, term_location); - } + let region_vid = self.borrowck_context + .universal_regions + .to_region_vid(late_bound_region); + self.borrowck_context + .constraints + .liveness_constraints + .add_element(region_vid, term_location); } self.check_call_inputs(mir, term, &sig, args, term_location, from_hir_call); @@ -1629,14 +1627,14 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { let dest_ty = dest.ty(mir, tcx).ty; let category = match *dest { Place::Base(PlaceBase::Local(RETURN_PLACE)) => { - if let Some(BorrowCheckContext { + if let BorrowCheckContext { universal_regions: UniversalRegions { defining_ty: DefiningTy::Const(def_id, _), .. }, .. - }) = self.borrowck_context + } = self.borrowck_context { if tcx.is_static(*def_id) { ConstraintCategory::UseAsStatic @@ -2343,10 +2341,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { all_facts, constraints, .. - } = match self.borrowck_context { - Some(ref mut borrowck_context) => borrowck_context, - None => return, - }; + } = self.borrowck_context; // In Polonius mode, we also push a `borrow_region` fact // linking the loan to the region (in some cases, though, @@ -2512,45 +2507,43 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { let closure_constraints = closure_region_requirements.apply_requirements(tcx, def_id, substs); - if let Some(ref mut borrowck_context) = self.borrowck_context { - let bounds_mapping = closure_constraints - .iter() - .enumerate() - .filter_map(|(idx, constraint)| { - let ty::OutlivesPredicate(k1, r2) = - constraint.no_bound_vars().unwrap_or_else(|| { - bug!("query_constraint {:?} contained bound vars", constraint,); - }); - - match k1.unpack() { - UnpackedKind::Lifetime(r1) => { - // constraint is r1: r2 - let r1_vid = borrowck_context.universal_regions.to_region_vid(r1); - let r2_vid = borrowck_context.universal_regions.to_region_vid(r2); - let outlives_requirements = - &closure_region_requirements.outlives_requirements[idx]; - Some(( - (r1_vid, r2_vid), - ( - outlives_requirements.category, - outlives_requirements.blame_span, - ), - )) - } - UnpackedKind::Type(_) | UnpackedKind::Const(_) => None, + let bounds_mapping = closure_constraints + .iter() + .enumerate() + .filter_map(|(idx, constraint)| { + let ty::OutlivesPredicate(k1, r2) = + constraint.no_bound_vars().unwrap_or_else(|| { + bug!("query_constraint {:?} contained bound vars", constraint,); + }); + + match k1.unpack() { + UnpackedKind::Lifetime(r1) => { + // constraint is r1: r2 + let r1_vid = self.borrowck_context.universal_regions.to_region_vid(r1); + let r2_vid = self.borrowck_context.universal_regions.to_region_vid(r2); + let outlives_requirements = + &closure_region_requirements.outlives_requirements[idx]; + Some(( + (r1_vid, r2_vid), + ( + outlives_requirements.category, + outlives_requirements.blame_span, + ), + )) } - }) - .collect(); - - let existing = borrowck_context - .constraints - .closure_bounds_mapping - .insert(location, bounds_mapping); - assert!( - existing.is_none(), - "Multiple closures at the same location." - ); - } + UnpackedKind::Type(_) | UnpackedKind::Const(_) => None, + } + }) + .collect(); + + let existing = self.borrowck_context + .constraints + .closure_bounds_mapping + .insert(location, bounds_mapping); + assert!( + existing.is_none(), + "Multiple closures at the same location." + ); self.push_region_constraints( location.to_locations(), @@ -2668,56 +2661,6 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } -pub struct TypeckMir; - -impl MirPass for TypeckMir { - fn run_pass<'a, 'tcx>( - &self, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - src: MirSource<'tcx>, - mir: &mut Mir<'tcx>, - ) { - let def_id = src.def_id(); - debug!("run_pass: {:?}", def_id); - - // FIXME: We don't need this MIR pass anymore. - if true { - return; - } - - if tcx.sess.err_count() > 0 { - // compiling a broken program can obviously result in a - // broken MIR, so try not to report duplicate errors. - return; - } - - if tcx.is_constructor(def_id) { - // We just assume that the automatically generated struct/variant constructors are - // correct. See the comment in the `mir_borrowck` implementation for an - // explanation why we need this. - return; - } - - let param_env = tcx.param_env(def_id); - tcx.infer_ctxt().enter(|infcx| { - type_check_internal( - &infcx, - def_id, - param_env, - mir, - &vec![], - None, - None, - None, - |_| (), - ); - - // For verification purposes, we just ignore the resulting - // region constraint sets. Not our problem. =) - }); - } -} - trait NormalizeLocation: fmt::Debug + Copy { fn to_locations(self) -> Locations; } diff --git a/src/librustc_mir/borrow_check/place_ext.rs b/src/librustc_mir/borrow_check/place_ext.rs index 913884a821837..cf9a6165d71a2 100644 --- a/src/librustc_mir/borrow_check/place_ext.rs +++ b/src/librustc_mir/borrow_check/place_ext.rs @@ -1,6 +1,6 @@ use rustc::hir; use rustc::mir::ProjectionElem; -use rustc::mir::{Local, Mir, Place, PlaceBase, Mutability, Static, StaticKind}; +use rustc::mir::{Mir, Place, PlaceBase, Mutability, Static, StaticKind}; use rustc::ty::{self, TyCtxt}; use crate::borrow_check::borrow_set::LocalsStateAtExit; @@ -16,10 +16,6 @@ crate trait PlaceExt<'tcx> { mir: &Mir<'tcx>, locals_state_at_exit: &LocalsStateAtExit, ) -> bool; - - /// If this is a place like `x.f.g`, returns the local - /// `x`. Returns `None` if this is based in a static. - fn root_local(&self) -> Option; } impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { @@ -82,15 +78,4 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { }, } } - - fn root_local(&self) -> Option { - let mut p = self; - loop { - match p { - Place::Projection(pi) => p = &pi.base, - Place::Base(PlaceBase::Static(_)) => return None, - Place::Base(PlaceBase::Local(l)) => return Some(*l), - } - } - } } diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 27cb87f5dcaa0..b609164415717 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -1,4 +1,3 @@ -use crate::borrow_check::nll::type_check; use crate::build; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::mir::{Mir, MirPhase, Promoted}; @@ -205,7 +204,6 @@ fn mir_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Stea run_passes(tcx, &mut mir, InstanceDef::Item(def_id), MirPhase::Const, &[ // What we need to do constant evaluation. &simplify::SimplifyCfg::new("initial"), - &type_check::TypeckMir, &rustc_peek::SanityCheck, &uniform_array_move_out::UniformArrayMoveOut, ]); diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index bf3cdf4abf797..4563c9f18a3e4 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -12,26 +12,10 @@ pub enum Origin { } impl fmt::Display for Origin { - fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { - // If the user passed `-Z borrowck=compare`, then include - // origin info as part of the error report, - // otherwise - let display_origin = ty::tls::with_opt(|opt_tcx| { - if let Some(tcx) = opt_tcx { - tcx.sess.opts.borrowck_mode == BorrowckMode::Compare - } else { - false - } - }); - if display_origin { - match *self { - Origin::Mir => write!(w, " (Mir)"), - Origin::Ast => write!(w, " (Ast)"), - } - } else { - // Print no origin info - Ok(()) - } + fn fmt(&self, _w: &mut fmt::Formatter<'_>) -> fmt::Result { + // FIXME(chrisvittal) remove Origin entirely + // Print no origin info + Ok(()) } } diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 1377f88df8f21..1699447886aef 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -522,7 +522,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let msg = format!("you can convert an `{}` to `{}`", checked_ty, expected_ty); let cast_msg = format!("you can cast an `{} to `{}`", checked_ty, expected_ty); - let try_msg = format!("{} or panic if it the converted value wouldn't fit", msg); + let try_msg = format!("{} and panic if the converted value wouldn't fit", msg); let lit_msg = format!( "change the type of the numeric literal from `{}` to `{}`", checked_ty, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c5173aa556953..d46feeab33599 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -7149,7 +7149,9 @@ impl<'a> Parser<'a> { // `()` or a tuple might be allowed. For example, `struct Struct(pub (), pub (usize));`. // Because of this, we only `bump` the `(` if we're assured it is appropriate to do so // by the following tokens. - if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) { + if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) && + self.look_ahead(2, |t| t != &token::ModSep) // account for `pub(crate::foo)` + { // `pub(crate)` self.bump(); // `(` self.bump(); // `crate` @@ -7192,7 +7194,7 @@ impl<'a> Parser<'a> { `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path"##; let path = self.parse_path(PathStyle::Mod)?; - let sp = self.prev_span; + let sp = path.span; let help_msg = format!("make this visible only to module `{}` with `in`", path); self.expect(&token::CloseDelim(token::Paren))?; // `)` let mut err = struct_span_err!(self.sess.span_diagnostic, sp, E0704, "{}", msg); diff --git a/src/test/mir-opt/storage_ranges.rs b/src/test/mir-opt/storage_ranges.rs index c099b1dccb668..6d22e9cd9fab9 100644 --- a/src/test/mir-opt/storage_ranges.rs +++ b/src/test/mir-opt/storage_ranges.rs @@ -7,7 +7,7 @@ fn main() { } // END RUST SOURCE -// START rustc.main.TypeckMir.before.mir +// START rustc.main.nll.0.mir // bb0: { // StorageLive(_1); // _1 = const 0i32; @@ -31,4 +31,4 @@ fn main() { // StorageDead(_1); // return; // } -// END rustc.main.TypeckMir.before.mir +// END rustc.main.nll.0.mir diff --git a/src/test/run-pass/binding/match-pipe-binding.rs b/src/test/run-pass/binding/match-pipe-binding.rs index 40dbd2468950e..7d4a7c708ddd7 100644 --- a/src/test/run-pass/binding/match-pipe-binding.rs +++ b/src/test/run-pass/binding/match-pipe-binding.rs @@ -1,5 +1,4 @@ // run-pass -// compile-flags: -Z borrowck=compare fn test1() { // from issue 6338 diff --git a/src/test/run-pass/issues/issue-16671.rs b/src/test/run-pass/issues/issue-16671.rs index 81a6b669b70ef..eff8e275bb58b 100644 --- a/src/test/run-pass/issues/issue-16671.rs +++ b/src/test/run-pass/issues/issue-16671.rs @@ -1,5 +1,4 @@ // run-pass -//compile-flags: -Z borrowck=compare #![deny(warnings)] diff --git a/src/test/run-pass/issues/issue-49955.rs b/src/test/run-pass/issues/issue-49955.rs index aa114ec0c1383..f2f3ebff2db18 100644 --- a/src/test/run-pass/issues/issue-49955.rs +++ b/src/test/run-pass/issues/issue-49955.rs @@ -1,5 +1,4 @@ // run-pass -// compile-flags: -Z borrowck=compare const ALL_THE_NUMS: [u32; 1] = [ 1 diff --git a/src/test/run-pass/issues/issue-8860.rs b/src/test/run-pass/issues/issue-8860.rs index 7925ef3b5dfab..b89a80c1307cf 100644 --- a/src/test/run-pass/issues/issue-8860.rs +++ b/src/test/run-pass/issues/issue-8860.rs @@ -1,6 +1,5 @@ // run-pass #![allow(dead_code)] -// compile-flags: -Z borrowck=compare static mut DROP: isize = 0; static mut DROP_S: isize = 0; diff --git a/src/test/run-pass/numbers-arithmetic/i128.rs b/src/test/run-pass/numbers-arithmetic/i128.rs index f3b5506ae32a6..ea0ef95e4f1af 100644 --- a/src/test/run-pass/numbers-arithmetic/i128.rs +++ b/src/test/run-pass/numbers-arithmetic/i128.rs @@ -3,7 +3,6 @@ // ignore-emscripten i128 doesn't work -// compile-flags: -Z borrowck=compare #![feature(test)] diff --git a/src/test/run-pass/numbers-arithmetic/u128.rs b/src/test/run-pass/numbers-arithmetic/u128.rs index 56d1f221d844c..9394071632377 100644 --- a/src/test/run-pass/numbers-arithmetic/u128.rs +++ b/src/test/run-pass/numbers-arithmetic/u128.rs @@ -1,7 +1,6 @@ // run-pass // ignore-emscripten u128 not supported -// compile-flags: -Z borrowck=compare #![feature(test)] diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index ae4de92ff7488..6b00293b6e52a 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -2,7 +2,6 @@ #![allow(dead_code)] #![allow(unreachable_code)] #![allow(unused_parens)] -// compile-flags: -Z borrowck=compare #![recursion_limit = "256"] diff --git a/src/test/ui/associated-types/associated-types-path-2.stderr b/src/test/ui/associated-types/associated-types-path-2.stderr index c25f12d008703..1405cb1b4736c 100644 --- a/src/test/ui/associated-types/associated-types-path-2.stderr +++ b/src/test/ui/associated-types/associated-types-path-2.stderr @@ -49,7 +49,7 @@ error[E0308]: mismatched types | LL | let _: i32 = f2(2i32); | ^^^^^^^^ expected i32, found u32 -help: you can convert an `u32` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit | LL | let _: i32 = f2(2i32).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/async-await/issue-60518.rs b/src/test/ui/async-await/issue-60518.rs new file mode 100644 index 0000000000000..f603c5bd3f946 --- /dev/null +++ b/src/test/ui/async-await/issue-60518.rs @@ -0,0 +1,12 @@ +// compile-pass +// edition:2018 + +#![feature(async_await)] + +// This is a regression test to ensure that simple bindings (where replacement arguments aren't +// created during async fn lowering) that have their DefId used during HIR lowering (such as impl +// trait) are visited during def collection and thus have a DefId. + +async fn foo(ws: impl Iterator) {} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut.rs b/src/test/ui/borrowck/borrowck-closures-two-mut.rs index 1fced982f8d68..5fe51654f3b79 100644 --- a/src/test/ui/borrowck/borrowck-closures-two-mut.rs +++ b/src/test/ui/borrowck/borrowck-closures-two-mut.rs @@ -2,8 +2,6 @@ // access to the variable, whether that mutable access be used // for direct assignment or for taking mutable ref. Issue #6801. -// compile-flags: -Z borrowck=compare - #![feature(box_syntax)] fn to_fn_mut(f: F) -> F { f } @@ -12,7 +10,6 @@ fn a() { let mut x = 3; let c1 = to_fn_mut(|| x = 4); let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } @@ -24,7 +21,6 @@ fn b() { let mut x = 3; let c1 = to_fn_mut(|| set(&mut x)); let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } @@ -32,7 +28,6 @@ fn c() { let mut x = 3; let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } @@ -41,7 +36,6 @@ fn d() { let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) //~^ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } @@ -54,7 +48,6 @@ fn g() { let c1 = to_fn_mut(|| set(&mut *x.f)); let c2 = to_fn_mut(|| set(&mut *x.f)); //~^ ERROR cannot borrow `x` as mutable more than once - //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut.stderr b/src/test/ui/borrowck/borrowck-closures-two-mut.stderr index e881201ddfcc0..bffb11640744c 100644 --- a/src/test/ui/borrowck/borrowck-closures-two-mut.stderr +++ b/src/test/ui/borrowck/borrowck-closures-two-mut.stderr @@ -1,80 +1,5 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:14:24 - | -LL | let c1 = to_fn_mut(|| x = 4); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| x = 5); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:26:24 - | -LL | let c1 = to_fn_mut(|| set(&mut x)); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut x)); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:34:24 - | -LL | let c1 = to_fn_mut(|| x = 5); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut x)); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:42:24 - | -LL | let c1 = to_fn_mut(|| x = 5); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) - --> $DIR/borrowck-closures-two-mut.rs:55:24 - | -LL | let c1 = to_fn_mut(|| set(&mut *x.f)); - | -- - previous borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut *x.f)); - | ^^ - borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:14:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:12:24 | LL | let c1 = to_fn_mut(|| x = 4); | -- - first borrow occurs due to use of `x` in closure @@ -84,12 +9,11 @@ LL | let c2 = to_fn_mut(|| x = 5); | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -LL | LL | drop((c1, c2)); | -- first borrow later used here -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:26:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:23:24 | LL | let c1 = to_fn_mut(|| set(&mut x)); | -- - first borrow occurs due to use of `x` in closure @@ -99,12 +23,11 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -LL | LL | drop((c1, c2)); | -- first borrow later used here -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:34:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:30:24 | LL | let c1 = to_fn_mut(|| x = 5); | -- - first borrow occurs due to use of `x` in closure @@ -114,12 +37,11 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -LL | LL | drop((c1, c2)); | -- first borrow later used here -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:42:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:37:24 | LL | let c1 = to_fn_mut(|| x = 5); | -- - first borrow occurs due to use of `x` in closure @@ -129,12 +51,12 @@ LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nes | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -... +LL | LL | drop((c1, c2)); | -- first borrow later used here -error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) - --> $DIR/borrowck-closures-two-mut.rs:55:24 +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:49:24 | LL | let c1 = to_fn_mut(|| set(&mut *x.f)); | -- - first borrow occurs due to use of `x` in closure @@ -144,10 +66,10 @@ LL | let c2 = to_fn_mut(|| set(&mut *x.f)); | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -... +LL | LL | drop((c1, c2)); | -- first borrow later used here -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-reinit.rs b/src/test/ui/borrowck/borrowck-reinit.rs index e8e38a92c81e9..866b3a2a8af9b 100644 --- a/src/test/ui/borrowck/borrowck-reinit.rs +++ b/src/test/ui/borrowck/borrowck-reinit.rs @@ -1,10 +1,7 @@ -// compile-flags: -Z borrowck=compare - fn main() { let mut x = Box::new(0); let _u = x; // error shouldn't note this move x = Box::new(1); drop(x); - let _ = (1,x); //~ ERROR use of moved value: `x` (Ast) - //~^ ERROR use of moved value: `x` (Mir) + let _ = (1,x); //~ ERROR use of moved value: `x` } diff --git a/src/test/ui/borrowck/borrowck-reinit.stderr b/src/test/ui/borrowck/borrowck-reinit.stderr index 3618a7cb2cd39..f8f14b6435f08 100644 --- a/src/test/ui/borrowck/borrowck-reinit.stderr +++ b/src/test/ui/borrowck/borrowck-reinit.stderr @@ -1,15 +1,5 @@ -error[E0382]: use of moved value: `x` (Ast) - --> $DIR/borrowck-reinit.rs:8:16 - | -LL | drop(x); - | - value moved here -LL | let _ = (1,x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x` (Mir) - --> $DIR/borrowck-reinit.rs:8:16 +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-reinit.rs:6:16 | LL | let mut x = Box::new(0); | ----- move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait @@ -19,6 +9,6 @@ LL | drop(x); LL | let _ = (1,x); | ^ value used here after move -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-storage-dead.rs b/src/test/ui/borrowck/borrowck-storage-dead.rs index 72c3bc1371985..fe9844610425e 100644 --- a/src/test/ui/borrowck/borrowck-storage-dead.rs +++ b/src/test/ui/borrowck/borrowck-storage-dead.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z borrowck=compare - fn ok() { loop { let _x = 1; @@ -15,8 +13,7 @@ fn also_ok() { fn fail() { loop { let x: i32; - let _ = x + 1; //~ERROR (Ast) [E0381] - //~^ ERROR (Mir) [E0381] + let _ = x + 1; //~ERROR [E0381] } } diff --git a/src/test/ui/borrowck/borrowck-storage-dead.stderr b/src/test/ui/borrowck/borrowck-storage-dead.stderr index c291ed224eb3c..5b9f49c2e7c92 100644 --- a/src/test/ui/borrowck/borrowck-storage-dead.stderr +++ b/src/test/ui/borrowck/borrowck-storage-dead.stderr @@ -1,15 +1,9 @@ -error[E0381]: use of possibly uninitialized variable: `x` (Ast) - --> $DIR/borrowck-storage-dead.rs:18:17 +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-storage-dead.rs:16:17 | LL | let _ = x + 1; | ^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x` (Mir) - --> $DIR/borrowck-storage-dead.rs:18:17 - | -LL | let _ = x + 1; - | ^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/immutable-arg.rs b/src/test/ui/borrowck/immutable-arg.rs index 8d1cd3c80455c..2352d1bbe6456 100644 --- a/src/test/ui/borrowck/immutable-arg.rs +++ b/src/test/ui/borrowck/immutable-arg.rs @@ -1,9 +1,6 @@ -//compile-flags: -Z borrowck=compare - fn foo(_x: u32) { _x = 4; - //~^ ERROR cannot assign to immutable argument `_x` (Mir) - //~^^ ERROR cannot assign twice to immutable variable `_x` (Ast) + //~^ ERROR cannot assign to immutable argument `_x` } fn main() {} diff --git a/src/test/ui/borrowck/immutable-arg.stderr b/src/test/ui/borrowck/immutable-arg.stderr index 8b21e92666674..7255ca327e753 100644 --- a/src/test/ui/borrowck/immutable-arg.stderr +++ b/src/test/ui/borrowck/immutable-arg.stderr @@ -1,19 +1,11 @@ -error[E0384]: cannot assign twice to immutable variable `_x` (Ast) - --> $DIR/immutable-arg.rs:4:5 - | -LL | fn foo(_x: u32) { - | -- first assignment to `_x` -LL | _x = 4; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign to immutable argument `_x` (Mir) - --> $DIR/immutable-arg.rs:4:5 +error[E0384]: cannot assign to immutable argument `_x` + --> $DIR/immutable-arg.rs:2:5 | LL | fn foo(_x: u32) { | -- help: make this binding mutable: `mut _x` LL | _x = 4; | ^^^^^^ cannot assign to immutable argument -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/borrowck/issue-41962.rs b/src/test/ui/borrowck/issue-41962.rs index 2bcc074542d17..38a01b138e47d 100644 --- a/src/test/ui/borrowck/issue-41962.rs +++ b/src/test/ui/borrowck/issue-41962.rs @@ -1,13 +1,9 @@ -// compile-flags: -Z borrowck=compare - pub fn main(){ let maybe = Some(vec![true, true]); loop { if let Some(thing) = maybe { } - //~^^ ERROR use of partially moved value: `maybe` (Ast) [E0382] - //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] - //~| ERROR use of moved value (Mir) [E0382] + //~^^ ERROR use of moved value [E0382] } } diff --git a/src/test/ui/borrowck/issue-41962.stderr b/src/test/ui/borrowck/issue-41962.stderr index fd4d318b5ddf1..422d1605aa46b 100644 --- a/src/test/ui/borrowck/issue-41962.stderr +++ b/src/test/ui/borrowck/issue-41962.stderr @@ -1,29 +1,11 @@ -error[E0382]: use of partially moved value: `maybe` (Ast) - --> $DIR/issue-41962.rs:7:30 - | -LL | if let Some(thing) = maybe { - | ----- ^^^^^ value used here after move - | | - | value moved here - | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) - --> $DIR/issue-41962.rs:7:21 - | -LL | if let Some(thing) = maybe { - | ^^^^^ value moved here in previous iteration of loop - | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error[E0382]: use of moved value (Mir) - --> $DIR/issue-41962.rs:7:21 +error[E0382]: use of moved value + --> $DIR/issue-41962.rs:5:21 | LL | if let Some(thing) = maybe { | ^^^^^ value moved here, in previous iteration of loop | = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/generator/yield-while-local-borrowed.rs b/src/test/ui/generator/yield-while-local-borrowed.rs index 38061e71358c4..b643bbf3376fb 100644 --- a/src/test/ui/generator/yield-while-local-borrowed.rs +++ b/src/test/ui/generator/yield-while-local-borrowed.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z borrowck=compare - #![feature(generators, generator_trait)] use std::ops::{GeneratorState, Generator}; @@ -13,8 +11,7 @@ fn borrow_local_inline() { // `b` and gets extended by region inference.) let mut b = move || { let a = &mut 3; - //~^ ERROR borrow may still be in use when generator yields (Ast) - //~| ERROR borrow may still be in use when generator yields (Mir) + //~^ ERROR borrow may still be in use when generator yields yield(); println!("{}", a); }; @@ -41,8 +38,7 @@ fn borrow_local() { let a = 3; { let b = &a; - //~^ ERROR borrow may still be in use when generator yields (Ast) - //~| ERROR borrow may still be in use when generator yields (Mir) + //~^ ERROR borrow may still be in use when generator yields yield(); println!("{}", b); } diff --git a/src/test/ui/generator/yield-while-local-borrowed.stderr b/src/test/ui/generator/yield-while-local-borrowed.stderr index 56f425b7e70a0..c1513ef9b7157 100644 --- a/src/test/ui/generator/yield-while-local-borrowed.stderr +++ b/src/test/ui/generator/yield-while-local-borrowed.stderr @@ -1,39 +1,21 @@ -error[E0626]: borrow may still be in use when generator yields (Ast) - --> $DIR/yield-while-local-borrowed.rs:15:22 - | -LL | let a = &mut 3; - | ^ -... -LL | yield(); - | ------- possible yield occurs here - -error[E0626]: borrow may still be in use when generator yields (Ast) - --> $DIR/yield-while-local-borrowed.rs:43:22 - | -LL | let b = &a; - | ^ -... -LL | yield(); - | ------- possible yield occurs here - -error[E0626]: borrow may still be in use when generator yields (Mir) - --> $DIR/yield-while-local-borrowed.rs:15:17 +error[E0626]: borrow may still be in use when generator yields + --> $DIR/yield-while-local-borrowed.rs:13:17 | LL | let a = &mut 3; | ^^^^^^ -... +LL | LL | yield(); | ------- possible yield occurs here -error[E0626]: borrow may still be in use when generator yields (Mir) - --> $DIR/yield-while-local-borrowed.rs:43:21 +error[E0626]: borrow may still be in use when generator yields + --> $DIR/yield-while-local-borrowed.rs:40:21 | LL | let b = &a; | ^^ -... +LL | LL | yield(); | ------- possible yield occurs here -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/impl-trait/can-return-unconstrained-closure.rs b/src/test/ui/impl-trait/can-return-unconstrained-closure.rs new file mode 100644 index 0000000000000..a982b176ecda1 --- /dev/null +++ b/src/test/ui/impl-trait/can-return-unconstrained-closure.rs @@ -0,0 +1,19 @@ +// Test that we are special casing "outlives" for opaque types. +// +// The return type of a closure is not required to outlive the closure. As such +// the following code would not compile if we used a standard outlives check +// when checking the return type, because the return type of the closure would +// be `&ReEmpty i32`, and we don't allow `ReEmpty` to occur in the concrete +// type used for an opaque type. +// +// However, opaque types are special cased to include check all regions in the +// concrete type against the bound, which forces the return type to be +// `&'static i32` here. + +// compile-pass + +fn make_identity() -> impl Sized { + |x: &'static i32| x +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs b/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs index 7ebc348996f5e..50646edd61a85 100644 --- a/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs +++ b/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs @@ -1,9 +1,9 @@ // This used to ICE because it creates an `impl Trait` that captures a // hidden empty region. -#![feature(conservative_impl_trait)] +// compile-pass -fn server() -> impl FilterBase2 { //~ ERROR [E0700] +fn server() -> impl FilterBase2 { segment2(|| { loop { } }).map2(|| "") } diff --git a/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr b/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr deleted file mode 100644 index 6311a7f00674f..0000000000000 --- a/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/issue-55608-captures-empty-region.rs:6:16 - | -LL | fn server() -> impl FilterBase2 { - | ^^^^^^^^^^^^^^^^ - | - = note: hidden type `Map2<[closure@$DIR/issue-55608-captures-empty-region.rs:7:36: 7:41]>` captures an empty lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/impl-trait/issue-57464-unexpected-regions.rs b/src/test/ui/impl-trait/issue-57464-unexpected-regions.rs new file mode 100644 index 0000000000000..29e271c68ec90 --- /dev/null +++ b/src/test/ui/impl-trait/issue-57464-unexpected-regions.rs @@ -0,0 +1,22 @@ +// Regression test for issue 57464. +// +// Closure are (surprisingly) allowed to outlive their signature. As such it +// was possible to end up with `ReScope`s appearing in the concrete type of an +// opaque type. As all regions are now required to outlive the bound in an +// opaque type we avoid the issue here. + +// compile-pass + +struct A(F); + +unsafe impl <'a, 'b, F: Fn(&'a i32) -> &'b i32> Send for A {} + +fn wrapped_closure() -> impl Sized { + let f = |x| x; + f(&0); + A(f) +} + +fn main() { + let x: Box = Box::new(wrapped_closure()); +} diff --git a/src/test/ui/indexing-requires-a-uint.stderr b/src/test/ui/indexing-requires-a-uint.stderr index 9dafe1c24f1c2..3300db58d44c3 100644 --- a/src/test/ui/indexing-requires-a-uint.stderr +++ b/src/test/ui/indexing-requires-a-uint.stderr @@ -12,7 +12,7 @@ error[E0308]: mismatched types | LL | bar::(i); // i should not be re-coerced back to an isize | ^ expected isize, found usize -help: you can convert an `usize` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `isize` and panic if the converted value wouldn't fit | LL | bar::(i.try_into().unwrap()); // i should not be re-coerced back to an isize | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/integer-literal-suffix-inference.stderr b/src/test/ui/integer-literal-suffix-inference.stderr index b5b3f27f0e6cd..80b601dc4394b 100644 --- a/src/test/ui/integer-literal-suffix-inference.stderr +++ b/src/test/ui/integer-literal-suffix-inference.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | id_i8(a16); | ^^^ expected i8, found i16 -help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(a16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ error[E0308]: mismatched types | LL | id_i8(a32); | ^^^ expected i8, found i32 -help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(a32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ error[E0308]: mismatched types | LL | id_i8(a64); | ^^^ expected i8, found i64 -help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ error[E0308]: mismatched types | LL | id_i16(a32); | ^^^ expected i16, found i32 -help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i16` and panic if the converted value wouldn't fit | LL | id_i16(a32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ error[E0308]: mismatched types | LL | id_i16(a64); | ^^^ expected i16, found i64 -help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i16` and panic if the converted value wouldn't fit | LL | id_i16(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ error[E0308]: mismatched types | LL | id_i32(a64); | ^^^ expected i32, found i64 -help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | LL | id_i32(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -117,7 +117,7 @@ error[E0308]: mismatched types | LL | id_i8(c16); | ^^^ expected i8, found i16 -help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(c16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ error[E0308]: mismatched types | LL | id_i8(c32); | ^^^ expected i8, found i32 -help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(c32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ error[E0308]: mismatched types | LL | id_i8(c64); | ^^^ expected i8, found i64 -help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -156,7 +156,7 @@ error[E0308]: mismatched types | LL | id_i16(c32); | ^^^ expected i16, found i32 -help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i16` and panic if the converted value wouldn't fit | LL | id_i16(c32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ error[E0308]: mismatched types | LL | id_i16(c64); | ^^^ expected i16, found i64 -help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i16` and panic if the converted value wouldn't fit | LL | id_i16(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -194,7 +194,7 @@ error[E0308]: mismatched types | LL | id_i32(c64); | ^^^ expected i32, found i64 -help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | LL | id_i32(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -231,7 +231,7 @@ error[E0308]: mismatched types | LL | id_u8(b16); | ^^^ expected u8, found u16 -help: you can convert an `u16` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `u8` and panic if the converted value wouldn't fit | LL | id_u8(b16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ error[E0308]: mismatched types | LL | id_u8(b32); | ^^^ expected u8, found u32 -help: you can convert an `u32` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `u8` and panic if the converted value wouldn't fit | LL | id_u8(b32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -251,7 +251,7 @@ error[E0308]: mismatched types | LL | id_u8(b64); | ^^^ expected u8, found u64 -help: you can convert an `u64` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u8` and panic if the converted value wouldn't fit | LL | id_u8(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -270,7 +270,7 @@ error[E0308]: mismatched types | LL | id_u16(b32); | ^^^ expected u16, found u32 -help: you can convert an `u32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `u16` and panic if the converted value wouldn't fit | LL | id_u16(b32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -280,7 +280,7 @@ error[E0308]: mismatched types | LL | id_u16(b64); | ^^^ expected u16, found u64 -help: you can convert an `u64` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u16` and panic if the converted value wouldn't fit | LL | id_u16(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -308,7 +308,7 @@ error[E0308]: mismatched types | LL | id_u32(b64); | ^^^ expected u32, found u64 -help: you can convert an `u64` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u32` and panic if the converted value wouldn't fit | LL | id_u32(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-13359.stderr b/src/test/ui/issues/issue-13359.stderr index b16b7a5b2cf04..7cfd754f72d8e 100644 --- a/src/test/ui/issues/issue-13359.stderr +++ b/src/test/ui/issues/issue-13359.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | foo(1*(1 as isize)); | ^^^^^^^^^^^^^^ expected i16, found isize -help: you can convert an `isize` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i16` and panic if the converted value wouldn't fit | LL | foo((1*(1 as isize)).try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ error[E0308]: mismatched types | LL | bar(1*(1 as usize)); | ^^^^^^^^^^^^^^ expected u32, found usize -help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit | LL | bar((1*(1 as usize)).try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-31910.stderr b/src/test/ui/issues/issue-31910.stderr index 8dd9287ffec79..e7555b958a3d4 100644 --- a/src/test/ui/issues/issue-31910.stderr +++ b/src/test/ui/issues/issue-31910.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | X = Trait::Number, | ^^^^^^^^^^^^^ expected isize, found i32 -help: you can convert an `i32` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit | LL | X = Trait::Number.try_into().unwrap(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-44373-2.rs b/src/test/ui/issues/issue-44373-2.rs index ab92bf458fb60..18b2ce85125f2 100644 --- a/src/test/ui/issues/issue-44373-2.rs +++ b/src/test/ui/issues/issue-44373-2.rs @@ -1,6 +1,5 @@ // compile-pass #![allow(dead_code)] -// compile-flags: -Z borrowck=compare struct Foo(bool); diff --git a/src/test/ui/issues/issue-45697-1.rs b/src/test/ui/issues/issue-45697-1.rs index c9b267ca5a10a..b45f1170b86c5 100644 --- a/src/test/ui/issues/issue-45697-1.rs +++ b/src/test/ui/issues/issue-45697-1.rs @@ -1,7 +1,7 @@ // Test that assignments to an `&mut` pointer which is found in a // borrowed (but otherwise non-aliasable) location is illegal. -// compile-flags: -Z borrowck=compare -C overflow-checks=on +// compile-flags: -C overflow-checks=on struct S<'a> { pointer: &'a mut isize @@ -18,9 +18,8 @@ fn main() { let mut y = S { pointer: &mut x }; let z = copy_borrowed_ptr(&mut y); *y.pointer += 1; - //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] - //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503] - //~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506] + //~^ ERROR cannot use `*y.pointer` because it was mutably borrowed [E0503] + //~| ERROR cannot assign to `*y.pointer` because it is borrowed [E0506] *z.pointer += 1; } } diff --git a/src/test/ui/issues/issue-45697-1.stderr b/src/test/ui/issues/issue-45697-1.stderr index 854e18003f330..30c69f19658c8 100644 --- a/src/test/ui/issues/issue-45697-1.stderr +++ b/src/test/ui/issues/issue-45697-1.stderr @@ -1,12 +1,4 @@ -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) - --> $DIR/issue-45697-1.rs:20:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here - -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed --> $DIR/issue-45697-1.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); @@ -17,7 +9,7 @@ LL | *y.pointer += 1; LL | *z.pointer += 1; | --------------- borrow later used here -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir) +error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/issue-45697-1.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); @@ -28,7 +20,7 @@ LL | *y.pointer += 1; LL | *z.pointer += 1; | --------------- borrow later used here -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0503, E0506. For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/issues/issue-45697.rs b/src/test/ui/issues/issue-45697.rs index 5bb30432fede4..db6d1d8fa2a92 100644 --- a/src/test/ui/issues/issue-45697.rs +++ b/src/test/ui/issues/issue-45697.rs @@ -1,7 +1,7 @@ // Test that assignments to an `&mut` pointer which is found in a // borrowed (but otherwise non-aliasable) location is illegal. -// compile-flags: -Z borrowck=compare -C overflow-checks=off +// compile-flags: -C overflow-checks=off struct S<'a> { pointer: &'a mut isize @@ -18,9 +18,8 @@ fn main() { let mut y = S { pointer: &mut x }; let z = copy_borrowed_ptr(&mut y); *y.pointer += 1; - //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] - //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503] - //~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506] + //~^ ERROR cannot use `*y.pointer` because it was mutably borrowed [E0503] + //~| ERROR cannot assign to `*y.pointer` because it is borrowed [E0506] *z.pointer += 1; } } diff --git a/src/test/ui/issues/issue-45697.stderr b/src/test/ui/issues/issue-45697.stderr index 01ae416b1cf14..26749d36f0b7b 100644 --- a/src/test/ui/issues/issue-45697.stderr +++ b/src/test/ui/issues/issue-45697.stderr @@ -1,12 +1,4 @@ -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) - --> $DIR/issue-45697.rs:20:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here - -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed --> $DIR/issue-45697.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); @@ -17,7 +9,7 @@ LL | *y.pointer += 1; LL | *z.pointer += 1; | --------------- borrow later used here -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir) +error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/issue-45697.rs:20:9 | LL | let z = copy_borrowed_ptr(&mut y); @@ -28,7 +20,7 @@ LL | *y.pointer += 1; LL | *z.pointer += 1; | --------------- borrow later used here -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0503, E0506. For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/issues/issue-46471-1.rs b/src/test/ui/issues/issue-46471-1.rs index 3cf3f35284951..aa161d40f702d 100644 --- a/src/test/ui/issues/issue-46471-1.rs +++ b/src/test/ui/issues/issue-46471-1.rs @@ -1,11 +1,8 @@ -// compile-flags: -Z borrowck=compare - fn main() { let y = { let mut z = 0; &mut z }; - //~^^ ERROR `z` does not live long enough (Ast) [E0597] - //~| ERROR `z` does not live long enough (Mir) [E0597] + //~^^ ERROR `z` does not live long enough [E0597] println!("{}", y); } diff --git a/src/test/ui/issues/issue-46471-1.stderr b/src/test/ui/issues/issue-46471-1.stderr index 51026c9f2d834..b09f31729a5fd 100644 --- a/src/test/ui/issues/issue-46471-1.stderr +++ b/src/test/ui/issues/issue-46471-1.stderr @@ -1,16 +1,5 @@ -error[E0597]: `z` does not live long enough (Ast) - --> $DIR/issue-46471-1.rs:6:14 - | -LL | &mut z - | ^ borrowed value does not live long enough -LL | }; - | - `z` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here - -error[E0597]: `z` does not live long enough (Mir) - --> $DIR/issue-46471-1.rs:6:9 +error[E0597]: `z` does not live long enough + --> $DIR/issue-46471-1.rs:4:9 | LL | &mut z | ^^^^^^ @@ -20,6 +9,6 @@ LL | &mut z LL | }; | - `z` dropped here while still borrowed -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-46471.rs b/src/test/ui/issues/issue-46471.rs index 0905c8bb1eb12..8922005d2f82c 100644 --- a/src/test/ui/issues/issue-46471.rs +++ b/src/test/ui/issues/issue-46471.rs @@ -1,10 +1,7 @@ -// compile-flags: -Z borrowck=compare - fn foo() -> &'static u32 { let x = 0; &x - //~^ ERROR `x` does not live long enough (Ast) [E0597] - //~| ERROR cannot return reference to local variable `x` (Mir) [E0515] + //~^ ERROR cannot return reference to local variable `x` [E0515] } fn main() { } diff --git a/src/test/ui/issues/issue-46471.stderr b/src/test/ui/issues/issue-46471.stderr index 90202e307eb11..935414c1f3f9d 100644 --- a/src/test/ui/issues/issue-46471.stderr +++ b/src/test/ui/issues/issue-46471.stderr @@ -1,21 +1,9 @@ -error[E0597]: `x` does not live long enough (Ast) - --> $DIR/issue-46471.rs:5:6 - | -LL | &x - | ^ borrowed value does not live long enough -... -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error[E0515]: cannot return reference to local variable `x` (Mir) - --> $DIR/issue-46471.rs:5:5 +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-46471.rs:3:5 | LL | &x | ^^ returns a reference to data owned by the current function -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0515, E0597. -For more information about an error, try `rustc --explain E0515`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-46472.rs b/src/test/ui/issues/issue-46472.rs index 88f97e99aeaff..b9e20e8dbcb5f 100644 --- a/src/test/ui/issues/issue-46472.rs +++ b/src/test/ui/issues/issue-46472.rs @@ -1,9 +1,6 @@ -// compile-flags: -Z borrowck=compare - fn bar<'a>() -> &'a mut u32 { &mut 4 - //~^ ERROR borrowed value does not live long enough (Ast) [E0597] - //~| ERROR cannot return reference to temporary value (Mir) [E0515] + //~^ ERROR cannot return reference to temporary value [E0515] } fn main() { } diff --git a/src/test/ui/issues/issue-46472.stderr b/src/test/ui/issues/issue-46472.stderr index 0cc93a081b2af..6e561e03a8b7a 100644 --- a/src/test/ui/issues/issue-46472.stderr +++ b/src/test/ui/issues/issue-46472.stderr @@ -1,20 +1,5 @@ -error[E0597]: borrowed value does not live long enough (Ast) - --> $DIR/issue-46472.rs:4:10 - | -LL | &mut 4 - | ^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 3:8... - --> $DIR/issue-46472.rs:3:8 - | -LL | fn bar<'a>() -> &'a mut u32 { - | ^^ - -error[E0515]: cannot return reference to temporary value (Mir) - --> $DIR/issue-46472.rs:4:5 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-46472.rs:2:5 | LL | &mut 4 | ^^^^^- @@ -22,7 +7,6 @@ LL | &mut 4 | | temporary value created here | returns a reference to data owned by the current function -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0515, E0597. -For more information about an error, try `rustc --explain E0515`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-49556.rs b/src/test/ui/issues/issue-49556.rs index b8fcc645a59d3..46d9e749aae23 100644 --- a/src/test/ui/issues/issue-49556.rs +++ b/src/test/ui/issues/issue-49556.rs @@ -2,10 +2,10 @@ fn iter<'a>(data: &'a [usize]) -> impl Iterator + 'a { data.iter() .map( - |x| x // fn(&'a usize) -> &'(ReScope) usize + |x| x // fn(&'a usize) -> &'a usize ) .map( - |x| *x // fn(&'(ReScope) usize) -> usize + |x| *x // fn(&'a usize) -> usize ) } diff --git a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs index 99949e17b6f4a..81a20c58776c8 100644 --- a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs +++ b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.rs @@ -1,17 +1,13 @@ -// FIXME: Change to UI Test // Check notes are placed on an assignment that can actually precede the current assignment // Don't emit a first assignment for assignment in a loop. -// compile-flags: -Zborrowck=compare - fn test() { let x; if true { x = 1; } else { x = 2; - x = 3; //~ ERROR (Ast) [E0384] - //~^ ERROR (Mir) [E0384] + x = 3; //~ ERROR [E0384] } } @@ -22,8 +18,7 @@ fn test_in_loop() { x = 1; } else { x = 2; - x = 3; //~ ERROR (Ast) [E0384] - //~^ ERROR (Mir) [E0384] + x = 3; //~ ERROR [E0384] } } } @@ -32,11 +27,9 @@ fn test_using_loop() { let x; loop { if true { - x = 1; //~ ERROR (Ast) [E0384] - //~^ ERROR (Mir) [E0384] + x = 1; //~ ERROR [E0384] } else { - x = 2; //~ ERROR (Ast) [E0384] - //~^ ERROR (Mir) [E0384] + x = 2; //~ ERROR [E0384] } } } diff --git a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr index e15290f0b9ee9..c646912d3b679 100644 --- a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr @@ -1,36 +1,5 @@ -error[E0384]: cannot assign twice to immutable variable `x` (Ast) - --> $DIR/liveness-assign-imm-local-notes.rs:13:9 - | -LL | x = 2; - | ----- first assignment to `x` -LL | x = 3; - | ^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` (Ast) - --> $DIR/liveness-assign-imm-local-notes.rs:25:13 - | -LL | x = 2; - | ----- first assignment to `x` -LL | x = 3; - | ^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` (Ast) - --> $DIR/liveness-assign-imm-local-notes.rs:35:13 - | -LL | x = 1; - | ^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` (Ast) - --> $DIR/liveness-assign-imm-local-notes.rs:38:13 - | -LL | x = 1; - | ----- first assignment to `x` -... -LL | x = 2; - | ^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` (Mir) - --> $DIR/liveness-assign-imm-local-notes.rs:13:9 +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/liveness-assign-imm-local-notes.rs:10:9 | LL | let x; | - help: make this binding mutable: `mut x` @@ -40,8 +9,8 @@ LL | x = 2; LL | x = 3; | ^^^^^ cannot assign twice to immutable variable -error[E0384]: cannot assign twice to immutable variable `x` (Mir) - --> $DIR/liveness-assign-imm-local-notes.rs:25:13 +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/liveness-assign-imm-local-notes.rs:21:13 | LL | let x; | - help: make this binding mutable: `mut x` @@ -51,8 +20,8 @@ LL | x = 2; LL | x = 3; | ^^^^^ cannot assign twice to immutable variable -error[E0384]: cannot assign twice to immutable variable `x` (Mir) - --> $DIR/liveness-assign-imm-local-notes.rs:35:13 +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/liveness-assign-imm-local-notes.rs:30:13 | LL | let x; | - help: make this binding mutable: `mut x` @@ -60,18 +29,18 @@ LL | let x; LL | x = 1; | ^^^^^ cannot assign twice to immutable variable -error[E0384]: cannot assign twice to immutable variable `x` (Mir) - --> $DIR/liveness-assign-imm-local-notes.rs:38:13 +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/liveness-assign-imm-local-notes.rs:32:13 | LL | let x; | - help: make this binding mutable: `mut x` ... LL | x = 1; | ----- first assignment to `x` -... +LL | } else { LL | x = 2; | ^^^^^ cannot assign twice to immutable variable -error: aborting due to 8 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr index be701b2bb3973..063a4865b1987 100644 --- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr +++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr @@ -11,7 +11,7 @@ error[E0308]: mismatched types | LL | let y: usize = x.foo(); | ^^^^^^^ expected usize, found isize -help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | LL | let y: usize = x.foo().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/mismatched_types/issue-26480.stderr b/src/test/ui/mismatched_types/issue-26480.stderr index 1a81df8e2c464..881d9fd32029e 100644 --- a/src/test/ui/mismatched_types/issue-26480.stderr +++ b/src/test/ui/mismatched_types/issue-26480.stderr @@ -6,7 +6,7 @@ LL | $arr.len() * size_of($arr[0])); ... LL | write!(hello); | -------------- in this macro invocation -help: you can convert an `usize` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u64` and panic if the converted value wouldn't fit | LL | ($arr.len() * size_of($arr[0])).try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/moves/moves-based-on-type-tuple.rs b/src/test/ui/moves/moves-based-on-type-tuple.rs index d99fe51931a1f..828d90cd7ac7f 100644 --- a/src/test/ui/moves/moves-based-on-type-tuple.rs +++ b/src/test/ui/moves/moves-based-on-type-tuple.rs @@ -1,11 +1,8 @@ #![feature(box_syntax)] -// compile-flags: -Z borrowck=compare - fn dup(x: Box) -> Box<(Box,Box)> { box (x, x) - //~^ use of moved value: `x` (Ast) [E0382] - //~| use of moved value: `x` (Mir) [E0382] + //~^ use of moved value: `x` [E0382] } fn main() { diff --git a/src/test/ui/moves/moves-based-on-type-tuple.stderr b/src/test/ui/moves/moves-based-on-type-tuple.stderr index c49dbdab40210..2e1ddbdf57f98 100644 --- a/src/test/ui/moves/moves-based-on-type-tuple.stderr +++ b/src/test/ui/moves/moves-based-on-type-tuple.stderr @@ -1,15 +1,5 @@ -error[E0382]: use of moved value: `x` (Ast) - --> $DIR/moves-based-on-type-tuple.rs:6:13 - | -LL | box (x, x) - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x` (Mir) - --> $DIR/moves-based-on-type-tuple.rs:6:13 +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-tuple.rs:4:13 | LL | fn dup(x: Box) -> Box<(Box,Box)> { | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait @@ -18,6 +8,6 @@ LL | box (x, x) | | | value moved here -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/nll/get_default.rs b/src/test/ui/nll/get_default.rs index 89f693bfb654e..ffac8a33da104 100644 --- a/src/test/ui/nll/get_default.rs +++ b/src/test/ui/nll/get_default.rs @@ -3,8 +3,6 @@ // a variety of errors from the older, AST-based machinery (notably // borrowck), and then we get the NLL error at the end. -// compile-flags:-Zborrowck=compare - struct Map { } @@ -21,8 +19,7 @@ fn ok(map: &mut Map) -> &String { } None => { map.set(String::new()); // Ideally, this would not error. - //~^ ERROR borrowed as immutable (Ast) - //~| ERROR borrowed as immutable (Mir) + //~^ ERROR borrowed as immutable } } } @@ -33,14 +30,12 @@ fn err(map: &mut Map) -> &String { match map.get() { Some(v) => { map.set(String::new()); // Both AST and MIR error here - //~^ ERROR borrowed as immutable (Mir) - //~| ERROR borrowed as immutable (Ast) + //~^ ERROR borrowed as immutable return v; } None => { map.set(String::new()); // Ideally, just AST would error here - //~^ ERROR borrowed as immutable (Ast) - //~| ERROR borrowed as immutable (Mir) + //~^ ERROR borrowed as immutable } } } diff --git a/src/test/ui/nll/get_default.stderr b/src/test/ui/nll/get_default.stderr index abb5343845b57..af79771e7e1b9 100644 --- a/src/test/ui/nll/get_default.stderr +++ b/src/test/ui/nll/get_default.stderr @@ -1,41 +1,5 @@ -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:23:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -... -LL | map.set(String::new()); // Ideally, this would not error. - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:35:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -LL | Some(v) => { -LL | map.set(String::new()); // Both AST and MIR error here - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:41:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -... -LL | map.set(String::new()); // Ideally, just AST would error here - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:23:17 +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable + --> $DIR/get_default.rs:21:17 | LL | fn ok(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -47,10 +11,10 @@ LL | return v; | - returning this value requires that `*map` is borrowed for `'1` ... LL | map.set(String::new()); // Ideally, this would not error. - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:35:17 +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable + --> $DIR/get_default.rs:32:17 | LL | fn err(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -59,13 +23,13 @@ LL | match map.get() { | --- immutable borrow occurs here LL | Some(v) => { LL | map.set(String::new()); // Both AST and MIR error here - | ^^^ mutable borrow occurs here -... + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | LL | return v; | - returning this value requires that `*map` is borrowed for `'1` -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:41:17 +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable + --> $DIR/get_default.rs:37:17 | LL | fn err(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -77,8 +41,8 @@ LL | return v; | - returning this value requires that `*map` is borrowed for `'1` ... LL | map.set(String::new()); // Ideally, just AST would error here - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/nll/loan_ends_mid_block_pair.rs b/src/test/ui/nll/loan_ends_mid_block_pair.rs index bad214deac129..acd6ec706080d 100644 --- a/src/test/ui/nll/loan_ends_mid_block_pair.rs +++ b/src/test/ui/nll/loan_ends_mid_block_pair.rs @@ -1,5 +1,3 @@ -// compile-flags:-Zborrowck=compare - #![allow(warnings)] #![feature(rustc_attrs)] @@ -12,12 +10,9 @@ fn nll_fail() { let c = &mut data.0; capitalize(c); data.0 = 'e'; - //~^ ERROR (Ast) [E0506] - //~| ERROR (Mir) [E0506] + //~^ ERROR [E0506] data.0 = 'f'; - //~^ ERROR (Ast) [E0506] data.0 = 'g'; - //~^ ERROR (Ast) [E0506] capitalize(c); } @@ -26,11 +21,8 @@ fn nll_ok() { let c = &mut data.0; capitalize(c); data.0 = 'e'; - //~^ ERROR (Ast) [E0506] data.0 = 'f'; - //~^ ERROR (Ast) [E0506] data.0 = 'g'; - //~^ ERROR (Ast) [E0506] } fn capitalize(_: &mut char) { diff --git a/src/test/ui/nll/loan_ends_mid_block_pair.stderr b/src/test/ui/nll/loan_ends_mid_block_pair.stderr index 85703bda31c4e..eb8442b31d7c7 100644 --- a/src/test/ui/nll/loan_ends_mid_block_pair.stderr +++ b/src/test/ui/nll/loan_ends_mid_block_pair.stderr @@ -1,59 +1,5 @@ -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:14:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -LL | capitalize(c); -LL | data.0 = 'e'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:17:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -... -LL | data.0 = 'f'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:19:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -... -LL | data.0 = 'g'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:28:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -LL | capitalize(c); -LL | data.0 = 'e'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:30:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -... -LL | data.0 = 'f'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) - --> $DIR/loan_ends_mid_block_pair.rs:32:5 - | -LL | let c = &mut data.0; - | ------ borrow of `data.0` occurs here -... -LL | data.0 = 'g'; - | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here - -error[E0506]: cannot assign to `data.0` because it is borrowed (Mir) - --> $DIR/loan_ends_mid_block_pair.rs:14:5 +error[E0506]: cannot assign to `data.0` because it is borrowed + --> $DIR/loan_ends_mid_block_pair.rs:12:5 | LL | let c = &mut data.0; | ----------- borrow of `data.0` occurs here @@ -64,6 +10,6 @@ LL | data.0 = 'e'; LL | capitalize(c); | - borrow later used here -error: aborting due to 7 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/nll/loan_ends_mid_block_vec.rs b/src/test/ui/nll/loan_ends_mid_block_vec.rs index 682e7e3e96fee..2edcdef0af86c 100644 --- a/src/test/ui/nll/loan_ends_mid_block_vec.rs +++ b/src/test/ui/nll/loan_ends_mid_block_vec.rs @@ -1,5 +1,3 @@ -// compile-flags:-Zborrowck=compare - #![allow(warnings)] #![feature(rustc_attrs)] @@ -11,14 +9,11 @@ fn nll_fail() { let slice = &mut data; capitalize(slice); data.push('d'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] + //~^ ERROR [E0499] data.push('e'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] + //~^ ERROR [E0499] data.push('f'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] + //~^ ERROR [E0499] capitalize(slice); } @@ -27,11 +22,8 @@ fn nll_ok() { let slice = &mut data; capitalize(slice); data.push('d'); - //~^ ERROR (Ast) [E0499] data.push('e'); - //~^ ERROR (Ast) [E0499] data.push('f'); - //~^ ERROR (Ast) [E0499] } fn capitalize(_: &mut [char]) { diff --git a/src/test/ui/nll/loan_ends_mid_block_vec.stderr b/src/test/ui/nll/loan_ends_mid_block_vec.stderr index a3f1391f00140..c0b97bea348c4 100644 --- a/src/test/ui/nll/loan_ends_mid_block_vec.stderr +++ b/src/test/ui/nll/loan_ends_mid_block_vec.stderr @@ -1,77 +1,5 @@ -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:13:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -LL | capitalize(slice); -LL | data.push('d'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:16:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -... -LL | data.push('e'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:19:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -... -LL | data.push('f'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:29:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -LL | capitalize(slice); -LL | data.push('d'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:31:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -... -LL | data.push('e'); - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) - --> $DIR/loan_ends_mid_block_vec.rs:33:5 - | -LL | let slice = &mut data; - | ---- first mutable borrow occurs here -... -LL | data.push('f'); - | ^^^^ second mutable borrow occurs here -LL | -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) - --> $DIR/loan_ends_mid_block_vec.rs:13:5 +error[E0499]: cannot borrow `data` as mutable more than once at a time + --> $DIR/loan_ends_mid_block_vec.rs:11:5 | LL | let slice = &mut data; | --------- first mutable borrow occurs here @@ -82,8 +10,8 @@ LL | data.push('d'); LL | capitalize(slice); | ----- first borrow later used here -error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) - --> $DIR/loan_ends_mid_block_vec.rs:16:5 +error[E0499]: cannot borrow `data` as mutable more than once at a time + --> $DIR/loan_ends_mid_block_vec.rs:13:5 | LL | let slice = &mut data; | --------- first mutable borrow occurs here @@ -94,18 +22,18 @@ LL | data.push('e'); LL | capitalize(slice); | ----- first borrow later used here -error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) - --> $DIR/loan_ends_mid_block_vec.rs:19:5 +error[E0499]: cannot borrow `data` as mutable more than once at a time + --> $DIR/loan_ends_mid_block_vec.rs:15:5 | LL | let slice = &mut data; | --------- first mutable borrow occurs here ... LL | data.push('f'); | ^^^^ second mutable borrow occurs here -... +LL | LL | capitalize(slice); | ----- first borrow later used here -error: aborting due to 9 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/nll/region-ends-after-if-condition.rs b/src/test/ui/nll/region-ends-after-if-condition.rs index 1bf13a91b9116..f67de03caf225 100644 --- a/src/test/ui/nll/region-ends-after-if-condition.rs +++ b/src/test/ui/nll/region-ends-after-if-condition.rs @@ -2,8 +2,6 @@ // in the type of `p` includes the points after `&v[0]` up to (but not // including) the call to `use_x`. The `else` branch is not included. -// compile-flags:-Zborrowck=compare - #![allow(warnings)] #![feature(rustc_attrs)] @@ -17,7 +15,6 @@ fn foo1() { let value = &my_struct.field; if value.is_empty() { my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0502] } } @@ -27,8 +24,7 @@ fn foo2() { let value = &my_struct.field; if value.is_empty() { my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0502] - //~| ERROR (Mir) [E0502] + //~^ ERROR [E0502] } drop(value); } diff --git a/src/test/ui/nll/region-ends-after-if-condition.stderr b/src/test/ui/nll/region-ends-after-if-condition.stderr index aa876a0bcb3bf..c03e385790616 100644 --- a/src/test/ui/nll/region-ends-after-if-condition.stderr +++ b/src/test/ui/nll/region-ends-after-if-condition.stderr @@ -1,39 +1,15 @@ -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/region-ends-after-if-condition.rs:19:9 - | -LL | let value = &my_struct.field; - | --------------- immutable borrow occurs here -LL | if value.is_empty() { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/region-ends-after-if-condition.rs:29:9 - | -LL | let value = &my_struct.field; - | --------------- immutable borrow occurs here -LL | if value.is_empty() { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/region-ends-after-if-condition.rs:29:9 +error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable + --> $DIR/region-ends-after-if-condition.rs:26:9 | LL | let value = &my_struct.field; | ---------------- immutable borrow occurs here LL | if value.is_empty() { LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here ... LL | drop(value); | ----- immutable borrow later used here -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/nll/return_from_loop.rs b/src/test/ui/nll/return_from_loop.rs index 23a1e0b816cbd..49541089405f2 100644 --- a/src/test/ui/nll/return_from_loop.rs +++ b/src/test/ui/nll/return_from_loop.rs @@ -2,8 +2,6 @@ // in the type of `p` includes the points after `&v[0]` up to (but not // including) the call to `use_x`. The `else` branch is not included. -// compile-flags:-Zborrowck=compare - #![allow(warnings)] #![feature(rustc_attrs)] @@ -20,8 +18,7 @@ fn nll_fail() { let value = &mut my_struct.field; loop { my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] + //~^ ERROR [E0499] value.len(); return; } @@ -33,7 +30,6 @@ fn nll_ok() { let value = &mut my_struct.field; loop { my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0499] return; } } diff --git a/src/test/ui/nll/return_from_loop.stderr b/src/test/ui/nll/return_from_loop.stderr index 09882d55cb70e..efd56ea2dd542 100644 --- a/src/test/ui/nll/return_from_loop.stderr +++ b/src/test/ui/nll/return_from_loop.stderr @@ -1,39 +1,15 @@ -error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Ast) - --> $DIR/return_from_loop.rs:22:9 - | -LL | let value = &mut my_struct.field; - | --------------- first mutable borrow occurs here -LL | loop { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Ast) - --> $DIR/return_from_loop.rs:35:9 - | -LL | let value = &mut my_struct.field; - | --------------- first mutable borrow occurs here -LL | loop { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Mir) - --> $DIR/return_from_loop.rs:22:9 +error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time + --> $DIR/return_from_loop.rs:20:9 | LL | let value = &mut my_struct.field; | -------------------- first mutable borrow occurs here LL | loop { LL | my_struct.field.push_str("Hello, world!"); | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -... +LL | LL | value.len(); | ----- first borrow later used here -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/numeric/const-scope.stderr b/src/test/ui/numeric/const-scope.stderr index ead3a79da0270..3f69bcc7d4a2f 100644 --- a/src/test/ui/numeric/const-scope.stderr +++ b/src/test/ui/numeric/const-scope.stderr @@ -37,7 +37,7 @@ error[E0308]: mismatched types | LL | let d: i8 = c; | ^ expected i8, found i32 -help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | LL | let d: i8 = c.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/numeric/len.stderr b/src/test/ui/numeric/len.stderr index 5a9349b4c0f29..c767bdd9bd5a5 100644 --- a/src/test/ui/numeric/len.stderr +++ b/src/test/ui/numeric/len.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | test(array.len()); | ^^^^^^^^^^^ expected u32, found usize -help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit | LL | test(array.len().try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/numeric/numeric-cast-2.stderr b/src/test/ui/numeric/numeric-cast-2.stderr index be4411e630bec..f58389ce96c3b 100644 --- a/src/test/ui/numeric/numeric-cast-2.stderr +++ b/src/test/ui/numeric/numeric-cast-2.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | let x: u16 = foo(); | ^^^^^ expected u16, found i32 -help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit | LL | let x: u16 = foo().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ error[E0308]: mismatched types | LL | let y: i64 = x + x; | ^^^^^ expected i64, found u16 -help: you can convert an `u16` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i64` and panic if the converted value wouldn't fit | LL | let y: i64 = (x + x).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ error[E0308]: mismatched types | LL | let z: i32 = x + x; | ^^^^^ expected i32, found u16 -help: you can convert an `u16` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i32` and panic if the converted value wouldn't fit | LL | let z: i32 = (x + x).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/numeric/numeric-cast.stderr b/src/test/ui/numeric/numeric-cast.stderr index 9e7dcf7e41b55..e66b83f2b39f5 100644 --- a/src/test/ui/numeric/numeric-cast.stderr +++ b/src/test/ui/numeric/numeric-cast.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected usize, found u64 -help: you can convert an `u64` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected usize, found u32 -help: you can convert an `u32` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected usize, found u16 -help: you can convert an `u16` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected usize, found u8 -help: you can convert an `u8` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected usize, found isize -help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected usize, found i64 -help: you can convert an `i64` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected usize, found i32 -help: you can convert an `i32` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected usize, found i16 -help: you can convert an `i16` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected usize, found i8 -help: you can convert an `i8` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +93,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected isize, found usize -help: you can convert an `usize` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected isize, found u64 -help: you can convert an `u64` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected isize, found u32 -help: you can convert an `u32` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,7 +123,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected isize, found u16 -help: you can convert an `u16` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected isize, found u8 -help: you can convert an `u8` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -143,7 +143,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected isize, found i64 -help: you can convert an `i64` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -153,7 +153,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected isize, found i32 -help: you can convert an `i32` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected isize, found i16 -help: you can convert an `i16` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -173,7 +173,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected isize, found i8 -help: you can convert an `i8` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -183,7 +183,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected u64, found usize -help: you can convert an `usize` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +220,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected u64, found isize -help: you can convert an `isize` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +230,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected u64, found i64 -help: you can convert an `i64` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -240,7 +240,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected u64, found i32 -help: you can convert an `i32` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -250,7 +250,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected u64, found i16 -help: you can convert an `i16` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -260,7 +260,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected u64, found i8 -help: you can convert an `i8` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -270,7 +270,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected i64, found usize -help: you can convert an `usize` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -280,7 +280,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected i64, found u64 -help: you can convert an `u64` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -290,7 +290,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected i64, found u32 -help: you can convert an `u32` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -300,7 +300,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected i64, found u16 -help: you can convert an `u16` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -310,7 +310,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected i64, found u8 -help: you can convert an `u8` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -320,7 +320,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected i64, found isize -help: you can convert an `isize` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -357,7 +357,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected u32, found usize -help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -367,7 +367,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected u32, found u64 -help: you can convert an `u64` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -395,7 +395,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected u32, found isize -help: you can convert an `isize` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected u32, found i64 -help: you can convert an `i64` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -415,7 +415,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected u32, found i32 -help: you can convert an `i32` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -425,7 +425,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected u32, found i16 -help: you can convert an `i16` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -435,7 +435,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected u32, found i8 -help: you can convert an `i8` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -445,7 +445,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected i32, found usize -help: you can convert an `usize` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected i32, found u64 -help: you can convert an `u64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -465,7 +465,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected i32, found u32 -help: you can convert an `u32` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -475,7 +475,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected i32, found u16 -help: you can convert an `u16` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -485,7 +485,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected i32, found u8 -help: you can convert an `u8` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -495,7 +495,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected i32, found isize -help: you can convert an `isize` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -505,7 +505,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected i32, found i64 -help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -533,7 +533,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected u16, found usize -help: you can convert an `usize` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -543,7 +543,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected u16, found u64 -help: you can convert an `u64` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -553,7 +553,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected u16, found u32 -help: you can convert an `u32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -572,7 +572,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected u16, found isize -help: you can convert an `isize` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -582,7 +582,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected u16, found i64 -help: you can convert an `i64` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -592,7 +592,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected u16, found i32 -help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -602,7 +602,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected u16, found i16 -help: you can convert an `i16` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -612,7 +612,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected u16, found i8 -help: you can convert an `i8` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -622,7 +622,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected i16, found usize -help: you can convert an `usize` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -632,7 +632,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected i16, found u64 -help: you can convert an `u64` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -642,7 +642,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected i16, found u32 -help: you can convert an `u32` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -652,7 +652,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected i16, found u16 -help: you can convert an `u16` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -662,7 +662,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected i16, found u8 -help: you can convert an `u8` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -672,7 +672,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected i16, found isize -help: you can convert an `isize` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -682,7 +682,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected i16, found i64 -help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -692,7 +692,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected i16, found i32 -help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -711,7 +711,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected u8, found usize -help: you can convert an `usize` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -721,7 +721,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected u8, found u64 -help: you can convert an `u64` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -731,7 +731,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected u8, found u32 -help: you can convert an `u32` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -741,7 +741,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected u8, found u16 -help: you can convert an `u16` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -751,7 +751,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected u8, found isize -help: you can convert an `isize` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -761,7 +761,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected u8, found i64 -help: you can convert an `i64` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -771,7 +771,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected u8, found i32 -help: you can convert an `i32` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -781,7 +781,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected u8, found i16 -help: you can convert an `i16` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -791,7 +791,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected u8, found i8 -help: you can convert an `i8` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -801,7 +801,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected i8, found usize -help: you can convert an `usize` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -811,7 +811,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected i8, found u64 -help: you can convert an `u64` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -821,7 +821,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected i8, found u32 -help: you can convert an `u32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -831,7 +831,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected i8, found u16 -help: you can convert an `u16` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -841,7 +841,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected i8, found u8 -help: you can convert an `u8` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -851,7 +851,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected i8, found isize -help: you can convert an `isize` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -861,7 +861,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected i8, found i64 -help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -871,7 +871,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected i8, found i32 -help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -881,7 +881,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected i8, found i16 -help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/pub/pub-restricted.rs b/src/test/ui/pub/pub-restricted.rs index 8793cb9d3357f..b4bc4a08c7b6d 100644 --- a/src/test/ui/pub/pub-restricted.rs +++ b/src/test/ui/pub/pub-restricted.rs @@ -4,6 +4,8 @@ mod a {} pub (a) fn afn() {} //~ incorrect visibility restriction pub (b) fn bfn() {} //~ incorrect visibility restriction +pub (crate::a) fn cfn() {} //~ incorrect visibility restriction + pub fn privfn() {} mod x { mod y { diff --git a/src/test/ui/pub/pub-restricted.stderr b/src/test/ui/pub/pub-restricted.stderr index 7eeefa9550543..596264ba16b42 100644 --- a/src/test/ui/pub/pub-restricted.stderr +++ b/src/test/ui/pub/pub-restricted.stderr @@ -21,7 +21,18 @@ LL | pub (b) fn bfn() {} `pub(in path::to::module)`: visible only on the specified path error[E0704]: incorrect visibility restriction - --> $DIR/pub-restricted.rs:22:14 + --> $DIR/pub-restricted.rs:7:6 + | +LL | pub (crate::a) fn cfn() {} + | ^^^^^^^^ help: make this visible only to module `crate::a` with `in`: `in crate::a` + | + = help: some possible visibility restrictions are: + `pub(crate)`: visible only on the current crate + `pub(super)`: visible only in the current module's parent + `pub(in path::to::module)`: visible only on the specified path + +error[E0704]: incorrect visibility restriction + --> $DIR/pub-restricted.rs:24:14 | LL | pub (a) invalid: usize, | ^ help: make this visible only to module `a` with `in`: `in a` @@ -32,7 +43,7 @@ LL | pub (a) invalid: usize, `pub(in path::to::module)`: visible only on the specified path error[E0704]: incorrect visibility restriction - --> $DIR/pub-restricted.rs:31:6 + --> $DIR/pub-restricted.rs:33:6 | LL | pub (xyz) fn xyz() {} | ^^^ help: make this visible only to module `xyz` with `in`: `in xyz` @@ -43,11 +54,11 @@ LL | pub (xyz) fn xyz() {} `pub(in path::to::module)`: visible only on the specified path error: visibilities can only be restricted to ancestor modules - --> $DIR/pub-restricted.rs:23:17 + --> $DIR/pub-restricted.rs:25:17 | LL | pub (in x) non_parent_invalid: usize, | ^ -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0704`. diff --git a/src/test/ui/repeat_count.stderr b/src/test/ui/repeat_count.stderr index 6772aa1c38d2c..df73ac0b182f0 100644 --- a/src/test/ui/repeat_count.stderr +++ b/src/test/ui/repeat_count.stderr @@ -42,7 +42,7 @@ error[E0308]: mismatched types | LL | let f = [0; -4_isize]; | ^^^^^^^^ expected usize, found isize -help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | LL | let f = [0; (-4_isize).try_into().unwrap()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ error[E0308]: mismatched types | LL | let f = [0_usize; -1_isize]; | ^^^^^^^^ expected usize, found isize -help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | LL | let f = [0_usize; (-1_isize).try_into().unwrap()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/shift-various-bad-types.stderr b/src/test/ui/shift-various-bad-types.stderr index 97523fe82cd4e..409fabb951adc 100644 --- a/src/test/ui/shift-various-bad-types.stderr +++ b/src/test/ui/shift-various-bad-types.stderr @@ -27,7 +27,7 @@ error[E0308]: mismatched types | LL | let _: i32 = 22_i64 >> 1_i32; | ^^^^^^^^^^^^^^^ expected i32, found i64 -help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | LL | let _: i32 = (22_i64 >> 1_i32).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr index 9acd63c2c25f1..e9c28248044f9 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr @@ -6,7 +6,7 @@ LL | fn global_bound_is_hidden() -> u8 ... LL | B::get_x() | ^^^^^^^^^^ expected u8, found i32 -help: you can convert an `i32` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u8` and panic if the converted value wouldn't fit | LL | B::get_x().try_into().unwrap() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/tutorial-suffix-inference-test.stderr b/src/test/ui/tutorial-suffix-inference-test.stderr index f51f2defd4759..f3e1cc41cada2 100644 --- a/src/test/ui/tutorial-suffix-inference-test.stderr +++ b/src/test/ui/tutorial-suffix-inference-test.stderr @@ -12,7 +12,7 @@ error[E0308]: mismatched types | LL | identity_u16(y); | ^ expected u16, found i32 -help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit | LL | identity_u16(y.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ error[E0308]: mismatched types | LL | identity_u16(a); | ^ expected u16, found isize -help: you can convert an `isize` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u16` and panic if the converted value wouldn't fit | LL | identity_u16(a.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index f5db2487618d6..433e9264dd1dc 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -2,6 +2,7 @@ name = "tidy" version = "0.1.0" authors = ["Alex Crichton "] +edition = "2018" [dependencies] regex = "1" diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 411961d70bf88..e90737febd5bf 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -5,6 +5,7 @@ use std::fs; use std::path::Path; use std::process::Command; +use serde_derive::Deserialize; use serde_json; const LICENSES: &[&str] = &[ diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 3144df6dd4cdf..f9f3623679e17 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -18,7 +18,7 @@ use std::path::Path; use regex::{Regex, escape}; mod version; -use self::version::Version; +use version::Version; const FEATURE_GROUP_START_PREFIX: &str = "// feature-group-start"; const FEATURE_GROUP_END_PREFIX: &str = "// feature-group-end"; diff --git a/src/tools/tidy/src/features/version.rs b/src/tools/tidy/src/features/version.rs index 6027e7d35e28c..1ce9fe127dd93 100644 --- a/src/tools/tidy/src/features/version.rs +++ b/src/tools/tidy/src/features/version.rs @@ -31,15 +31,13 @@ impl FromStr for Version { fn from_str(s: &str) -> Result { let mut iter = s.split('.').map(|part| Ok(part.parse()?)); - let parts = { - let mut part = || { - iter.next() - .unwrap_or(Err(ParseVersionError::WrongNumberOfParts)) - }; - - [part()?, part()?, part()?] + let mut part = || { + iter.next() + .unwrap_or(Err(ParseVersionError::WrongNumberOfParts)) }; + let parts = [part()?, part()?, part()?]; + if let Some(_) = iter.next() { // Ensure we don't have more than 3 parts. return Err(ParseVersionError::WrongNumberOfParts); diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 30080452edc01..d06c99725bc6a 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -3,13 +3,6 @@ //! This library contains the tidy lints and exposes it //! to be used by tools. -#![deny(rust_2018_idioms)] - -extern crate regex; -extern crate serde_json; -#[macro_use] -extern crate serde_derive; - use std::fs; use std::path::Path; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 6622403826665..eef3719043825 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -4,10 +4,8 @@ //! etc. This is run by default on `make check` and as part of the auto //! builders. -#![deny(rust_2018_idioms)] #![deny(warnings)] -extern crate tidy; use tidy::*; use std::process;