From 079817d62481ca8d84ca87dde9a276a1d5d663cf Mon Sep 17 00:00:00 2001 From: Donough Liu Date: Sat, 25 Apr 2020 08:56:07 +0800 Subject: [PATCH 01/26] Make `prefix` immutable --- src/librustc_typeck/check/demand.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 7db376b20aa..7e33bb8c2a7 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -614,24 +614,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // For now, don't suggest casting with `as`. let can_cast = false; - let mut prefix = String::new(); - if let Some(hir::Node::Expr(hir::Expr { - kind: hir::ExprKind::Struct(_, fields, _), .. + let prefix = if let Some(hir::Node::Expr(hir::Expr { + kind: hir::ExprKind::Struct(_, fields, _), + .. })) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id)) { // `expr` is a literal field for a struct, only suggest if appropriate - for field in *fields { - if field.expr.hir_id == expr.hir_id && field.is_shorthand { - // This is a field literal - prefix = format!("{}: ", field.ident); - break; - } - } - if &prefix == "" { + match (*fields) + .iter() + .find(|field| field.expr.hir_id == expr.hir_id && field.is_shorthand) + { + // This is a field literal + Some(field) => format!("{}: ", field.ident), // Likely a field was meant, but this field wasn't found. Do not suggest anything. - return false; + None => return false, } - } + } else { + String::new() + }; if let hir::ExprKind::Call(path, args) = &expr.kind { if let (hir::ExprKind::Path(hir::QPath::TypeRelative(base_ty, path_segment)), 1) = (&path.kind, args.len()) @@ -723,7 +723,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder<'_>, is_fallible: bool| { - let into_sugg = into_suggestion.clone(); err.span_suggestion( expr.span, if literal_is_ty_suffixed(expr) { @@ -738,7 +737,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else if is_fallible { try_into_suggestion } else { - into_sugg + into_suggestion.clone() }, Applicability::MachineApplicable, ); From c9f1162a6ffc81adcb114a616899edad0f7d0750 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 4 May 2020 10:17:39 +0100 Subject: [PATCH 02/26] Rephrase the any::type_name docs a bit. This attempts to be a little clearer (including in terminology) about the lack of guarantees that any::type_name provides. --- src/libcore/any.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 39df803bbea..67698e5409f 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -446,14 +446,14 @@ impl TypeId { /// # Note /// /// This is intended for diagnostic use. The exact contents and format of the -/// string are not specified, other than being a best-effort description of the -/// type. For example, `type_name::>()` could return the -/// `"Option"` or `"std::option::Option"`, but not -/// `"foobar"`. In addition, the output may change between versions of the -/// compiler. +/// string retrned are not specified, other than being a best-effort description +/// of the type. For example, amongst the strings +/// that `type_name::>()` might map to are `"Option"` and +/// `"std::option::Option"`. /// -/// The type name should not be considered a unique identifier of a type; -/// multiple types may share the same type name. +/// The returned string must not be considered to be a unique identifier of a +/// type as multiple types may map to the same type name. In addition, the +/// output may change between versions of the compiler. /// /// The current implementation uses the same infrastructure as compiler /// diagnostics and debuginfo, but this is not guaranteed. From 93f877ce870e9fd13ad7c6a05ccb4abd46a3d106 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 4 May 2020 11:01:31 +0100 Subject: [PATCH 03/26] Document that lifetimes do not currently appear in any::type_name()'s output. --- src/libcore/any.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 67698e5409f..2628f890332 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -452,7 +452,9 @@ impl TypeId { /// `"std::option::Option"`. /// /// The returned string must not be considered to be a unique identifier of a -/// type as multiple types may map to the same type name. In addition, the +/// type as multiple types may map to the same type name. Similarly, there is no +/// guarantee that all parts of a type will appear in the returned string: for +/// example, lifetime specifiers are currently not included. In addition, the /// output may change between versions of the compiler. /// /// The current implementation uses the same infrastructure as compiler From 876001c8ac331a15661638fbb18b8b64facf2c96 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 4 May 2020 14:28:58 +0100 Subject: [PATCH 04/26] Fix typo. --- src/libcore/any.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 2628f890332..996a9cdfc4d 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -446,8 +446,8 @@ impl TypeId { /// # Note /// /// This is intended for diagnostic use. The exact contents and format of the -/// string retrned are not specified, other than being a best-effort description -/// of the type. For example, amongst the strings +/// string returned are not specified, other than being a best-effort +/// description of the type. For example, amongst the strings /// that `type_name::>()` might map to are `"Option"` and /// `"std::option::Option"`. /// From 5cb2fa487bf6405a18c13041bc18544884f603a7 Mon Sep 17 00:00:00 2001 From: Dolpheyn Date: Mon, 4 May 2020 22:14:25 +0800 Subject: [PATCH 05/26] Document From trait for Option implementations --- src/libcore/option.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 63a5277100f..a87f3c1804c 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1357,12 +1357,38 @@ impl<'a, T> IntoIterator for &'a mut Option { #[stable(since = "1.12.0", feature = "option_from")] impl From for Option { + /// Copies val to a new Option::Some + /// + /// # Examples + /// + /// ``` + /// let o: Option = Option::from(67); + /// assert_eq!(Some(67), o); + /// ``` fn from(val: T) -> Option { Some(val) } } #[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] + /// Converts from &Option to Option<&T> + /// + /// # Examples + /// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original. + /// The [`map`] method takes the `self` argument by value, consuming the original, + /// so this technique uses `as_ref` to first take an `Option` to a reference + /// to the value inside the original. + /// + /// [`map`]: enum.Option.html#method.map + /// [`String`]: ../../std/string/struct.String.html + /// [`usize`]: ../../std/primitive.usize.html + /// + /// ``` + /// let s: Option = Some(String::from("Hello, Rustaceans!")); + /// let o: Option = Option::from(&s).map(|ss: &String| ss.len()); + /// println!("Can still print s: {}", s); + /// assert_eq!(o, Some(18)); + /// ``` impl<'a, T> From<&'a Option> for Option<&'a T> { fn from(o: &'a Option) -> Option<&'a T> { o.as_ref() @@ -1371,6 +1397,19 @@ impl<'a, T> From<&'a Option> for Option<&'a T> { #[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] impl<'a, T> From<&'a mut Option> for Option<&'a mut T> { + /// Converts from &mut Option to Option<&mut T> + /// + /// # Examples + /// + /// ``` + /// let mut s = Some(String::from("Hello")); + /// let o: Option<&mut String> = Option::from(&mut s); + /// match o { + /// Some(t) => *t = String::from("Hello, Rustaceans!"), + /// None => (), + /// } + /// assert_eq!(s, Some(String::from("Hello, Rustaceans!"))); + /// ``` fn from(o: &'a mut Option) -> Option<&'a mut T> { o.as_mut() } From 73f07a47b892216c47a741e229924b90a86585e1 Mon Sep 17 00:00:00 2001 From: Dolpheyn Date: Tue, 5 May 2020 08:25:20 +0800 Subject: [PATCH 06/26] Fix comment position --- src/libcore/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a87f3c1804c..480fe4fd4be 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1371,6 +1371,7 @@ impl From for Option { } #[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] +impl<'a, T> From<&'a Option> for Option<&'a T> { /// Converts from &Option to Option<&T> /// /// # Examples @@ -1389,7 +1390,6 @@ impl From for Option { /// println!("Can still print s: {}", s); /// assert_eq!(o, Some(18)); /// ``` -impl<'a, T> From<&'a Option> for Option<&'a T> { fn from(o: &'a Option) -> Option<&'a T> { o.as_ref() } From 2badd41d043c9ff549855ad832e7bcd2ad44970d Mon Sep 17 00:00:00 2001 From: Dolpheyn Date: Tue, 5 May 2020 09:50:59 +0800 Subject: [PATCH 07/26] Fix example --- src/libcore/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 480fe4fd4be..4647ad01006 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1387,7 +1387,7 @@ impl<'a, T> From<&'a Option> for Option<&'a T> { /// ``` /// let s: Option = Some(String::from("Hello, Rustaceans!")); /// let o: Option = Option::from(&s).map(|ss: &String| ss.len()); - /// println!("Can still print s: {}", s); + /// println!("Can still print s: {:?}", s); /// assert_eq!(o, Some(18)); /// ``` fn from(o: &'a Option) -> Option<&'a T> { From d80ac6416d1a6b38756e18c5b5ea421bbd11dfba Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Sun, 10 May 2020 18:06:30 +0800 Subject: [PATCH 08/26] Fix link to `map` documentation in example Co-authored-by: Timo --- src/libcore/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 4647ad01006..4df9eaa4815 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1380,7 +1380,7 @@ impl<'a, T> From<&'a Option> for Option<&'a T> { /// so this technique uses `as_ref` to first take an `Option` to a reference /// to the value inside the original. /// - /// [`map`]: enum.Option.html#method.map + /// [`map`]: ../../std/option/enum.Option.html#method.map /// [`String`]: ../../std/string/struct.String.html /// [`usize`]: ../../std/primitive.usize.html /// From 41f6b958d502b3e3d4de1b787a3981c9d752dd78 Mon Sep 17 00:00:00 2001 From: Jack Huey Date: Tue, 12 May 2020 01:56:29 -0400 Subject: [PATCH 09/26] Remove ty::UnnormalizedProjection --- .../debuginfo/type_names.rs | 1 - .../infer/canonical/canonicalizer.rs | 1 - .../infer/error_reporting/need_type_info.rs | 2 +- src/librustc_infer/infer/freshen.rs | 1 - src/librustc_lint/types.rs | 1 - src/librustc_middle/traits/query.rs | 2 -- src/librustc_middle/ty/context.rs | 1 - src/librustc_middle/ty/error.rs | 2 -- src/librustc_middle/ty/fast_reject.rs | 1 - src/librustc_middle/ty/flags.rs | 5 ----- src/librustc_middle/ty/layout.rs | 9 +++----- src/librustc_middle/ty/mod.rs | 2 +- src/librustc_middle/ty/outlives.rs | 2 -- src/librustc_middle/ty/print/mod.rs | 1 - src/librustc_middle/ty/print/obsolete.rs | 1 - src/librustc_middle/ty/print/pretty.rs | 3 --- src/librustc_middle/ty/relate.rs | 5 ----- src/librustc_middle/ty/structural_impls.rs | 7 +----- src/librustc_middle/ty/sty.rs | 7 ------ src/librustc_middle/ty/util.rs | 4 +--- src/librustc_middle/ty/walk.rs | 2 +- .../interpret/intrinsics/type_name.rs | 1 - src/librustc_mir/interpret/validity.rs | 1 - src/librustc_privacy/lib.rs | 2 +- src/librustc_symbol_mangling/legacy.rs | 2 -- src/librustc_symbol_mangling/v0.rs | 1 - .../traits/coherence.rs | 7 +++--- .../traits/error_reporting/mod.rs | 1 - .../traits/query/dropck_outlives.rs | 2 -- src/librustc_trait_selection/traits/select.rs | 9 +++----- src/librustc_trait_selection/traits/wf.rs | 2 -- src/librustc_traits/chalk/lowering.rs | 1 - src/librustc_traits/dropck_outlives.rs | 2 -- src/librustc_ty/ty.rs | 2 -- src/librustc_typeck/check/cast.rs | 1 - src/librustc_typeck/variance/constraints.rs | 6 +---- src/librustdoc/clean/mod.rs | 1 - .../internal-lints/ty_tykind_usage.rs | 1 - .../internal-lints/ty_tykind_usage.stderr | 22 +++++++------------ 39 files changed, 24 insertions(+), 100 deletions(-) diff --git a/src/librustc_codegen_ssa/debuginfo/type_names.rs b/src/librustc_codegen_ssa/debuginfo/type_names.rs index 6c0e4128e30..1d8730db546 100644 --- a/src/librustc_codegen_ssa/debuginfo/type_names.rs +++ b/src/librustc_codegen_ssa/debuginfo/type_names.rs @@ -198,7 +198,6 @@ pub fn push_debuginfo_type_name<'tcx>( ty::Error | ty::Infer(_) | ty::Placeholder(..) - | ty::UnnormalizedProjection(..) | ty::Projection(..) | ty::Bound(..) | ty::Opaque(..) diff --git a/src/librustc_infer/infer/canonical/canonicalizer.rs b/src/librustc_infer/infer/canonical/canonicalizer.rs index a0b5dd45a0e..5551b56ab79 100644 --- a/src/librustc_infer/infer/canonical/canonicalizer.rs +++ b/src/librustc_infer/infer/canonical/canonicalizer.rs @@ -415,7 +415,6 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { | ty::Never | ty::Tuple(..) | ty::Projection(..) - | ty::UnnormalizedProjection(..) | ty::Foreign(..) | ty::Param(..) | ty::Opaque(..) => { diff --git a/src/librustc_infer/infer/error_reporting/need_type_info.rs b/src/librustc_infer/infer/error_reporting/need_type_info.rs index d8133c58df7..0141ba82737 100644 --- a/src/librustc_infer/infer/error_reporting/need_type_info.rs +++ b/src/librustc_infer/infer/error_reporting/need_type_info.rs @@ -554,7 +554,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let output = bound_output.skip_binder(); err.span_label(e.span, &format!("this method call resolves to `{:?}`", output)); let kind = &output.kind; - if let ty::Projection(proj) | ty::UnnormalizedProjection(proj) = kind { + if let ty::Projection(proj) = kind { if let Some(span) = self.tcx.hir().span_if_local(proj.item_def_id) { err.span_label(span, &format!("`{:?}` defined here", output)); } diff --git a/src/librustc_infer/infer/freshen.rs b/src/librustc_infer/infer/freshen.rs index 47346c3a856..c9ed687eaf2 100644 --- a/src/librustc_infer/infer/freshen.rs +++ b/src/librustc_infer/infer/freshen.rs @@ -204,7 +204,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> { | ty::Never | ty::Tuple(..) | ty::Projection(..) - | ty::UnnormalizedProjection(..) | ty::Foreign(..) | ty::Param(..) | ty::Closure(..) diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 1d97b286024..703c2a7a443 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -888,7 +888,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { | ty::Generator(..) | ty::GeneratorWitness(..) | ty::Placeholder(..) - | ty::UnnormalizedProjection(..) | ty::Projection(..) | ty::Opaque(..) | ty::FnDef(..) => bug!("unexpected type in foreign function: {:?}", ty), diff --git a/src/librustc_middle/traits/query.rs b/src/librustc_middle/traits/query.rs index 67f4b15f919..e030125b5b1 100644 --- a/src/librustc_middle/traits/query.rs +++ b/src/librustc_middle/traits/query.rs @@ -255,8 +255,6 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { | ty::Infer(_) | ty::Bound(..) | ty::Generator(..) => false, - - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), } } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index 86b740b8503..7feb080d4b8 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -1878,7 +1878,6 @@ impl<'tcx> TyCtxt<'tcx> { Bound, Param, Infer, - UnnormalizedProjection, Projection, Opaque, Foreign diff --git a/src/librustc_middle/ty/error.rs b/src/librustc_middle/ty/error.rs index f3b6a53dfeb..cf63a659e6c 100644 --- a/src/librustc_middle/ty/error.rs +++ b/src/librustc_middle/ty/error.rs @@ -284,7 +284,6 @@ impl<'tcx> ty::TyS<'tcx> { ty::Infer(ty::FreshIntTy(_)) => "fresh integral type".into(), ty::Infer(ty::FreshFloatTy(_)) => "fresh floating-point type".into(), ty::Projection(_) => "associated type".into(), - ty::UnnormalizedProjection(_) => "non-normalized associated type".into(), ty::Param(p) => format!("type parameter `{}`", p).into(), ty::Opaque(..) => "opaque type".into(), ty::Error => "type error".into(), @@ -323,7 +322,6 @@ impl<'tcx> ty::TyS<'tcx> { ty::Placeholder(..) => "higher-ranked type".into(), ty::Bound(..) => "bound type variable".into(), ty::Projection(_) => "associated type".into(), - ty::UnnormalizedProjection(_) => "associated type".into(), ty::Param(_) => "type parameter".into(), ty::Opaque(..) => "opaque type".into(), } diff --git a/src/librustc_middle/ty/fast_reject.rs b/src/librustc_middle/ty/fast_reject.rs index 2a937d6581d..16d8e379407 100644 --- a/src/librustc_middle/ty/fast_reject.rs +++ b/src/librustc_middle/ty/fast_reject.rs @@ -90,7 +90,6 @@ pub fn simplify_type( ty::Never => Some(NeverSimplifiedType), ty::Tuple(ref tys) => Some(TupleSimplifiedType(tys.len())), ty::FnPtr(ref f) => Some(FunctionSimplifiedType(f.skip_binder().inputs().len())), - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), ty::Projection(_) | ty::Param(_) => { if can_simplify_params { // In normalized types, projections don't unify with diff --git a/src/librustc_middle/ty/flags.rs b/src/librustc_middle/ty/flags.rs index a88f3628109..042ffc4d1e5 100644 --- a/src/librustc_middle/ty/flags.rs +++ b/src/librustc_middle/ty/flags.rs @@ -121,11 +121,6 @@ impl FlagComputation { self.add_projection_ty(data); } - &ty::UnnormalizedProjection(ref data) => { - self.add_flags(TypeFlags::HAS_TY_PROJECTION); - self.add_projection_ty(data); - } - &ty::Opaque(_, substs) => { self.add_flags(TypeFlags::HAS_TY_OPAQUE); self.add_substs(substs); diff --git a/src/librustc_middle/ty/layout.rs b/src/librustc_middle/ty/layout.rs index 7c4e4d095bc..1339281667e 100644 --- a/src/librustc_middle/ty/layout.rs +++ b/src/librustc_middle/ty/layout.rs @@ -1241,11 +1241,9 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { tcx.layout_raw(param_env.and(normalized))? } - ty::Bound(..) - | ty::Placeholder(..) - | ty::UnnormalizedProjection(..) - | ty::GeneratorWitness(..) - | ty::Infer(_) => bug!("Layout::compute: unexpected type `{}`", ty), + ty::Bound(..) | ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) => { + bug!("Layout::compute: unexpected type `{}`", ty) + } ty::Param(_) | ty::Error => { return Err(LayoutError::Unknown(ty)); @@ -2138,7 +2136,6 @@ where } ty::Projection(_) - | ty::UnnormalizedProjection(..) | ty::Bound(..) | ty::Placeholder(..) | ty::Opaque(..) diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 02fe7adcd07..5ed3c3dab93 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -555,7 +555,7 @@ bitflags! { | TypeFlags::HAS_CT_PLACEHOLDER.bits | TypeFlags::HAS_FREE_LOCAL_REGIONS.bits; - /// Does this have [Projection] or [UnnormalizedProjection]? + /// Does this have [Projection]? const HAS_TY_PROJECTION = 1 << 10; /// Does this have [Opaque]? const HAS_TY_OPAQUE = 1 << 11; diff --git a/src/librustc_middle/ty/outlives.rs b/src/librustc_middle/ty/outlives.rs index 4fd4d0d1f06..afd670b8577 100644 --- a/src/librustc_middle/ty/outlives.rs +++ b/src/librustc_middle/ty/outlives.rs @@ -135,8 +135,6 @@ fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Compo } } - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), - // We assume that inference variables are fully resolved. // So, if we encounter an inference variable, just record // the unresolved variable as a component. diff --git a/src/librustc_middle/ty/print/mod.rs b/src/librustc_middle/ty/print/mod.rs index 6bdc65eb056..69b36980bd7 100644 --- a/src/librustc_middle/ty/print/mod.rs +++ b/src/librustc_middle/ty/print/mod.rs @@ -294,7 +294,6 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option { | ty::FnPtr(_) | ty::Projection(_) | ty::Placeholder(..) - | ty::UnnormalizedProjection(..) | ty::Param(_) | ty::Opaque(..) | ty::Infer(_) diff --git a/src/librustc_middle/ty/print/obsolete.rs b/src/librustc_middle/ty/print/obsolete.rs index 757a8bd23f6..41a6cd5466f 100644 --- a/src/librustc_middle/ty/print/obsolete.rs +++ b/src/librustc_middle/ty/print/obsolete.rs @@ -148,7 +148,6 @@ impl DefPathBasedNames<'tcx> { | ty::Bound(..) | ty::Infer(_) | ty::Placeholder(..) - | ty::UnnormalizedProjection(..) | ty::Projection(..) | ty::Param(_) | ty::GeneratorWitness(_) diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index 2684492a406..06ad90a147a 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -540,9 +540,6 @@ pub trait PrettyPrinter<'tcx>: p!(print_def_path(def_id, &[])); } ty::Projection(ref data) => p!(print(data)), - ty::UnnormalizedProjection(ref data) => { - p!(write("Unnormalized("), print(data), write(")")) - } ty::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)), ty::Opaque(def_id, substs) => { // FIXME(eddyb) print this with `print_def_path`. diff --git a/src/librustc_middle/ty/relate.rs b/src/librustc_middle/ty/relate.rs index 9c198dd556a..d68bc7221f9 100644 --- a/src/librustc_middle/ty/relate.rs +++ b/src/librustc_middle/ty/relate.rs @@ -477,11 +477,6 @@ pub fn super_relate_tys>( Ok(tcx.mk_fn_ptr(fty)) } - (ty::UnnormalizedProjection(a_data), ty::UnnormalizedProjection(b_data)) => { - let projection_ty = relation.relate(a_data, b_data)?; - Ok(tcx.mk_ty(ty::UnnormalizedProjection(projection_ty))) - } - // these two are already handled downstream in case of lazy normalization (ty::Projection(a_data), ty::Projection(b_data)) => { let projection_ty = relation.relate(a_data, b_data)?; diff --git a/src/librustc_middle/ty/structural_impls.rs b/src/librustc_middle/ty/structural_impls.rs index c8406a024ec..680b7187921 100644 --- a/src/librustc_middle/ty/structural_impls.rs +++ b/src/librustc_middle/ty/structural_impls.rs @@ -888,9 +888,6 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)), ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)), ty::Projection(ref data) => ty::Projection(data.fold_with(folder)), - ty::UnnormalizedProjection(ref data) => { - ty::UnnormalizedProjection(data.fold_with(folder)) - } ty::Opaque(did, substs) => ty::Opaque(did, substs.fold_with(folder)), ty::Bool @@ -931,9 +928,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { ty::Generator(_did, ref substs, _) => substs.visit_with(visitor), ty::GeneratorWitness(ref types) => types.visit_with(visitor), ty::Closure(_did, ref substs) => substs.visit_with(visitor), - ty::Projection(ref data) | ty::UnnormalizedProjection(ref data) => { - data.visit_with(visitor) - } + ty::Projection(ref data) => data.visit_with(visitor), ty::Opaque(_, ref substs) => substs.visit_with(visitor), ty::Bool diff --git a/src/librustc_middle/ty/sty.rs b/src/librustc_middle/ty/sty.rs index a6cf3b7e2ee..2ad673b2c19 100644 --- a/src/librustc_middle/ty/sty.rs +++ b/src/librustc_middle/ty/sty.rs @@ -181,11 +181,6 @@ pub enum TyKind<'tcx> { /// `>::N`. Projection(ProjectionTy<'tcx>), - /// A placeholder type used when we do not have enough information - /// to normalize the projection of an associated type to an - /// existing concrete type. Currently only used with chalk-engine. - UnnormalizedProjection(ProjectionTy<'tcx>), - /// Opaque (`impl Trait`) type found in a return type. /// The `DefId` comes either from /// * the `impl Trait` ast::Ty node, @@ -2186,8 +2181,6 @@ impl<'tcx> TyS<'tcx> { ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false, - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), - ty::Infer(ty::TyVar(_)) => false, ty::Bound(..) diff --git a/src/librustc_middle/ty/util.rs b/src/librustc_middle/ty/util.rs index a89927ecfb7..f9c10488ffb 100644 --- a/src/librustc_middle/ty/util.rs +++ b/src/librustc_middle/ty/util.rs @@ -745,8 +745,7 @@ impl<'tcx> ty::TyS<'tcx> { | ty::Opaque(..) | ty::Param(_) | ty::Placeholder(_) - | ty::Projection(_) - | ty::UnnormalizedProjection(_) => false, + | ty::Projection(_) => false, } } @@ -1077,7 +1076,6 @@ pub fn needs_drop_components( // These require checking for `Copy` bounds or `Adt` destructors. ty::Adt(..) | ty::Projection(..) - | ty::UnnormalizedProjection(..) | ty::Param(_) | ty::Bound(..) | ty::Placeholder(..) diff --git a/src/librustc_middle/ty/walk.rs b/src/librustc_middle/ty/walk.rs index b6cadd00996..0093c60d768 100644 --- a/src/librustc_middle/ty/walk.rs +++ b/src/librustc_middle/ty/walk.rs @@ -127,7 +127,7 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>) stack.push(ty.into()); stack.push(lt.into()); } - ty::Projection(data) | ty::UnnormalizedProjection(data) => { + ty::Projection(data) => { stack.extend(data.substs.iter().copied().rev()); } ty::Dynamic(obj, lt) => { diff --git a/src/librustc_mir/interpret/intrinsics/type_name.rs b/src/librustc_mir/interpret/intrinsics/type_name.rs index b81a454cac4..71cca725982 100644 --- a/src/librustc_mir/interpret/intrinsics/type_name.rs +++ b/src/librustc_mir/interpret/intrinsics/type_name.rs @@ -60,7 +60,6 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { | ty::FnDef(def_id, substs) | ty::Opaque(def_id, substs) | ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs }) - | ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs }) | ty::Closure(def_id, substs) | ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs), ty::Foreign(def_id) => self.print_def_path(def_id, &[]), diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 4f90f83b735..748cb8d9d1a 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -566,7 +566,6 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' | ty::Bound(..) | ty::Param(..) | ty::Opaque(..) - | ty::UnnormalizedProjection(..) | ty::Projection(..) | ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty), } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 917e2f54830..b474b23ac4f 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -160,7 +160,7 @@ where } } } - ty::Projection(proj) | ty::UnnormalizedProjection(proj) => { + ty::Projection(proj) => { if self.def_id_visitor.skip_assoc_tys() { // Visitors searching for minimal visibility/reachability want to // conservatively approximate associated types like `::Alias` diff --git a/src/librustc_symbol_mangling/legacy.rs b/src/librustc_symbol_mangling/legacy.rs index 01e9356b42f..3038b0c6bd7 100644 --- a/src/librustc_symbol_mangling/legacy.rs +++ b/src/librustc_symbol_mangling/legacy.rs @@ -216,7 +216,6 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { ty::FnDef(def_id, substs) | ty::Opaque(def_id, substs) | ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs }) - | ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs }) | ty::Closure(def_id, substs) | ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs), _ => self.pretty_print_type(ty), @@ -264,7 +263,6 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { ty::FnDef(..) | ty::Opaque(..) | ty::Projection(_) - | ty::UnnormalizedProjection(_) | ty::Closure(..) | ty::Generator(..) if trait_ref.is_none() => diff --git a/src/librustc_symbol_mangling/v0.rs b/src/librustc_symbol_mangling/v0.rs index 53df140e0b5..3b439e09a9d 100644 --- a/src/librustc_symbol_mangling/v0.rs +++ b/src/librustc_symbol_mangling/v0.rs @@ -413,7 +413,6 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { | ty::FnDef(def_id, substs) | ty::Opaque(def_id, substs) | ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs }) - | ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs }) | ty::Closure(def_id, substs) | ty::Generator(def_id, substs, _) => { self = self.print_def_path(def_id, substs)?; diff --git a/src/librustc_trait_selection/traits/coherence.rs b/src/librustc_trait_selection/traits/coherence.rs index f9ff772900b..85c2f9246af 100644 --- a/src/librustc_trait_selection/traits/coherence.rs +++ b/src/librustc_trait_selection/traits/coherence.rs @@ -567,9 +567,8 @@ fn ty_is_non_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> Option> ty::Error => None, - ty::UnnormalizedProjection(..) - | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) => bug!("ty_is_local invoked on unexpected type: {:?}", ty), + ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) => { + bug!("ty_is_local invoked on unexpected type: {:?}", ty) + } } } diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs index 405c656bad5..1620bdfa66e 100644 --- a/src/librustc_trait_selection/traits/error_reporting/mod.rs +++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs @@ -1194,7 +1194,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { ty::Foreign(..) => Some(19), ty::GeneratorWitness(..) => Some(20), ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error => None, - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), } } diff --git a/src/librustc_trait_selection/traits/query/dropck_outlives.rs b/src/librustc_trait_selection/traits/query/dropck_outlives.rs index 64cc5fadeab..856a2111fc8 100644 --- a/src/librustc_trait_selection/traits/query/dropck_outlives.rs +++ b/src/librustc_trait_selection/traits/query/dropck_outlives.rs @@ -135,7 +135,5 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { | ty::Infer(_) | ty::Bound(..) | ty::Generator(..) => false, - - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), } } diff --git a/src/librustc_trait_selection/traits/select.rs b/src/librustc_trait_selection/traits/select.rs index b595f77e4d6..f0ff30232b9 100644 --- a/src/librustc_trait_selection/traits/select.rs +++ b/src/librustc_trait_selection/traits/select.rs @@ -2178,8 +2178,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => None, ty::Infer(ty::TyVar(_)) => Ambiguous, - ty::UnnormalizedProjection(..) - | ty::Placeholder(..) + ty::Placeholder(..) | ty::Bound(..) | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty); @@ -2250,8 +2249,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Ambiguous } - ty::UnnormalizedProjection(..) - | ty::Placeholder(..) + ty::Placeholder(..) | ty::Bound(..) | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty); @@ -2284,8 +2282,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Never | ty::Char => Vec::new(), - ty::UnnormalizedProjection(..) - | ty::Placeholder(..) + ty::Placeholder(..) | ty::Dynamic(..) | ty::Param(..) | ty::Foreign(..) diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index 1d4afeaae42..ba7ec96775c 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -389,8 +389,6 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { self.compute_projection(data); } - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), - ty::Adt(def, substs) => { // WfNominalType let obligations = self.nominal_obligations(def.did, substs); diff --git a/src/librustc_traits/chalk/lowering.rs b/src/librustc_traits/chalk/lowering.rs index 4dc15a6b2b6..6ba8e63886b 100644 --- a/src/librustc_traits/chalk/lowering.rs +++ b/src/librustc_traits/chalk/lowering.rs @@ -353,7 +353,6 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { apply(chalk_ir::TypeName::Tuple(substs.len()), substs.lower_into(interner)) } Projection(proj) => TyData::Alias(proj.lower_into(interner)).intern(interner), - UnnormalizedProjection(_proj) => unimplemented!(), Opaque(_def_id, _substs) => unimplemented!(), // This should have been done eagerly prior to this, and all Params // should have been substituted to placeholders diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index 76ff58d61a2..08475d6a09d 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -271,8 +271,6 @@ fn dtorck_constraint_for_ty<'tcx>( constraints.dtorck_types.push(ty); } - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), - ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error => { // By the time this code runs, all type variables ought to // be fully resolved. diff --git a/src/librustc_ty/ty.rs b/src/librustc_ty/ty.rs index 6add099e75b..1aa11a761c8 100644 --- a/src/librustc_ty/ty.rs +++ b/src/librustc_ty/ty.rs @@ -47,8 +47,6 @@ fn sized_constraint_for_ty<'tcx>( vec![ty] } - UnnormalizedProjection(..) => bug!("only used with chalk-engine"), - Param(..) => { // perf hack: if there is a `T: Sized` bound, then // we know that `T` is Sized and do not need to check diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 981e6d2c47e..46d6706cbf4 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -115,7 +115,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::Foreign(..) => Some(PointerKind::Thin), // We should really try to normalize here. ty::Projection(ref pi) => Some(PointerKind::OfProjection(pi)), - ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), ty::Opaque(def_id, substs) => Some(PointerKind::OfOpaque(def_id, substs)), ty::Param(ref p) => Some(PointerKind::OfParam(p)), // Insufficient type information. diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 01d077d47f0..3a680f55c8c 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -344,11 +344,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { // types, where we use Error as the Self type } - ty::Placeholder(..) - | ty::UnnormalizedProjection(..) - | ty::GeneratorWitness(..) - | ty::Bound(..) - | ty::Infer(..) => { + ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Bound(..) | ty::Infer(..) => { bug!( "unexpected type encountered in \ variance inference: {}", diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 8cd9ab41aa4..6c001bc5484 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1722,7 +1722,6 @@ impl<'tcx> Clean for Ty<'tcx> { ty::Bound(..) => panic!("Bound"), ty::Placeholder(..) => panic!("Placeholder"), - ty::UnnormalizedProjection(..) => panic!("UnnormalizedProjection"), ty::GeneratorWitness(..) => panic!("GeneratorWitness"), ty::Infer(..) => panic!("Infer"), ty::Error => panic!("Error"), diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs index 66b594a1b09..27fe432e96d 100644 --- a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs +++ b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs @@ -32,7 +32,6 @@ fn main() { TyKind::Never => (), //~ ERROR usage of `ty::TyKind::` TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::UnnormalizedProjection(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::` diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr index ee9f1ff10f8..0486c90a5a0 100644 --- a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr +++ b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr @@ -139,58 +139,52 @@ LL | TyKind::Projection(..) => (), error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:35:9 | -LL | TyKind::UnnormalizedProjection(..) => (), +LL | TyKind::Opaque(..) => (), | ^^^^^^ help: try using ty:: directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:36:9 | -LL | TyKind::Opaque(..) => (), +LL | TyKind::Param(..) => (), | ^^^^^^ help: try using ty:: directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:37:9 | -LL | TyKind::Param(..) => (), +LL | TyKind::Bound(..) => (), | ^^^^^^ help: try using ty:: directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:38:9 | -LL | TyKind::Bound(..) => (), +LL | TyKind::Placeholder(..) => (), | ^^^^^^ help: try using ty:: directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:39:9 | -LL | TyKind::Placeholder(..) => (), +LL | TyKind::Infer(..) => (), | ^^^^^^ help: try using ty:: directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:40:9 | -LL | TyKind::Infer(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:41:9 - | LL | TyKind::Error => (), | ^^^^^^ help: try using ty:: directly: `ty` error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:46:12 + --> $DIR/ty_tykind_usage.rs:45:12 | LL | if let TyKind::Int(int_ty) = kind {} | ^^^^^^ help: try using ty:: directly: `ty` error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:48:24 + --> $DIR/ty_tykind_usage.rs:47:24 | LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} | ^^^^^^^^^^ | = help: try using `Ty` instead -error: aborting due to 31 previous errors +error: aborting due to 30 previous errors From 3fccdb3ded1aea60b699cc3d11dcd886f70fbb0e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 1 May 2020 12:10:06 +0200 Subject: [PATCH 10/26] Pointer printing: do not print 0 offset --- src/librustc_middle/mir/interpret/pointer.rs | 28 ++++++++++++------- ...main.SimplifyCfg-elaborate-drops.after.mir | 4 +-- .../rustc.BAR-promoted[0].ConstProp.after.mir | 6 ++-- .../rustc.BAR.PromoteTemps.diff | 6 ++-- .../rustc.FOO-promoted[0].ConstProp.after.mir | 6 ++-- .../rustc.FOO.PromoteTemps.diff | 6 ++-- .../32bit/rustc.main.ConstProp.after.mir | 20 ++++++------- .../64bit/rustc.main.ConstProp.after.mir | 24 ++++++++-------- .../32bit/rustc.main.ConstProp.after.mir | 18 ++++++------ .../64bit/rustc.main.ConstProp.after.mir | 18 ++++++------ .../32bit/rustc.main.ConstProp.after.mir | 12 ++++---- .../64bit/rustc.main.ConstProp.after.mir | 12 ++++---- .../rustc.main.ConstProp.diff | 6 ++-- .../rustc.main.ConstProp.diff | 12 ++++---- ...nst-pointer-values-in-various-types.stderr | 14 +++++----- .../consts/const-eval/ref_to_int_match.stderr | 2 +- src/test/ui/consts/const-eval/ub-enum.stderr | 10 +++---- src/test/ui/consts/const-eval/ub-ref.stderr | 2 +- 18 files changed, 107 insertions(+), 99 deletions(-) diff --git a/src/librustc_middle/mir/interpret/pointer.rs b/src/librustc_middle/mir/interpret/pointer.rs index 0b060056499..70cc546199b 100644 --- a/src/librustc_middle/mir/interpret/pointer.rs +++ b/src/librustc_middle/mir/interpret/pointer.rs @@ -89,27 +89,35 @@ pub struct Pointer { static_assert_size!(Pointer, 16); +/// Print the address of a pointer (without the tag) +fn print_ptr_addr(ptr: &Pointer, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Forward `alternate` flag to `alloc_id` printing. + if f.alternate() { + write!(f, "{:#?}", ptr.alloc_id)?; + } else { + write!(f, "{:?}", ptr.alloc_id)?; + } + // Print offset only if it is non-zero. + if ptr.offset.bytes() > 0 { + write!(f, "+0x{:x}", ptr.offset.bytes())?; + } + Ok(()) +} + // We want the `Debug` output to be readable as it is used by `derive(Debug)` for // all the Miri types. // We have to use `Debug` output for the tag, because `()` does not implement // `Display` so we cannot specialize that. impl fmt::Debug for Pointer { default fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if f.alternate() { - write!(f, "{:#?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag) - } else { - write!(f, "{:?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag) - } + print_ptr_addr(self, f)?; + write!(f, "[{:?}]", self.tag) } } // Specialization for no tag impl fmt::Debug for Pointer<()> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if f.alternate() { - write!(f, "{:#?}+0x{:x}", self.alloc_id, self.offset.bytes()) - } else { - write!(f, "{:?}+0x{:x}", self.alloc_id, self.offset.bytes()) - } + print_ptr_addr(self, f) } } diff --git a/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir index b8ecaf787fe..88cb09ac15a 100644 --- a/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -16,10 +16,10 @@ fn main() -> () { _1 = const b"foo"; // scope 0 at $DIR/byte_slice.rs:5:13: 5:19 // ty::Const // + ty: &[u8; 3] - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/byte_slice.rs:5:13: 5:19 - // + literal: Const { ty: &[u8; 3], val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &[u8; 3], val: Value(Scalar(alloc0)) } StorageLive(_2); // scope 1 at $DIR/byte_slice.rs:6:9: 6:10 _2 = [const 5u8, const 120u8]; // scope 1 at $DIR/byte_slice.rs:6:13: 6:24 // ty::Const diff --git a/src/test/mir-opt/const-promotion-extern-static/rustc.BAR-promoted[0].ConstProp.after.mir b/src/test/mir-opt/const-promotion-extern-static/rustc.BAR-promoted[0].ConstProp.after.mir index d202531c7ab..509947071b0 100644 --- a/src/test/mir-opt/const-promotion-extern-static/rustc.BAR-promoted[0].ConstProp.after.mir +++ b/src/test/mir-opt/const-promotion-extern-static/rustc.BAR-promoted[0].ConstProp.after.mir @@ -7,13 +7,13 @@ promoted[0] in BAR: &[&i32; 1] = { let mut _3: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34 bb0: { - _3 = const {alloc0+0x0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34 + _3 = const {alloc0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34 // ty::Const // + ty: &i32 - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34 - // + literal: Const { ty: &i32, val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &i32, val: Value(Scalar(alloc0)) } _2 = _3; // scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34 _1 = [move _2]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 _0 = &_1; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 diff --git a/src/test/mir-opt/const-promotion-extern-static/rustc.BAR.PromoteTemps.diff b/src/test/mir-opt/const-promotion-extern-static/rustc.BAR.PromoteTemps.diff index d517207390d..8eb8d4c667b 100644 --- a/src/test/mir-opt/const-promotion-extern-static/rustc.BAR.PromoteTemps.diff +++ b/src/test/mir-opt/const-promotion-extern-static/rustc.BAR.PromoteTemps.diff @@ -16,16 +16,16 @@ - StorageLive(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 - StorageLive(_4); // scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34 - StorageLive(_5); // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34 -- _5 = const {alloc0+0x0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34 +- _5 = const {alloc0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34 + _6 = const BAR::promoted[0]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 // ty::Const - // + ty: &i32 -- // + val: Value(Scalar(alloc0+0x0)) +- // + val: Value(Scalar(alloc0)) + // + ty: &[&i32; 1] + // + val: Unevaluated(DefId(0:6 ~ const_promotion_extern_static[317d]::BAR[0]), [], Some(promoted[0])) // mir::Constant - // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34 -- // + literal: Const { ty: &i32, val: Value(Scalar(alloc0+0x0)) } +- // + literal: Const { ty: &i32, val: Value(Scalar(alloc0)) } - _4 = &(*_5); // scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34 - _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 - _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 diff --git a/src/test/mir-opt/const-promotion-extern-static/rustc.FOO-promoted[0].ConstProp.after.mir b/src/test/mir-opt/const-promotion-extern-static/rustc.FOO-promoted[0].ConstProp.after.mir index b49c1aaa866..d9c6b4f0029 100644 --- a/src/test/mir-opt/const-promotion-extern-static/rustc.FOO-promoted[0].ConstProp.after.mir +++ b/src/test/mir-opt/const-promotion-extern-static/rustc.FOO-promoted[0].ConstProp.after.mir @@ -9,13 +9,13 @@ promoted[0] in FOO: &[&i32; 1] = { } bb0: { - _3 = const {alloc2+0x0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:13:42: 13:43 + _3 = const {alloc2: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:13:42: 13:43 // ty::Const // + ty: &i32 - // + val: Value(Scalar(alloc2+0x0)) + // + val: Value(Scalar(alloc2)) // mir::Constant // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43 - // + literal: Const { ty: &i32, val: Value(Scalar(alloc2+0x0)) } + // + literal: Const { ty: &i32, val: Value(Scalar(alloc2)) } _2 = _3; // scope 0 at $DIR/const-promotion-extern-static.rs:13:41: 13:43 _1 = [move _2]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 _0 = &_1; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 diff --git a/src/test/mir-opt/const-promotion-extern-static/rustc.FOO.PromoteTemps.diff b/src/test/mir-opt/const-promotion-extern-static/rustc.FOO.PromoteTemps.diff index 09c08cf449f..781aa3c5500 100644 --- a/src/test/mir-opt/const-promotion-extern-static/rustc.FOO.PromoteTemps.diff +++ b/src/test/mir-opt/const-promotion-extern-static/rustc.FOO.PromoteTemps.diff @@ -18,16 +18,16 @@ - StorageLive(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 - StorageLive(_4); // scope 0 at $DIR/const-promotion-extern-static.rs:13:32: 13:45 - StorageLive(_5); // scope 1 at $DIR/const-promotion-extern-static.rs:13:42: 13:43 -- _5 = const {alloc2+0x0: &i32}; // scope 1 at $DIR/const-promotion-extern-static.rs:13:42: 13:43 +- _5 = const {alloc2: &i32}; // scope 1 at $DIR/const-promotion-extern-static.rs:13:42: 13:43 + _6 = const FOO::promoted[0]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 // ty::Const - // + ty: &i32 -- // + val: Value(Scalar(alloc2+0x0)) +- // + val: Value(Scalar(alloc2)) + // + ty: &[&i32; 1] + // + val: Unevaluated(DefId(0:7 ~ const_promotion_extern_static[317d]::FOO[0]), [], Some(promoted[0])) // mir::Constant - // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43 -- // + literal: Const { ty: &i32, val: Value(Scalar(alloc2+0x0)) } +- // + literal: Const { ty: &i32, val: Value(Scalar(alloc2)) } - _4 = &(*_5); // scope 1 at $DIR/const-promotion-extern-static.rs:13:41: 13:43 - _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 - _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 diff --git a/src/test/mir-opt/const_allocation/32bit/rustc.main.ConstProp.after.mir b/src/test/mir-opt/const_allocation/32bit/rustc.main.ConstProp.after.mir index a20dd7bf0fc..30a383fd162 100644 --- a/src/test/mir-opt/const_allocation/32bit/rustc.main.ConstProp.after.mir +++ b/src/test/mir-opt/const_allocation/32bit/rustc.main.ConstProp.after.mir @@ -8,13 +8,13 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 StorageLive(_2); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 - _2 = const {alloc0+0x0: &&[(std::option::Option, &[&str])]}; // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 + _2 = const {alloc0: &&[(std::option::Option, &[&str])]}; // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 // ty::Const // + ty: &&[(std::option::Option, &[&str])] - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/const_allocation.rs:8:5: 8:8 - // + literal: Const { ty: &&[(std::option::Option, &[&str])], val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &&[(std::option::Option, &[&str])], val: Value(Scalar(alloc0)) } _1 = (*_2); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9 StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9 @@ -30,19 +30,19 @@ fn main() -> () { } alloc0 (static: FOO, size: 8, align: 4) { - ╾─a17+0x0─╼ 03 00 00 00 │ ╾──╼.... + ╾─alloc17─╼ 03 00 00 00 │ ╾──╼.... } alloc17 (size: 48, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾─a4+0x0──╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾─a8+0x0──╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾─a13+0x0─╼ 03 00 00 00 │ ....*...╾──╼.... + 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc4──╼ 00 00 00 00 │ ....░░░░╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc8──╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc13─╼ 03 00 00 00 │ ....*...╾──╼.... } alloc4 (size: 0, align: 4) {} alloc8 (size: 16, align: 4) { - ╾─a7+0x0──╼ 03 00 00 00 ╾─a9+0x0──╼ 03 00 00 00 │ ╾──╼....╾──╼.... + ╾─alloc7──╼ 03 00 00 00 ╾─alloc9──╼ 03 00 00 00 │ ╾──╼....╾──╼.... } alloc7 (size: 3, align: 1) { @@ -54,8 +54,8 @@ alloc9 (size: 3, align: 1) { } alloc13 (size: 24, align: 4) { - 0x00 │ ╾─a12+0x0─╼ 03 00 00 00 ╾─a14+0x0─╼ 03 00 00 00 │ ╾──╼....╾──╼.... - 0x10 │ ╾─a15+0x0─╼ 04 00 00 00 │ ╾──╼.... + 0x00 │ ╾─alloc12─╼ 03 00 00 00 ╾─alloc14─╼ 03 00 00 00 │ ╾──╼....╾──╼.... + 0x10 │ ╾─alloc15─╼ 04 00 00 00 │ ╾──╼.... } alloc12 (size: 3, align: 1) { diff --git a/src/test/mir-opt/const_allocation/64bit/rustc.main.ConstProp.after.mir b/src/test/mir-opt/const_allocation/64bit/rustc.main.ConstProp.after.mir index ff89ac9ad93..5fa54ae5a58 100644 --- a/src/test/mir-opt/const_allocation/64bit/rustc.main.ConstProp.after.mir +++ b/src/test/mir-opt/const_allocation/64bit/rustc.main.ConstProp.after.mir @@ -8,13 +8,13 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 StorageLive(_2); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 - _2 = const {alloc0+0x0: &&[(std::option::Option, &[&str])]}; // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 + _2 = const {alloc0: &&[(std::option::Option, &[&str])]}; // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 // ty::Const // + ty: &&[(std::option::Option, &[&str])] - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/const_allocation.rs:8:5: 8:8 - // + literal: Const { ty: &&[(std::option::Option, &[&str])], val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &&[(std::option::Option, &[&str])], val: Value(Scalar(alloc0)) } _1 = (*_2); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9 StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9 @@ -30,22 +30,22 @@ fn main() -> () { } alloc0 (static: FOO, size: 16, align: 8) { - ╾─────alloc17+0x0─────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + ╾───────alloc17───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } alloc17 (size: 72, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾─────alloc4+0x0──────╼ │ ....░░░░╾──────╼ + 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc4────────╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾─────alloc8+0x0──────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾─────alloc13+0x0─────╼ │ ....*...╾──────╼ + 0x20 │ ╾───────alloc8────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc13───────╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } alloc4 (size: 0, align: 8) {} alloc8 (size: 32, align: 8) { - 0x00 │ ╾─────alloc7+0x0──────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x10 │ ╾─────alloc9+0x0──────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x00 │ ╾───────alloc7────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x10 │ ╾───────alloc9────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } alloc7 (size: 3, align: 1) { @@ -57,9 +57,9 @@ alloc9 (size: 3, align: 1) { } alloc13 (size: 48, align: 8) { - 0x00 │ ╾─────alloc12+0x0─────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x10 │ ╾─────alloc14+0x0─────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x20 │ ╾─────alloc15+0x0─────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x00 │ ╾───────alloc12───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x10 │ ╾───────alloc14───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x20 │ ╾───────alloc15───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } alloc12 (size: 3, align: 1) { diff --git a/src/test/mir-opt/const_allocation2/32bit/rustc.main.ConstProp.after.mir b/src/test/mir-opt/const_allocation2/32bit/rustc.main.ConstProp.after.mir index e392eaa6aed..d386d247829 100644 --- a/src/test/mir-opt/const_allocation2/32bit/rustc.main.ConstProp.after.mir +++ b/src/test/mir-opt/const_allocation2/32bit/rustc.main.ConstProp.after.mir @@ -8,13 +8,13 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 StorageLive(_2); // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 - _2 = const {alloc0+0x0: &&[(std::option::Option, &[&u8])]}; // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 + _2 = const {alloc0: &&[(std::option::Option, &[&u8])]}; // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 // ty::Const // + ty: &&[(std::option::Option, &[&u8])] - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/const_allocation2.rs:5:5: 5:8 - // + literal: Const { ty: &&[(std::option::Option, &[&u8])], val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &&[(std::option::Option, &[&u8])], val: Value(Scalar(alloc0)) } _1 = (*_2); // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9 StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9 @@ -30,19 +30,19 @@ fn main() -> () { } alloc0 (static: FOO, size: 8, align: 4) { - ╾─a21+0x0─╼ 03 00 00 00 │ ╾──╼.... + ╾─alloc21─╼ 03 00 00 00 │ ╾──╼.... } alloc21 (size: 48, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾─a4+0x0──╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾─a9+0x0──╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾─a19+0x0─╼ 03 00 00 00 │ ....*...╾──╼.... + 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc4──╼ 00 00 00 00 │ ....░░░░╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc9──╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc19─╼ 03 00 00 00 │ ....*...╾──╼.... } alloc4 (size: 0, align: 4) {} alloc9 (size: 8, align: 4) { - ╾─a7+0x0──╼ ╾─a8+0x0──╼ │ ╾──╼╾──╼ + ╾─alloc7──╼ ╾─alloc8──╼ │ ╾──╼╾──╼ } alloc7 (size: 1, align: 1) { @@ -54,7 +54,7 @@ alloc8 (size: 1, align: 1) { } alloc19 (size: 12, align: 4) { - ╾─a15+0x3─╼ ╾─a16+0x0─╼ ╾─a18+0x2─╼ │ ╾──╼╾──╼╾──╼ + ╾─a15+0x3─╼ ╾─alloc16─╼ ╾─a18+0x2─╼ │ ╾──╼╾──╼╾──╼ } alloc15 (size: 4, align: 1) { diff --git a/src/test/mir-opt/const_allocation2/64bit/rustc.main.ConstProp.after.mir b/src/test/mir-opt/const_allocation2/64bit/rustc.main.ConstProp.after.mir index 81dc0372b5d..d7acd0f0f43 100644 --- a/src/test/mir-opt/const_allocation2/64bit/rustc.main.ConstProp.after.mir +++ b/src/test/mir-opt/const_allocation2/64bit/rustc.main.ConstProp.after.mir @@ -8,13 +8,13 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 StorageLive(_2); // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 - _2 = const {alloc0+0x0: &&[(std::option::Option, &[&u8])]}; // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 + _2 = const {alloc0: &&[(std::option::Option, &[&u8])]}; // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 // ty::Const // + ty: &&[(std::option::Option, &[&u8])] - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/const_allocation2.rs:5:5: 5:8 - // + literal: Const { ty: &&[(std::option::Option, &[&u8])], val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &&[(std::option::Option, &[&u8])], val: Value(Scalar(alloc0)) } _1 = (*_2); // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9 StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9 @@ -30,21 +30,21 @@ fn main() -> () { } alloc0 (static: FOO, size: 16, align: 8) { - ╾─────alloc21+0x0─────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + ╾───────alloc21───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } alloc21 (size: 72, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾─────alloc4+0x0──────╼ │ ....░░░░╾──────╼ + 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc4────────╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾─────alloc9+0x0──────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾─────alloc19+0x0─────╼ │ ....*...╾──────╼ + 0x20 │ ╾───────alloc9────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc19───────╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } alloc4 (size: 0, align: 8) {} alloc9 (size: 16, align: 8) { - ╾─────alloc7+0x0──────╼ ╾─────alloc8+0x0──────╼ │ ╾──────╼╾──────╼ + ╾───────alloc7────────╼ ╾───────alloc8────────╼ │ ╾──────╼╾──────╼ } alloc7 (size: 1, align: 1) { @@ -56,7 +56,7 @@ alloc8 (size: 1, align: 1) { } alloc19 (size: 24, align: 8) { - 0x00 │ ╾─────alloc15+0x3─────╼ ╾─────alloc16+0x0─────╼ │ ╾──────╼╾──────╼ + 0x00 │ ╾─────alloc15+0x3─────╼ ╾───────alloc16───────╼ │ ╾──────╼╾──────╼ 0x10 │ ╾─────alloc18+0x2─────╼ │ ╾──────╼ } diff --git a/src/test/mir-opt/const_allocation3/32bit/rustc.main.ConstProp.after.mir b/src/test/mir-opt/const_allocation3/32bit/rustc.main.ConstProp.after.mir index a29327eb973..39c60ad987a 100644 --- a/src/test/mir-opt/const_allocation3/32bit/rustc.main.ConstProp.after.mir +++ b/src/test/mir-opt/const_allocation3/32bit/rustc.main.ConstProp.after.mir @@ -8,13 +8,13 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 StorageLive(_2); // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 - _2 = const {alloc0+0x0: &&Packed}; // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 + _2 = const {alloc0: &&Packed}; // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 // ty::Const // + ty: &&Packed - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/const_allocation3.rs:5:5: 5:8 - // + literal: Const { ty: &&Packed, val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &&Packed, val: Value(Scalar(alloc0)) } _1 = (*_2); // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9 StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9 @@ -30,19 +30,19 @@ fn main() -> () { } alloc0 (static: FOO, size: 4, align: 4) { - ╾─a9+0x0──╼ │ ╾──╼ + ╾─alloc9──╼ │ ╾──╼ } alloc9 (size: 168, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─a4+0x0──╼ │ ............╾──╼ + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─alloc4──╼ │ ............╾──╼ 0x20 │ 01 ef cd ab 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x50 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾─a6+0x0──╼ 00 00 │ ..........╾──╼.. + 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾─alloc6──╼ 00 00 │ ..........╾──╼.. 0x90 │ ╾─a7+0x63─╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ 0xa0 │ 00 00 00 00 00 00 00 00 │ ........ } diff --git a/src/test/mir-opt/const_allocation3/64bit/rustc.main.ConstProp.after.mir b/src/test/mir-opt/const_allocation3/64bit/rustc.main.ConstProp.after.mir index 865c7c93432..96024f1c82c 100644 --- a/src/test/mir-opt/const_allocation3/64bit/rustc.main.ConstProp.after.mir +++ b/src/test/mir-opt/const_allocation3/64bit/rustc.main.ConstProp.after.mir @@ -8,13 +8,13 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 StorageLive(_2); // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 - _2 = const {alloc0+0x0: &&Packed}; // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 + _2 = const {alloc0: &&Packed}; // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 // ty::Const // + ty: &&Packed - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/const_allocation3.rs:5:5: 5:8 - // + literal: Const { ty: &&Packed, val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &&Packed, val: Value(Scalar(alloc0)) } _1 = (*_2); // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9 StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9 @@ -30,12 +30,12 @@ fn main() -> () { } alloc0 (static: FOO, size: 8, align: 8) { - ╾─────alloc9+0x0──────╼ │ ╾──────╼ + ╾───────alloc9────────╼ │ ╾──────╼ } alloc9 (size: 180, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾alloc4+0x0 │ ............╾─── + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾──alloc4── │ ............╾─── 0x20 │ ──────────╼ 01 ef cd ab 00 00 00 00 00 00 00 00 │ ───╼............ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ @@ -43,7 +43,7 @@ alloc9 (size: 180, align: 1) { 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x80 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ╾──── │ ..............╾─ - 0x90 │ ───alloc6+0x0───╼ 00 00 ╾─────alloc7+0x63─────╼ │ ─────╼..╾──────╼ + 0x90 │ ─────alloc6─────╼ 00 00 ╾─────alloc7+0x63─────╼ │ ─────╼..╾──────╼ 0xa0 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0xb0 │ 00 00 00 00 │ .... } diff --git a/src/test/mir-opt/const_prop/mutable_variable_no_prop/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_no_prop/rustc.main.ConstProp.diff index 1e9cbe6024c..b7f1242d8d1 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_no_prop/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_no_prop/rustc.main.ConstProp.diff @@ -29,13 +29,13 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:8:5: 10:6 StorageLive(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:9:13: 9:19 StorageLive(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:9:13: 9:19 - _4 = const {alloc0+0x0: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:9:13: 9:19 + _4 = const {alloc0: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:9:13: 9:19 // ty::Const // + ty: *mut u32 - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/mutable_variable_no_prop.rs:9:13: 9:19 - // + literal: Const { ty: *mut u32, val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: *mut u32, val: Value(Scalar(alloc0)) } _3 = (*_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:9:13: 9:19 _1 = move _3; // scope 2 at $DIR/mutable_variable_no_prop.rs:9:9: 9:19 StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:9:18: 9:19 diff --git a/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff index bbe0d106011..103444f796e 100644 --- a/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff @@ -16,13 +16,13 @@ StorageLive(_1); // scope 0 at $DIR/read_immutable_static.rs:7:9: 7:10 StorageLive(_2); // scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 StorageLive(_3); // scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 - _3 = const {alloc0+0x0: &u8}; // scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + _3 = const {alloc0: &u8}; // scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 // ty::Const // + ty: &u8 - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/read_immutable_static.rs:7:13: 7:16 - // + literal: Const { ty: &u8, val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &u8, val: Value(Scalar(alloc0)) } - _2 = (*_3); // scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + _2 = const 2u8; // scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + // ty::Const @@ -33,13 +33,13 @@ + // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } StorageLive(_4); // scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 StorageLive(_5); // scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 - _5 = const {alloc0+0x0: &u8}; // scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + _5 = const {alloc0: &u8}; // scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 // ty::Const // + ty: &u8 - // + val: Value(Scalar(alloc0+0x0)) + // + val: Value(Scalar(alloc0)) // mir::Constant // + span: $DIR/read_immutable_static.rs:7:19: 7:22 - // + literal: Const { ty: &u8, val: Value(Scalar(alloc0+0x0)) } + // + literal: Const { ty: &u8, val: Value(Scalar(alloc0)) } - _4 = (*_5); // scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 - _1 = Add(move _2, move _4); // scope 0 at $DIR/read_immutable_static.rs:7:13: 7:22 + _4 = const 2u8; // scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr index 649105812b0..d24491e1bc5 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:25:5 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc2+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc2, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -36,7 +36,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:37:5 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc22+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc22, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -76,7 +76,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:52:5 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc47+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc47, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -100,7 +100,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:61:5 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc62+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc62, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -148,7 +148,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:79:5 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc86+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc86, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -188,7 +188,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:94:5 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc101+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc101, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -212,7 +212,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:103:5 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc110+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc110, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.stderr b/src/test/ui/consts/const-eval/ref_to_int_match.stderr index df6fc66620b..cb0ba5d9929 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.stderr +++ b/src/test/ui/consts/const-eval/ref_to_int_match.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ref_to_int_match.rs:25:1 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc2+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc2, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. diff --git a/src/test/ui/consts/const-eval/ub-enum.stderr b/src/test/ui/consts/const-eval/ub-enum.stderr index 8f0ce58eaf5..d8dafac3e70 100644 --- a/src/test/ui/consts/const-eval/ub-enum.stderr +++ b/src/test/ui/consts/const-eval/ub-enum.stderr @@ -10,7 +10,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:27:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc8+0x0 at ., but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc8 at ., but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -18,7 +18,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:30:1 | LL | const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc13+0x0 at .0., but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc13 at .0., but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -34,7 +34,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:44:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc20+0x0 at ., but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc20 at ., but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -42,7 +42,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc25+0x0 at .0., but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc25 at .0., but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. @@ -58,7 +58,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:60:1 | LL | const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc32+0x0 at ., but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc32 at ., but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. diff --git a/src/test/ui/consts/const-eval/ub-ref.stderr b/src/test/ui/consts/const-eval/ub-ref.stderr index 95a83d11acd..a219679f182 100644 --- a/src/test/ui/consts/const-eval/ub-ref.stderr +++ b/src/test/ui/consts/const-eval/ub-ref.stderr @@ -34,7 +34,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref.rs:24:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc16+0x0, but expected initialized plain (non-pointer) bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc16, but expected initialized plain (non-pointer) bytes | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. From 61fbe57f4afd8f5b1a348b644d00c912d4b2e9fb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 12 May 2020 13:36:57 +0200 Subject: [PATCH 11/26] Clean up E0581 explanation --- src/librustc_error_codes/error_codes/E0581.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0581.md b/src/librustc_error_codes/error_codes/E0581.md index 947ec255a9d..89f6e3269ec 100644 --- a/src/librustc_error_codes/error_codes/E0581.md +++ b/src/librustc_error_codes/error_codes/E0581.md @@ -1,4 +1,4 @@ -In a `fn` type, a lifetime appears only in the return type, +In a `fn` type, a lifetime appears only in the return type and not in the arguments types. Erroneous code example: @@ -10,8 +10,11 @@ fn main() { } ``` -To fix this issue, either use the lifetime in the arguments, or use -`'static`. Example: +The problem here is that the lifetime isn't contrained by any of the arguments, +making it impossible to determine how long it's supposed to live. + +To fix this issue, either use the lifetime in the arguments, or use the +`'static` lifetime. Example: ``` fn main() { From 5063297c798c98f785047d4e18a3b9fd1a5331d8 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Tue, 12 May 2020 08:11:58 -0400 Subject: [PATCH 12/26] Add doc comment for `rustc_middle::mir::mono::Linkage` --- src/librustc_middle/mir/mono.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_middle/mir/mono.rs b/src/librustc_middle/mir/mono.rs index 632607e3356..c889dbc0a44 100644 --- a/src/librustc_middle/mir/mono.rs +++ b/src/librustc_middle/mir/mono.rs @@ -239,6 +239,9 @@ pub struct CodegenUnit<'tcx> { size_estimate: Option, } +/// Specifies the linkage type for a `MonoItem`. +/// +/// See https://llvm.org/docs/LangRef.html#linkage-types for more details about these variants. #[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable)] pub enum Linkage { External, From 34b2072599c2d14a36ed8cb7adeb0db44b8f76b3 Mon Sep 17 00:00:00 2001 From: Joshua Cotton Date: Wed, 6 May 2020 20:24:40 -0400 Subject: [PATCH 13/26] Fix bootstrap failing on win32 --- src/bootstrap/bootstrap.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 9a91f37c5de..b7d0fac5be3 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -180,13 +180,16 @@ def format_build_time(duration): def default_build_triple(): """Build triple as in LLVM""" default_encoding = sys.getdefaultencoding() - required = not sys.platform == 'win32' - ostype = require(["uname", "-s"], exit=required).decode(default_encoding) - cputype = require(['uname', '-m'], exit=required).decode(default_encoding) + required = sys.platform != 'win32' + ostype = require(["uname", "-s"], exit=required) + cputype = require(['uname', '-m'], exit=required) if ostype is None or cputype is None: return 'x86_64-pc-windows-msvc' + ostype = ostype.decode(default_encoding) + cputype = cputype.decode(default_encoding) + # The goal here is to come up with the same triple as LLVM would, # at least for the subset of platforms we're willing to target. ostype_mapper = { From 003ed802c4a289d959d4212ad80f33df7f3e2bc3 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Tue, 12 May 2020 16:54:29 +0100 Subject: [PATCH 14/26] Map to -> return. --- src/libcore/any.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 996a9cdfc4d..79b6304958d 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -448,7 +448,7 @@ impl TypeId { /// This is intended for diagnostic use. The exact contents and format of the /// string returned are not specified, other than being a best-effort /// description of the type. For example, amongst the strings -/// that `type_name::>()` might map to are `"Option"` and +/// that `type_name::>()` might return are `"Option"` and /// `"std::option::Option"`. /// /// The returned string must not be considered to be a unique identifier of a From 722b3df454f427db019de2e3c54739b61e6f713b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 12 May 2020 11:27:03 -0700 Subject: [PATCH 15/26] Update books --- src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/book b/src/doc/book index e37c0e84e2e..6247be15a7f 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit e37c0e84e2ef73d3a4ebffda8011db6814a3b02d +Subproject commit 6247be15a7f7509559f7981ee2209b9e0cc121df diff --git a/src/doc/edition-guide b/src/doc/edition-guide index 8204c1d1234..49270740c7a 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit 8204c1d123472cd17f0c1c5c77300ae802eb0271 +Subproject commit 49270740c7a4bff2763e6bc730b191d45b7d5167 diff --git a/src/doc/embedded-book b/src/doc/embedded-book index 40beccdf1bb..366c50a03be 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit 40beccdf1bb8eb9184a2e3b42db8b8c6e394247f +Subproject commit 366c50a03bed928589771eba8a6f18e0c0c01d23 diff --git a/src/doc/nomicon b/src/doc/nomicon index 4d2d2759977..d1517d4e3f2 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit 4d2d275997746d35eabfc4d992dfbdcce2f626ed +Subproject commit d1517d4e3f29264c5c67bce2658516bb5202c800 diff --git a/src/doc/reference b/src/doc/reference index ed22e6fbfcb..892b928b565 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit ed22e6fbfcb6ce436e9ea3b4bb4a55b2fb50a57e +Subproject commit 892b928b565e35d25b6f9c47faee03b94bc41489 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index ffc99581689..ab072b14393 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit ffc99581689fe2455908aaef5f5cf50dd03bb8f5 +Subproject commit ab072b14393cbd9e8a1d1d75879bf51e27217bbb From bb2ff593a63dc5500b0dd8d83cfa9bdca5768b79 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 13 May 2020 13:40:55 +0200 Subject: [PATCH 16/26] Clean up E0582 explanation --- src/librustc_error_codes/error_codes/E0582.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0582.md b/src/librustc_error_codes/error_codes/E0582.md index c0cf44852c4..e50cc60ea33 100644 --- a/src/librustc_error_codes/error_codes/E0582.md +++ b/src/librustc_error_codes/error_codes/E0582.md @@ -1,5 +1,5 @@ -A lifetime appears only in an associated-type binding, -and not in the input types to the trait. +A lifetime is only present in an associated-type binding, and not in the input +types to the trait. Erroneous code example: From 46e9cbea3a65aff70c838ebbd157d715ee84718b Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Wed, 13 May 2020 21:04:52 +0800 Subject: [PATCH 17/26] Update src/libcore/option.rs Co-authored-by: Steve Klabnik --- src/libcore/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 4df9eaa4815..542115763c2 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1357,7 +1357,7 @@ impl<'a, T> IntoIterator for &'a mut Option { #[stable(since = "1.12.0", feature = "option_from")] impl From for Option { - /// Copies val to a new Option::Some + /// Copies `val` into a new `Some`. /// /// # Examples /// From 4588c26e53a39f0379a0f25ace4228bc207f4a73 Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Wed, 13 May 2020 21:05:53 +0800 Subject: [PATCH 18/26] Update src/libcore/option.rs Co-authored-by: Steve Klabnik --- src/libcore/option.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 542115763c2..515040dd4cc 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1363,6 +1363,7 @@ impl From for Option { /// /// ``` /// let o: Option = Option::from(67); + /// /// assert_eq!(Some(67), o); /// ``` fn from(val: T) -> Option { From a9e7d572380c271848f1137f39ef09257144bd37 Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Wed, 13 May 2020 21:12:35 +0800 Subject: [PATCH 19/26] Update src/libcore/option.rs Co-authored-by: Steve Klabnik --- src/libcore/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 515040dd4cc..3e64177a467 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1373,7 +1373,7 @@ impl From for Option { #[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] impl<'a, T> From<&'a Option> for Option<&'a T> { - /// Converts from &Option to Option<&T> + /// Converts from `&Option` to `Option<&T>`. /// /// # Examples /// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original. From 644bb24e335bd15c7c90a2c31afa63d9ba5f5dbc Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Wed, 13 May 2020 21:12:50 +0800 Subject: [PATCH 20/26] Update src/libcore/option.rs Co-authored-by: Steve Klabnik --- src/libcore/option.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 3e64177a467..848560bd795 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1405,6 +1405,7 @@ impl<'a, T> From<&'a mut Option> for Option<&'a mut T> { /// ``` /// let mut s = Some(String::from("Hello")); /// let o: Option<&mut String> = Option::from(&mut s); + /// /// match o { /// Some(t) => *t = String::from("Hello, Rustaceans!"), /// None => (), From adc2bf0cfe3f4c6611ebcd80b570ed8ebd76b548 Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Wed, 13 May 2020 21:13:08 +0800 Subject: [PATCH 21/26] Update src/libcore/option.rs Co-authored-by: Steve Klabnik --- src/libcore/option.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 848560bd795..340637a55f7 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1376,6 +1376,7 @@ impl<'a, T> From<&'a Option> for Option<&'a T> { /// Converts from `&Option` to `Option<&T>`. /// /// # Examples + /// /// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original. /// The [`map`] method takes the `self` argument by value, consuming the original, /// so this technique uses `as_ref` to first take an `Option` to a reference From f445a8286e4d889ac33935768f2ac0823b2c01ba Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Wed, 13 May 2020 21:13:17 +0800 Subject: [PATCH 22/26] Update src/libcore/option.rs Co-authored-by: Steve Klabnik --- src/libcore/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 340637a55f7..a6a8d4bd7e1 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1399,7 +1399,7 @@ impl<'a, T> From<&'a Option> for Option<&'a T> { #[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] impl<'a, T> From<&'a mut Option> for Option<&'a mut T> { - /// Converts from &mut Option to Option<&mut T> + /// Converts from `&mut Option` to `Option<&mut T>` /// /// # Examples /// From ef1688db8e33b635287462854b7203f86c7acbf5 Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Wed, 13 May 2020 21:13:27 +0800 Subject: [PATCH 23/26] Update src/libcore/option.rs Co-authored-by: Steve Klabnik --- src/libcore/option.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a6a8d4bd7e1..ebaa4894862 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1411,6 +1411,7 @@ impl<'a, T> From<&'a mut Option> for Option<&'a mut T> { /// Some(t) => *t = String::from("Hello, Rustaceans!"), /// None => (), /// } + /// /// assert_eq!(s, Some(String::from("Hello, Rustaceans!"))); /// ``` fn from(o: &'a mut Option) -> Option<&'a mut T> { From 6c3856f3ec5bbcd1c748d01a463f04a8fef0bd6c Mon Sep 17 00:00:00 2001 From: Faris Sufyan <47665123+Dolpheyn@users.noreply.github.com> Date: Wed, 13 May 2020 21:13:35 +0800 Subject: [PATCH 24/26] Update src/libcore/option.rs Co-authored-by: Steve Klabnik --- src/libcore/option.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index ebaa4894862..e8483875c97 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1389,7 +1389,9 @@ impl<'a, T> From<&'a Option> for Option<&'a T> { /// ``` /// let s: Option = Some(String::from("Hello, Rustaceans!")); /// let o: Option = Option::from(&s).map(|ss: &String| ss.len()); + /// /// println!("Can still print s: {:?}", s); + /// /// assert_eq!(o, Some(18)); /// ``` fn from(o: &'a Option) -> Option<&'a T> { From e44f87fca30186b6dd34932a8532d4e52b9b88fe Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Wed, 13 May 2020 23:02:56 +0200 Subject: [PATCH 25/26] docs: fix link source https://github.com/rust-lang/rust/pull/72163#issuecomment-628234966 --- src/librustc_mir_build/build/scope.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir_build/build/scope.rs b/src/librustc_mir_build/build/scope.rs index 710a41bc8fd..19b983018c9 100644 --- a/src/librustc_mir_build/build/scope.rs +++ b/src/librustc_mir_build/build/scope.rs @@ -223,7 +223,7 @@ impl Scope { } } -/// A trait that determined how [DropTree::lower_to_mir] creates its blocks and +/// A trait that determined how [DropTree::build_mir] creates its blocks and /// links to any entry nodes. trait DropTreeBuilder<'tcx> { /// Create a new block for the tree. This should call either From dab3a5813e2590b2161d84a410e4d5bdc072152d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Thu, 14 May 2020 00:00:00 +0000 Subject: [PATCH 26/26] Fix Arc::decr_strong_count doc test --- src/liballoc/sync.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 19d289c87fd..dbee9d27d8a 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -835,12 +835,14 @@ impl Arc { /// /// unsafe { /// let ptr = Arc::into_raw(five); - /// Arc::decr_strong_count(ptr); + /// Arc::incr_strong_count(ptr); /// - /// // This assertion is deterministic because we haven't shared + /// // Those assertions are deterministic because we haven't shared /// // the `Arc` between threads. /// let five = Arc::from_raw(ptr); - /// assert_eq!(0, Arc::strong_count(&five)); + /// assert_eq!(2, Arc::strong_count(&five)); + /// Arc::decr_strong_count(ptr); + /// assert_eq!(1, Arc::strong_count(&five)); /// } /// ``` #[inline]