Skip to content

Commit d9c600c

Browse files
authored
Unrolled build for rust-lang#122577
Rollup merge of rust-lang#122577 - fmease:speculative-say-what, r=compiler-errors Remove obsolete parameter `speculative` from `instantiate_poly_trait_ref` In rust-lang#122527 I totally missed that `speculative` has become obsolete with the removal of `hir_trait_to_predicates` / due to rust-lang#113671. Fixes rust-lang#114635. r? `@compiler-errors`
2 parents 4c1b9c3 + a37fe00 commit d9c600c

File tree

3 files changed

+48
-58
lines changed

3 files changed

+48
-58
lines changed

compiler/rustc_hir_analysis/src/astconv/bounds.rs

+47-54
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
149149
polarity,
150150
param_ty,
151151
bounds,
152-
false,
153152
only_self_bounds,
154153
);
155154
}
@@ -231,14 +230,13 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
231230
/// **A note on binders:** given something like `T: for<'a> Iterator<Item = &'a u32>`, the
232231
/// `trait_ref` here will be `for<'a> T: Iterator`. The `binding` data however is from *inside*
233232
/// the binder (e.g., `&'a u32`) and hence may reference bound regions.
234-
#[instrument(level = "debug", skip(self, bounds, speculative, dup_bindings, path_span))]
233+
#[instrument(level = "debug", skip(self, bounds, dup_bindings, path_span))]
235234
pub(super) fn add_predicates_for_ast_type_binding(
236235
&self,
237236
hir_ref_id: hir::HirId,
238237
trait_ref: ty::PolyTraitRef<'tcx>,
239238
binding: &hir::TypeBinding<'tcx>,
240239
bounds: &mut Bounds<'tcx>,
241-
speculative: bool,
242240
dup_bindings: &mut FxIndexMap<DefId, Span>,
243241
path_span: Span,
244242
only_self_bounds: OnlySelfBounds,
@@ -317,19 +315,17 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
317315
}
318316
tcx.check_stability(assoc_item.def_id, Some(hir_ref_id), binding.span, None);
319317

320-
if !speculative {
321-
dup_bindings
322-
.entry(assoc_item.def_id)
323-
.and_modify(|prev_span| {
324-
tcx.dcx().emit_err(errors::ValueOfAssociatedStructAlreadySpecified {
325-
span: binding.span,
326-
prev_span: *prev_span,
327-
item_name: binding.ident,
328-
def_path: tcx.def_path_str(assoc_item.container_id(tcx)),
329-
});
330-
})
331-
.or_insert(binding.span);
332-
}
318+
dup_bindings
319+
.entry(assoc_item.def_id)
320+
.and_modify(|prev_span| {
321+
tcx.dcx().emit_err(errors::ValueOfAssociatedStructAlreadySpecified {
322+
span: binding.span,
323+
prev_span: *prev_span,
324+
item_name: binding.ident,
325+
def_path: tcx.def_path_str(assoc_item.container_id(tcx)),
326+
});
327+
})
328+
.or_insert(binding.span);
333329

334330
let projection_ty = if let ty::AssocKind::Fn = assoc_kind {
335331
let mut emitted_bad_param_err = None;
@@ -433,9 +429,8 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
433429
});
434430

435431
// Provide the resolved type of the associated constant to `type_of(AnonConst)`.
436-
if !speculative
437-
&& let hir::TypeBindingKind::Equality { term: hir::Term::Const(anon_const) } =
438-
binding.kind
432+
if let hir::TypeBindingKind::Equality { term: hir::Term::Const(anon_const) } =
433+
binding.kind
439434
{
440435
let ty = alias_ty.map_bound(|ty| tcx.type_of(ty.def_id).instantiate(tcx, ty.args));
441436
// Since the arguments passed to the alias type above may contain early-bound
@@ -463,42 +458,40 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
463458
hir::Term::Const(ct) => ty::Const::from_anon_const(tcx, ct.def_id).into(),
464459
};
465460

