Skip to content

Commit e9b7045

Browse files
authored
Rustup (#15616)
r? @ghost changelog: integer-to-pointer-transmutes are now handled by the upstream `integer_to_ptr_transmutes` Rust lint and no longer by the [`useless_transmute`] Clippy lint
2 parents b3c3efe + e9810e5 commit e9b7045

20 files changed

+63
-95
lines changed

clippy_lints/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ url = "2.2"
2727
[dev-dependencies]
2828
walkdir = "2.3"
2929

30+
[lints.rust.unexpected_cfgs]
31+
level = "warn"
32+
check-cfg = ['cfg(bootstrap)']
33+
3034
[package.metadata.rust-analyzer]
3135
# This crate uses #[feature(rustc_private)]
3236
rustc_private = true

clippy_lints/src/equatable_if_let.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn unary_pattern(pat: &Pat<'_>) -> bool {
5353
| PatKind::Never
5454
| PatKind::Or(_)
5555
| PatKind::Err(_) => false,
56-
PatKind::Struct(_, a, etc) => !etc && a.iter().all(|x| unary_pattern(x.pat)),
56+
PatKind::Struct(_, a, etc) => etc.is_none() && a.iter().all(|x| unary_pattern(x.pat)),
5757
PatKind::Tuple(a, etc) | PatKind::TupleStruct(_, a, etc) => etc.as_opt_usize().is_none() && array_rec(a),
5858
PatKind::Ref(x, _) | PatKind::Box(x) | PatKind::Deref(x) | PatKind::Guard(x, _) => unary_pattern(x),
5959
PatKind::Expr(_) => true,

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#![feature(iter_intersperse)]
88
#![feature(iter_partition_in_place)]
99
#![feature(never_type)]
10-
#![feature(round_char_boundary)]
10+
#![cfg_attr(bootstrap, feature(round_char_boundary))]
1111
#![feature(rustc_private)]
1212
#![feature(stmt_expr_attributes)]
1313
#![feature(unwrap_infallible)]

clippy_lints/src/manual_let_else.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn replace_in_pattern(
287287
}
288288
return or_pat;
289289
},
290-
PatKind::Struct(path, fields, has_dot_dot) => {
290+
PatKind::Struct(path, fields, dot_dot) => {
291291
let fields = fields
292292
.iter()
293293
.map(|fld| {
@@ -311,7 +311,7 @@ fn replace_in_pattern(
311311
.collect::<Vec<_>>();
312312
let fields_string = fields.join(", ");
313313

314-
let dot_dot_str = if has_dot_dot { " .." } else { "" };
314+
let dot_dot_str = if dot_dot.is_some() { " .." } else { "" };
315315
let (sn_pth, _) = snippet_with_context(cx, path.span(), span.ctxt(), "", app);
316316
return format!("{sn_pth} {{ {fields_string}{dot_dot_str} }}");
317317
},

clippy_lints/src/matches/rest_pat_in_fully_bound_struct.rs

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

88
pub(crate) fn check(cx: &LateContext<'_>, pat: &Pat<'_>) {
99
if !pat.span.from_expansion()
10-
&& let PatKind::Struct(QPath::Resolved(_, path), fields, true) = pat.kind
10+
&& let PatKind::Struct(QPath::Resolved(_, path), fields, Some(_)) = pat.kind
1111
&& let Some(def_id) = path.res.opt_def_id()
1212
&& let ty = cx.tcx.type_of(def_id).instantiate_identity()
1313
&& let ty::Adt(def, _) = ty.kind()

clippy_lints/src/missing_inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,5 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
188188
/// and a rustc warning would be triggered, see #15301
189189
fn fn_is_externally_exported(cx: &LateContext<'_>, def_id: DefId) -> bool {
190190
let attrs = cx.tcx.codegen_fn_attrs(def_id);
191-
attrs.contains_extern_indicator(cx.tcx, def_id)
191+
attrs.contains_extern_indicator()
192192
}

clippy_lints/src/transmute/useless_transmute.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,7 @@ pub(super) fn check<'tcx>(
4949
true
5050
},
5151
(ty::Int(_) | ty::Uint(_), ty::RawPtr(_, _)) => {
52-
span_lint_and_then(
53-
cx,
54-
USELESS_TRANSMUTE,
55-
e.span,
56-
"transmute from an integer to a pointer",
57-
|diag| {
58-
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
59-
diag.span_suggestion(e.span, "try", arg.as_ty(to_ty.to_string()), Applicability::Unspecified);
60-
}
61-
},
62-
);
52+
// Handled by the upstream rustc `integer_to_ptr_transmutes` lint
6353
true
6454
},
6555
_ => false,

clippy_lints/src/utils/author.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,8 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
754754
self.ident(name);
755755
sub.if_some(|p| self.pat(p));
756756
},
757-
PatKind::Struct(ref qpath, fields, ignore) => {
757+
PatKind::Struct(ref qpath, fields, etc) => {
758+
let ignore = etc.is_some();
758759
bind!(self, qpath, fields);
759760
kind!("Struct(ref {qpath}, {fields}, {ignore})");
760761
self.qpath(qpath, pat);

clippy_utils/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This crate is only guaranteed to build with this `nightly` toolchain:
88

99
<!-- begin autogenerated nightly -->
1010
```
11-
nightly-2025-08-22
11+
nightly-2025-09-04
1212
```
1313
<!-- end autogenerated nightly -->
1414

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ pub fn is_expr_identity_of_pat(cx: &LateContext<'_>, pat: &Pat<'_>, expr: &Expr<
20122012
false
20132013
}
20142014
},
2015-
(PatKind::Struct(pat_ident, field_pats, false), ExprKind::Struct(ident, fields, hir::StructTailExpr::None))
2015+
(PatKind::Struct(pat_ident, field_pats, None), ExprKind::Struct(ident, fields, hir::StructTailExpr::None))
20162016
if field_pats.len() == fields.len() =>
20172017
{
20182018
// check ident

0 commit comments

Comments
 (0)