Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Nov 18, 2024
1 parent 9cba14b commit 2e087d2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
// Test the callee's predicates, substituting in `ref_ty` for the moved argument type.
clauses.instantiate(tcx, new_args).predicates.iter().all(|&(mut clause)| {
// Normalize before testing to see through type aliases and projections.
if let Ok(normalized) = tcx.try_normalize_erasing_regions(self.param_env, clause) {
if let Ok(normalized) =
tcx.try_normalize_erasing_regions(self.infcx.typing_env(self.param_env), clause)
{
clause = normalized;
}
self.infcx.predicate_must_hold_modulo_regions(&Obligation::new(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ fn check_type_defn<'tcx>(
let ty = tcx.type_of(variant.tail().did).instantiate_identity();
let ty = tcx.erase_regions(ty);
assert!(!ty.has_infer());
ty.needs_drop(tcx, ty::TypingEnv::non_body_analysis(tcx, item.owner_id.def_id))
ty.needs_drop(tcx, wfcx.infcx.typing_env(wfcx.param_env))
}
};
// All fields (except for possibly the last) should be sized.
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ impl<'tcx> InferCtxt<'tcx> {
u
}

/// Extract [ty::TypingMode] of this inference context to get a `TypingEnv`
/// Extract [`ty::TypingMode`] of this inference context to get a `TypingEnv`
/// which contains the necessary information to use the trait system without
/// using canonicalization or carrying this inference context around.
pub fn typing_env(&self, param_env: ty::ParamEnv<'tcx>) -> ty::TypingEnv<'tcx> {
Expand All @@ -1304,8 +1304,8 @@ impl<'tcx> InferCtxt<'tcx> {
ty::TypingEnv { typing_mode, param_env }
}

/// Similar to [Self::canonicalize_query], except that it returns
/// a [PseudoCanonicalInput] and requires both the `value` and the
/// Similar to [`Self::canonicalize_query`], except that it returns
/// a [`PseudoCanonicalInput`] and requires both the `value` and the
/// `param_env` to not contain any inference variables or placeholders.
pub fn pseudo_canonicalize_query<V>(
&self,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,8 @@ impl<'tcx> TypingEnv<'tcx> {
// as these placeholders are also local to the current inference context. However, we
// currently use pseudo-canonical queries in the trait solver which replaces params with
// placeholders. We should also simply not use pseudo-canonical queries in the trait
// solver, at which point we can readd this assert.
// solver, at which point we can readd this assert. As of writing this comment, this is
// only used by `fn layout_is_pointer_like` when calling `layout_of`.
//
// debug_assert!(!value.has_placeholders());
PseudoCanonicalInput { typing_env: self, value }
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if range.start <= range.end { BinOp::BitAnd } else { BinOp::BitOr };

let mut comparer = |range: u128, bin_op: BinOp| -> Place<'tcx> {
// We can use `ty::TypingEnv::fully_monomorphized()`` here
// as we only need it to compute the layout of a primitive.
let range_val = Const::from_bits(
this.tcx,
range,
Expand Down

0 comments on commit 2e087d2

Please sign in to comment.