466-
if !speculative {
467-
// Find any late-bound regions declared in `ty` that are not
468-
// declared in the trait-ref or assoc_item. These are not well-formed.
469-
//
470-
// Example:
471-
//
472-
// for<'a> <T as Iterator>::Item = &'a str // <-- 'a is bad
473-
// for<'a> <T as FnMut<(&'a u32,)>>::Output = &'a str // <-- 'a is ok
474-
let late_bound_in_projection_ty =
475-
tcx.collect_constrained_late_bound_regions(projection_ty);
476-
let late_bound_in_term =
477-
tcx.collect_referenced_late_bound_regions(trait_ref.rebind(term));
478-
debug!(?late_bound_in_projection_ty);
479-
debug!(?late_bound_in_term);
461+
// Find any late-bound regions declared in `ty` that are not
462+
// declared in the trait-ref or assoc_item. These are not well-formed.
463+
//
464+
// Example:
465+
//
466+
// for<'a> <T as Iterator>::Item = &'a str // <-- 'a is bad
467+
// for<'a> <T as FnMut<(&'a u32,)>>::Output = &'a str // <-- 'a is ok
468+
let late_bound_in_projection_ty =
469+
tcx.collect_constrained_late_bound_regions(projection_ty);
470+
let late_bound_in_term =
471+
tcx.collect_referenced_late_bound_regions(trait_ref.rebind(term));
472+
debug!(?late_bound_in_projection_ty);
473+
debug!(?late_bound_in_term);
480474

481-
// FIXME: point at the type params that don't have appropriate lifetimes:
482-
// struct S1<F: for<'a> Fn(&i32, &i32) -> &'a i32>(F);
483-
// ---- ---- ^^^^^^^
484-
// NOTE(associated_const_equality): This error should be impossible to trigger
485-
// with associated const equality bounds.
486-
self.validate_late_bound_regions(
487-
late_bound_in_projection_ty,
488-
late_bound_in_term,
489-
|br_name| {
490-
struct_span_code_err!(
491-
tcx.dcx(),
492-
binding.span,
493-
E0582,
494-
"binding for associated type `{}` references {}, \
495-
which does not appear in the trait input types",
496-
binding.ident,
497-
br_name
498-
)
499-
},
500-
);
501-
}
475+
// FIXME: point at the type params that don't have appropriate lifetimes:
476+
// struct S1<F: for<'a> Fn(&i32, &i32) -> &'a i32>(F);
477+
// ---- ---- ^^^^^^^
478+
// NOTE(associated_const_equality): This error should be impossible to trigger
479+
// with associated const equality bounds.
480+
self.validate_late_bound_regions(
481+
late_bound_in_projection_ty,
482+
late_bound_in_term,
483+
|br_name| {
484+
struct_span_code_err!(
485+
tcx.dcx(),
486+
binding.span,
487+
E0582,
488+
"binding for associated type `{}` references {}, \
489+
which does not appear in the trait input types",
490+
binding.ident,
491+
br_name
492+
)
493+
},
494+
);
502495

503496
// "Desugar" a constraint like `T: Iterator<Item = u32>` this to
504497
// the "projection predicate" for:

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
639639
/// where `'a` is a bound region at depth 0. Similarly, the `poly_trait_ref` would be
640640
/// `Bar<'a>`. The returned poly-trait-ref will have this binder instantiated explicitly,
641641
/// however.
642-
#[instrument(level = "debug", skip(self, span, constness, bounds, speculative))]
642+
#[instrument(level = "debug", skip(self, span, constness, bounds))]
643643
pub(crate) fn instantiate_poly_trait_ref(
644644
&self,
645645
trait_ref: &hir::TraitRef<'tcx>,
@@ -648,7 +648,6 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
648648
polarity: ty::ImplPolarity,
649649
self_ty: Ty<'tcx>,
650650
bounds: &mut Bounds<'tcx>,
651-
speculative: bool,
652651
only_self_bounds: OnlySelfBounds,
653652
) -> GenericArgCountResult {
654653
let trait_def_id = trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise());
@@ -697,7 +696,6 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
697696
poly_trait_ref,
698697
binding,
699698
bounds,
700-
speculative,
701699
&mut dup_bindings,
702700
binding.span,
703701
only_self_bounds,

compiler/rustc_hir_analysis/src/astconv/object_safety.rs

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
4444
ty::ImplPolarity::Positive,
4545
dummy_self,
4646
&mut bounds,
47-
false,
4847
// True so we don't populate `bounds` with associated type bounds, even
4948
// though they're disallowed from object types.
5049
OnlySelfBounds(true),

0 commit comments

Comments
 (0)