Skip to content

Commit 809b420

Browse files
committed
move fn is_item_raw to TypingEnv
1 parent bb93c23 commit 809b420

File tree

14 files changed

+17
-17
lines changed

14 files changed

+17
-17
lines changed

clippy_lints/src/casts/ptr_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: &Msrv) {
3939
(Mutability::Not, Mutability::Not) | (Mutability::Mut, Mutability::Mut))
4040
// The `U` in `pointer::cast` have to be `Sized`
4141
// as explained here: https://github.com/rust-lang/rust/issues/60602.
42-
&& to_pointee_ty.is_sized(cx.tcx, cx.param_env)
42+
&& to_pointee_ty.is_sized(cx.tcx, cx.typing_env())
4343
{
4444
let mut app = Applicability::MachineApplicable;
4545
let turbofish = match &cast_to_hir_ty.kind {

clippy_lints/src/dereference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ fn report<'tcx>(
10281028
State::ExplicitDeref { mutability } => {
10291029
if is_block_like(expr)
10301030
&& let ty::Ref(_, ty, _) = data.adjusted_ty.kind()
1031-
&& ty.is_sized(cx.tcx, cx.param_env)
1031+
&& ty.is_sized(cx.tcx, cx.typing_env())
10321032
{
10331033
// Rustc bug: auto deref doesn't work on block expression when targeting sized types.
10341034
return;

clippy_lints/src/functions/must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, tys: &mut DefIdSet)
198198
// primitive types are never mutable
199199
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => false,
200200
ty::Adt(adt, args) => {
201-
tys.insert(adt.did()) && !ty.is_freeze(cx.tcx, cx.param_env)
201+
tys.insert(adt.did()) && !ty.is_freeze(cx.tcx, cx.typing_env())
202202
|| matches!(cx.tcx.get_diagnostic_name(adt.did()), Some(sym::Rc | sym::Arc))
203203
&& args.types().any(|ty| is_mutable_ty(cx, ty, tys))
204204
},

clippy_lints/src/let_if_seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
8080
let has_interior_mutability = !cx
8181
.typeck_results()
8282
.node_type(canonical_id)
83-
.is_freeze(cx.tcx, cx.param_env);
83+
.is_freeze(cx.tcx, cx.typing_env());
8484
if has_interior_mutability {
8585
return;
8686
}

clippy_lints/src/methods/manual_inspect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, name:
148148
_ => {},
149149
}
150150
}
151-
requires_copy |= !ty.is_copy_modulo_regions(cx.tcx, cx.param_env);
151+
requires_copy |= !ty.is_copy_modulo_regions(cx.tcx, cx.typing_env());
152152
break;
153153
}
154154
},
@@ -158,9 +158,9 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, name:
158158
}
159159

