Skip to content
Merged

Rustup #15616

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ url = "2.2"
[dev-dependencies]
walkdir = "2.3"

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(bootstrap)']

[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)]
rustc_private = true
2 changes: 1 addition & 1 deletion clippy_lints/src/equatable_if_let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn unary_pattern(pat: &Pat<'_>) -> bool {
| PatKind::Never
| PatKind::Or(_)
| PatKind::Err(_) => false,
PatKind::Struct(_, a, etc) => !etc && a.iter().all(|x| unary_pattern(x.pat)),
PatKind::Struct(_, a, etc) => etc.is_none() && a.iter().all(|x| unary_pattern(x.pat)),
PatKind::Tuple(a, etc) | PatKind::TupleStruct(_, a, etc) => etc.as_opt_usize().is_none() && array_rec(a),
PatKind::Ref(x, _) | PatKind::Box(x) | PatKind::Deref(x) | PatKind::Guard(x, _) => unary_pattern(x),
PatKind::Expr(_) => true,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![feature(iter_intersperse)]
#![feature(iter_partition_in_place)]
#![feature(never_type)]
#![feature(round_char_boundary)]
#![cfg_attr(bootstrap, feature(round_char_boundary))]
#![feature(rustc_private)]
#![feature(stmt_expr_attributes)]
#![feature(unwrap_infallible)]
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/manual_let_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fn replace_in_pattern(
}
return or_pat;
},
PatKind::Struct(path, fields, has_dot_dot) => {
PatKind::Struct(path, fields, dot_dot) => {
let fields = fields
.iter()
.map(|fld| {
Expand All @@ -311,7 +311,7 @@ fn replace_in_pattern(
.collect::<Vec<_>>();
let fields_string = fields.join(", ");

let dot_dot_str = if has_dot_dot { " .." } else { "" };
let dot_dot_str = if dot_dot.is_some() { " .." } else { "" };
let (sn_pth, _) = snippet_with_context(cx, path.span(), span.ctxt(), "", app);
return format!("{sn_pth} {{ {fields_string}{dot_dot_str} }}");
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/rest_pat_in_fully_bound_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::REST_PAT_IN_FULLY_BOUND_STRUCTS;

pub(crate) fn check(cx: &LateContext<'_>, pat: &Pat<'_>) {
if !pat.span.from_expansion()
&& let PatKind::Struct(QPath::Resolved(_, path), fields, true) = pat.kind
&& let PatKind::Struct(QPath::Resolved(_, path), fields, Some(_)) = pat.kind
&& let Some(def_id) = path.res.opt_def_id()
&& let ty = cx.tcx.type_of(def_id).instantiate_identity()
&& let ty::Adt(def, _) = ty.kind()
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/missing_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,5 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
/// and a rustc warning would be triggered, see #15301
fn fn_is_externally_exported(cx: &LateContext<'_>, def_id: DefId) -> bool {
let attrs = cx.tcx.codegen_fn_attrs(def_id);
attrs.contains_extern_indicator(cx.tcx, def_id)
attrs.contains_extern_indicator()
}
12 changes: 1 addition & 11 deletions clippy_lints/src/transmute/useless_transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,7 @@ pub(super) fn check<'tcx>(
true
},
(ty::Int(_) | ty::Uint(_), ty::RawPtr(_, _)) => {
span_lint_and_then(
cx,
USELESS_TRANSMUTE,
e.span,
"transmute from an integer to a pointer",
|diag| {
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
diag.span_suggestion(e.span, "try", arg.as_ty(to_ty.to_string()), Applicability::Unspecified);
}
},
);
// Handled by the upstream rustc `integer_to_ptr_transmutes` lint
true
},
_ => false,
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,8 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
self.ident(name);
sub.if_some(|p| self.pat(p));
},
PatKind::Struct(ref qpath, fields, ignore) => {
PatKind::Struct(ref qpath, fields, etc) => {
let ignore = etc.is_some();
bind!(self, qpath, fields);
kind!("Struct(ref {qpath}, {fields}, {ignore})");
self.qpath(qpath, pat);
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This crate is only guaranteed to build with this `nightly` toolchain:

<!-- begin autogenerated nightly -->
```
nightly-2025-08-22
nightly-2025-09-04
```
<!-- end autogenerated nightly -->

Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ pub fn is_expr_identity_of_pat(cx: &LateContext<'_>, pat: &Pat<'_>, expr: &Expr<
false
}
},
(PatKind::Struct(pat_ident, field_pats, false), ExprKind::Struct(ident, fields, hir::StructTailExpr::None))
(PatKind::Struct(pat_ident, field_pats, None), ExprKind::Struct(ident, fields, hir::StructTailExpr::None))
if field_pats.len() == fields.len() =>
{
// check ident
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[toolchain]
# begin autogenerated nightly
channel = "nightly-2025-08-22"
channel = "nightly-2025-09-04"
# end autogenerated nightly
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
profile = "minimal"
1 change: 0 additions & 1 deletion tests/ui/char_indices_as_byte_indices.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(round_char_boundary)]
#![warn(clippy::char_indices_as_byte_indices)]

trait StrExt {
Expand Down
1 change: 0 additions & 1 deletion tests/ui/char_indices_as_byte_indices.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(round_char_boundary)]
#![warn(clippy::char_indices_as_byte_indices)]

trait StrExt {
Expand Down
28 changes: 14 additions & 14 deletions tests/ui/char_indices_as_byte_indices.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error: indexing into a string with a character position where a byte index is expected
--> tests/ui/char_indices_as_byte_indices.rs:13:24
--> tests/ui/char_indices_as_byte_indices.rs:12:24
|
LL | let _ = prim[..idx];
| ^^^
|
= note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
--> tests/ui/char_indices_as_byte_indices.rs:12:10
--> tests/ui/char_indices_as_byte_indices.rs:11:10
|
LL | for (idx, _) in prim.chars().enumerate() {
| ^^^ ^^^^^^^^^^^
Expand All @@ -19,14 +19,14 @@ LL + for (idx, _) in prim.char_indices() {
|

error: passing a character position to a method that expects a byte index
--> tests/ui/char_indices_as_byte_indices.rs:15:23
--> tests/ui/char_indices_as_byte_indices.rs:14:23
|
LL | prim.split_at(idx);
| ^^^
|
= note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
--> tests/ui/char_indices_as_byte_indices.rs:12:10
--> tests/ui/char_indices_as_byte_indices.rs:11:10
|
LL | for (idx, _) in prim.chars().enumerate() {
| ^^^ ^^^^^^^^^^^
Expand All @@ -37,14 +37,14 @@ LL + for (idx, _) in prim.char_indices() {
|

error: passing a character position to a method that expects a byte index
--> tests/ui/char_indices_as_byte_indices.rs:19:49
--> tests/ui/char_indices_as_byte_indices.rs:18:49
|
LL | let _ = prim[..prim.floor_char_boundary(idx)];
| ^^^
|
= note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
--> tests/ui/char_indices_as_byte_indices.rs:12:10
--> tests/ui/char_indices_as_byte_indices.rs:11:10
|
LL | for (idx, _) in prim.chars().enumerate() {
| ^^^ ^^^^^^^^^^^
Expand All @@ -55,14 +55,14 @@ LL + for (idx, _) in prim.char_indices() {
|

error: indexing into a string with a character position where a byte index is expected
--> tests/ui/char_indices_as_byte_indices.rs:29:24
--> tests/ui/char_indices_as_byte_indices.rs:28:24
|
LL | let _ = prim[..c.0];
| ^^^
|
= note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
--> tests/ui/char_indices_as_byte_indices.rs:28:9
--> tests/ui/char_indices_as_byte_indices.rs:27:9
|
LL | for c in prim.chars().enumerate() {
| ^ ^^^^^^^^^^^
Expand All @@ -73,14 +73,14 @@ LL + for c in prim.char_indices() {
|

error: passing a character position to a method that expects a byte index
--> tests/ui/char_indices_as_byte_indices.rs:31:23
--> tests/ui/char_indices_as_byte_indices.rs:30:23
|
LL | prim.split_at(c.0);
| ^^^
|
= note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
--> tests/ui/char_indices_as_byte_indices.rs:28:9
--> tests/ui/char_indices_as_byte_indices.rs:27:9
|
LL | for c in prim.chars().enumerate() {
| ^ ^^^^^^^^^^^
Expand All @@ -91,14 +91,14 @@ LL + for c in prim.char_indices() {
|

error: indexing into a string with a character position where a byte index is expected
--> tests/ui/char_indices_as_byte_indices.rs:36:26
--> tests/ui/char_indices_as_byte_indices.rs:35:26
|
LL | let _ = string[..idx];
| ^^^
|
= note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
--> tests/ui/char_indices_as_byte_indices.rs:35:10
--> tests/ui/char_indices_as_byte_indices.rs:34:10
|
LL | for (idx, _) in string.chars().enumerate() {
| ^^^ ^^^^^^^^^^^
Expand All @@ -109,14 +109,14 @@ LL + for (idx, _) in string.char_indices() {
|

error: passing a character position to a method that expects a byte index
--> tests/ui/char_indices_as_byte_indices.rs:38:25
--> tests/ui/char_indices_as_byte_indices.rs:37:25
|
LL | string.split_at(idx);
| ^^^
|
= note: a character can take up more than one byte, so they are not interchangeable
note: position comes from the enumerate iterator
--> tests/ui/char_indices_as_byte_indices.rs:35:10
--> tests/ui/char_indices_as_byte_indices.rs:34:10
|
LL | for (idx, _) in string.chars().enumerate() {
| ^^^ ^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/ptr_arg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ LL | fn barbar(_x: &mut Vec<u32>, y: &mut String) {
| ^^^^^^^^^^^ help: change this to: `&mut str`

error: eliding a lifetime that's named elsewhere is confusing
--> tests/ui/ptr_arg.rs:314:36
--> tests/ui/ptr_arg.rs:314:56
|
LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
| ^^ ^^ ---- the same lifetime is elided here
| -- -- ^^^^ the same lifetime is elided here
| | |
| | the lifetime is named here
| the lifetime is named here
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
dead_code,
clippy::borrow_as_ptr,
unnecessary_transmutes,
integer_to_ptr_transmutes,
clippy::needless_lifetimes,
clippy::missing_transmute_annotations
)]
Expand Down Expand Up @@ -60,12 +61,10 @@ fn useless() {
//~^ useless_transmute

let _: *const usize = std::mem::transmute(5_isize);
//~^ useless_transmute

let _ = std::ptr::dangling::<usize>();

let _: *const usize = std::mem::transmute(1 + 1usize);
//~^ useless_transmute

let _ = (1 + 1_usize) as *const usize;
}
Expand Down
Loading