diff options
| -rw-r--r-- | src/librustc/ty/error.rs | 81 | ||||
| -rw-r--r-- | src/librustc/ty/query/config.rs | 423 | ||||
| -rw-r--r-- | src/librustc/ty/query/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc/ty/query/plumbing.rs | 4 |
4 files changed, 261 insertions, 248 deletions
diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index a1edf67e475..2367d482ec8 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -10,6 +10,7 @@ use hir::def_id::DefId; use ty::{self, BoundRegion, Region, Ty, TyCtxt}; +use std::borrow::Cow; use std::fmt; use rustc_target::spec::abi; use syntax::ast; @@ -71,7 +72,7 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::TypeError::*; fn report_maybe_different(f: &mut fmt::Formatter<'_>, - expected: String, found: String) -> fmt::Result { + expected: &str, found: &str) -> fmt::Result { // A naive approach to making sure that we're not reporting silly errors such as: // (expected closure, found closure). if expected == found { @@ -126,15 +127,15 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { br) } Sorts(values) => ty::tls::with(|tcx| { - report_maybe_different(f, values.expected.sort_string(tcx), - values.found.sort_string(tcx)) + report_maybe_different(f, &values.expected.sort_string(tcx), + &values.found.sort_string(tcx)) }), Traits(values) => ty::tls::with(|tcx| { report_maybe_different(f, - format!("trait `{}`", - tcx.item_path_str(values.expected)), - format!("trait `{}`", - tcx.item_path_str(values.found))) + &format!("trait `{}`", + tcx.item_path_str(values.expected)), + &format!("trait `{}`", + tcx.item_path_str(values.found))) }), IntMismatch(ref values) => { write!(f, "expected `{:?}`, found `{:?}`", @@ -162,8 +163,8 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { values.found) }, ExistentialMismatch(ref values) => { - report_maybe_different(f, format!("trait `{}`", values.expected), - format!("trait `{}`", values.found)) + report_maybe_different(f, &format!("trait `{}`", values.expected), + &format!("trait `{}`", values.found)) } OldStyleLUB(ref err) => { write!(f, "{}", err) @@ -173,22 +174,22 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { } impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { - pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> String { + pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> Cow<'static, str> { match self.sty { ty::Bool | ty::Char | ty::Int(_) | - ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string(), - ty::Tuple(ref tys) if tys.is_empty() => self.to_string(), + ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string().into(), + ty::Tuple(ref tys) if tys.is_empty() => self.to_string().into(), - ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)), - ty::Foreign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)), + ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)).into(), + ty::Foreign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)).into(), ty::Array(_, n) => { match n.assert_usize(tcx) { - Some(n) => format!("array of {} elements", n), - None => "array".to_string(), + Some(n) => format!("array of {} elements", n).into(), + None => "array".into(), } } - ty::Slice(_) => "slice".to_string(), - ty::RawPtr(_) => "*-ptr".to_string(), + ty::Slice(_) => "slice".into(), + ty::RawPtr(_) => "*-ptr".into(), ty::Ref(region, ty, mutbl) => { let tymut = ty::TypeAndMut { ty, mutbl }; let tymut_string = tymut.to_string(); @@ -199,39 +200,39 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { format!("{}reference", match mutbl { hir::Mutability::MutMutable => "mutable ", _ => "" - }) + }).into() } else { - format!("&{}", tymut_string) + format!("&{}", tymut_string).into() } } - ty::FnDef(..) => "fn item".to_string(), - ty::FnPtr(_) => "fn pointer".to_string(), + ty::FnDef(..) => "fn item".into(), + ty::FnPtr(_) => "fn pointer".into(), ty::Dynamic(ref inner, ..) => { - inner.principal().map_or_else(|| "trait".to_string(), - |p| format!("trait {}", tcx.item_path_str(p.def_id()))) + inner.principal().map_or_else(|| "trait".into(), + |p| format!("trait {}", tcx.item_path_str(p.def_id())).into()) } - ty::Closure(..) => "closure".to_string(), - ty::Generator(..) => "generator".to_string(), - ty::GeneratorWitness(..) => "generator witness".to_string(), - ty::Tuple(..) => "tuple".to_string(), - ty::Infer(ty::TyVar(_)) => "inferred type".to_string(), - ty::Infer(ty::IntVar(_)) => "integral variable".to_string(), - ty::Infer(ty::FloatVar(_)) => "floating-point variable".to_string(), + ty::Closure(..) => "closure".into(), + ty::Generator(..) => "generator".into(), + ty::GeneratorWitness(..) => "generator witness".into(), + ty::Tuple(..) => "tuple".into(), + ty::Infer(ty::TyVar(_)) => "inferred type".into(), + ty::Infer(ty::IntVar(_)) => "integral variable".into(), + ty::Infer(ty::FloatVar(_)) => "floating-point variable".into(), ty::Infer(ty::CanonicalTy(_)) | - ty::Infer(ty::FreshTy(_)) => "fresh type".to_string(), - ty::Infer(ty::FreshIntTy(_)) => "fresh integral type".to_string(), - ty::Infer(ty::FreshFloatTy(_)) => "fresh floating-point type".to_string(), - ty::Projection(_) => "associated type".to_string(), - ty::UnnormalizedProjection(_) => "non-normalized associated type".to_string(), + ty::Infer(ty::FreshTy(_)) => "fresh type".into(), + 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(ref p) => { if p.is_self() { - "Self".to_string() + "Self".into() } else { - "type parameter".to_string() + "type parameter".into() } } - ty::Opaque(..) => "opaque type".to_string(), - ty::Error => "type error".to_string(), + ty::Opaque(..) => "opaque type".into(), + ty::Error => "type error".into(), } } } diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index 0e11d6e0eec..79eab3c6f34 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -23,6 +23,7 @@ use ty::query::Query; use ty::query::QueryCache; use util::profiling::ProfileCategory; +use std::borrow::Cow; use std::hash::Hash; use std::fmt::Debug; use syntax_pos::symbol::InternedString; @@ -55,7 +56,7 @@ pub(super) trait QueryAccessors<'tcx>: QueryConfig<'tcx> { } pub(super) trait QueryDescription<'tcx>: QueryAccessors<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, key: Self::Key) -> String; + fn describe(tcx: TyCtxt<'_, '_, '_>, key: Self::Key) -> Cow<'static, str>; #[inline] fn cache_on_disk(_: Self::Key) -> bool { @@ -70,12 +71,12 @@ pub(super) trait QueryDescription<'tcx>: QueryAccessors<'tcx> { } impl<'tcx, M: QueryAccessors<'tcx, Key=DefId>> QueryDescription<'tcx> for M { - default fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { + default fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { if !tcx.sess.verbose() { - format!("processing `{}`", tcx.item_path_str(def_id)) + format!("processing `{}`", tcx.item_path_str(def_id)).into() } else { let name = unsafe { ::std::intrinsics::type_name::<M>() }; - format!("processing `{}` applied to `{:?}`", name, def_id) + format!("processing `{}` applied to `{:?}`", name, def_id).into() } } } @@ -84,57 +85,59 @@ impl<'tcx> QueryDescription<'tcx> for queries::normalize_projection_ty<'tcx> { fn describe( _tcx: TyCtxt<'_, '_, '_>, goal: CanonicalProjectionGoal<'tcx>, - ) -> String { - format!("normalizing `{:?}`", goal) + ) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::implied_outlives_bounds<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTyGoal<'tcx>) -> String { - format!("computing implied outlives bounds for `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTyGoal<'tcx>) -> Cow<'static, str> { + format!("computing implied outlives bounds for `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::dropck_outlives<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTyGoal<'tcx>) -> String { - format!("computing dropck types for `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTyGoal<'tcx>) -> Cow<'static, str> { + format!("computing dropck types for `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::normalize_ty_after_erasing_regions<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("normalizing `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::evaluate_obligation<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalPredicateGoal<'tcx>) -> String { - format!("evaluating trait selection obligation `{}`", goal.value.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalPredicateGoal<'tcx>) -> Cow<'static, str> { + format!("evaluating trait selection obligation `{}`", goal.value.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_eq<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpEqGoal<'tcx>) -> String { - format!("evaluating `type_op_eq` `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpEqGoal<'tcx>) -> Cow<'static, str> { + format!("evaluating `type_op_eq` `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_subtype<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpSubtypeGoal<'tcx>) -> String { - format!("evaluating `type_op_subtype` `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpSubtypeGoal<'tcx>) + -> Cow<'static, str> { + format!("evaluating `type_op_subtype` `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_prove_predicate<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpProvePredicateGoal<'tcx>) -> String { - format!("evaluating `type_op_prove_predicate` `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpProvePredicateGoal<'tcx>) + -> Cow<'static, str> { + format!("evaluating `type_op_prove_predicate` `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_ty<'tcx> { fn describe(_tcx: TyCtxt<'_, '_, '_>, - goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>) -> String { - format!("normalizing `{:?}`", goal) + goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } @@ -142,8 +145,8 @@ impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_predicate<'tcx> fn describe( _tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>, - ) -> String { - format!("normalizing `{:?}`", goal) + ) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } @@ -151,134 +154,141 @@ impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_poly_fn_sig<'tc fn describe( _tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>, - ) -> String { - format!("normalizing `{:?}`", goal) + ) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_fn_sig<'tcx> { fn describe(_tcx: TyCtxt<'_, '_, '_>, - goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>) -> String { - format!("normalizing `{:?}`", goal) + goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_copy_raw<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing whether `{}` is `Copy`", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing whether `{}` is `Copy`", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_sized_raw<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing whether `{}` is `Sized`", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing whether `{}` is `Sized`", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_freeze_raw<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing whether `{}` is freeze", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing whether `{}` is freeze", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::needs_drop_raw<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing whether `{}` needs drop", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing whether `{}` needs drop", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::layout_raw<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing layout of `{}`", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing layout of `{}`", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::super_predicates_of<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("computing the supertraits of `{}`", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::erase_regions_ty<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>) -> String { - format!("erasing regions from `{:?}`", ty) + fn describe(_tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>) -> Cow<'static, str> { + format!("erasing regions from `{:?}`", ty).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_param_predicates<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, (_, def_id): (DefId, DefId)) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, (_, def_id): (DefId, DefId)) -> Cow<'static, str> { let id = tcx.hir.as_local_node_id(def_id).unwrap(); format!("computing the bounds for type parameter `{}`", - tcx.hir.ty_param_name(id)) + tcx.hir.ty_param_name(id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::coherent_trait<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("coherence checking all impls of trait `{}`", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::upstream_monomorphizations<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, k: CrateNum) -> String { - format!("collecting available upstream monomorphizations `{:?}`", k) + fn describe(_: TyCtxt<'_, '_, '_>, k: CrateNum) -> Cow<'static, str> { + format!("collecting available upstream monomorphizations `{:?}`", k).into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_inherent_impls<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, k: CrateNum) -> String { - format!("all inherent impls defined in crate `{:?}`", k) + fn describe(_: TyCtxt<'_, '_, '_>, k: CrateNum) -> Cow<'static, str> { + format!("all inherent impls defined in crate `{:?}`", k).into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_inherent_impls_overlap_check<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "check for overlap between inherent impls defined in this crate".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "check for overlap between inherent impls defined in this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_variances<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "computing the variances for items in this crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "computing the variances for items in this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::inferred_outlives_crate<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "computing the inferred outlives predicates for items in this crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "computing the inferred outlives predicates for items in this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::mir_shims<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def: ty::InstanceDef<'tcx>) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def: ty::InstanceDef<'tcx>) -> Cow<'static, str> { format!("generating MIR shim for `{}`", - tcx.item_path_str(def.def_id())) + tcx.item_path_str(def.def_id())).into() } } impl<'tcx> QueryDescription<'tcx> for queries::privacy_access_levels<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "privacy access levels".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "privacy access levels".into() } } impl<'tcx> QueryDescription<'tcx> for queries::typeck_item_bodies<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "type-checking all item bodies".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "type-checking all item bodies".into() } } impl<'tcx> QueryDescription<'tcx> for queries::reachable_set<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "reachability".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "reachability".into() } } impl<'tcx> QueryDescription<'tcx> for queries::const_eval<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) -> String { - format!("const-evaluating `{}`", tcx.item_path_str(key.value.instance.def.def_id())) + fn describe(tcx: TyCtxt<'_, '_, '_>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) + -> Cow<'static, str> + { + format!("const-evaluating `{}`", tcx.item_path_str(key.value.instance.def.def_id())).into() } #[inline] @@ -295,14 +305,14 @@ impl<'tcx> QueryDescription<'tcx> for queries::const_eval<'tcx> { } impl<'tcx> QueryDescription<'tcx> for queries::mir_keys<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "getting a list of all mir_keys".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "getting a list of all mir_keys".into() } } impl<'tcx> QueryDescription<'tcx> for queries::symbol_name<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, instance: ty::Instance<'tcx>) -> String { - format!("computing the symbol for `{}`", instance) + fn describe(_tcx: TyCtxt<'_, '_, '_>, instance: ty::Instance<'tcx>) -> Cow<'static, str> { + format!("computing the symbol for `{}`", instance).into() } #[inline] @@ -319,64 +329,64 @@ impl<'tcx> QueryDescription<'tcx> for queries::symbol_name<'tcx> { } impl<'tcx> QueryDescription<'tcx> for queries::describe_def<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("describe_def") } } impl<'tcx> QueryDescription<'tcx> for queries::def_span<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("def_span") } } impl<'tcx> QueryDescription<'tcx> for queries::lookup_stability<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("stability") } } impl<'tcx> QueryDescription<'tcx> for queries::lookup_deprecation_entry<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("deprecation") } } impl<'tcx> QueryDescription<'tcx> for queries::item_attrs<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("item_attrs") } } impl<'tcx> QueryDescription<'tcx> for queries::is_reachable_non_generic<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("is_reachable_non_generic") } } impl<'tcx> QueryDescription<'tcx> for queries::fn_arg_names<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("fn_arg_names") } } impl<'tcx> QueryDescription<'tcx> for queries::impl_parent<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("impl_parent") } } impl<'tcx> QueryDescription<'tcx> for queries::trait_of_item<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("trait_of_item") } } impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_static<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("const checking if rvalue is promotable to static `{}`", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } #[inline] @@ -393,23 +403,24 @@ impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_sta } impl<'tcx> QueryDescription<'tcx> for queries::rvalue_promotable_map<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("checking which parts of `{}` are promotable to static", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_mir_available<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("checking if item is mir available: `{}`", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::codegen_fulfill_obligation<'tcx> { fn describe(tcx: TyCtxt<'_, '_, '_>, - key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> String { + key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Cow<'static, str> { format!("checking if `{}` fulfills its obligations", tcx.item_path_str(key.1.def_id())) + .into() } #[inline] @@ -426,320 +437,320 @@ impl<'tcx> QueryDescription<'tcx> for queries::codegen_fulfill_obligation<'tcx> } impl<'tcx> QueryDescription<'tcx> for queries::trait_impls_of<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { - format!("trait impls of `{}`", tcx.item_path_str(def_id)) + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { + format!("trait impls of `{}`", tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_object_safe<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { - format!("determine object safety of trait `{}`", tcx.item_path_str(def_id)) + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { + format!("determine object safety of trait `{}`", tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_const_fn_raw<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> String { - format!("checking if item is const fn: `{}`", tcx.item_path_str(def_id)) + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { + format!("checking if item is const fn: `{}`", tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::dylib_dependency_formats<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "dylib dependency formats of crate".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "dylib dependency formats of crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_panic_runtime<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "checking if the crate is_panic_runtime".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "checking if the crate is_panic_runtime".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_compiler_builtins<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "checking if the crate is_compiler_builtins".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "checking if the crate is_compiler_builtins".into() } } impl<'tcx> QueryDescription<'tcx> for queries::has_global_allocator<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "checking if the crate has_global_allocator".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "checking if the crate has_global_allocator".into() } } impl<'tcx> QueryDescription<'tcx> for queries::has_panic_handler<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "checking if the crate has_panic_handler".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "checking if the crate has_panic_handler".into() } } impl<'tcx> QueryDescription<'tcx> for queries::extern_crate<'tcx> { - fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> String { - "getting crate's ExternCrateData".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { + "getting crate's ExternCrateData".into() } } impl<'tcx> QueryDescription<'tcx> for queries::lint_levels<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "computing the lint levels for items in this crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "computing the lint levels for items in this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::specializes<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: (DefId, DefId)) -> String { - "computing whether impls specialize one another".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: (DefId, DefId)) -> Cow<'static, str> { + "computing whether impls specialize one another".into() } } impl<'tcx> QueryDescription<'tcx> for queries::in_scope_traits_map<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> String { - "traits in scope at a block".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { + "traits in scope at a block".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_no_builtins<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "test whether a crate has #![no_builtins]".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "test whether a crate has #![no_builtins]".into() } } impl<'tcx> QueryDescription<'tcx> for queries::panic_strategy<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "query a crate's configured panic strategy".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "query a crate's configured panic strategy".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_profiler_runtime<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "query a crate is #![profiler_runtime]".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "query a crate is #![profiler_runtime]".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_sanitizer_runtime<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "query a crate is #![sanitizer_runtime]".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "query a crate is #![sanitizer_runtime]".into() } } impl<'tcx> QueryDescription<'tcx> for queries::reachable_non_generics<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the exported symbols of a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the exported symbols of a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::native_libraries<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the native libraries of a linked crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the native libraries of a linked crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::foreign_modules<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the foreign modules of a linked crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the foreign modules of a linked crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::plugin_registrar_fn<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the plugin registrar for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the plugin registrar for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::derive_registrar_fn<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the derive registrar for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the derive registrar for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_disambiguator<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the disambiguator a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the disambiguator a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_hash<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the hash a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the hash a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::original_crate_name<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the original name a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the original name a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::extra_filename<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the extra filename for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the extra filename for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::implementations_of_trait<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: (CrateNum, DefId)) -> String { - "looking up implementations of a trait in a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: (CrateNum, DefId)) -> Cow<'static, str> { + "looking up implementations of a trait in a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::all_trait_implementations<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up all (?) trait implementations".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up all (?) trait implementations".into() } } impl<'tcx> QueryDescription<'tcx> for queries::link_args<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up link arguments for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up link arguments for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::resolve_lifetimes<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "resolving lifetimes".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "resolving lifetimes".into() } } impl<'tcx> QueryDescription<'tcx> for queries::named_region_map<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> String { - "looking up a named region".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { + "looking up a named region".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_late_bound_map<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> String { - "testing if a region is late bound".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { + "testing if a region is late bound".into() } } impl<'tcx> QueryDescription<'tcx> for queries::object_lifetime_defaults_map<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> String { - "looking up lifetime defaults for a region".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { + "looking up lifetime defaults for a region".into() } } impl<'tcx> QueryDescription<'tcx> for queries::dep_kind<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "fetching what a dependency looks like".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "fetching what a dependency looks like".into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_name<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "fetching what a crate is named".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "fetching what a crate is named".into() } } impl<'tcx> QueryDescription<'tcx> for queries::get_lib_features<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - format!("calculating the lib features map") + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the lib features map".into() } } impl<'tcx> QueryDescription<'tcx> for queries::defined_lib_features<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - format!("calculating the lib features defined in a crate") + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the lib features defined in a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::get_lang_items<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "calculating the lang items map".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the lang items map".into() } } impl<'tcx> QueryDescription<'tcx> for queries::defined_lang_items<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "calculating the lang items defined in a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the lang items defined in a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::missing_lang_items<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "calculating the missing lang items in a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the missing lang items in a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::visible_parent_map<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "calculating the visible parent map".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the visible parent map".into() } } impl<'tcx> QueryDescription<'tcx> for queries::missing_extern_crate_item<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "seeing if we're missing an `extern crate` item for this crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "seeing if we're missing an `extern crate` item for this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::used_crate_source<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking at the source for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking at the source for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::postorder_cnums<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "generating a postorder list of CrateNums".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "generating a postorder list of CrateNums".into() } } impl<'tcx> QueryDescription<'tcx> for queries::maybe_unused_extern_crates<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up all possibly unused extern crates".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up all possibly unused extern crates".into() } } impl<'tcx> QueryDescription<'tcx> for queries::stability_index<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "calculating the stability index for the local crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the stability index for the local crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::all_traits<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "fetching all foreign and local traits".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "fetching all foreign and local traits".into() } } impl<'tcx> QueryDescription<'tcx> for queries::all_crate_nums<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "fetching all foreign CrateNum instances".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "fetching all foreign CrateNum instances".into() } } impl<'tcx> QueryDescription<'tcx> for queries::exported_symbols<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "exported_symbols".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "exported_symbols".into() } } impl<'tcx> QueryDescription<'tcx> for queries::collect_and_partition_mono_items<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "collect_and_partition_mono_items".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "collect_and_partition_mono_items".into() } } impl<'tcx> QueryDescription<'tcx> for queries::codegen_unit<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: InternedString) -> String { - "codegen_unit".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: InternedString) -> Cow<'static, str> { + "codegen_unit".into() } } impl<'tcx> QueryDescription<'tcx> for queries::output_filenames<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "output_filenames".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "output_filenames".into() } } impl<'tcx> QueryDescription<'tcx> for queries::vtable_methods<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, key: ty::PolyTraitRef<'tcx> ) -> String { - format!("finding all methods for trait {}", tcx.item_path_str(key.def_id())) + fn describe(tcx: TyCtxt<'_, '_, '_>, key: ty::PolyTraitRef<'tcx> ) -> Cow<'static, str> { + format!("finding all methods for trait {}", tcx.item_path_str(key.def_id())).into() } } impl<'tcx> QueryDescription<'tcx> for queries::features_query<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up enabled feature gates".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up enabled feature gates".into() } } @@ -776,20 +787,20 @@ impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> { } impl<'tcx> QueryDescription<'tcx> for queries::substitute_normalize_and_test_predicates<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, key: (DefId, &'tcx Substs<'tcx>)) -> String { - format!("testing substituted normalized predicates:`{}`", tcx.item_path_str(key.0)) + fn describe(tcx: TyCtxt<'_, '_, '_>, key: (DefId, &'tcx Substs<'tcx>)) -> Cow<'static, str> { + format!("testing substituted normalized predicates:`{}`", tcx.item_path_str(key.0)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::target_features_whitelist<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "looking up the whitelist of target features".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the whitelist of target features".into() } } impl<'tcx> QueryDescription<'tcx> for queries::instance_def_size_estimate<'tcx> { - fn describe(tcx: TyCtxt<'_, '_, '_>, def: ty::InstanceDef<'tcx>) -> String { - format!("estimating size for `{}`", tcx.item_path_str(def.def_id())) + fn describe(tcx: TyCtxt<'_, '_, '_>, def: ty::InstanceDef<'tcx>) -> Cow<'static, str> { + format!("estimating size for `{}`", tcx.item_path_str(def.def_id())).into() } } @@ -809,26 +820,26 @@ impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> { } impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefId) -> String { - "generating chalk-style clauses".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { + "generating chalk-style clauses".into() } } impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for_env<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: ty::ParamEnv<'tcx>) -> String { - "generating chalk-style clauses for param env".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: ty::ParamEnv<'tcx>) -> Cow<'static, str> { + "generating chalk-style clauses for param env".into() } } impl<'tcx> QueryDescription<'tcx> for queries::wasm_import_module_map<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "wasm import module map".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "wasm import module map".into() } } impl<'tcx> QueryDescription<'tcx> for queries::dllimport_foreign_items<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> String { - "wasm import module map".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "wasm import module map".into() } } diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 44c9c55b8a4..7f5bc35f91f 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -56,6 +56,7 @@ use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::sync::Lrc; use rustc_target::spec::PanicStrategy; +use std::borrow::Cow; use std::ops::Deref; use std::sync::Arc; use syntax_pos::{Span, DUMMY_SP}; diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 5f6fdbddf8f..50eae945a8c 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -733,14 +733,14 @@ macro_rules! define_queries_inner { } } - pub fn describe(&self, tcx: TyCtxt<'_, '_, '_>) -> String { + pub fn describe(&self, tcx: TyCtxt<'_, '_, '_>) -> Cow<'static, str> { let (r, name) = match *self { $(Query::$name(key) => { (queries::$name::describe(tcx, key), stringify!($name)) })* }; if tcx.sess.verbose() { - format!("{} [{}]", r, name) + format!("{} [{}]", r, name).into() } else { r } |
