Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit dac96d4

Browse files
committed
Fix use of bare trait objects everywhere
1 parent 36f1f04 commit dac96d4

File tree

22 files changed

+88
-74
lines changed

22 files changed

+88
-74
lines changed

compiler/rustc_trait_selection/src/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> {
124124
DUMMY_SP,
125125
canonical_key,
126126
|ref infcx, key, canonical_inference_vars| {
127-
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
127+
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
128128
let value = operation(infcx, &mut *fulfill_cx, key)?;
129129
infcx.make_canonicalized_query_response(
130130
canonical_inference_vars,

compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn scrape_region_constraints<'tcx, R>(
6262
infcx: &InferCtxt<'_, 'tcx>,
6363
op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
6464
) -> Fallible<(R, Option<Rc<QueryRegionConstraints<'tcx>>>)> {
65-
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
65+
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
6666
let dummy_body_id = ObligationCause::dummy().body_id;
6767

6868
// During NLL, we expect that nobody will register region

compiler/rustc_traits/src/dropck_outlives.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn dropck_outlives<'tcx>(
7575
// Set used to detect infinite recursion.
7676
let mut ty_set = FxHashSet::default();
7777

78-
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
78+
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
7979

8080
let cause = ObligationCause::dummy();
8181
let mut constraints = DtorckConstraint::empty();

compiler/rustc_typeck/src/check/coercion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15541554
if let hir::FnRetTy::Return(ty) = fn_output {
15551555
// Get the return type.
15561556
if let hir::TyKind::OpaqueDef(..) = ty.kind {
1557-
let ty = AstConv::ast_ty_to_ty(fcx, ty);
1557+
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
15581558
// Get the `impl Trait`'s `DefId`.
15591559
if let ty::Opaque(def_id, _) = ty.kind() {
15601560
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> {
16161616
fn is_return_ty_unsized(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool {
16171617
if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) {
16181618
if let hir::FnRetTy::Return(ty) = fn_decl.output {
1619-
let ty = AstConv::ast_ty_to_ty(fcx, ty);
1619+
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
16201620
if let ty::Dynamic(..) = ty.kind() {
16211621
return true;
16221622
}

compiler/rustc_typeck/src/check/dropck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
7777
tcx.infer_ctxt().enter(|ref infcx| {
7878
let impl_param_env = tcx.param_env(self_type_did);
7979
let tcx = infcx.tcx;
80-
let mut fulfillment_cx = TraitEngine::new(tcx);
80+
let mut fulfillment_cx = <dyn TraitEngine<'_>>::new(tcx);
8181

8282
let named_type = tcx.type_of(self_type_did);
8383

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
472472
}
473473

474474
pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> {
475-
let t = AstConv::ast_ty_to_ty(self, ast_t);
475+
let t = <dyn AstConv<'_>>::ast_ty_to_ty(self, ast_t);
476476
self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation);
477477
t
478478
}
@@ -854,7 +854,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
854854
// out unconstrained or ambiguous, as we're
855855
// just trying to get hints here.
856856
self.save_and_restore_in_snapshot_flag(|_| {
857-
let mut fulfill = TraitEngine::new(self.tcx);
857+
let mut fulfill = <dyn TraitEngine<'_>>::new(self.tcx);
858858
for obligation in ok.obligations {
859859
fulfill.register_predicate_obligation(self, obligation);
860860
}
@@ -1174,9 +1174,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11741174

11751175
let path_segs = match res {
11761176
Res::Local(_) | Res::SelfCtor(_) => vec![],
1177-
Res::Def(kind, def_id) => {
1178-
AstConv::def_ids_for_value_path_segments(self, segments, self_ty, kind, def_id)
1179-
}
1177+
Res::Def(kind, def_id) => <dyn AstConv<'_>>::def_ids_for_value_path_segments(
1178+
self, segments, self_ty, kind, def_id,
1179+
),
11801180
_ => bug!("instantiate_value_path on {:?}", res),
11811181
};
11821182

@@ -1219,7 +1219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12191219
// errors if type parameters are provided in an inappropriate place.
12201220

12211221
let generic_segs: FxHashSet<_> = path_segs.iter().map(|PathSeg(_, index)| index).collect();
1222-
let generics_has_err = AstConv::prohibit_generics(
1222+
let generics_has_err = <dyn AstConv<'_>>::prohibit_generics(
12231223
self,
12241224
segments.iter().enumerate().filter_map(|(index, seg)| {
12251225
if !generic_segs.contains(&index) || is_alias_variant_ctor {
@@ -1262,7 +1262,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12621262
if let GenericArgCountResult {
12631263
correct: Err(GenericArgCountMismatch { reported: Some(_), .. }),
12641264
..
1265-
} = AstConv::check_generic_arg_count_for_call(
1265+
} = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
12661266
tcx,
12671267
span,
12681268
def_id,
@@ -1370,7 +1370,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13701370
) -> subst::GenericArg<'tcx> {
13711371
match (&param.kind, arg) {
13721372
(GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
1373-
AstConv::ast_region_to_region(self.fcx, lt, Some(param)).into()
1373+
<dyn AstConv<'_>>::ast_region_to_region(self.fcx, lt, Some(param)).into()
13741374
}
13751375
(GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
13761376
self.fcx.to_ty(ty).into()
@@ -1423,7 +1423,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14231423
}
14241424

14251425
let substs = self_ctor_substs.unwrap_or_else(|| {
1426-
AstConv::create_substs_for_generic_args(
1426+
<dyn AstConv<'_>>::create_substs_for_generic_args(
14271427
tcx,
14281428
def_id,
14291429
&[][..],

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
875875
match *qpath {
876876
QPath::Resolved(ref maybe_qself, ref path) => {
877877
let self_ty = maybe_qself.as_ref().map(|qself| self.to_ty(qself));
878-
let ty = AstConv::res_to_ty(self, self_ty, path, true);
878+
let ty = <dyn AstConv<'_>>::res_to_ty(self, self_ty, path, true);
879879
(path.res, ty)
880880
}
881881
QPath::TypeRelative(ref qself, ref segment) => {
@@ -886,8 +886,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
886886
} else {
887887
Res::Err
888888
};
889-
let result =
890-
AstConv::associated_path_to_ty(self, hir_id, path_span, ty, res, segment, true);
889+
let result = <dyn AstConv<'_>>::associated_path_to_ty(
890+
self, hir_id, path_span, ty, res, segment, true,
891+
);
891892
let ty = result.map(|(ty, _, _)| ty).unwrap_or_else(|_| self.tcx().ty_error());
892893
let result = result.map(|(_, kind, def_id)| (kind, def_id));
893894

@@ -1000,7 +1001,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10001001
// would trigger in `is_send::<T::AssocType>();`
10011002
// from `typeck-default-trait-impl-assoc-type.rs`.
10021003
} else {
1003-
let ty = AstConv::ast_ty_to_ty(self, hir_ty);
1004+
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, hir_ty);
10041005
let ty = self.resolve_vars_if_possible(ty);
10051006
if ty == predicate.self_ty() {
10061007
error.obligation.cause.make_mut().span = hir_ty.span;

compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
461461
// are not, the expectation must have been caused by something else.
462462
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind);
463463
let sp = ty.span;
464-
let ty = AstConv::ast_ty_to_ty(self, ty);
464+
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, ty);
465465
debug!("suggest_missing_return_type: return type {:?}", ty);
466466
debug!("suggest_missing_return_type: expected type {:?}", ty);
467467
if ty.kind() == expected.kind() {
@@ -486,7 +486,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
486486
}
487487
let found = self.resolve_vars_with_obligations(found);
488488
if let hir::FnRetTy::Return(ty) = fn_decl.output {
489-
let ty = AstConv::ast_ty_to_ty(self, ty);
489+
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, ty);
490490
let ty = self.tcx.erase_late_bound_regions(Binder::bind(ty));
491491
let ty = self.normalize_associated_types_in(expr.span, ty);
492492
if self.can_coerce(found, ty) {

compiler/rustc_typeck/src/check/inherited.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl Inherited<'a, 'tcx> {
117117
maybe_typeck_results: infcx.in_progress_typeck_results,
118118
},
119119
infcx,
120-
fulfillment_cx: RefCell::new(TraitEngine::new(tcx)),
120+
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),
121121
locals: RefCell::new(Default::default()),
122122
deferred_sized_obligations: RefCell::new(Vec::new()),
123123
deferred_call_resolutions: RefCell::new(Default::default()),

compiler/rustc_typeck/src/check/method/confirm.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
314314
// variables.
315315
let generics = self.tcx.generics_of(pick.item.def_id);
316316

317-
let arg_count_correct = AstConv::check_generic_arg_count_for_call(
317+
let arg_count_correct = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
318318
self.tcx,
319319
self.span,
320320
pick.item.def_id,
@@ -352,7 +352,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
352352
) -> subst::GenericArg<'tcx> {
353353
match (&param.kind, arg) {
354354
(GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
355-
AstConv::ast_region_to_region(self.cfcx.fcx, lt, Some(param)).into()
355+
<dyn AstConv<'_>>::ast_region_to_region(self.cfcx.fcx, lt, Some(param))
356+
.into()
356357
}
357358
(GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
358359
self.cfcx.to_ty(ty).into()
@@ -373,7 +374,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
373374
self.cfcx.var_for_def(self.cfcx.span, param)
374375
}
375376
}
376-
AstConv::create_substs_for_generic_args(
377+
<dyn AstConv<'_>>::create_substs_for_generic_args(
377378
self.tcx,
378379
pick.item.def_id,
379380
parent_substs,

0 commit comments

Comments
 (0)