Skip to content

Commit 2ab402e

Browse files
committed
Driveby fixes
1 parent 1347fee commit 2ab402e

File tree

6 files changed

+9
-10
lines changed

6 files changed

+9
-10
lines changed

compiler/rustc_hir_typeck/src/writeback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,8 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
929929
// borrowck, and specifically region constraints will be populated during
930930
// MIR typeck which is run on the new body.
931931
//
932-
// We're not using `tcx.erase_and_anonymize_regions` as that also anonymizes bound variables,
933-
// regressing borrowck diagnostics.
932+
// We're not using `tcx.erase_and_anonymize_regions` as that also
933+
// anonymizes bound variables, regressing borrowck diagnostics.
934934
value = fold_regions(tcx, value, |_, _| tcx.lifetimes.re_erased);
935935

936936
// Normalize consts in writeback, because GCE doesn't normalize eagerly.

compiler/rustc_middle/src/ty/util.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ impl<'tcx> TyCtxt<'tcx> {
131131
/// Creates a hash of the type `Ty` which will be the same no matter what crate
132132
/// context it's calculated within. This is used by the `type_id` intrinsic.
133133
pub fn type_id_hash(self, ty: Ty<'tcx>) -> Hash128 {
134-
// We want the type_id be independent of the types free regions, so we
135-
// erase them. We also want type_id to be independnt of the names of bound
136-
// regions so we anonymize them.
134+
// We don't have region information, so we erase all free regions. Equal types
135+
// must have the same `TypeId`, so we must anonymize all bound regions as well.
137136
let ty = self.erase_and_anonymize_regions(ty);
138137

139138
self.with_stable_hashing_context(|mut hcx| {

compiler/rustc_mir_build/src/check_tail_calls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
6464
"`become` outside of functions should have been disallowed by hir_typeck"
6565
)
6666
};
67-
// While the `caller_sig` does have its regions erased, it does not have its
67+
// While the `caller_sig` does have its free regions erased, it does not have its
6868
// binders anonymized. We call `erase_and_anonymize_regions` once again to anonymize any binders
6969
// within the signature, such as in function pointer or `dyn Trait` args.
7070
let caller_sig = self.tcx.erase_and_anonymize_regions(caller_sig);

compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
350350
// Note that we don't care about whether the resume type has any drops since this is
351351
// redundant; there is no storage for the resume type, so if it is actually stored
352352
// in the interior, we'll already detect the need for a drop by checking the interior.
353+
//
354+
// FIXME(@lcnr): Why do we erase regions in the env here? Seems odd
353355
let typing_env = tcx.erase_and_anonymize_regions(typing_env);
354356
let needs_drop = tcx.mir_coroutine_witnesses(def_id).is_some_and(|witness| {
355357
witness.field_tys.iter().any(|field| field.ty.needs_drop(tcx, typing_env))

compiler/rustc_transmute/src/layout/tree.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,7 @@ pub(crate) mod rustc {
426426
assert!(def.is_enum());
427427

428428
// Computes the layout of a variant.
429-
let layout_of_variant = |index,
430-
encoding: Option<TagEncoding<VariantIdx>>|
431-
-> Result<Self, Err> {
429+
let layout_of_variant = |index, encoding: Option<_>| -> Result<Self, Err> {
432430
let variant_layout = ty_variant(cx, (ty, layout), index);
433431
if variant_layout.is_uninhabited() {
434432
return Ok(Self::uninhabited());

compiler/rustc_type_ir/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ impl std::fmt::Debug for HasTypeFlagsVisitor {
398398
// looks, particular for `Ty`/`Predicate` where it's just a field access.
399399
//
400400
// N.B. The only case where this isn't totally true is binders, which also
401-
// add `HAS_{RE,TY,CT}_LATE_BOUND` flag depending on the *bound variables* that
401+
// add `HAS_BINDER_VARS` flag depending on the *bound variables* that
402402
// are present, regardless of whether those bound variables are used. This
403403
// is important for anonymization of binders in `TyCtxt::erase_and_anonymize_regions`. We
404404
// specifically detect this case in `visit_binder`.

0 commit comments

Comments
 (0)