From d110803c628ad3c7804a01886ef30ece51479bcf Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 20 Aug 2018 07:18:30 +0300 Subject: [PATCH] rustc: remove Ty::{is_self, has_self_ty}. --- src/librustc/infer/error_reporting/mod.rs | 32 ++++++++----------- src/librustc/traits/object_safety.rs | 13 +++++--- src/librustc/ty/error.rs | 8 +---- src/librustc/ty/flags.rs | 8 ++--- src/librustc/ty/fold.rs | 3 -- src/librustc/ty/layout.rs | 3 +- src/librustc/ty/mod.rs | 30 ++++++++--------- src/librustc/ty/sty.rs | 18 ----------- src/librustc_lint/builtin.rs | 3 +- src/librustc_typeck/astconv.rs | 4 ++- src/librustc_typeck/collect.rs | 4 --- .../outlives/implicit_infer.rs | 7 +++- src/librustdoc/clean/simplify.rs | 3 +- .../associated-types-issue-20346.stderr | 2 +- .../reordered-type-param.stderr | 2 +- .../impl-generic-mismatch-ab.stderr | 2 +- .../universal-mismatched-type.stderr | 2 +- .../universal-two-impl-traits.stderr | 6 ++-- src/test/ui/issues/issue-13853.stderr | 2 +- src/test/ui/issues/issue-20225.stderr | 6 ++-- src/test/ui/issues/issue-24204.stderr | 2 +- src/test/ui/issues/issue-2951.rs | 2 +- src/test/ui/issues/issue-2951.stderr | 2 +- .../ui/mismatched_types/issue-35030.stderr | 4 +-- .../struct-path-self-type-mismatch.stderr | 4 +-- src/test/ui/structs/struct-path-self.rs | 6 ++-- src/test/ui/structs/struct-path-self.stderr | 6 ++-- src/test/ui/type/type-parameter-names.rs | 2 +- src/test/ui/type/type-parameter-names.stderr | 2 +- .../type/type-params-in-different-spaces-1.rs | 2 +- .../type-params-in-different-spaces-1.stderr | 2 +- .../type-params-in-different-spaces-3.stderr | 2 +- 32 files changed, 82 insertions(+), 112 deletions(-) diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 02da3701db297..00d1a83403eee 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -1117,19 +1117,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let table = table.borrow(); table.local_id_root.and_then(|did| { let generics = self.tcx.generics_of(did); - // Account for the case where `did` corresponds to `Self`, which doesn't have - // the expected type argument. - if !param.is_self() { - let type_param = generics.type_param(param, self.tcx); - let hir = &self.tcx.hir; - hir.as_local_node_id(type_param.def_id).map(|id| { - // Get the `hir::Param` to verify whether it already has any bounds. - // We do this to avoid suggesting code that ends up as `T: 'a'b`, - // instead we suggest `T: 'a + 'b` in that case. - let mut has_bounds = false; - if let hir_map::NodeGenericParam(ref param) = hir.get(id) { - has_bounds = !param.bounds.is_empty(); - } + let type_param = generics.type_param(param, self.tcx); + let hir = &self.tcx.hir; + hir.as_local_node_id(type_param.def_id).and_then(|id| { + // Get the `hir::Param` to verify whether it already has any bounds. + // We do this to avoid suggesting code that ends up as `T: 'a'b`, + // instead we suggest `T: 'a + 'b` in that case. + // Also, `Self` isn't in the HIR so we rule it out here. + if let hir_map::NodeGenericParam(ref hir_param) = hir.get(id) { + let has_bounds = !hir_param.bounds.is_empty(); let sp = hir.span(id); // `sp` only covers `T`, change it so that it covers // `T:` when appropriate @@ -1141,11 +1137,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } else { sp }; - (sp, has_bounds) - }) - } else { - None - } + Some((sp, has_bounds)) + } else { + None + } + }) }) } _ => None, diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 17d55b77625b2..c9f18e30c6b85 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -169,6 +169,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { trait_def_id: DefId, supertraits_only: bool) -> bool { + let trait_self_ty = self.mk_self_type(); let trait_ref = ty::Binder::dummy(ty::TraitRef::identity(self, trait_def_id)); let predicates = if supertraits_only { self.super_predicates_of(trait_def_id) @@ -183,7 +184,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { match predicate { ty::Predicate::Trait(ref data) => { // In the case of a trait predicate, we can skip the "self" type. - data.skip_binder().input_types().skip(1).any(|t| t.has_self_ty()) + data.skip_binder().input_types().skip(1).any(|t| { + t.walk().any(|ty| ty == trait_self_ty) + }) } ty::Predicate::Projection(..) | ty::Predicate::WellFormed(..) | @@ -204,6 +207,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } fn generics_require_sized_self(self, def_id: DefId) -> bool { + let trait_self_ty = self.mk_self_type(); let sized_def_id = match self.lang_items().sized_trait() { Some(def_id) => def_id, None => { return false; /* No Sized trait, can't require it! */ } @@ -216,7 +220,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { .any(|predicate| { match predicate { ty::Predicate::Trait(ref trait_pred) if trait_pred.def_id() == sized_def_id => { - trait_pred.skip_binder().self_ty().is_self() + trait_pred.skip_binder().self_ty() == trait_self_ty } ty::Predicate::Projection(..) | ty::Predicate::Trait(..) | @@ -367,12 +371,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // object type, and we cannot resolve `Self as SomeOtherTrait` // without knowing what `Self` is. + let trait_self_ty = self.mk_self_type(); let mut supertraits: Option>> = None; let mut error = false; ty.maybe_walk(|ty| { match ty.sty { - ty::Param(ref param_ty) => { - if param_ty.is_self() { + ty::Param(_) => { + if ty == trait_self_ty { error = true; } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index aa6ee420a2162..3fd3b6b55a718 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -222,13 +222,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { ty::Infer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(), ty::Infer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(), ty::Projection(_) => "associated type".to_string(), - ty::Param(ref p) => { - if p.is_self() { - "Self".to_string() - } else { - "type parameter".to_string() - } - } + ty::Param(_) => format!("`{}` parameter", self), ty::Anon(..) => "anonymized type".to_string(), ty::Error => "type error".to_string(), } diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index b9371ec39ccda..fdaac2670aec5 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -90,13 +90,9 @@ impl FlagComputation { self.add_flags(TypeFlags::HAS_TY_ERR) } - &ty::Param(ref p) => { + &ty::Param(_) => { self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES); - if p.is_self() { - self.add_flags(TypeFlags::HAS_SELF); - } else { - self.add_flags(TypeFlags::HAS_PARAMS); - } + self.add_flags(TypeFlags::HAS_PARAMS); } &ty::Generator(_, ref substs, _) => { diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index 26010c3d5f55c..359b522aec95e 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -93,9 +93,6 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { fn has_param_types(&self) -> bool { self.has_type_flags(TypeFlags::HAS_PARAMS) } - fn has_self_ty(&self) -> bool { - self.has_type_flags(TypeFlags::HAS_SELF) - } fn has_infer_types(&self) -> bool { self.has_type_flags(TypeFlags::HAS_TY_INFER) } diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index d485b9b32d431..437907e1a9e88 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1130,7 +1130,6 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { if !self.tcx.sess.opts.debugging_opts.print_type_sizes || layout.ty.has_param_types() || - layout.ty.has_self_ty() || !self.param_env.caller_bounds.is_empty() { return; @@ -1300,7 +1299,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> { let tail = tcx.struct_tail(pointee); match tail.sty { ty::Param(_) | ty::Projection(_) => { - debug_assert!(tail.has_param_types() || tail.has_self_ty()); + debug_assert!(tail.has_param_types()); Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(&tail) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 77b4d32c397d7..a8bb206a00828 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -423,57 +423,54 @@ pub struct CReaderCacheKey { bitflags! { pub struct TypeFlags: u32 { const HAS_PARAMS = 1 << 0; - const HAS_SELF = 1 << 1; - const HAS_TY_INFER = 1 << 2; - const HAS_RE_INFER = 1 << 3; - const HAS_RE_SKOL = 1 << 4; + const HAS_TY_INFER = 1 << 1; + const HAS_RE_INFER = 1 << 2; + const HAS_RE_SKOL = 1 << 3; /// Does this have any `ReEarlyBound` regions? Used to /// determine whether substitition is required, since those /// represent regions that are bound in a `ty::Generics` and /// hence may be substituted. - const HAS_RE_EARLY_BOUND = 1 << 5; + const HAS_RE_EARLY_BOUND = 1 << 4; /// Does this have any region that "appears free" in the type? /// Basically anything but `ReLateBound` and `ReErased`. - const HAS_FREE_REGIONS = 1 << 6; + const HAS_FREE_REGIONS = 1 << 5; /// Is an error type reachable? - const HAS_TY_ERR = 1 << 7; - const HAS_PROJECTION = 1 << 8; + const HAS_TY_ERR = 1 << 6; + const HAS_PROJECTION = 1 << 7; // FIXME: Rename this to the actual property since it's used for generators too - const HAS_TY_CLOSURE = 1 << 9; + const HAS_TY_CLOSURE = 1 << 8; // true if there are "names" of types and regions and so forth // that are local to a particular fn - const HAS_FREE_LOCAL_NAMES = 1 << 10; + const HAS_FREE_LOCAL_NAMES = 1 << 9; // Present if the type belongs in a local type context. // Only set for Infer other than Fresh. - const KEEP_IN_LOCAL_TCX = 1 << 11; + const KEEP_IN_LOCAL_TCX = 1 << 10; // Is there a projection that does not involve a bound region? // Currently we can't normalize projections w/ bound regions. - const HAS_NORMALIZABLE_PROJECTION = 1 << 12; + const HAS_NORMALIZABLE_PROJECTION = 1 << 11; // Set if this includes a "canonical" type or region var -- // ought to be true only for the results of canonicalization. - const HAS_CANONICAL_VARS = 1 << 13; + const HAS_CANONICAL_VARS = 1 << 12; /// Does this have any `ReLateBound` regions? Used to check /// if a global bound is safe to evaluate. - const HAS_RE_LATE_BOUND = 1 << 14; + const HAS_RE_LATE_BOUND = 1 << 13; const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits | - TypeFlags::HAS_SELF.bits | TypeFlags::HAS_RE_EARLY_BOUND.bits; // Flags representing the nominal content of a type, // computed by FlagsComputation. If you add a new nominal // flag, it should be added here too. const NOMINAL_FLAGS = TypeFlags::HAS_PARAMS.bits | - TypeFlags::HAS_SELF.bits | TypeFlags::HAS_TY_INFER.bits | TypeFlags::HAS_RE_INFER.bits | TypeFlags::HAS_RE_SKOL.bits | @@ -1632,7 +1629,6 @@ impl<'tcx> ParamEnv<'tcx> { if value.has_skol() || value.needs_infer() || value.has_param_types() - || value.has_self_ty() { ParamEnvAnd { param_env: self, diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 7c7ee9b330ecc..3784fa2252efb 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -982,17 +982,6 @@ impl<'a, 'gcx, 'tcx> ParamTy { pub fn to_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { tcx.mk_ty_param(self.idx, self.name) } - - pub fn is_self(&self) -> bool { - // FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere, - // but this should only be possible when using `-Z continue-parse-after-error` like - // `compile-fail/issue-36638.rs`. - if self.name == keywords::SelfType.name().as_str() && self.idx == 0 { - true - } else { - false - } - } } /// A [De Bruijn index][dbi] is a standard means of representing @@ -1519,13 +1508,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } } - pub fn is_self(&self) -> bool { - match self.sty { - Param(ref p) => p.is_self(), - _ => false, - } - } - pub fn is_slice(&self) -> bool { match self.sty { RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => match ty.sty { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c26d8555214c1..1be34b761bab3 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1075,6 +1075,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { // A trait method, from any number of possible sources. // Attempt to select a concrete impl before checking. ty::TraitContainer(trait_def_id) => { + let trait_self_ty = tcx.mk_self_type(); let trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, callee_substs); let trait_ref = ty::Binder::bind(trait_ref); let span = tcx.hir.span(expr_id); @@ -1090,7 +1091,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { // If `T` is `Self`, then this call is inside // a default method definition. Ok(Some(traits::VtableParam(_))) => { - let on_self = trait_ref.self_ty().is_self(); + let on_self = trait_ref.self_ty() == trait_self_ty; // We can only be recurring in a default // method if we're being called literally // on the `Self` type. diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index a528c8e9b4f96..635c25e96c43f 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -597,7 +597,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { let default_needs_object_self = |param: &ty::GenericParamDef| { if let GenericParamDefKind::Type { has_default, .. } = param.kind { if is_object && has_default { - if tcx.at(span).type_of(param.def_id).has_self_ty() { + let trait_self_ty = tcx.mk_self_type(); + let default = tcx.at(span).type_of(param.def_id); + if default.walk().any(|ty| ty == trait_self_ty) { // There is no suitable inference default for a type parameter // that references self, in an object type. return true; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 956d542ab7d4e..bf0eaff4b1a52 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -919,10 +919,6 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut i = 0; params.extend(ast_generics.params.iter().filter_map(|param| match param.kind { GenericParamKind::Type { ref default, synthetic, .. } => { - if param.name.ident().name == keywords::SelfType.name() { - span_bug!(param.span, "`Self` should not be the name of a regular parameter"); - } - if !allow_defaults && default.is_some() { if !tcx.features().default_type_parameter_fallback { tcx.lint_node( diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index ec36fa0fbc145..c7aa6fb88375e 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -267,6 +267,11 @@ pub fn check_explicit_predicates<'tcx>( debug!("required_predicates = {:?}", required_predicates); let explicit_predicates = explicit_map.explicit_predicates_of(tcx, *def_id); + let ignore_self_ty = if ignore_self_ty { + Some(tcx.mk_self_type()) + } else { + None + }; for outlives_predicate in explicit_predicates.iter() { debug!("outlives_predicate = {:?}", &outlives_predicate); @@ -297,7 +302,7 @@ pub fn check_explicit_predicates<'tcx>( // to apply the substs, and not filter this predicate, we might then falsely // conclude that e.g. `X: 'x` was a reasonable inferred requirement. if let UnpackedKind::Type(ty) = outlives_predicate.0.unpack() { - if ty.is_self() && ignore_self_ty { + if Some(ty) == ignore_self_ty { debug!("skipping self ty = {:?}", &ty); continue; } diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index e938d2d0a1652..61b4c347c86fe 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -156,10 +156,11 @@ fn trait_is_same_or_supertrait(cx: &DocContext, child: DefId, if child == trait_ { return true } + let trait_self_ty = cx.tcx.mk_self_type(); let predicates = cx.tcx.super_predicates_of(child).predicates; predicates.iter().filter_map(|pred| { if let ty::Predicate::Trait(ref pred) = *pred { - if pred.skip_binder().trait_ref.self_ty().is_self() { + if pred.skip_binder().trait_ref.self_ty() == trait_self_ty { Some(pred.def_id()) } else { None diff --git a/src/test/ui/associated-types/associated-types-issue-20346.stderr b/src/test/ui/associated-types/associated-types-issue-20346.stderr index 6f3dfbe0898ec..7bd698401c964 100644 --- a/src/test/ui/associated-types/associated-types-issue-20346.stderr +++ b/src/test/ui/associated-types/associated-types-issue-20346.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving ` as Iterator>::Item == std::op --> $DIR/associated-types-issue-20346.rs:44:5 | LL | is_iterator_of::, _>(&adapter); //~ ERROR type mismatch - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found enum `std::option::Option` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `T` parameter, found enum `std::option::Option` | = note: expected type `T` found type `std::option::Option` diff --git a/src/test/ui/compare-method/reordered-type-param.stderr b/src/test/ui/compare-method/reordered-type-param.stderr index 1efd5f2fb258d..6092bd94564fd 100644 --- a/src/test/ui/compare-method/reordered-type-param.stderr +++ b/src/test/ui/compare-method/reordered-type-param.stderr @@ -5,7 +5,7 @@ LL | fn b(&self, x: C) -> C; | - type in trait ... LL | fn b(&self, _x: G) -> G { panic!() } //~ ERROR method `b` has an incompatible type - | ^ expected type parameter, found a different type parameter + | ^ expected `F` parameter, found `G` parameter | = note: expected type `fn(&E, F) -> F` found type `fn(&E, G) -> G` diff --git a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr index 77ecdf2f5acf0..3c25a15142c02 100644 --- a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr +++ b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr @@ -5,7 +5,7 @@ LL | fn foo(&self, a: &A, b: &impl Debug); | -- type in trait ... LL | fn foo(&self, a: &impl Debug, b: &B) { } - | ^^^^^^^^^^^ expected type parameter, found a different type parameter + | ^^^^^^^^^^^ expected `B` parameter, found `impl Debug` parameter | = note: expected type `fn(&(), &B, &impl Debug)` found type `fn(&(), &impl Debug, &B)` diff --git a/src/test/ui/impl-trait/universal-mismatched-type.stderr b/src/test/ui/impl-trait/universal-mismatched-type.stderr index 031db511ff30d..9a85e1b9d7706 100644 --- a/src/test/ui/impl-trait/universal-mismatched-type.stderr +++ b/src/test/ui/impl-trait/universal-mismatched-type.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | fn foo(x: impl Debug) -> String { | ------ expected `std::string::String` because of return type LL | x //~ ERROR mismatched types - | ^ expected struct `std::string::String`, found type parameter + | ^ expected struct `std::string::String`, found `impl Debug` parameter | = note: expected type `std::string::String` found type `impl Debug` diff --git a/src/test/ui/impl-trait/universal-two-impl-traits.stderr b/src/test/ui/impl-trait/universal-two-impl-traits.stderr index ed406895fc699..ada72b7c802bf 100644 --- a/src/test/ui/impl-trait/universal-two-impl-traits.stderr +++ b/src/test/ui/impl-trait/universal-two-impl-traits.stderr @@ -2,10 +2,10 @@ error[E0308]: mismatched types --> $DIR/universal-two-impl-traits.rs:15:9 | LL | a = y; //~ ERROR mismatched - | ^ expected type parameter, found a different type parameter + | ^ expected `impl Debug` parameter, found a different `impl Debug` parameter | - = note: expected type `impl Debug` (type parameter) - found type `impl Debug` (type parameter) + = note: expected type `impl Debug` (`impl Debug` parameter) + found type `impl Debug` (`impl Debug` parameter) error: aborting due to previous error diff --git a/src/test/ui/issues/issue-13853.stderr b/src/test/ui/issues/issue-13853.stderr index 188bfd5930105..d85abc66d4dc4 100644 --- a/src/test/ui/issues/issue-13853.stderr +++ b/src/test/ui/issues/issue-13853.stderr @@ -5,7 +5,7 @@ LL | fn nodes<'a, I: Iterator>(&self) -> I | - expected `I` because of return type ... LL | self.iter() //~ ERROR mismatched types - | ^^^^^^^^^^^ expected type parameter, found struct `std::slice::Iter` + | ^^^^^^^^^^^ expected `I` parameter, found struct `std::slice::Iter` | = note: expected type `I` found type `std::slice::Iter<'_, N>` diff --git a/src/test/ui/issues/issue-20225.stderr b/src/test/ui/issues/issue-20225.stderr index 7813dc5c11dba..fc6dbc301a554 100644 --- a/src/test/ui/issues/issue-20225.stderr +++ b/src/test/ui/issues/issue-20225.stderr @@ -2,7 +2,7 @@ error[E0053]: method `call` has an incompatible type for trait --> $DIR/issue-20225.rs:16:3 | LL | extern "rust-call" fn call(&self, (_,): (T,)) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found `T` parameter | = note: expected type `extern "rust-call" fn(&Foo, (&'a T,))` found type `extern "rust-call" fn(&Foo, (T,))` @@ -11,7 +11,7 @@ error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/issue-20225.rs:22:3 | LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found `T` parameter | = note: expected type `extern "rust-call" fn(&mut Foo, (&'a T,))` found type `extern "rust-call" fn(&mut Foo, (T,))` @@ -20,7 +20,7 @@ error[E0053]: method `call_once` has an incompatible type for trait --> $DIR/issue-20225.rs:30:3 | LL | extern "rust-call" fn call_once(self, (_,): (T,)) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found `T` parameter | = note: expected type `extern "rust-call" fn(Foo, (&'a T,))` found type `extern "rust-call" fn(Foo, (T,))` diff --git a/src/test/ui/issues/issue-24204.stderr b/src/test/ui/issues/issue-24204.stderr index 809db28403208..fa766198e66bf 100644 --- a/src/test/ui/issues/issue-24204.stderr +++ b/src/test/ui/issues/issue-24204.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<::A as MultiDispatch>:: --> $DIR/issue-24204.rs:24:1 | LL | fn test>(b: i32) -> T where T::A: MultiDispatch { T::new(b) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found type parameter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found `T` parameter | = note: expected type `<::A as MultiDispatch>::O` found type `T` diff --git a/src/test/ui/issues/issue-2951.rs b/src/test/ui/issues/issue-2951.rs index 11ff7ab2476b9..9dddb2c6e2f22 100644 --- a/src/test/ui/issues/issue-2951.rs +++ b/src/test/ui/issues/issue-2951.rs @@ -14,7 +14,7 @@ fn foo(x: T, y: U) { //~^ ERROR mismatched types //~| expected type `T` //~| found type `U` - //~| expected type parameter, found a different type parameter + //~| expected `T` parameter, found `U` parameter } fn main() { diff --git a/src/test/ui/issues/issue-2951.stderr b/src/test/ui/issues/issue-2951.stderr index 8c166807c46ad..562937a771cd0 100644 --- a/src/test/ui/issues/issue-2951.stderr +++ b/src/test/ui/issues/issue-2951.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-2951.rs:13:10 | LL | xx = y; - | ^ expected type parameter, found a different type parameter + | ^ expected `T` parameter, found `U` parameter | = note: expected type `T` found type `U` diff --git a/src/test/ui/mismatched_types/issue-35030.stderr b/src/test/ui/mismatched_types/issue-35030.stderr index 062bda4468a39..a085f8f672d93 100644 --- a/src/test/ui/mismatched_types/issue-35030.stderr +++ b/src/test/ui/mismatched_types/issue-35030.stderr @@ -2,9 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-35030.rs:19:14 | LL | Some(true) //~ ERROR mismatched types - | ^^^^ expected type parameter, found bool + | ^^^^ expected `bool` parameter, found bool | - = note: expected type `bool` (type parameter) + = note: expected type `bool` (`bool` parameter) found type `bool` (bool) error: aborting due to previous error diff --git a/src/test/ui/structs/struct-path-self-type-mismatch.stderr b/src/test/ui/structs/struct-path-self-type-mismatch.stderr index cfba3be613060..347d924ff265d 100644 --- a/src/test/ui/structs/struct-path-self-type-mismatch.stderr +++ b/src/test/ui/structs/struct-path-self-type-mismatch.stderr @@ -8,7 +8,7 @@ error[E0308]: mismatched types --> $DIR/struct-path-self-type-mismatch.rs:25:20 | LL | inner: u - | ^ expected type parameter, found a different type parameter + | ^ expected `T` parameter, found `U` parameter | = note: expected type `T` found type `U` @@ -23,7 +23,7 @@ LL | | //~^ ERROR mismatched types LL | | inner: u LL | | //~^ ERROR mismatched types LL | | } - | |_________^ expected type parameter, found a different type parameter + | |_________^ expected `U` parameter, found `T` parameter | = note: expected type `Foo` found type `Foo` diff --git a/src/test/ui/structs/struct-path-self.rs b/src/test/ui/structs/struct-path-self.rs index 067d6ac22dc6f..59659db0d03ef 100644 --- a/src/test/ui/structs/struct-path-self.rs +++ b/src/test/ui/structs/struct-path-self.rs @@ -13,13 +13,13 @@ struct S; trait Tr { fn f() { let s = Self {}; - //~^ ERROR expected struct, variant or union type, found Self + //~^ ERROR expected struct, variant or union type, found `Self` parameter let z = Self:: {}; - //~^ ERROR expected struct, variant or union type, found Self + //~^ ERROR expected struct, variant or union type, found `Self` parameter //~| ERROR type parameters are not allowed on this type match s { Self { .. } => {} - //~^ ERROR expected struct, variant or union type, found Self + //~^ ERROR expected struct, variant or union type, found `Self` parameter } } } diff --git a/src/test/ui/structs/struct-path-self.stderr b/src/test/ui/structs/struct-path-self.stderr index 1b5506072e81c..37652621cbd6c 100644 --- a/src/test/ui/structs/struct-path-self.stderr +++ b/src/test/ui/structs/struct-path-self.stderr @@ -1,4 +1,4 @@ -error[E0071]: expected struct, variant or union type, found Self +error[E0071]: expected struct, variant or union type, found `Self` parameter --> $DIR/struct-path-self.rs:15:17 | LL | let s = Self {}; @@ -10,13 +10,13 @@ error[E0109]: type parameters are not allowed on this type LL | let z = Self:: {}; | ^^ type parameter not allowed -error[E0071]: expected struct, variant or union type, found Self +error[E0071]: expected struct, variant or union type, found `Self` parameter --> $DIR/struct-path-self.rs:17:17 | LL | let z = Self:: {}; | ^^^^^^^^^^ not a struct -error[E0071]: expected struct, variant or union type, found Self +error[E0071]: expected struct, variant or union type, found `Self` parameter --> $DIR/struct-path-self.rs:21:13 | LL | Self { .. } => {} diff --git a/src/test/ui/type/type-parameter-names.rs b/src/test/ui/type/type-parameter-names.rs index 11a2fc2665ca4..389fdb190dbc9 100644 --- a/src/test/ui/type/type-parameter-names.rs +++ b/src/test/ui/type/type-parameter-names.rs @@ -16,7 +16,7 @@ fn foo(x: Foo) -> Bar { //~^ ERROR mismatched types //~| expected type `Bar` //~| found type `Foo` -//~| expected type parameter, found a different type parameter +//~| expected `Bar` parameter, found `Foo` parameter } fn main() {} diff --git a/src/test/ui/type/type-parameter-names.stderr b/src/test/ui/type/type-parameter-names.stderr index 8e3d39357ed0f..c6d4398c70edb 100644 --- a/src/test/ui/type/type-parameter-names.stderr +++ b/src/test/ui/type/type-parameter-names.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | fn foo(x: Foo) -> Bar { | --- expected `Bar` because of return type LL | x - | ^ expected type parameter, found a different type parameter + | ^ expected `Bar` parameter, found `Foo` parameter | = note: expected type `Bar` found type `Foo` diff --git a/src/test/ui/type/type-params-in-different-spaces-1.rs b/src/test/ui/type/type-params-in-different-spaces-1.rs index 26eac6adde221..c6385ff733163 100644 --- a/src/test/ui/type/type-params-in-different-spaces-1.rs +++ b/src/test/ui/type/type-params-in-different-spaces-1.rs @@ -15,7 +15,7 @@ trait BrokenAdd: Copy + Add { *self + rhs //~ ERROR mismatched types //~| expected type `Self` //~| found type `T` - //~| expected Self, found type parameter + //~| expected `Self` parameter, found `T` parameter } } diff --git a/src/test/ui/type/type-params-in-different-spaces-1.stderr b/src/test/ui/type/type-params-in-different-spaces-1.stderr index 31f332f609596..1eabf9e8a4975 100644 --- a/src/test/ui/type/type-params-in-different-spaces-1.stderr +++ b/src/test/ui/type/type-params-in-different-spaces-1.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/type-params-in-different-spaces-1.rs:15:17 | LL | *self + rhs //~ ERROR mismatched types - | ^^^ expected Self, found type parameter + | ^^^ expected `Self` parameter, found `T` parameter | = note: expected type `Self` found type `T` diff --git a/src/test/ui/type/type-params-in-different-spaces-3.stderr b/src/test/ui/type/type-params-in-different-spaces-3.stderr index e1b4cbb2ab3f4..ca2366d5865a2 100644 --- a/src/test/ui/type/type-params-in-different-spaces-3.stderr +++ b/src/test/ui/type/type-params-in-different-spaces-3.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | fn test(u: X) -> Self { | ---- expected `Self` because of return type LL | u //~ ERROR mismatched types - | ^ expected Self, found type parameter + | ^ expected `Self` parameter, found `X` parameter | = note: expected type `Self` found type `X`