Skip to content

Commit bb93c23

Browse files
committed
use TypingEnv when no infcx is available
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
1 parent 1ceaa90 commit bb93c23

33 files changed

+83
-79
lines changed

clippy_lints/src/assigning_clones.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
9696
},
9797
_ => return,
9898
}
99-
&& let Ok(Some(resolved_fn)) = Instance::try_resolve(cx.tcx, cx.param_env, fn_id, fn_gen_args)
99+
&& let Ok(Some(resolved_fn)) = Instance::try_resolve(cx.tcx, cx.typing_env(), fn_id, fn_gen_args)
100100
// TODO: This check currently bails if the local variable has no initializer.
101101
// That is overly conservative - the lint should fire even if there was no initializer,
102102
// but the variable has been initialized before `lhs` was evaluated.

clippy_lints/src/bool_assert_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
6262
})
6363
.is_some_and(|assoc_item| {
6464
let proj = Ty::new_projection(cx.tcx, assoc_item.def_id, cx.tcx.mk_args_trait(ty, []));
65-
let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj);
65+
let nty = cx.tcx.normalize_erasing_regions(cx.typing_env(), proj);
6666

6767
nty.is_bool()
6868
})

clippy_lints/src/dereference.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir::{
1717
};
1818
use rustc_lint::{LateContext, LateLintPass};
1919
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
20-
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeVisitableExt, TypeckResults};
20+
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypeckResults};
2121
use rustc_session::impl_lint_pass;
2222
use rustc_span::symbol::sym;
2323
use rustc_span::{Span, Symbol};
@@ -755,7 +755,8 @@ impl TyCoercionStability {
755755
DefinedTy::Hir(ty) => Self::for_hir_ty(ty),
756756
DefinedTy::Mir(ty) => Self::for_mir_ty(
757757
cx.tcx,
758-
ty.param_env,
758+
// FIXME(#132279): convert `DefinedTy` to use `TypingEnv` instead.
759+
ty::TypingEnv::from_param_env(ty.param_env),
759760
cx.tcx.instantiate_bound_regions_with_erased(ty.value),
760761
for_return,
761762
),
@@ -823,12 +824,12 @@ impl TyCoercionStability {
823824
}
824825
}
825826

