Skip to content
Merged

Rustup #16094

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ff9a175
refactor ub_checks and contract_checks to share logic
pitaj May 4, 2025
07b6b32
Trait aliases are rare large ast nodes, box them
oli-obk Jul 21, 2025
42f074d
Implement pattern matching for `&pin mut|const T`
frank-king Apr 13, 2025
8992878
Rename `#[pin_project]` to `#[pin_v2]` to avoid naming conflicts
frank-king Oct 24, 2025
0fd7406
fix: Only special case single line item attribute suggestions
Muscraft Oct 22, 2025
3f5ea6b
Constify trait aliases
oli-obk Jul 21, 2025
33232af
Rollup merge of #144291 - oli-obk:const_trait_alias, r=fee1-dead
matthiaskrgr Oct 31, 2025
c71f7b6
Merge commit 'c936595d17413c1f08e162e117e504fb4ed126e4' into clippy-s…
flip1995 Oct 31, 2025
78adb20
Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril…
matthiaskrgr Nov 1, 2025
7ec6593
Rollup merge of #148340 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Nov 1, 2025
eefeff5
mgca: Add ConstArg representation for const items
camelid Oct 14, 2025
ce0c449
Generalize branch references to HEAD
Kobzol Nov 2, 2025
99124be
Rollup merge of #148004 - Muscraft:only-single-line-item-attributes, …
matthiaskrgr Nov 3, 2025
5db7300
feat: Use annotate-snippets by default on nightly
Muscraft Oct 15, 2025
8cb6e1b
Fix clippy
camelid Nov 1, 2025
7a745ff
Use "rhs" terminology instead of "body"
camelid Nov 1, 2025
5b5709b
Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU
bors Nov 8, 2025
f5ccdae
Rollup merge of #128666 - pitaj:intrinsic-overflow_checks, r=BoxyUwU
Zalathar Nov 9, 2025
2760531
Implement `&pin` patterns and `ref pin` bindings
frank-king Nov 2, 2025
d16f26b
Allow `function_casts_as_integer` in non-related clippy ui tests
GuillaumeGomez May 24, 2025
39107ff
Rollup merge of #141470 - GuillaumeGomez:function_casts_as_integer, r…
Zalathar Nov 11, 2025
a72893f
Simplify jemalloc setup
madsmtm Nov 11, 2025
70cfebb
Fix building rustdoc and clippy with jemalloc feature
madsmtm Oct 25, 2025
18de216
Make clippy happy.
m-ou-se Nov 10, 2025
7ae882e
Bless clippy tests.
m-ou-se Nov 11, 2025
3352bea
Bless clippy tests.
m-ou-se Nov 12, 2025
03cd6b6
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Nov 14, 2025
ca4557c
Bump nightly version -> 2025-11-15
flip1995 Nov 14, 2025
72fc40c
Fix fn_to_numeric_cast 32 bit stderr
flip1995 Nov 14, 2025
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tempfile = { version = "3.20", optional = true }
termize = "0.2"
color-print = "0.3.4"
anstream = "0.6.18"
tikv-jemalloc-sys = { version = "0.6.1", optional = true, features = ['override_allocator_on_supported_platforms'] }

[dev-dependencies]
cargo_metadata = "0.18.1"
Expand All @@ -56,7 +57,7 @@ rustc_tools_util = { path = "rustc_tools_util", version = "0.4.2" }
[features]
integration = ["dep:tempfile"]
internal = ["dep:clippy_lints_internal", "dep:tempfile"]
jemalloc = []
jemalloc = ["dep:tikv-jemalloc-sys"]

[package.metadata.rust-analyzer]
# This package uses #[feature(rustc_private)]
Expand Down
2 changes: 1 addition & 1 deletion book/src/development/infrastructure/changelog_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ written for. If not, update the version to the changelog version.

