Skip to content

Commit 72e8b12

Browse files
committed
Auto merge of rust-lang#3469 - rust-lang:rustup-2024-04-16, r=RalfJung
Automatic Rustup
2 parents 7ae909f + a73005e commit 72e8b12

File tree

12 files changed

+20
-56
lines changed

12 files changed

+20
-56
lines changed

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ impl TyCoercionStability {
821821
| TyKind::Array(..)
822822
| TyKind::Ptr(_)
823823
| TyKind::BareFn(_)
824+
| TyKind::Pat(..)
824825
| TyKind::Never
825826
| TyKind::Tup(_)
826827
| TyKind::Path(_) => Self::Deref,
@@ -869,6 +870,7 @@ impl TyCoercionStability {
869870
| ty::Int(_)
870871
| ty::Uint(_)
871872
| ty::Array(..)
873+
| ty::Pat(..)
872874
| ty::Float(_)
873875
| ty::RawPtr(..)
874876
| ty::FnPtr(_)

clippy_lints/src/large_include_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl LateLintPass<'_> for LargeIncludeFile {
7171
span_lint_and_note(
7272
cx,
7373
LARGE_INCLUDE_FILE,
74-
expr.span,
74+
expr.span.source_callsite(),
7575
"attempted to include a large file",
7676
None,
7777
format!(

clippy_lints/src/lifetimes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ fn elision_suggestions(
294294
let span = cx
295295
.sess()
296296
.source_map()
297-
.span_extend_while(usage.ident.span, |ch| ch.is_ascii_whitespace())
298-
.unwrap_or(usage.ident.span);
297+
.span_extend_while_whitespace(usage.ident.span);
299298

300299
(span, String::new())
301300
},

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc_errors::Applicability;
1212
use rustc_hir::def::{DefKind, Res};
1313
use rustc_hir::def_id::DefId;
1414
use rustc_hir::{BorrowKind, Expr, ExprKind, ItemKind, LangItem, Node};
15-
use rustc_hir_typeck::{FnCtxt, TypeckRootCtxt};
1615
use rustc_infer::infer::TyCtxtInferExt;
1716
use rustc_lint::LateContext;
1817
use rustc_middle::mir::Mutability;
@@ -437,9 +436,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
437436
Node::Item(item) => {
438437
if let ItemKind::Fn(_, _, body_id) = &item.kind
439438
&& let output_ty = return_ty(cx, item.owner_id)
440-
&& let root_ctxt = TypeckRootCtxt::new(cx.tcx, item.owner_id.def_id)
441-
&& let fn_ctxt = FnCtxt::new(&root_ctxt, cx.param_env, item.owner_id.def_id)
442-
&& fn_ctxt.can_coerce(ty, output_ty)
439+
&& rustc_hir_typeck::can_coerce(cx.tcx, cx.param_env, item.owner_id.def_id, ty, output_ty)
443440
{
444441
if has_lifetime(output_ty) && has_lifetime(ty) {
445442
return false;

clippy_lints/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ declare_clippy_lint! {
6666
///
6767
/// ### Known problems
6868
/// The lint does not work properly with desugaring and
69-
/// macro, it has been allowed in the mean time.
69+
/// macro, it has been allowed in the meantime.
7070
///
7171
/// ### Example
7272
/// ```no_run

clippy_lints/src/strings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl<'tcx> LateLintPass<'tcx> for StringLitAsBytes {
300300
e.span,
301301
"calling `as_bytes()` on `include_str!(..)`",
302302
"consider using `include_bytes!(..)` instead",
303-
snippet_with_applicability(cx, receiver.span, r#""foo""#, &mut applicability).replacen(
303+
snippet_with_applicability(cx, receiver.span.source_callsite(), r#""foo""#, &mut applicability).replacen(
304304
"include_str",
305305
"include_bytes",
306306
1,

clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::utils::check_cast;
1+
use rustc_hir_typeck::cast::check_cast;
22
use super::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS;
33
use clippy_utils::diagnostics::span_lint_and_sugg;
44
use clippy_utils::sugg::Sugg;
@@ -22,7 +22,7 @@ pub(super) fn check<'tcx>(
2222
) -> bool {
2323
use CastKind::{AddrPtrCast, ArrayPtrCast, FnPtrAddrCast, FnPtrPtrCast, PtrAddrCast, PtrPtrCast};
2424
let mut app = Applicability::MachineApplicable;
25-
let mut sugg = match check_cast(cx, e, from_ty, to_ty) {
25+
let mut sugg = match check_cast(cx.tcx, cx.param_env, e, from_ty, to_ty) {
2626
Some(FnPtrAddrCast | PtrAddrCast) if const_context => return false,
2727
Some(PtrPtrCast | AddrPtrCast | ArrayPtrCast | FnPtrPtrCast | FnPtrAddrCast) => {
2828
Sugg::hir_with_context(cx, arg, e.span.ctxt(), "..", &mut app)

clippy_lints/src/transmute/utils.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
use rustc_hir as hir;
2-
use rustc_hir::Expr;
3-
use rustc_hir_typeck::{cast, FnCtxt, TypeckRootCtxt};
41
use rustc_lint::LateContext;
5-
use rustc_middle::ty::cast::CastKind;
62
use rustc_middle::ty::Ty;
7-
use rustc_span::DUMMY_SP;
83

94
// check if the component types of the transmuted collection and the result have different ABI,
105
// size or alignment
@@ -20,35 +15,3 @@ pub(super) fn is_layout_incompatible<'tcx>(cx: &LateContext<'tcx>, from: Ty<'tcx
2015
false
2116
}
2217
}
23-
24-
/// If a cast from `from_ty` to `to_ty` is valid, returns an Ok containing the kind of
25-
/// the cast. In certain cases, including some invalid casts from array references
26-
/// to pointers, this may cause additional errors to be emitted and/or ICE error
27-
/// messages. This function will panic if that occurs.
28-
pub(super) fn check_cast<'tcx>(
29-
cx: &LateContext<'tcx>,
30-
e: &'tcx Expr<'_>,
31-
from_ty: Ty<'tcx>,
32-
to_ty: Ty<'tcx>,
33-
) -> Option<CastKind> {
34-
let hir_id = e.hir_id;
35-
let local_def_id = hir_id.owner.def_id;
36-
37-
let root_ctxt = TypeckRootCtxt::new(cx.tcx, local_def_id);
38-
let fn_ctxt = FnCtxt::new(&root_ctxt, cx.param_env, local_def_id);
39-
40-
if let Ok(check) = cast::CastCheck::new(
41-
&fn_ctxt,
42-
e,
43-
from_ty,
44-
to_ty,
45-
// We won't show any error to the user, so we don't care what the span is here.
46-
DUMMY_SP,
47-
DUMMY_SP,
48-
hir::Constness::NotConst,
49-
) {
50-
check.do_check(&fn_ctxt).ok()
51-
} else {
52-
None
53-
}
54-
}

clippy_utils/src/hir_utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,10 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
10681068
self.hash_ty(ty);
10691069
self.hash_array_length(len);
10701070
},
1071+
TyKind::Pat(ty, pat) => {
1072+
self.hash_ty(ty);
1073+
self.hash_pat(pat);
1074+
},
10711075
TyKind::Ptr(ref mut_ty) => {
10721076
self.hash_ty(mut_ty.ty);
10731077
mut_ty.mutbl.hash(&mut self.s);

tests/ui-internal/custom_ice_message.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
44

55
error: the compiler unexpectedly panicked. this is a bug.
66

7-
note: it seems that this compiler <version> is outdated, a newer nightly should have been released in the mean time
7+
note: it seems that this compiler <version> is outdated, a newer nightly should have been released in the meantime
88
|
99
= note: please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
1010
= note: if the problem still persists, we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

0 commit comments

Comments
 (0)