Skip to content

Commit dc53c8f

Browse files
committed
Update tooling
1 parent a17ccfa commit dc53c8f

File tree

15 files changed

+137
-99
lines changed

15 files changed

+137
-99
lines changed

compiler/rustc_codegen_cranelift/src/base.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -770,11 +770,7 @@ fn codegen_stmt<'tcx>(
770770
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
771771
}
772772
Rvalue::NullaryOp(null_op, ty) => {
773-
assert!(
774-
lval.layout()
775-
.ty
776-
.is_sized(fx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())
777-
);
773+
assert!(lval.layout().ty.is_sized(fx.tcx, ParamEnv::reveal_all()));
778774
let layout = fx.layout_of(fx.monomorphize(ty));
779775
let val = match null_op {
780776
NullOp::SizeOf => layout.size.bytes(),

compiler/rustc_codegen_cranelift/src/constant.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
55
use rustc_middle::mir::interpret::{
66
read_target_uint, AllocId, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar,
77
};
8-
use rustc_span::DUMMY_SP;
98

109
use cranelift_module::*;
1110

@@ -291,7 +290,7 @@ fn data_id_for_static(
291290
let is_mutable = if tcx.is_mutable_static(def_id) {
292291
true
293292
} else {
294-
!ty.is_freeze(tcx.at(DUMMY_SP), ParamEnv::reveal_all())
293+
!ty.is_freeze(tcx, ParamEnv::reveal_all())
295294
};
296295
let align = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().align.pref.bytes();
297296

src/librustdoc/clean/auto_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ where
148148
})
149149
.collect();
150150
// We are only interested in case the type *doesn't* implement the Sized trait.
151-
if !ty.is_sized(tcx.at(rustc_span::DUMMY_SP), param_env) {
151+
if !ty.is_sized(tcx, param_env) {
152152
// In case `#![no_core]` is used, `sized_trait` returns nothing.
153153
if let Some(item) = tcx.lang_items().sized_trait().and_then(|sized_trait_did| {
154154
self.generate_for_trait(ty, sized_trait_did, param_env, item_def_id, &f, true)

src/tools/clippy/clippy_lints/src/casts/ptr_as_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: Option<RustcVer
2626
(Mutability::Not, Mutability::Not) | (Mutability::Mut, Mutability::Mut));
2727
// The `U` in `pointer::cast` have to be `Sized`
2828
// as explained here: https://github.com/rust-lang/rust/issues/60602.
29-
if to_pointee_ty.is_sized(cx.tcx.at(expr.span), cx.param_env);
29+
if to_pointee_ty.is_sized(cx.tcx, cx.param_env);
3030
then {
3131
let mut applicability = Applicability::MachineApplicable;
3232
let cast_expr_sugg = Sugg::hir_with_applicability(cx, cast_expr, "_", &mut applicability);

src/tools/clippy/clippy_lints/src/dereference.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_middle::ty::{
2929
};
3030
use rustc_semver::RustcVersion;
3131
use rustc_session::{declare_tool_lint, impl_lint_pass};
32-
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
32+
use rustc_span::{symbol::sym, Span, Symbol};
3333
use rustc_trait_selection::infer::InferCtxtExt as _;
3434
use rustc_trait_selection::traits::{query::evaluate_obligation::InferCtxtExt as _, Obligation, ObligationCause};
3535
use std::collections::VecDeque;
@@ -990,7 +990,7 @@ fn binding_ty_auto_deref_stability<'tcx>(
990990
cx.typeck_results().node_type(ty.ty.hir_id),
991991
binder_args,
992992
))
993-
.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env.without_caller_bounds()),
993+
.is_sized(cx.tcx, cx.param_env.without_caller_bounds()),
994994
)
995995
}
996996
},
@@ -1005,7 +1005,7 @@ fn binding_ty_auto_deref_stability<'tcx>(
10051005
cx.typeck_results().node_type(ty.ty.hir_id),
10061006
binder_args,
10071007
))
1008-
.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env.without_caller_bounds()),
1008+
.is_sized(cx.tcx, cx.param_env.without_caller_bounds()),
10091009
),
10101010
TyKind::OpaqueDef(..) | TyKind::Infer | TyKind::Typeof(..) | TyKind::TraitObject(..) | TyKind::Err => {
10111011
Position::ReborrowStable(precedence)
@@ -1297,7 +1297,7 @@ impl<'tcx> TyPosition<'tcx> {
12971297
fn position_for_result(self, cx: &LateContext<'tcx>) -> Position {
12981298
match (self.position, self.ty) {
12991299
(Position::ReborrowStable(precedence), Some(ty)) => {
1300-
Position::DerefStable(precedence, ty.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env))
1300+
Position::DerefStable(precedence, ty.is_sized(cx.tcx, cx.param_env))
13011301
},
13021302
(position, _) => position,
13031303
}
@@ -1348,7 +1348,7 @@ fn ty_auto_deref_stability<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, precedenc
13481348
| ty::Tuple(_)
13491349
| ty::Projection(_) => Position::DerefStable(
13501350
precedence,
1351-
ty.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env.without_caller_bounds()),
1351+
ty.is_sized(cx.tcx, cx.param_env.without_caller_bounds()),
13521352
)
13531353
.into(),
13541354
};