[changelog]: https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md
[forge]: https://forge.rust-lang.org/
[rust_master_tools]: https://github.com/rust-lang/rust/tree/master/src/tools/clippy
[rust_master_tools]: https://github.com/rust-lang/rust/tree/HEAD/src/tools/clippy
[rust_beta_tools]: https://github.com/rust-lang/rust/tree/beta/src/tools/clippy
[rust_stable_tools]: https://github.com/rust-lang/rust/releases
[`beta-accepted`]: https://github.com/rust-lang/rust-clippy/issues?q=label%3Abeta-accepted+
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/disallowed_script_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl_lint_pass!(DisallowedScriptIdents => [DISALLOWED_SCRIPT_IDENTS]);
impl EarlyLintPass for DisallowedScriptIdents {
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
// Implementation is heavily inspired by the implementation of [`non_ascii_idents`] lint:
// https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint/src/non_ascii_idents.rs
// https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_lint/src/non_ascii_idents.rs

let check_disallowed_script_idents = cx.builder.lint_level(DISALLOWED_SCRIPT_IDENTS).level != Level::Allow;
if !check_disallowed_script_idents {
Expand Down
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 @@ -55,7 +55,7 @@ fn unary_pattern(pat: &Pat<'_>) -> bool {
| PatKind::Err(_) => false,
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::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/index_refutable_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<Hir
// We'll just ignore mut and ref mut for simplicity sake right now
if let hir::PatKind::Binding(hir::BindingMode(by_ref, hir::Mutability::Not), value_hir_id, ident, sub_pat) =
pat.kind
&& by_ref != hir::ByRef::Yes(hir::Mutability::Mut)
&& !matches!(by_ref, hir::ByRef::Yes(_, hir::Mutability::Mut))
{
// This block catches bindings with sub patterns. It would be hard to build a correct suggestion
// for them and it's likely that the user knows what they are doing in such a case.
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/item_name_repetitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ impl LateLintPass<'_> for ItemNameRepetitions {
| ItemKind::Macro(ident, ..)
| ItemKind::Static(_, ident, ..)
| ItemKind::Trait(_, _, _, ident, ..)
| ItemKind::TraitAlias(ident, ..)
| ItemKind::TraitAlias(_, ident, ..)
| ItemKind::TyAlias(ident, ..)
| ItemKind::Union(ident, ..)
| ItemKind::Use(_, UseKind::Single(ident)) => ident,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/manual_find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub(super) fn check<'tcx>(
let mut snippet = make_iterator_snippet(cx, arg, &mut applicability);
// Checks if `pat` is a single reference to a binding (`&x`)
let is_ref_to_binding =
matches!(pat.kind, PatKind::Ref(inner, _) if matches!(inner.kind, PatKind::Binding(..)));
matches!(pat.kind, PatKind::Ref(inner, _, _) if matches!(inner.kind, PatKind::Binding(..)));
// If `pat` is not a binding or a reference to a binding (`x` or `&x`)
// we need to map it to the binding returned by the function (i.e. `.map(|(x, _)| x)`)
if !(matches!(pat.kind, PatKind::Binding(..)) || is_ref_to_binding) {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/manual_retain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn check_iter(
),
);
},
hir::PatKind::Ref(pat, _) => make_span_lint_and_sugg(
hir::PatKind::Ref(pat, _, _) => make_span_lint_and_sugg(
cx,
parent_expr_span,
format!(
Expand Down Expand Up @@ -196,7 +196,7 @@ fn check_to_owned(
&& let filter_body = cx.tcx.hir_body(closure.body)
&& let [filter_params] = filter_body.params
&& msrv.meets(cx, msrvs::STRING_RETAIN)
&& let hir::PatKind::Ref(pat, _) = filter_params.pat.kind
&& let hir::PatKind::Ref(pat, _, _) = filter_params.pat.kind
{
make_span_lint_and_sugg(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/manual_ok_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn is_variant_or_wildcard(cx: &LateContext<'_>, pat: &Pat<'_>, can_be_wild: bool
.is_lang_item(cx, ResultErr)
== must_match_err
},
PatKind::Binding(_, _, _, Some(pat)) | PatKind::Ref(pat, _) => {
PatKind::Binding(_, _, _, Some(pat)) | PatKind::Ref(pat, _, _) => {
is_variant_or_wildcard(cx, pat, can_be_wild, must_match_err)
},
_ => false,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/manual_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub(super) fn try_parse_pattern<'tcx>(
) -> Option<OptionPat<'tcx>> {
match pat.kind {
PatKind::Wild => Some(OptionPat::Wild),
PatKind::Ref(pat, _) => f(cx, pat, ref_count + 1, ctxt),
PatKind::Ref(pat, _, _) => f(cx, pat, ref_count + 1, ctxt),
_ if is_none_pattern(cx, pat) => Some(OptionPat::None),
_ if let Some([pattern]) = as_some_pattern(cx, pat)
&& pat.span.ctxt() == ctxt =>
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/match_as_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr:
// Checks if arm has the form `Some(ref v) => Some(v)` (checks for `ref` and `ref mut`)
fn as_ref_some_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> Option<Mutability> {
if let Some([first_pat, ..]) = as_some_pattern(cx, arm.pat)
&& let PatKind::Binding(BindingMode(ByRef::Yes(mutabl), _), .., ident, _) = first_pat.kind
&& let PatKind::Binding(BindingMode(ByRef::Yes(_, mutabl), _), .., ident, _) = first_pat.kind
&& let Some(arg) = as_some_expr(cx, peel_blocks(arm.body))
&& let ExprKind::Path(QPath::Resolved(_, path2)) = arg.kind
&& path2.segments.len() == 1
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/match_ref_pats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ where
}

let remaining_suggs = pats.filter_map(|pat| {
if let PatKind::Ref(refp, _) = pat.kind {
if let PatKind::Ref(refp, _, _) = pat.kind {
Some((pat.span, snippet(cx, refp.span, "..").to_string()))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/match_same_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<'a> NormalizedPat<'a> {
PatKind::Binding(.., Some(pat))
| PatKind::Box(pat)
| PatKind::Deref(pat)
| PatKind::Ref(pat, _)
| PatKind::Ref(pat, _, _)
| PatKind::Guard(pat, _) => Self::from_pat(cx, arena, pat),
PatKind::Never => Self::Never,
PatKind::Struct(ref path, fields, _) => {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/needless_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn pat_same_as_expr(pat: &Pat<'_>, expr: &Expr<'_>) -> bool {
},
)),
) => {
return !matches!(annot, BindingMode(ByRef::Yes(_), _)) && pat_ident.name == first_seg.ident.name;
return !matches!(annot, BindingMode(ByRef::Yes(..), _)) && pat_ident.name == first_seg.ident.name;
},
// Example: `Custom::TypeA => Custom::TypeB`, or `None => None`
(
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/matches/redundant_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'tcx>], msrv:
&& !pat_contains_disallowed_or(cx, arm.pat, msrv)
{
let pat_span = match (arm.pat.kind, binding.byref_ident) {
(PatKind::Ref(pat, _), Some(_)) => pat.span,
(PatKind::Ref(pat, _, _), Some(_)) => pat.span,
(PatKind::Ref(..), None) | (_, Some(_)) => continue,
_ => arm.pat.span,
};
Expand All @@ -49,7 +49,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'tcx>], msrv:
&& !pat_contains_disallowed_or(cx, let_expr.pat, msrv)
{
let pat_span = match (let_expr.pat.kind, binding.byref_ident) {
(PatKind::Ref(pat, _), Some(_)) => pat.span,
(PatKind::Ref(pat, _, _), Some(_)) => pat.span,
(PatKind::Ref(..), None) | (_, Some(_)) => continue,
_ => let_expr.pat.span,
};
Expand Down Expand Up @@ -176,7 +176,7 @@ fn get_pat_binding<'tcx>(
if let PatKind::Binding(bind_annot, hir_id, ident, _) = pat.kind
&& hir_id == local
{
if matches!(bind_annot.0, rustc_ast::ByRef::Yes(_)) {
if matches!(bind_annot.0, rustc_ast::ByRef::Yes(..)) {
let _ = byref_ident.insert(ident);
}
// the second call of `replace()` returns a `Some(span)`, meaning a multi-binding pattern
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/redundant_pattern_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn find_method_sugg_for_if_let<'tcx>(
// also look inside refs
// if we have &None for example, peel it so we can detect "if let None = x"
let check_pat = match let_pat.kind {
PatKind::Ref(inner, _mutability) => inner,
PatKind::Ref(inner, _pinnedness, _mutability) => inner,
_ => let_pat,
};
let op_ty = cx.typeck_results().expr_ty(let_expr);
Expand Down
5 changes: 4 additions & 1 deletion clippy_lints/src/matches/single_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,10 @@ impl<'a> PatState<'a> {
},

// Patterns for things which can only contain a single sub-pattern.
PatKind::Binding(_, _, _, Some(pat)) | PatKind::Ref(pat, _) | PatKind::Box(pat) | PatKind::Deref(pat) => {
PatKind::Binding(_, _, _, Some(pat))
| PatKind::Ref(pat, _, _)
| PatKind::Box(pat)
| PatKind::Deref(pat) => {
self.add_pat(cx, pat)
},
PatKind::Tuple([sub_pat], pos)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/clone_on_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>)
_ => false,
},
// local binding capturing a reference
Node::LetStmt(l) if matches!(l.pat.kind, PatKind::Binding(BindingMode(ByRef::Yes(_), _), ..)) => {
Node::LetStmt(l) if matches!(l.pat.kind, PatKind::Binding(BindingMode(ByRef::Yes(..), _), ..)) => {
return;
},
_ => false,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/filter_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ fn is_find_or_filter<'a>(
&& let filter_body = cx.tcx.hir_body(filter_body_id)
&& let [filter_param] = filter_body.params
// optional ref pattern: `filter(|&x| ..)`
&& let (filter_pat, is_filter_param_ref) = if let PatKind::Ref(ref_pat, _) = filter_param.pat.kind {
&& let (filter_pat, is_filter_param_ref) = if let PatKind::Ref(ref_pat, _, _) = filter_param.pat.kind {
(ref_pat, true)
} else {
(filter_param.pat, false)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/iter_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn is_method(
fn pat_is_recv(ident: Ident, param: &hir::Pat<'_>) -> bool {
match param.kind {
hir::PatKind::Binding(_, _, other, _) => ident == other,
hir::PatKind::Ref(pat, _) => pat_is_recv(ident, pat),
hir::PatKind::Ref(pat, _, _) => pat_is_recv(ident, pat),
_ => false,
}
}
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/methods/iter_overeager_cloned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ pub(super) fn check<'tcx>(
}

match it.kind {
PatKind::Binding(BindingMode(_, Mutability::Mut), _, _, _) | PatKind::Ref(_, Mutability::Mut) => {
PatKind::Binding(BindingMode(_, Mutability::Mut), _, _, _)
| PatKind::Ref(_, _, Mutability::Mut) => {
to_be_discarded = true;
false
},
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_errors::Applicability;
use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir, LangItem};
use rustc_lint::LateContext;
use rustc_middle::mir::Mutability;
use rustc_middle::mir::{Mutability, Pinnedness};
use rustc_middle::ty;
use rustc_middle::ty::adjustment::Adjust;
use rustc_span::symbol::Ident;
Expand Down Expand Up @@ -50,7 +50,7 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_
let closure_body = cx.tcx.hir_body(body);
let closure_expr = peel_blocks(closure_body.value);
match closure_body.params[0].pat.kind {
hir::PatKind::Ref(inner, Mutability::Not) => {
hir::PatKind::Ref(inner, Pinnedness::Not, Mutability::Not) => {
if let hir::PatKind::Binding(hir::BindingMode::NONE, .., name, None) = inner.kind
&& ident_eq(name, closure_expr)
{
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/needless_borrowed_ref.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_then;
use rustc_errors::Applicability;
use rustc_hir::{BindingMode, Mutability, Node, Pat, PatKind};
use rustc_hir::{BindingMode, Mutability, Node, Pat, PatKind, Pinnedness};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;

Expand Down Expand Up @@ -37,7 +37,7 @@ declare_lint_pass!(NeedlessBorrowedRef => [NEEDLESS_BORROWED_REFERENCE]);

impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowedRef {
fn check_pat(&mut self, cx: &LateContext<'tcx>, ref_pat: &'tcx Pat<'_>) {
if let PatKind::Ref(pat, Mutability::Not) = ref_pat.kind
if let PatKind::Ref(pat, Pinnedness::Not, Mutability::Not) = ref_pat.kind
&& !ref_pat.span.from_expansion()
&& cx
.tcx
Expand Down
Loading