Skip to content

Commit 0f8eabd

Browse files
committed
Auto merge of rust-lang#13302 - Jarcho:rustup, r=Jarcho
Rustup r? ghost changelog: none
2 parents 30e0b69 + 0196e2d commit 0f8eabd

23 files changed

+31
-25
lines changed

clippy_dev/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(rustc_private)]
12
// warn on lints, that are included in `rust-lang/rust`s bootstrap
23
#![warn(rust_2018_idioms, unused_lifetimes)]
34

clippy_lints/src/casts/fn_to_numeric_cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
1515
}
1616

1717
match cast_from.kind() {
18-
ty::FnDef(..) | ty::FnPtr(_) => {
18+
ty::FnDef(..) | ty::FnPtr(..) => {
1919
let mut applicability = Applicability::MaybeIncorrect;
2020
let from_snippet = snippet_with_applicability(cx, cast_expr.span, "x", &mut applicability);
2121
let to_nbits = utils::int_ty_to_nbits(cast_to, cx.tcx);

clippy_lints/src/casts/fn_to_numeric_cast_any.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
1414
_ => { /* continue to checks */ },
1515
}
1616

17-
if let ty::FnDef(..) | ty::FnPtr(_) = cast_from.kind() {
17+
if let ty::FnDef(..) | ty::FnPtr(..) = cast_from.kind() {
1818
let mut applicability = Applicability::MaybeIncorrect;
1919
let from_snippet = snippet_with_applicability(cx, cast_expr.span, "..", &mut applicability);
2020

clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
1414
_ => return,
1515
}
1616
match cast_from.kind() {
17-
ty::FnDef(..) | ty::FnPtr(_) => {
17+
ty::FnDef(..) | ty::FnPtr(..) => {
1818
let mut applicability = Applicability::MaybeIncorrect;
1919
let from_snippet = snippet_with_applicability(cx, cast_expr.span, "x", &mut applicability);
2020

clippy_lints/src/default_numeric_fallback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fn fn_sig_opt<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<PolyFnSig<'
236236
// We can't use `Ty::fn_sig` because it automatically performs args, this may result in FNs.
237237
match node_ty.kind() {
238238
ty::FnDef(def_id, _) => Some(cx.tcx.fn_sig(*def_id).instantiate_identity()),
239-
ty::FnPtr(fn_sig) => Some(*fn_sig),
239+
ty::FnPtr(sig_tys, hdr) => Some(sig_tys.with(*hdr)),
240240
_ => None,
241241
}
242242
}

clippy_lints/src/dereference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ impl TyCoercionStability {
872872
| ty::Pat(..)
873873
| ty::Float(_)
874874
| ty::RawPtr(..)
875-
| ty::FnPtr(_)
875+
| ty::FnPtr(..)
876876
| ty::Str
877877
| ty::Slice(..)
878878
| ty::Adt(..)

clippy_lints/src/eta_reduction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn check_clousure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tc
158158

159159
cx.tcx.fn_sig(def).skip_binder().skip_binder()
160160
},
161-
ty::FnPtr(sig) => sig.skip_binder(),
161+
ty::FnPtr(sig_tys, hdr) => sig_tys.with(*hdr).skip_binder(),
162162
ty::Closure(_, subs) => cx
163163
.tcx
164164
.signature_unclosure(subs.as_closure().sig(), Safety::Safe)

clippy_lints/src/methods/map_flatten.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn try_get_caller_ty_name_and_method_name(
5858
fn is_map_to_option(cx: &LateContext<'_>, map_arg: &Expr<'_>) -> bool {
5959
let map_closure_ty = cx.typeck_results().expr_ty(map_arg);
6060
match map_closure_ty.kind() {
61-
ty::Closure(_, _) | ty::FnDef(_, _) | ty::FnPtr(_) => {
61+
ty::Closure(_, _) | ty::FnDef(_, _) | ty::FnPtr(..) => {
6262
let map_closure_sig = match map_closure_ty.kind() {
6363
ty::Closure(_, args) => args.as_closure().sig(),
6464
_ => map_closure_ty.fn_sig(cx.tcx),

clippy_lints/src/mixed_read_write_in_expression.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
166166
ExprKind::Call(func, _) => {
167167
let typ = self.cx.typeck_results().expr_ty(func);
168168
match typ.kind() {
169-
ty::FnDef(..) | ty::FnPtr(_) => {
169+
ty::FnDef(..) | ty::FnPtr(..) => {
170170
let sig = typ.fn_sig(self.cx.tcx);
171171
if self.cx.tcx.instantiate_bound_regions_with_erased(sig).output().kind() == &ty::Never {
172172
self.report_diverging_sub_expr(e);

clippy_lints/src/multiple_unsafe_ops_per_block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn collect_unsafe_exprs<'tcx>(
130130
ExprKind::Call(path_expr, _) => {
131131
let sig = match *cx.typeck_results().expr_ty(path_expr).kind() {
132132
ty::FnDef(id, _) => cx.tcx.fn_sig(id).skip_binder(),
133-
ty::FnPtr(sig) => sig,
133+
ty::FnPtr(sig_tys, hdr) => sig_tys.with(hdr),
134134
_ => return Continue(Descend::Yes),
135135
};
136136
if sig.safety() == Safety::Unsafe {

clippy_lints/src/mut_reference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn check_arguments<'tcx>(
7979
fn_kind: &str,
8080
) {
8181
match type_definition.kind() {
82-
ty::FnDef(..) | ty::FnPtr(_) => {
82+
ty::FnDef(..) | ty::FnPtr(..) => {
8383
let parameters = type_definition.fn_sig(cx.tcx).skip_binder().inputs();
8484
for (argument, parameter) in iter::zip(arguments, parameters) {
8585
match parameter.kind() {

clippy_utils/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2936,6 +2936,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> ExprU
29362936
moved_before_use,
29372937
same_ctxt,
29382938
},
2939+
#[allow(unreachable_patterns)]
29392940
Some(ControlFlow::Break(_)) => unreachable!("type of node is ControlFlow<!>"),
29402941
None => ExprUseCtxt {
29412942
node: Node::Crate(cx.tcx.hir().root_module()),

clippy_utils/src/qualify_min_const_fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn check_rvalue<'tcx>(
109109
) -> McfResult {
110110
match rvalue {
111111
Rvalue::ThreadLocalRef(_) => Err((span, "cannot access thread local storage in const fn".into())),
112-
Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
112+
Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => {
113113
check_place(tcx, *place, span, body, msrv)
114114
},
115115
Rvalue::CopyForDeref(place) => check_place(tcx, *place, span, body, msrv),
@@ -141,7 +141,7 @@ fn check_rvalue<'tcx>(
141141
// We cannot allow this for now.
142142
return Err((span, "unsizing casts are only allowed for references right now".into()));
143143
};
144-
let unsized_ty = tcx.struct_tail_erasing_lifetimes(pointee_ty, tcx.param_env(def_id));
144+
let unsized_ty = tcx.struct_tail_for_codegen(pointee_ty, tcx.param_env(def_id));
145145
if let ty::Slice(_) | ty::Str = unsized_ty.kind() {
146146
check_operand(tcx, op, span, body, msrv)?;
147147
// Casting/coercing things to slices is fine.

clippy_utils/src/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pub fn peel_mid_ty_refs_is_mutable(ty: Ty<'_>) -> (Ty<'_>, usize, Mutability) {
541541
/// Returns `true` if the given type is an `unsafe` function.
542542
pub fn type_is_unsafe_function<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
543543
match ty.kind() {
544-
ty::FnDef(..) | ty::FnPtr(_) => ty.fn_sig(cx.tcx).safety() == Safety::Unsafe,
544+
ty::FnDef(..) | ty::FnPtr(..) => ty.fn_sig(cx.tcx).safety() == Safety::Unsafe,
545545
_ => false,
546546
}
547547
}
@@ -721,7 +721,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
721721
cx.tcx.item_super_predicates(def_id).iter_instantiated(cx.tcx, args),
722722
cx.tcx.opt_parent(def_id),
723723
),
724-
ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)),
724+
ty::FnPtr(sig_tys, hdr) => Some(ExprFnSig::Sig(sig_tys.with(hdr), None)),
725725
ty::Dynamic(bounds, _, _) => {
726726
let lang_items = cx.tcx.lang_items();
727727
match bounds.principal() {

clippy_utils/src/visitors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ pub fn is_expr_unsafe<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool {
441441
ty::FnDef(id, _) if self.cx.tcx.fn_sig(id).skip_binder().safety() == Safety::Unsafe => {
442442
self.is_unsafe = true;
443443
},
444-
ty::FnPtr(sig) if sig.safety() == Safety::Unsafe => self.is_unsafe = true,
444+
ty::FnPtr(_, hdr) if hdr.safety == Safety::Unsafe => self.is_unsafe = true,
445445
_ => walk_expr(self, e),
446446
},
447447
ExprKind::Path(ref p)

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "nightly-2024-08-08"
2+
channel = "nightly-2024-08-23"
33
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
44
profile = "minimal"

src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// We need this feature as it changes `dylib` linking behavior and allows us to link to
2+
// `rustc_driver`.
3+
#![feature(rustc_private)]
14
// warn on lints, that are included in `rust-lang/rust`s bootstrap
25
#![warn(rust_2018_idioms, unused_lifetimes)]
36

tests/config-metadata.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(rustc_private)]
2+
13
use clippy_config::{get_configuration_metadata, ClippyConfiguration};
24
use itertools::Itertools;
35
use regex::Regex;

tests/ui/borrow_interior_mutable_const/others.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::sync::Once;
1010

1111
const ATOMIC: AtomicUsize = AtomicUsize::new(5);
1212
const CELL: Cell<usize> = Cell::new(6);
13-
const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7);
13+
const ATOMIC_TUPLE: ([AtomicUsize; 1], Option<Box<AtomicUsize>>, u8) = ([ATOMIC], None, 7);
1414
const INTEGER: u8 = 8;
1515
const STRING: String = String::new();
1616
const STR: &str = "012345";
@@ -74,7 +74,6 @@ fn main() {
7474
let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR: interior mutability
7575
let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR: interior mutability
7676
let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR: interior mutability
77-
let _ = &*ATOMIC_TUPLE.1;
7877
let _ = &ATOMIC_TUPLE.2;
7978
let _ = (&&&&ATOMIC_TUPLE).0;
8079
let _ = (&&&&ATOMIC_TUPLE).2;

tests/ui/borrow_interior_mutable_const/others.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,23 @@ LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst);
9292
= help: assign this const to a local or static variable, and use the variable here
9393

9494
error: a `const` item with interior mutability should not be borrowed
95-
--> tests/ui/borrow_interior_mutable_const/others.rs:82:13
95+
--> tests/ui/borrow_interior_mutable_const/others.rs:81:13
9696
|
9797
LL | let _ = ATOMIC_TUPLE.0[0];
9898
| ^^^^^^^^^^^^
9999
|
100100
= help: assign this const to a local or static variable, and use the variable here
101101

102102
error: a `const` item with interior mutability should not be borrowed
103-
--> tests/ui/borrow_interior_mutable_const/others.rs:87:5
103+
--> tests/ui/borrow_interior_mutable_const/others.rs:86:5
104104
|
105105
LL | CELL.set(2);
106106
| ^^^^
107107
|
108108
= help: assign this const to a local or static variable, and use the variable here
109109

110110
error: a `const` item with interior mutability should not be borrowed
111-
--> tests/ui/borrow_interior_mutable_const/others.rs:88:16
111+
--> tests/ui/borrow_interior_mutable_const/others.rs:87:16
112112
|
113113
LL | assert_eq!(CELL.get(), 6);
114114
| ^^^^

tests/ui/single_match_else.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn main() {
8989

9090
// lint here
9191
use std::convert::Infallible;
92-
if let Ok(a) = Result::<i32, Infallible>::Ok(1) { println!("${:?}", a) } else {
92+
if let Ok(a) = Result::<i32, &Infallible>::Ok(1) { println!("${:?}", a) } else {
9393
println!("else block");
9494
return;
9595
}

tests/ui/single_match_else.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn main() {
9898

9999
// lint here
100100
use std::convert::Infallible;
101-
match Result::<i32, Infallible>::Ok(1) {
101+
match Result::<i32, &Infallible>::Ok(1) {
102102
Ok(a) => println!("${:?}", a),
103103
Err(_) => {
104104
println!("else block");

tests/ui/single_match_else.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ LL + }
6464
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
6565
--> tests/ui/single_match_else.rs:101:5
6666
|
67-
LL | / match Result::<i32, Infallible>::Ok(1) {
67+
LL | / match Result::<i32, &Infallible>::Ok(1) {
6868
LL | | Ok(a) => println!("${:?}", a),
6969
LL | | Err(_) => {
7070
LL | | println!("else block");
@@ -75,7 +75,7 @@ LL | | }
7575
|
7676
help: try
7777
|
78-
LL ~ if let Ok(a) = Result::<i32, Infallible>::Ok(1) { println!("${:?}", a) } else {
78+
LL ~ if let Ok(a) = Result::<i32, &Infallible>::Ok(1) { println!("${:?}", a) } else {
7979
LL + println!("else block");
8080
LL + return;
8181
LL + }

0 commit comments

Comments
 (0)