From dac96d45af760dce26ff7cbab09c08411c9a9105 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 7 Mar 2021 18:47:39 +0300 Subject: [PATCH] Fix use of bare trait objects everywhere --- compiler/rustc_trait_selection/src/infer.rs | 2 +- .../src/traits/query/type_op/custom.rs | 2 +- compiler/rustc_traits/src/dropck_outlives.rs | 2 +- compiler/rustc_typeck/src/check/coercion.rs | 4 +- compiler/rustc_typeck/src/check/dropck.rs | 2 +- .../rustc_typeck/src/check/fn_ctxt/_impl.rs | 18 ++++---- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 9 ++-- .../src/check/fn_ctxt/suggestions.rs | 4 +- compiler/rustc_typeck/src/check/inherited.rs | 2 +- .../rustc_typeck/src/check/method/confirm.rs | 7 ++-- compiler/rustc_typeck/src/check/mod.rs | 4 +- .../rustc_typeck/src/coherence/builtin.rs | 4 +- compiler/rustc_typeck/src/collect.rs | 42 ++++++++++++------- .../rustc_typeck/src/collect/item_bounds.rs | 4 +- compiler/rustc_typeck/src/lib.rs | 4 +- library/core/src/any.rs | 12 +++--- src/test/ui/traits/impl.rs | 4 +- .../inheritance/repeated-supertrait-ambig.rs | 2 +- .../repeated-supertrait-ambig.stderr | 4 +- .../traits/inheritance/repeated-supertrait.rs | 2 +- src/test/ui/traits/item-privacy.rs | 10 ++--- src/test/ui/traits/item-privacy.stderr | 18 ++++---- 22 files changed, 88 insertions(+), 74 deletions(-) diff --git a/compiler/rustc_trait_selection/src/infer.rs b/compiler/rustc_trait_selection/src/infer.rs index da66fbc8587..a9ffb5542b6 100644 --- a/compiler/rustc_trait_selection/src/infer.rs +++ b/compiler/rustc_trait_selection/src/infer.rs @@ -124,7 +124,7 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> { DUMMY_SP, canonical_key, |ref infcx, key, canonical_inference_vars| { - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); let value = operation(infcx, &mut *fulfill_cx, key)?; infcx.make_canonicalized_query_response( canonical_inference_vars, diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs index 68356ce73aa..4f5476ca5d0 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs @@ -62,7 +62,7 @@ fn scrape_region_constraints<'tcx, R>( infcx: &InferCtxt<'_, 'tcx>, op: impl FnOnce() -> Fallible>, ) -> Fallible<(R, Option>>)> { - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); let dummy_body_id = ObligationCause::dummy().body_id; // During NLL, we expect that nobody will register region diff --git a/compiler/rustc_traits/src/dropck_outlives.rs b/compiler/rustc_traits/src/dropck_outlives.rs index cfcbc77c172..9d5b9d7357f 100644 --- a/compiler/rustc_traits/src/dropck_outlives.rs +++ b/compiler/rustc_traits/src/dropck_outlives.rs @@ -75,7 +75,7 @@ fn dropck_outlives<'tcx>( // Set used to detect infinite recursion. let mut ty_set = FxHashSet::default(); - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); let cause = ObligationCause::dummy(); let mut constraints = DtorckConstraint::empty(); diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index 32b3d0b0595..94aee87364a 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -1554,7 +1554,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { if let hir::FnRetTy::Return(ty) = fn_output { // Get the return type. if let hir::TyKind::OpaqueDef(..) = ty.kind { - let ty = AstConv::ast_ty_to_ty(fcx, ty); + let ty = >::ast_ty_to_ty(fcx, ty); // Get the `impl Trait`'s `DefId`. if let ty::Opaque(def_id, _) = ty.kind() { let hir_id = fcx.tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); @@ -1616,7 +1616,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { fn is_return_ty_unsized(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool { if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) { if let hir::FnRetTy::Return(ty) = fn_decl.output { - let ty = AstConv::ast_ty_to_ty(fcx, ty); + let ty = >::ast_ty_to_ty(fcx, ty); if let ty::Dynamic(..) = ty.kind() { return true; } diff --git a/compiler/rustc_typeck/src/check/dropck.rs b/compiler/rustc_typeck/src/check/dropck.rs index 4c3c4fd4470..4d74962d28e 100644 --- a/compiler/rustc_typeck/src/check/dropck.rs +++ b/compiler/rustc_typeck/src/check/dropck.rs @@ -77,7 +77,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>( tcx.infer_ctxt().enter(|ref infcx| { let impl_param_env = tcx.param_env(self_type_did); let tcx = infcx.tcx; - let mut fulfillment_cx = TraitEngine::new(tcx); + let mut fulfillment_cx = >::new(tcx); let named_type = tcx.type_of(self_type_did); diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 84ce6964f04..20fe0c1471c 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -472,7 +472,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> { - let t = AstConv::ast_ty_to_ty(self, ast_t); + let t = >::ast_ty_to_ty(self, ast_t); self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation); t } @@ -854,7 +854,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // out unconstrained or ambiguous, as we're // just trying to get hints here. self.save_and_restore_in_snapshot_flag(|_| { - let mut fulfill = TraitEngine::new(self.tcx); + let mut fulfill = >::new(self.tcx); for obligation in ok.obligations { fulfill.register_predicate_obligation(self, obligation); } @@ -1174,9 +1174,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let path_segs = match res { Res::Local(_) | Res::SelfCtor(_) => vec![], - Res::Def(kind, def_id) => { - AstConv::def_ids_for_value_path_segments(self, segments, self_ty, kind, def_id) - } + Res::Def(kind, def_id) => >::def_ids_for_value_path_segments( + self, segments, self_ty, kind, def_id, + ), _ => bug!("instantiate_value_path on {:?}", res), }; @@ -1219,7 +1219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // errors if type parameters are provided in an inappropriate place. let generic_segs: FxHashSet<_> = path_segs.iter().map(|PathSeg(_, index)| index).collect(); - let generics_has_err = AstConv::prohibit_generics( + let generics_has_err = >::prohibit_generics( self, segments.iter().enumerate().filter_map(|(index, seg)| { if !generic_segs.contains(&index) || is_alias_variant_ctor { @@ -1262,7 +1262,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let GenericArgCountResult { correct: Err(GenericArgCountMismatch { reported: Some(_), .. }), .. - } = AstConv::check_generic_arg_count_for_call( + } = >::check_generic_arg_count_for_call( tcx, span, def_id, @@ -1370,7 +1370,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> subst::GenericArg<'tcx> { match (¶m.kind, arg) { (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { - AstConv::ast_region_to_region(self.fcx, lt, Some(param)).into() + >::ast_region_to_region(self.fcx, lt, Some(param)).into() } (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => { self.fcx.to_ty(ty).into() @@ -1423,7 +1423,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let substs = self_ctor_substs.unwrap_or_else(|| { - AstConv::create_substs_for_generic_args( + >::create_substs_for_generic_args( tcx, def_id, &[][..], diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 528a6d1bd52..c92c7f7ad0b 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -875,7 +875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match *qpath { QPath::Resolved(ref maybe_qself, ref path) => { let self_ty = maybe_qself.as_ref().map(|qself| self.to_ty(qself)); - let ty = AstConv::res_to_ty(self, self_ty, path, true); + let ty = >::res_to_ty(self, self_ty, path, true); (path.res, ty) } QPath::TypeRelative(ref qself, ref segment) => { @@ -886,8 +886,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { Res::Err }; - let result = - AstConv::associated_path_to_ty(self, hir_id, path_span, ty, res, segment, true); + let result = >::associated_path_to_ty( + self, hir_id, path_span, ty, res, segment, true, + ); let ty = result.map(|(ty, _, _)| ty).unwrap_or_else(|_| self.tcx().ty_error()); let result = result.map(|(_, kind, def_id)| (kind, def_id)); @@ -1000,7 +1001,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // would trigger in `is_send::();` // from `typeck-default-trait-impl-assoc-type.rs`. } else { - let ty = AstConv::ast_ty_to_ty(self, hir_ty); + let ty = >::ast_ty_to_ty(self, hir_ty); let ty = self.resolve_vars_if_possible(ty); if ty == predicate.self_ty() { error.obligation.cause.make_mut().span = hir_ty.span; diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs index 9f15993e471..f90159efb5c 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs @@ -461,7 +461,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // are not, the expectation must have been caused by something else. debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind); let sp = ty.span; - let ty = AstConv::ast_ty_to_ty(self, ty); + let ty = >::ast_ty_to_ty(self, ty); debug!("suggest_missing_return_type: return type {:?}", ty); debug!("suggest_missing_return_type: expected type {:?}", ty); if ty.kind() == expected.kind() { @@ -486,7 +486,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let found = self.resolve_vars_with_obligations(found); if let hir::FnRetTy::Return(ty) = fn_decl.output { - let ty = AstConv::ast_ty_to_ty(self, ty); + let ty = >::ast_ty_to_ty(self, ty); let ty = self.tcx.erase_late_bound_regions(Binder::bind(ty)); let ty = self.normalize_associated_types_in(expr.span, ty); if self.can_coerce(found, ty) { diff --git a/compiler/rustc_typeck/src/check/inherited.rs b/compiler/rustc_typeck/src/check/inherited.rs index 0011a3fc71b..1dacbade1bd 100644 --- a/compiler/rustc_typeck/src/check/inherited.rs +++ b/compiler/rustc_typeck/src/check/inherited.rs @@ -117,7 +117,7 @@ impl Inherited<'a, 'tcx> { maybe_typeck_results: infcx.in_progress_typeck_results, }, infcx, - fulfillment_cx: RefCell::new(TraitEngine::new(tcx)), + fulfillment_cx: RefCell::new(>::new(tcx)), locals: RefCell::new(Default::default()), deferred_sized_obligations: RefCell::new(Vec::new()), deferred_call_resolutions: RefCell::new(Default::default()), diff --git a/compiler/rustc_typeck/src/check/method/confirm.rs b/compiler/rustc_typeck/src/check/method/confirm.rs index 7a80524f1b7..4a2dd6faf0c 100644 --- a/compiler/rustc_typeck/src/check/method/confirm.rs +++ b/compiler/rustc_typeck/src/check/method/confirm.rs @@ -314,7 +314,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // variables. let generics = self.tcx.generics_of(pick.item.def_id); - let arg_count_correct = AstConv::check_generic_arg_count_for_call( + let arg_count_correct = >::check_generic_arg_count_for_call( self.tcx, self.span, pick.item.def_id, @@ -352,7 +352,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { ) -> subst::GenericArg<'tcx> { match (¶m.kind, arg) { (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { - AstConv::ast_region_to_region(self.cfcx.fcx, lt, Some(param)).into() + >::ast_region_to_region(self.cfcx.fcx, lt, Some(param)) + .into() } (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => { self.cfcx.to_ty(ty).into() @@ -373,7 +374,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.cfcx.var_for_def(self.cfcx.span, param) } } - AstConv::create_substs_for_generic_args( + >::create_substs_for_generic_args( self.tcx, pick.item.def_id, parent_substs, diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 85bd45f0ca8..ad9bb703779 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -495,7 +495,7 @@ fn typeck_with_fallback<'tcx>( let fcx = if let (Some(header), Some(decl)) = (fn_header, fn_decl) { let fn_sig = if crate::collect::get_infer_ret_ty(&decl.output).is_some() { let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id); - AstConv::ty_of_fn( + >::ty_of_fn( &fcx, header.unsafety, header.abi, @@ -527,7 +527,7 @@ fn typeck_with_fallback<'tcx>( let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id); let expected_type = body_ty .and_then(|ty| match ty.kind { - hir::TyKind::Infer => Some(AstConv::ast_ty_to_ty(&fcx, ty)), + hir::TyKind::Infer => Some(>::ast_ty_to_ty(&fcx, ty)), _ => None, }) .unwrap_or_else(|| match tcx.hir().get(id) { diff --git a/compiler/rustc_typeck/src/coherence/builtin.rs b/compiler/rustc_typeck/src/coherence/builtin.rs index 5b44cb7eae5..8cae61e8c22 100644 --- a/compiler/rustc_typeck/src/coherence/builtin.rs +++ b/compiler/rustc_typeck/src/coherence/builtin.rs @@ -246,7 +246,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef )) .emit(); } else { - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); for field in coerced_fields { let predicate = predicate_for_trait_def( @@ -506,7 +506,7 @@ pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedI } }; - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); // Register an obligation for `A: Trait`. let cause = traits::ObligationCause::misc(span, impl_hir_id); diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index a175da32706..e5136355ca9 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -310,7 +310,7 @@ impl ItemCtxt<'tcx> { } pub fn to_ty(&self, ast_ty: &hir::Ty<'_>) -> Ty<'tcx> { - AstConv::ast_ty_to_ty(self, ast_ty) + >::ast_ty_to_ty(self, ast_ty) } pub fn hir_id(&self) -> hir::HirId { @@ -1096,7 +1096,7 @@ fn super_predicates_that_define_assoc_type( // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo: Bar + Zed`. let self_param_ty = tcx.types.self_param; let superbounds1 = if let Some(assoc_name) = assoc_name { - AstConv::compute_bounds_that_match_assoc_type( + >::compute_bounds_that_match_assoc_type( &icx, self_param_ty, &bounds, @@ -1105,7 +1105,13 @@ fn super_predicates_that_define_assoc_type( assoc_name, ) } else { - AstConv::compute_bounds(&icx, self_param_ty, &bounds, SizedByDefault::No, item.span) + >::compute_bounds( + &icx, + self_param_ty, + &bounds, + SizedByDefault::No, + item.span, + ) }; let superbounds1 = superbounds1.predicates(tcx, self_param_ty); @@ -1689,7 +1695,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { ty::Binder::bind(fn_sig) } - None => AstConv::ty_of_fn( + None => >::ty_of_fn( &icx, sig.header.unsafety, sig.header.abi, @@ -1706,7 +1712,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { ident, generics, .. - }) => AstConv::ty_of_fn( + }) => >::ty_of_fn( &icx, header.unsafety, header.abi, @@ -1767,7 +1773,7 @@ fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { match tcx.hir().expect_item(hir_id).kind { hir::ItemKind::Impl(ref impl_) => impl_.of_trait.as_ref().map(|ast_trait_ref| { let selfty = tcx.type_of(def_id); - AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty) + >::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty) }), _ => bug!(), } @@ -2018,7 +2024,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP GenericParamKind::Lifetime { .. } => { param.bounds.iter().for_each(|bound| match bound { hir::GenericBound::Outlives(lt) => { - let bound = AstConv::ast_region_to_region(&icx, <, None); + let bound = >::ast_region_to_region(&icx, <, None); let outlives = ty::Binder::bind(ty::OutlivesPredicate(region, bound)); predicates.insert((outlives.to_predicate(tcx), lt.span)); } @@ -2041,8 +2047,13 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP index += 1; let sized = SizedByDefault::Yes; - let bounds = - AstConv::compute_bounds(&icx, param_ty, ¶m.bounds, sized, param.span); + let bounds = >::compute_bounds( + &icx, + param_ty, + ¶m.bounds, + sized, + param.span, + ); predicates.extend(bounds.predicates(tcx, param_ty)); } GenericParamKind::Const { .. } => { @@ -2091,7 +2102,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP }; let mut bounds = Bounds::default(); - let _ = AstConv::instantiate_poly_trait_ref( + let _ = >::instantiate_poly_trait_ref( &icx, &poly_trait_ref, constness, @@ -2103,7 +2114,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP &hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => { let mut bounds = Bounds::default(); - AstConv::instantiate_lang_item_trait_ref( + >::instantiate_lang_item_trait_ref( &icx, lang_item, span, @@ -2116,7 +2127,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP } hir::GenericBound::Outlives(lifetime) => { - let region = AstConv::ast_region_to_region(&icx, lifetime, None); + let region = + >::ast_region_to_region(&icx, lifetime, None); predicates.insert(( ty::Binder::bind(ty::PredicateKind::TypeOutlives( ty::OutlivesPredicate(ty, region), @@ -2130,11 +2142,11 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP } hir::WherePredicate::RegionPredicate(region_pred) => { - let r1 = AstConv::ast_region_to_region(&icx, ®ion_pred.lifetime, None); + let r1 = >::ast_region_to_region(&icx, ®ion_pred.lifetime, None); predicates.extend(region_pred.bounds.iter().map(|bound| { let (r2, span) = match bound { hir::GenericBound::Outlives(lt) => { - (AstConv::ast_region_to_region(&icx, lt, None), lt.span) + (>::ast_region_to_region(&icx, lt, None), lt.span) } _ => bug!(), }; @@ -2377,7 +2389,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( } else { hir::Unsafety::Unsafe }; - let fty = AstConv::ty_of_fn( + let fty = >::ty_of_fn( &ItemCtxt::new(tcx, def_id), unsafety, abi, diff --git a/compiler/rustc_typeck/src/collect/item_bounds.rs b/compiler/rustc_typeck/src/collect/item_bounds.rs index fe18dc5ed0c..a5b36445aae 100644 --- a/compiler/rustc_typeck/src/collect/item_bounds.rs +++ b/compiler/rustc_typeck/src/collect/item_bounds.rs @@ -25,7 +25,7 @@ fn associated_type_bounds<'tcx>( InternalSubsts::identity_for_item(tcx, assoc_item_def_id), ); - let bounds = AstConv::compute_bounds( + let bounds = >::compute_bounds( &ItemCtxt::new(tcx, assoc_item_def_id), item_ty, &bounds, @@ -66,7 +66,7 @@ fn opaque_type_bounds<'tcx>( let item_ty = tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id)); - let bounds = AstConv::compute_bounds( + let bounds = >::compute_bounds( &ItemCtxt::new(tcx, opaque_def_id), item_ty, &bounds, diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index 29d9df61906..88b47bf5b9c 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -142,7 +142,7 @@ fn require_same_types<'tcx>( ) -> bool { tcx.infer_ctxt().enter(|ref infcx| { let param_env = ty::ParamEnv::empty(); - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); match infcx.at(&cause, param_env).eq(expected, actual) { Ok(InferOk { obligations, .. }) => { fulfill_cx.register_predicate_obligations(infcx, obligations); @@ -444,7 +444,7 @@ pub fn hir_trait_to_predicates<'tcx>( let env_def_id = tcx.hir().local_def_id(env_hir_id); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.to_def_id()); let mut bounds = Bounds::default(); - let _ = AstConv::instantiate_poly_trait_ref_inner( + let _ = >::instantiate_poly_trait_ref_inner( &item_cx, hir_trait, DUMMY_SP, diff --git a/library/core/src/any.rs b/library/core/src/any.rs index eef8f2046d3..98c34f34425 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -285,7 +285,7 @@ impl dyn Any + Send { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn is(&self) -> bool { - Any::is::(self) + ::is::(self) } /// Forwards to the method defined on the type `Any`. @@ -309,7 +309,7 @@ impl dyn Any + Send { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn downcast_ref(&self) -> Option<&T> { - Any::downcast_ref::(self) + ::downcast_ref::(self) } /// Forwards to the method defined on the type `Any`. @@ -337,7 +337,7 @@ impl dyn Any + Send { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn downcast_mut(&mut self) -> Option<&mut T> { - Any::downcast_mut::(self) + ::downcast_mut::(self) } } @@ -363,7 +363,7 @@ impl dyn Any + Send + Sync { #[stable(feature = "any_send_sync_methods", since = "1.28.0")] #[inline] pub fn is(&self) -> bool { - Any::is::(self) + ::is::(self) } /// Forwards to the method defined on the type `Any`. @@ -387,7 +387,7 @@ impl dyn Any + Send + Sync { #[stable(feature = "any_send_sync_methods", since = "1.28.0")] #[inline] pub fn downcast_ref(&self) -> Option<&T> { - Any::downcast_ref::(self) + ::downcast_ref::(self) } /// Forwards to the method defined on the type `Any`. @@ -415,7 +415,7 @@ impl dyn Any + Send + Sync { #[stable(feature = "any_send_sync_methods", since = "1.28.0")] #[inline] pub fn downcast_mut(&mut self) -> Option<&mut T> { - Any::downcast_mut::(self) + ::downcast_mut::(self) } } diff --git a/src/test/ui/traits/impl.rs b/src/test/ui/traits/impl.rs index 14796ce19c8..f512d91ebeb 100644 --- a/src/test/ui/traits/impl.rs +++ b/src/test/ui/traits/impl.rs @@ -30,8 +30,8 @@ fn main() { let x: &dyn T = &42; x.foo(); - T::foo(x); - T::bar(); + ::foo(x); + ::bar(); unsafe { assert_eq!(COUNT, 12); } diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs index 6aaef8a305b..727897d20cb 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs +++ b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs @@ -31,7 +31,7 @@ fn with_trait(c: &C) -> bool { } fn with_ufcs1(c: &C) -> bool { - CompareToInts::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied + ::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfi } fn with_ufcs2(c: &C) -> bool { diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr index 5353b5e2260..bb11f18e545 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr +++ b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr @@ -21,8 +21,8 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfi LL | fn same_as(&self, t: T) -> bool; | -------------------------------- required by `CompareTo::same_as` ... -LL | CompareToInts::same_as(c, 22) - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` +LL | ::same_as(c, 22) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` error[E0277]: the trait bound `C: CompareTo` is not satisfied --> $DIR/repeated-supertrait-ambig.rs:38:5 diff --git a/src/test/ui/traits/inheritance/repeated-supertrait.rs b/src/test/ui/traits/inheritance/repeated-supertrait.rs index 339f9c37eea..cb2581ffa99 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait.rs +++ b/src/test/ui/traits/inheritance/repeated-supertrait.rs @@ -31,7 +31,7 @@ fn with_trait(c: &C) -> bool { } fn with_ufcs1(c: &C) -> bool { - CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64) + ::same_as(c, 22_i64) && ::same_as(c, 22_u64) } fn with_ufcs2(c: &C) -> bool { diff --git a/src/test/ui/traits/item-privacy.rs b/src/test/ui/traits/item-privacy.rs index 1ea1d65df62..38d06b967bc 100644 --- a/src/test/ui/traits/item-privacy.rs +++ b/src/test/ui/traits/item-privacy.rs @@ -81,8 +81,8 @@ fn check_method() { //~^ ERROR no function or associated item named `b` found S::c(&S); // OK // a, b, c are resolved as inherent items, their traits don't need to be in scope - C::a(&S); //~ ERROR associated function `a` is private - C::b(&S); // OK + ::a(&S); //~ ERROR associated function `a` is private + ::b(&S); // OK C::c(&S); // OK } @@ -98,9 +98,9 @@ fn check_assoc_const() { S::B; //~ ERROR no associated item named `B` found S::C; // OK // A, B, C are resolved as inherent items, their traits don't need to be in scope - C::A; //~ ERROR associated constant `A` is private - //~^ ERROR the trait `assoc_const::C` cannot be made into an object - C::B; // ERROR the trait `assoc_const::C` cannot be made into an object + ::A; //~ ERROR associated constant `A` is private + //~^ ERROR the trait `assoc_const::C` cannot be made into an object + ::B; // ERROR the trait `assoc_const::C` cannot be made into an object C::C; // OK } diff --git a/src/test/ui/traits/item-privacy.stderr b/src/test/ui/traits/item-privacy.stderr index b7dad54a6d3..68d527dc786 100644 --- a/src/test/ui/traits/item-privacy.stderr +++ b/src/test/ui/traits/item-privacy.stderr @@ -67,10 +67,10 @@ LL | use method::B; | error[E0624]: associated function `a` is private - --> $DIR/item-privacy.rs:84:8 + --> $DIR/item-privacy.rs:84:14 | -LL | C::a(&S); - | ^ private associated function +LL | ::a(&S); + | ^ private associated function error[E0599]: no associated item named `A` found for struct `S` in the current scope --> $DIR/item-privacy.rs:97:8 @@ -104,16 +104,16 @@ LL | use assoc_const::B; | error[E0624]: associated constant `A` is private - --> $DIR/item-privacy.rs:101:8 + --> $DIR/item-privacy.rs:101:14 | -LL | C::A; - | ^ private associated constant +LL | ::A; + | ^ private associated constant error[E0038]: the trait `assoc_const::C` cannot be made into an object - --> $DIR/item-privacy.rs:101:5 + --> $DIR/item-privacy.rs:101:6 | -LL | C::A; - | ^ `assoc_const::C` cannot be made into an object +LL | ::A; + | ^^^^^ `assoc_const::C` cannot be made into an object | = help: consider moving `C` to another trait = help: consider moving `B` to another trait