160160
if can_lint
161-
&& (!requires_copy || arg_ty.is_copy_modulo_regions(cx.tcx, cx.param_env))
161+
&& (!requires_copy || arg_ty.is_copy_modulo_regions(cx.tcx, cx.typing_env()))
162162
// This case could be handled, but a fair bit of care would need to be taken.
163-
&& (!requires_deref || arg_ty.is_freeze(cx.tcx, cx.param_env))
163+
&& (!requires_deref || arg_ty.is_freeze(cx.tcx, cx.typing_env()))
164164
{
165165
if requires_deref {
166166
edits.push((param.span.shrink_to_lo(), "&".into()));

clippy_lints/src/mut_mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for MutVisitor<'_, 'tcx> {
8080
"generally you want to avoid `&mut &mut _` if possible",
8181
);
8282
} else if let ty::Ref(_, ty, hir::Mutability::Mut) = self.cx.typeck_results().expr_ty(e).kind() {
83-
if ty.peel_refs().is_sized(self.cx.tcx, self.cx.param_env) {
83+
if ty.peel_refs().is_sized(self.cx.tcx, self.cx.typing_env()) {
8484
span_lint_hir(
8585
self.cx,
8686
MUT_MUT,

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
180180
if !is_self(arg)
181181
&& !ty.is_mutable_ptr()
182182
&& !is_copy(cx, ty)
183-
&& ty.is_sized(cx.tcx, cx.param_env)
183+
&& ty.is_sized(cx.tcx, cx.typing_env())
184184
&& !allowed_traits.iter().any(|&t| {
185185
implements_trait_with_env_from_iter(cx.tcx, cx.param_env, ty, t, None, [Option::<
186186
ty::GenericArg<'tcx>,

clippy_lints/src/question_mark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fn check_is_none_or_err_and_early_return<'tcx>(cx: &LateContext<'tcx>, expr: &Ex
251251
{
252252
let mut applicability = Applicability::MachineApplicable;
253253
let receiver_str = snippet_with_applicability(cx, caller.span, "..", &mut applicability);
254-
let by_ref = !caller_ty.is_copy_modulo_regions(cx.tcx, cx.param_env)
254+
let by_ref = !caller_ty.is_copy_modulo_regions(cx.tcx, cx.typing_env())
255255
&& !matches!(caller.kind, ExprKind::Call(..) | ExprKind::MethodCall(..));
256256
let sugg = if let Some(else_inner) = r#else {
257257
if eq_expr_value(cx, caller, peel_blocks(else_inner)) {

clippy_lints/src/transmute/transmute_ptr_to_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(super) fn check<'tcx>(
2727
|diag| {
2828
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
2929
if from_mutbl == to_mutbl
30-
&& to_pointee_ty.is_sized(cx.tcx, cx.param_env)
30+
&& to_pointee_ty.is_sized(cx.tcx, cx.typing_env())
3131
&& msrv.meets(msrvs::POINTER_CAST)
3232
{
3333
diag.span_suggestion_verbose(

clippy_lints/src/transmute/transmute_undefined_repr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ fn reduce_refs<'tcx>(cx: &LateContext<'tcx>, mut from_ty: Ty<'tcx>, mut to_ty: T
206206
continue;
207207
},
208208
(&(ty::Ref(_, unsized_ty, _) | ty::RawPtr(unsized_ty, _)), _)
209-
if !unsized_ty.is_sized(cx.tcx, cx.param_env) =>
209+
if !unsized_ty.is_sized(cx.tcx, cx.typing_env()) =>
210210
{
211211
(true, false)
212212
},
213213
(_, &(ty::Ref(_, unsized_ty, _) | ty::RawPtr(unsized_ty, _)))
214-
if !unsized_ty.is_sized(cx.tcx, cx.param_env) =>
214+
if !unsized_ty.is_sized(cx.tcx, cx.typing_env()) =>
215215
{
216216
(false, true)
217217
},

clippy_lints/src/types/redundant_allocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, hir_ty: &hir::Ty<'tcx>, qpath:
6060
// here because `mod.rs` guarantees this lint is only run on types outside of bodies and
6161
// is not run on locals.
6262
let ty = lower_ty(cx.tcx, hir_ty);
63-
if ty.has_escaping_bound_vars() || !ty.is_sized(cx.tcx, cx.param_env) {
63+
if ty.has_escaping_bound_vars() || !ty.is_sized(cx.tcx, cx.typing_env()) {
6464
return false;
6565
}
6666
hir_ty.span

clippy_lints/src/types/vec_box.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub(super) fn check<'tcx>(
3737
&& let boxed_alloc_ty = last.args.get(1)
3838
&& let ty_ty = lower_ty(cx.tcx, boxed_ty)
3939
&& !ty_ty.has_escaping_bound_vars()
40-
&& ty_ty.is_sized(cx.tcx, cx.param_env)
40+
&& ty_ty.is_sized(cx.tcx, cx.typing_env())
4141
&& let Ok(ty_ty_size) = cx.layout_of(ty_ty).map(|l| l.size.bytes())
4242
&& ty_ty_size < box_size_threshold
4343
// https://github.com/rust-lang/rust-clippy/issues/7114

clippy_lints/src/unnecessary_box_returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl UnnecessaryBoxReturns {
8282
// It's sometimes useful to return Box<T> if T is unsized, so don't lint those.
8383
// Also, don't lint if we know that T is very large, in which case returning
8484
// a Box<T> may be beneficial.
85-
if boxed_ty.is_sized(cx.tcx, cx.param_env) && approx_ty_size(cx, boxed_ty) <= self.maximum_size {
85+
if boxed_ty.is_sized(cx.tcx, cx.typing_env()) && approx_ty_size(cx, boxed_ty) <= self.maximum_size {
8686
span_lint_and_then(
8787
cx,
8888
UNNECESSARY_BOX_RETURNS,

clippy_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub use type_certainty::expr_type_is_certain;
3838

3939
/// Checks if the given type implements copy.
4040
pub fn is_copy<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
41-
ty.is_copy_modulo_regions(cx.tcx, cx.param_env)
41+
ty.is_copy_modulo_regions(cx.tcx, cx.typing_env())
4242
}
4343

4444
/// This checks whether a given type is known to implement Debug.

0 commit comments

Comments
 (0)