src/tools/clippy/clippy_lints/src/functions/must_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, tys: &m
188188
// primitive types are never mutable
189189
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => false,
190190
ty::Adt(adt, substs) => {
191-
tys.insert(adt.did()) && !ty.is_freeze(cx.tcx.at(span), cx.param_env)
191+
tys.insert(adt.did()) && !ty.is_freeze(cx.tcx, cx.param_env)
192192
|| KNOWN_WRAPPER_TYS
193193
.iter()
194194
.any(|&sym| cx.tcx.is_diagnostic_item(sym, adt.did()))

src/tools/clippy/clippy_lints/src/let_if_seq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
7474
let span = stmt.span.to(if_.span);
7575

7676
let has_interior_mutability = !cx.typeck_results().node_type(canonical_id).is_freeze(
77-
cx.tcx.at(span),
77+
cx.tcx,
7878
cx.param_env,
7979
);
8080
if has_interior_mutability { return; }

src/tools/clippy/clippy_lints/src/mut_key.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,14 @@ fn check_ty<'tcx>(cx: &LateContext<'tcx>, span: Span, ty: Ty<'tcx>) {
136136
/// [`Hash`] or [`Ord`].
137137
fn is_interior_mutable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span) -> bool {
138138
match *ty.kind() {
139-
Ref(_, inner_ty, mutbl) => mutbl == hir::Mutability::Mut || is_interior_mutable_type(cx, inner_ty, span),
139+
Ref(_, inner_ty, mutbl) => {
140+
mutbl == hir::Mutability::Mut || is_interior_mutable_type(cx, inner_ty, span)
141+
}
140142
Slice(inner_ty) => is_interior_mutable_type(cx, inner_ty, span),
141143
Array(inner_ty, size) => {
142144
size.try_eval_usize(cx.tcx, cx.param_env).map_or(true, |u| u != 0)
143145
&& is_interior_mutable_type(cx, inner_ty, span)
144-
},
146+
}
145147
Tuple(fields) => fields.iter().any(|ty| is_interior_mutable_type(cx, ty, span)),
146148
Adt(def, substs) => {
147149
// Special case for collections in `std` who's impl of `Hash` or `Ord` delegates to
@@ -167,9 +169,9 @@ fn is_interior_mutable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Sp
167169
} else {
168170
!ty.has_escaping_bound_vars()
169171
&& cx.tcx.layout_of(cx.param_env.and(ty)).is_ok()
170-
&& !ty.is_freeze(cx.tcx.at(span), cx.param_env)
172+
&& !ty.is_freeze(cx.tcx, cx.param_env)
171173
}
172-
},
174+
}
173175
_ => false,
174176
}
175177
}

src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_middle::mir::FakeReadCause;
1919
use rustc_middle::ty::{self, TypeVisitable};
2020
use rustc_session::{declare_lint_pass, declare_tool_lint};
2121
use rustc_span::symbol::kw;
22-
use rustc_span::{sym, Span, DUMMY_SP};
22+
use rustc_span::{sym, Span};
2323
use rustc_target::spec::abi::Abi;
2424
use rustc_trait_selection::traits;
2525
use rustc_trait_selection::traits::misc::can_type_implement_copy;
@@ -184,7 +184,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
184184
if !is_self(arg);
185185
if !ty.is_mutable_ptr();
186186
if !is_copy(cx, ty);
187-
if ty.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env);
187+
if ty.is_sized(cx.tcx, cx.param_env);
188188
if !allowed_traits.iter().any(|&t| implements_trait(cx, ty, t, &[]));
189189
if !implements_borrow_trait;
190190
if !all_borrowable_trait;

src/tools/clippy/clippy_lints/src/non_copy_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_middle::mir::interpret::{ConstValue, ErrorHandled};
2020
use rustc_middle::ty::adjustment::Adjust;
2121
use rustc_middle::ty::{self, Ty};
2222
use rustc_session::{declare_lint_pass, declare_tool_lint};
23-
use rustc_span::{sym, InnerSpan, Span, DUMMY_SP};
23+
use rustc_span::{sym, InnerSpan, Span};
2424

2525
// FIXME: this is a correctness problem but there's no suitable
2626
// warn-by-default category.
@@ -136,7 +136,7 @@ fn is_unfrozen<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
136136
// since it works when a pointer indirection involves (`Cell<*const T>`).
137137
// Making up a `ParamEnv` where every generic params and assoc types are `Freeze`is another option;
138138
// but I'm not sure whether it's a decent way, if possible.
139-
cx.tcx.layout_of(cx.param_env.and(ty)).is_ok() && !ty.is_freeze(cx.tcx.at(DUMMY_SP), cx.param_env)
139+
cx.tcx.layout_of(cx.param_env.and(ty)).is_ok() && !ty.is_freeze(cx.tcx, cx.param_env)
140140
}
141141

142142
fn is_value_unfrozen_raw<'tcx>(

src/tools/clippy/clippy_lints/src/question_mark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn check_is_none_or_err_and_early_return<'tcx>(cx: &LateContext<'tcx>, expr: &Ex
9494
then {
9595
let mut applicability = Applicability::MachineApplicable;
9696
let receiver_str = snippet_with_applicability(cx, caller.span, "..", &mut applicability);
97-
let by_ref = !caller_ty.is_copy_modulo_regions(cx.tcx.at(caller.span), cx.param_env) &&
97+
let by_ref = !caller_ty.is_copy_modulo_regions(cx.tcx, cx.param_env) &&
9898
!matches!(caller.kind, ExprKind::Call(..) | ExprKind::MethodCall(..));
9999
let sugg = if let Some(else_inner) = r#else {
100100
if eq_expr_value(cx, caller, peel_blocks(else_inner)) {

0 commit comments

Comments
 (0)