826-
fn for_mir_ty<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, for_return: bool) -> Self {
827+
fn for_mir_ty<'tcx>(tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>, ty: Ty<'tcx>, for_return: bool) -> Self {
827828
let ty::Ref(_, mut ty, _) = *ty.kind() else {
828829
return Self::None;
829830
};
830831

831-
ty = tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty);
832+
ty = tcx.try_normalize_erasing_regions(typing_env, ty).unwrap_or(ty);
832833
loop {
833834
break match *ty.kind() {
834835
ty::Ref(_, ref_ty, _) => {

clippy_lints/src/drop_forget_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
9999
sym::mem_forget if is_copy => return,
100100
sym::mem_drop if is_type_lang_item(cx, arg_ty, LangItem::ManuallyDrop) => return,
101101
sym::mem_drop
102-
if !(arg_ty.needs_drop(cx.tcx, cx.param_env)
102+
if !(arg_ty.needs_drop(cx.tcx, cx.typing_env())
103103
|| is_must_use_func_call(cx, arg)
104104
|| is_must_use_ty(cx, arg_ty)
105105
|| drop_is_single_call_in_arm) =>
106106
{
107107
(DROP_NON_DROP, DROP_NON_DROP_SUMMARY.into(), Some(arg.span))
108108
},
109109
sym::mem_forget => {
110-
if arg_ty.needs_drop(cx.tcx, cx.param_env) {
110+
if arg_ty.needs_drop(cx.tcx, cx.typing_env()) {
111111
(
112112
MEM_FORGET,
113113
Cow::Owned(format!(

clippy_lints/src/iter_not_returning_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn check_sig(cx: &LateContext<'_>, name: Symbol, sig: &FnSig<'_>, fn_id: LocalDe
7070
.instantiate_bound_regions_with_erased(cx.tcx.fn_sig(fn_id).instantiate_identity().output());
7171
let ret_ty = cx
7272
.tcx
73-
.try_normalize_erasing_regions(cx.param_env, ret_ty)
73+
.try_normalize_erasing_regions(cx.typing_env(), ret_ty)
7474
.unwrap_or(ret_ty);
7575
if cx
7676
.tcx

clippy_lints/src/iter_without_into_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl {self_ty_without_ref} {{
215215
&& implements_trait(cx, ret_ty, iterator_did, &[])
216216
&& let Some(iter_ty) = make_normalized_projection(
217217
cx.tcx,
218-
cx.param_env,
218+
cx.typing_env(),
219219
iterator_did,
220220
sym::Item,
221221
[ret_ty],

clippy_lints/src/large_const_arrays.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_errors::Applicability;
44
use rustc_hir::{Item, ItemKind};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_middle::ty::layout::LayoutOf;
7-
use rustc_middle::ty::{self, ParamEnv};
7+
use rustc_middle::ty;
88
use rustc_session::impl_lint_pass;
99
use rustc_span::{BytePos, Pos, Span};
1010

@@ -57,7 +57,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
5757
&& let ty = cx.tcx.type_of(item.owner_id).instantiate_identity()
5858
&& let ty::Array(element_type, cst) = ty.kind()
5959
&& let Some((ty::ValTree::Leaf(element_count), _)) = cx.tcx
60-
.try_normalize_erasing_regions(ParamEnv::empty(), *cst).unwrap_or(*cst).try_to_valtree()
60+
.try_normalize_erasing_regions(cx.typing_env(), *cst).unwrap_or(*cst).try_to_valtree()
6161
&& let element_count = element_count.to_target_usize(cx.tcx)
6262
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
6363
&& u128::from(self.maximum_allowed_size) < u128::from(element_count) * u128::from(element_size)

clippy_lints/src/large_futures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeFuture {
6363
&& let ty = cx.typeck_results().expr_ty(arg)
6464
&& let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait()
6565
&& implements_trait(cx, ty, future_trait_def_id, &[])
66-
&& let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(ty))
66+
&& let Ok(layout) = cx.tcx.layout_of(cx.typing_env().as_query_input(ty))
6767
&& let size = layout.layout.size()
6868
&& size >= Size::from_bytes(self.future_size_threshold)
6969
{

clippy_lints/src/large_stack_frames.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames {
150150
}
151151

152152
let mir = cx.tcx.optimized_mir(def_id);
153-
let param_env = cx.tcx.param_env(def_id);
153+
let typing_env = mir.typing_env(cx.tcx);
154154

155155
let sizes_of_locals = || {
156156
mir.local_decls.iter().filter_map(|local| {
157-
let layout = cx.tcx.layout_of(param_env.and(local.ty)).ok()?;
157+
let layout = cx.tcx.layout_of(typing_env.as_query_input(local.ty)).ok()?;
158158
Some((local, layout.size.bytes()))
159159
})
160160
};

clippy_lints/src/loops/explicit_iter_loop.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn is_ref_iterable<'tcx>(
151151
// Using by value won't consume anything
152152
if implements_trait(cx, self_ty, trait_id, &[])
153153
&& let Some(ty) =
154-
make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [self_ty])
154+
make_normalized_projection(cx.tcx, cx.typing_env(), trait_id, sym!(IntoIter), [self_ty])
155155
&& ty == res_ty
156156
{
157157
return Some((AdjustKind::None, self_ty));
@@ -168,7 +168,7 @@ fn is_ref_iterable<'tcx>(
168168
};
169169
if implements_trait(cx, self_ty, trait_id, &[])
170170
&& let Some(ty) =
171-
make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [self_ty])
171+
make_normalized_projection(cx.tcx, cx.typing_env(), trait_id, sym!(IntoIter), [self_ty])
172172
&& ty == res_ty
173173
{
174174
return Some((AdjustKind::reborrow(mutbl), self_ty));
@@ -181,7 +181,7 @@ fn is_ref_iterable<'tcx>(
181181
// Attempt to borrow
182182
let self_ty = Ty::new_ref(cx.tcx, cx.tcx.lifetimes.re_erased, self_ty, mutbl);
183183
if implements_trait(cx, self_ty, trait_id, &[])
184-
&& let Some(ty) = make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [self_ty])
184+
&& let Some(ty) = make_normalized_projection(cx.tcx, cx.typing_env(), trait_id, sym!(IntoIter), [self_ty])
185185
&& ty == res_ty
186186
{
187187
return Some((AdjustKind::borrow(mutbl), self_ty));
@@ -204,7 +204,7 @@ fn is_ref_iterable<'tcx>(
204204
&& target != self_ty
205205
&& implements_trait(cx, target, trait_id, &[])
206206
&& let Some(ty) =
207-
make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target])
207+
make_normalized_projection(cx.tcx, cx.typing_env(), trait_id, sym!(IntoIter), [target])
208208
&& ty == res_ty
209209
{
210210
Some((AdjustKind::auto_reborrow(mutbl), target))
@@ -222,7 +222,7 @@ fn is_ref_iterable<'tcx>(
222222
if is_copy(cx, target)
223223
&& implements_trait(cx, target, trait_id, &[])
224224
&& let Some(ty) =
225-
make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target])
225+
make_normalized_projection(cx.tcx, cx.typing_env(), trait_id, sym!(IntoIter), [target])
226226
&& ty == res_ty
227227
{
228228
Some((AdjustKind::Deref, target))
@@ -240,7 +240,7 @@ fn is_ref_iterable<'tcx>(
240240
if self_ty.is_ref()
241241
&& implements_trait(cx, target, trait_id, &[])
242242
&& let Some(ty) =
243-
make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target])
243+
make_normalized_projection(cx.tcx, cx.typing_env(), trait_id, sym!(IntoIter), [target])
244244
&& ty == res_ty
245245
{
246246
Some((AdjustKind::auto_borrow(mutbl), target))

clippy_lints/src/methods/needless_collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ fn is_is_empty_sig(cx: &LateContext<'_>, call_id: HirId) -> bool {
203203
fn iterates_same_ty<'tcx>(cx: &LateContext<'tcx>, iter_ty: Ty<'tcx>, collect_ty: Ty<'tcx>) -> bool {
204204
if let Some(iter_trait) = cx.tcx.get_diagnostic_item(sym::Iterator)
205205
&& let Some(into_iter_trait) = cx.tcx.get_diagnostic_item(sym::IntoIterator)
206-
&& let Some(iter_item_ty) = make_normalized_projection(cx.tcx, cx.param_env, iter_trait, sym::Item, [iter_ty])
206+
&& let Some(iter_item_ty) = make_normalized_projection(cx.tcx, cx.typing_env(), iter_trait, sym::Item, [iter_ty])
207207
&& let Some(into_iter_item_proj) = make_projection(cx.tcx, into_iter_trait, sym::Item, [collect_ty])
208208
&& let Ok(into_iter_item_ty) = cx.tcx.try_normalize_erasing_regions(
209-
cx.param_env,
209+
cx.typing_env(),
210210
Ty::new_projection_from_args(cx.tcx, into_iter_item_proj.def_id, into_iter_item_proj.args),
211211
)
212212
{
@@ -237,7 +237,7 @@ fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) -
237237
)
238238
&& let args = cx.tcx.mk_args(&[GenericArg::from(typeck.expr_ty_adjusted(iter_expr))])
239239
&& let proj_ty = Ty::new_projection_from_args(cx.tcx, iter_item.def_id, args)
240-
&& let Ok(item_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, proj_ty)
240+
&& let Ok(item_ty) = cx.tcx.try_normalize_erasing_regions(cx.typing_env(), proj_ty)
241241
{
242242
item_ty == EarlyBinder::bind(search_ty).instantiate(cx.tcx, cx.typeck_results().node_args(call_id))
243243
} else {

clippy_lints/src/methods/unnecessary_min_or_max.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(super) fn check<'tcx>(
1919
arg: &'tcx Expr<'_>,
2020
) {
2121
let typeck_results = cx.typeck_results();
22-
let ecx = ConstEvalCtxt::with_env(cx.tcx, cx.param_env, typeck_results);
22+
let ecx = ConstEvalCtxt::with_env(cx.tcx, cx.typing_env(), typeck_results);
2323
if let Some(id) = typeck_results.type_dependent_def_id(expr.hir_id)
2424
&& (cx.tcx.is_diagnostic_item(sym::cmp_ord_min, id) || cx.tcx.is_diagnostic_item(sym::cmp_ord_max, id))
2525
{

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
578578
if output_ty.contains(param_ty) {
579579
if let Ok(new_ty) = cx.tcx.try_instantiate_and_normalize_erasing_regions(
580580
new_subst,
581-
cx.param_env,
581+
cx.typing_env(),
582582
bound_fn_sig.rebind(output_ty),
583583
) {
584584
expr = parent_expr;

clippy_lints/src/methods/zst_offset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::ZST_OFFSET;
77

88
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) {
99
if let ty::RawPtr(ty, _) = cx.typeck_results().expr_ty(recv).kind()
10-
&& let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(*ty))
10+
&& let Ok(layout) = cx.tcx.layout_of(cx.typing_env().as_query_input(*ty))
1111
&& layout.is_zst()
1212
{
1313
span_lint(cx, ZST_OFFSET, expr.span, "offset calculation on zero-sized value");

clippy_lints/src/needless_borrows_for_generic_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn replace_types<'tcx>(
421421
.expect_ty(cx.tcx)
422422
.to_ty(cx.tcx);
423423

424-
if let Ok(projected_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, projection)
424+
if let Ok(projected_ty) = cx.tcx.try_normalize_erasing_regions(cx.typing_env(), projection)
425425
&& args[term_param_ty.index as usize] != GenericArg::from(projected_ty)
426426
{
427427
deque.push_back((*term_param_ty, projected_ty));

clippy_lints/src/non_copy_const.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,23 @@ impl<'tcx> NonCopyConst<'tcx> {
278278
fn is_value_unfrozen_expr(cx: &LateContext<'tcx>, hir_id: HirId, def_id: DefId, ty: Ty<'tcx>) -> bool {
279279
let args = cx.typeck_results().node_args(hir_id);
280280

281-
let result = Self::const_eval_resolve(cx.tcx, cx.param_env, ty::UnevaluatedConst::new(def_id, args), DUMMY_SP);
281+
let result = Self::const_eval_resolve(cx.tcx, cx.typing_env(), ty::UnevaluatedConst::new(def_id, args), DUMMY_SP);
282282
Self::is_value_unfrozen_raw(cx, result, ty)
283283
}
284284

285285
pub fn const_eval_resolve(
286286
tcx: TyCtxt<'tcx>,
287-
param_env: ty::ParamEnv<'tcx>,
287+
typing_env: ty::TypingEnv<'tcx>,
288288
ct: ty::UnevaluatedConst<'tcx>,
289289
span: Span,
290290
) -> EvalToValTreeResult<'tcx> {
291-
match ty::Instance::try_resolve(tcx, param_env, ct.def, ct.args) {
291+
match ty::Instance::try_resolve(tcx, typing_env, ct.def, ct.args) {
292292
Ok(Some(instance)) => {
293293
let cid = GlobalId {
294294
instance,
295295
promoted: None,
296296
};
297-
tcx.const_eval_global_id_for_typeck(param_env, cid, span)
297+
tcx.const_eval_global_id_for_typeck(typing_env.param_env, cid, span)
298298
},
299299
Ok(None) => Err(ErrorHandled::TooGeneric(span)),
300300
Err(err) => Err(ErrorHandled::Reported(err.into(), span)),
@@ -321,7 +321,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> {
321321

322322
// Normalize assoc types because ones originated from generic params
323323
// bounded other traits could have their bound.
324-
let normalized = cx.tcx.normalize_erasing_regions(cx.param_env, ty);
324+
let normalized = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
325325
if self.interior_mut.is_interior_mut_ty(cx, normalized)
326326
// When there's no default value, lint it only according to its type;
327327
// in other words, lint consts whose value *could* be unfrozen, not definitely is.
@@ -361,12 +361,12 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> {
361361
.trait_item_def_id
362362
&& cx
363363
.tcx
364-
.layout_of(cx.tcx.param_env(of_trait_def_id).and(
364+
.layout_of(ty::TypingEnv::post_analysis(cx.tcx, of_trait_def_id).as_query_input(
365365
// Normalize assoc types because ones originated from generic params
366366
// bounded other traits could have their bound at the trait defs;
367367
// and, in that case, the definition is *not* generic.
368368
cx.tcx.normalize_erasing_regions(
369-
cx.tcx.param_env(of_trait_def_id),
369+
ty::TypingEnv::post_analysis(cx.tcx, of_trait_def_id),
370370
cx.tcx.type_of(of_assoc_item).instantiate_identity(),
371371
),
372372
))
@@ -376,7 +376,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> {
376376
// similar to unknown layouts.
377377
// e.g. `layout_of(...).is_err() || has_frozen_variant(...);`
378378
&& let ty = cx.tcx.type_of(impl_item.owner_id).instantiate_identity()
379-
&& let normalized = cx.tcx.normalize_erasing_regions(cx.param_env, ty)
379+
&& let normalized = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty)
380380
&& self.interior_mut.is_interior_mut_ty(cx, normalized)
381381
&& Self::is_value_unfrozen_poly(cx, *body_id, normalized)
382382
{
@@ -386,7 +386,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> {
386386
ItemKind::Impl(Impl { of_trait: None, .. }) => {
387387
let ty = cx.tcx.type_of(impl_item.owner_id).instantiate_identity();
388388
// Normalize assoc types originated from generic params.
389-
let normalized = cx.tcx.normalize_erasing_regions(cx.param_env, ty);
389+
let normalized = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
390390

391391
if self.interior_mut.is_interior_mut_ty(cx, normalized)
392392
&& Self::is_value_unfrozen_poly(cx, *body_id, normalized)

clippy_lints/src/operators/const_comparisons.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn comparison_to_const<'tcx>(
2626
if let ExprKind::Binary(operator, left, right) = expr.kind
2727
&& let Ok(cmp_op) = CmpOp::try_from(operator.node)
2828
{
29-
let ecx = ConstEvalCtxt::with_env(cx.tcx, cx.param_env, typeck);
29+
let ecx = ConstEvalCtxt::with_env(cx.tcx, cx.typing_env(), typeck);
3030
match (ecx.eval(left), ecx.eval(right)) {
3131
(Some(_), Some(_)) => None,
3232
(_, Some(con)) => Some((cmp_op, left, right, con, typeck.expr_ty(right))),

clippy_lints/src/operators/erasing_op.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn check_op<'tcx>(
3939
other: &Expr<'tcx>,
4040
parent: &Expr<'tcx>,
4141
) {
42-
if ConstEvalCtxt::with_env(cx.tcx, cx.param_env, tck).eval_simple(op) == Some(Constant::Int(0)) {
42+
if ConstEvalCtxt::with_env(cx.tcx, cx.typing_env(), tck).eval_simple(op) == Some(Constant::Int(0)) {
4343
if different_types(tck, other, parent) {
4444
return;
4545
}

clippy_lints/src/operators/float_cmp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ pub(crate) fn check<'tcx>(
1717
right: &'tcx Expr<'_>,
1818
) {
1919
if (op == BinOpKind::Eq || op == BinOpKind::Ne) && is_float(cx, left) {
20-
let typeck = cx.typeck_results();
21-
let ecx = ConstEvalCtxt::with_env(cx.tcx, cx.param_env, typeck);
20+
let ecx = ConstEvalCtxt::new(cx);
2221
let left_is_local = match ecx.eval_with_source(left) {
2322
Some((c, s)) if !is_allowed(&c) => s.is_local(),
2423
Some(_) => return,

clippy_lints/src/redundant_slicing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing {
136136
});
137137
} else if let Some(target_id) = cx.tcx.lang_items().deref_target() {
138138
if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions(
139-
cx.param_env,
139+
cx.typing_env(),
140140
Ty::new_projection_from_args(cx.tcx, target_id, cx.tcx.mk_args(&[GenericArg::from(indexed_ty)])),
141141
) {
142142
if deref_ty == expr_ty {

clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ fn check_final_expr<'tcx>(
391391

392392
if let Some(inner) = inner {
393393
if for_each_unconsumed_temporary(cx, inner, |temporary_ty| {
394-
if temporary_ty.has_significant_drop(cx.tcx, cx.param_env)
394+
if temporary_ty.has_significant_drop(cx.tcx, cx.typing_env())
395395
&& temporary_ty
396396
.walk()
397397
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))

0 commit comments

Comments
 (0)