Skip to content
Merged

Rustup #15823

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: 2 additions & 2 deletions clippy_lints/src/casts/cast_ptr_alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, cast_f
expr.span,
format!(
"casting from `{cast_from}` to a more-strictly-aligned pointer (`{cast_to}`) ({} < {} bytes)",
from_layout.align.abi.bytes(),
to_layout.align.abi.bytes(),
from_layout.align.bytes(),
to_layout.align.bytes(),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/casts/manual_dangling_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn is_literal_aligned(cx: &LateContext<'_>, lit: &Spanned<LitKind>, to: &Ty<'_>)
cx.tcx
.layout_of(cx.typing_env().as_query_input(to_mid_ty))
.is_ok_and(|layout| {
let align = u128::from(layout.align.abi.bytes());
let align = u128::from(layout.align.bytes());
u128::from(val) <= align
})
}
1 change: 0 additions & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#![feature(iter_intersperse)]
#![feature(iter_partition_in_place)]
#![feature(never_type)]
#![cfg_attr(bootstrap, feature(round_char_boundary))]
#![feature(rustc_private)]
#![feature(stmt_expr_attributes)]
#![feature(unwrap_infallible)]
Expand Down
8 changes: 5 additions & 3 deletions clippy_lints/src/macro_metavars_in_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_hir_and_then;
use clippy_utils::is_lint_allowed;
use itertools::Itertools;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_stmt};
use rustc_hir::{BlockCheckMode, Expr, ExprKind, HirId, Stmt, UnsafeSource};
use rustc_hir::{BlockCheckMode, Expr, ExprKind, HirId, Stmt, UnsafeSource, find_attr};
use rustc_lint::{LateContext, LateLintPass, Level, LintContext};
use rustc_middle::lint::LevelAndSource;
use rustc_session::impl_lint_pass;
use rustc_span::{Span, SyntaxContext, sym};
use rustc_span::{Span, SyntaxContext};
use std::collections::BTreeMap;
use std::collections::btree_map::Entry;

Expand Down Expand Up @@ -146,7 +147,8 @@ struct BodyVisitor<'a, 'tcx> {
}

fn is_public_macro(cx: &LateContext<'_>, def_id: LocalDefId) -> bool {
(cx.effective_visibilities.is_exported(def_id) || cx.tcx.has_attr(def_id, sym::macro_export))
(cx.effective_visibilities.is_exported(def_id)
|| find_attr!(cx.tcx.get_all_attrs(def_id), AttributeKind::MacroExport { .. }))
&& !cx.tcx.is_doc_hidden(def_id)
}

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/pass_by_ref_or_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_hir::{BindingMode, Body, FnDecl, Impl, ItemKind, MutTy, Mutability, No
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::adjustment::{Adjust, PointerCoercion};
use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::ty::{self, RegionKind, TyCtxt};
use rustc_middle::ty::{self, BoundVarIndexKind, RegionKind, TyCtxt};
use rustc_session::impl_lint_pass;
use rustc_span::def_id::LocalDefId;
use rustc_span::{Span, sym};
Expand Down Expand Up @@ -151,7 +151,7 @@ impl PassByRefOrValue {
match *ty.skip_binder().kind() {
ty::Ref(lt, ty, Mutability::Not) => {
match lt.kind() {
RegionKind::ReBound(index, region)
RegionKind::ReBound(BoundVarIndexKind::Bound(index), region)
if index.as_u32() == 0 && output_regions.contains(&region) =>
{
continue;
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-09-18
nightly-2025-10-06
```
<!-- end autogenerated nightly -->

Expand Down
6 changes: 3 additions & 3 deletions clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, msrv: Msrv)
ty::FnPtr(..) => {
return Err((span, "function pointers in const fn are unstable".into()));
},
ty::Dynamic(preds, _, _) => {
ty::Dynamic(preds, _) => {
for pred in *preds {
match pred.skip_binder() {
ty::ExistentialPredicate::AutoTrait(_) | ty::ExistentialPredicate::Projection(_) => {
Expand Down Expand Up @@ -141,7 +141,8 @@ fn check_rvalue<'tcx>(
| CastKind::FloatToFloat
| CastKind::FnPtrToPtr
| CastKind::PtrToPtr
| CastKind::PointerCoercion(PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer, _),
| CastKind::PointerCoercion(PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer, _)
| CastKind::Subtype,
operand,
_,
) => check_operand(cx, operand, span, body, msrv),
Expand Down Expand Up @@ -312,7 +313,6 @@ fn check_place<'tcx>(
| ProjectionElem::OpaqueCast(..)
| ProjectionElem::Downcast(..)
| ProjectionElem::Subslice { .. }
| ProjectionElem::Subtype(_)
| ProjectionElem::Index(_)
| ProjectionElem::UnwrapUnsafeBinder(_) => {},
}
Expand Down
12 changes: 6 additions & 6 deletions clippy_utils/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use rustc_middle::traits::EvaluationResult;
use rustc_middle::ty::adjustment::{Adjust, Adjustment};
use rustc_middle::ty::layout::ValidityRequirement;
use rustc_middle::ty::{
self, AdtDef, AliasTy, AssocItem, AssocTag, Binder, BoundRegion, FnSig, GenericArg, GenericArgKind, GenericArgsRef,
GenericParamDefKind, IntTy, Region, RegionKind, TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
TypeVisitableExt, TypeVisitor, UintTy, Upcast, VariantDef, VariantDiscr,
self, AdtDef, AliasTy, AssocItem, AssocTag, Binder, BoundRegion, BoundVarIndexKind, FnSig, GenericArg,
GenericArgKind, GenericArgsRef, GenericParamDefKind, IntTy, Region, RegionKind, TraitRef, Ty, TyCtxt,
TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, UintTy, Upcast, VariantDef, VariantDiscr,
};
use rustc_span::symbol::Ident;
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
Expand Down Expand Up @@ -344,7 +344,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
}
false
},
ty::Dynamic(binder, _, _) => {
ty::Dynamic(binder, _) => {
for predicate in *binder {
if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder()
&& find_attr!(cx.tcx.get_all_attrs(trait_ref.def_id), AttributeKind::MustUse { .. })
Expand Down Expand Up @@ -655,7 +655,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
cx.tcx.opt_parent(def_id),
),
ty::FnPtr(sig_tys, hdr) => Some(ExprFnSig::Sig(sig_tys.with(hdr), None)),
ty::Dynamic(bounds, _, _) => {
ty::Dynamic(bounds, _) => {
let lang_items = cx.tcx.lang_items();
match bounds.principal() {
Some(bound)
Expand Down Expand Up @@ -826,7 +826,7 @@ pub fn for_each_top_level_late_bound_region<B>(
impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow<B>> TypeVisitor<TyCtxt<'tcx>> for V<F> {
type Result = ControlFlow<B>;
fn visit_region(&mut self, r: Region<'tcx>) -> Self::Result {
if let RegionKind::ReBound(idx, bound) = r.kind()
if let RegionKind::ReBound(BoundVarIndexKind::Bound(idx), bound) = r.kind()
&& idx.as_u32() == self.index
{
(self.f)(bound)
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-09-18"
channel = "nightly-2025-10-06"
# end autogenerated nightly
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
profile = "minimal"
1 change: 0 additions & 1 deletion tests/missing-test-files.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![warn(rust_2018_idioms, unused_lifetimes)]
#![allow(clippy::assertions_on_constants)]
#![cfg_attr(bootstrap, feature(path_file_prefix))]

use std::cmp::Ordering;
use std::ffi::OsStr;
Expand Down
32 changes: 20 additions & 12 deletions tests/ui/author/macro_in_closure.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,42 @@ if let StmtKind::Let(local) = stmt.kind
&& paths::STD_IO_STDIO__PRINT.matches_path(cx, func) // Add the path to `clippy_utils::paths` if needed
&& args.len() == 1
&& let ExprKind::Block(block1, None) = args[0].kind
&& block1.stmts.len() == 1
&& block1.stmts.len() == 2
&& let StmtKind::Let(local1) = block1.stmts[0].kind
&& let Some(init1) = local1.init
&& let ExprKind::Array(elements) = init1.kind
&& let ExprKind::Tup(elements) = init1.kind
&& elements.len() == 1
&& let ExprKind::Call(func1, args1) = elements[0].kind
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
&& args1.len() == 1
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = args1[0].kind
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = elements[0].kind
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local1.pat.kind
&& name.as_str() == "args"
&& let StmtKind::Let(local2) = block1.stmts[1].kind
&& let Some(init2) = local2.init
&& let ExprKind::Array(elements1) = init2.kind
&& elements1.len() == 1
&& let ExprKind::Call(func1, args1) = elements1[0].kind
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
&& args1.len() == 1
&& let ExprKind::Field(object, field_name) = args1[0].kind
&& field_name.as_str() == "0"
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local2.pat.kind
&& name1.as_str() == "args"
&& let Some(trailing_expr) = block1.expr
&& let ExprKind::Call(func2, args2) = trailing_expr.kind
&& paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
&& args2.len() == 2
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind
&& let ExprKind::Array(elements1) = inner1.kind
&& elements1.len() == 2
&& let ExprKind::Lit(ref lit) = elements1[0].kind
&& let ExprKind::Array(elements2) = inner1.kind
&& elements2.len() == 2
&& let ExprKind::Lit(ref lit) = elements2[0].kind
&& let LitKind::Str(s, _) = lit.node
&& s.as_str() == ""
&& let ExprKind::Lit(ref lit1) = elements1[1].kind
&& let ExprKind::Lit(ref lit1) = elements2[1].kind
&& let LitKind::Str(s1, _) = lit1.node
&& s1.as_str() == "\n"
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[1].kind
&& block.expr.is_none()
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
&& name1.as_str() == "print_text"
&& let PatKind::Binding(BindingMode::NONE, _, name2, None) = local.pat.kind
&& name2.as_str() == "print_text"
{
// report your lint here
}
28 changes: 18 additions & 10 deletions tests/ui/author/macro_in_loop.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,36 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo
&& paths::STD_IO_STDIO__PRINT.matches_path(cx, func) // Add the path to `clippy_utils::paths` if needed
&& args.len() == 1
&& let ExprKind::Block(block2, None) = args[0].kind
&& block2.stmts.len() == 1
&& block2.stmts.len() == 2
&& let StmtKind::Let(local) = block2.stmts[0].kind
&& let Some(init) = local.init
&& let ExprKind::Array(elements) = init.kind
&& let ExprKind::Tup(elements) = init.kind
&& elements.len() == 1
&& let ExprKind::Call(func1, args1) = elements[0].kind
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
&& args1.len() == 1
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = args1[0].kind
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = elements[0].kind
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
&& name1.as_str() == "args"
&& let StmtKind::Let(local1) = block2.stmts[1].kind
&& let Some(init1) = local1.init
&& let ExprKind::Array(elements1) = init1.kind
&& elements1.len() == 1
&& let ExprKind::Call(func1, args1) = elements1[0].kind
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
&& args1.len() == 1
&& let ExprKind::Field(object, field_name) = args1[0].kind
&& field_name.as_str() == "0"
&& let PatKind::Binding(BindingMode::NONE, _, name2, None) = local1.pat.kind
&& name2.as_str() == "args"
&& let Some(trailing_expr) = block2.expr
&& let ExprKind::Call(func2, args2) = trailing_expr.kind
&& paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
&& args2.len() == 2
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind
&& let ExprKind::Array(elements1) = inner1.kind
&& elements1.len() == 2
&& let ExprKind::Lit(ref lit2) = elements1[0].kind
&& let ExprKind::Array(elements2) = inner1.kind
&& elements2.len() == 2
&& let ExprKind::Lit(ref lit2) = elements2[0].kind
&& let LitKind::Str(s, _) = lit2.node
&& s.as_str() == ""
&& let ExprKind::Lit(ref lit3) = elements1[1].kind
&& let ExprKind::Lit(ref lit3) = elements2[1].kind
&& let LitKind::Str(s1, _) = lit3.node
&& s1.as_str() == "\n"
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[1].kind
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/useless_attribute.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub mod redundant_imports_issue {
() => {};
}

#[expect(redundant_imports)]
#[expect(unused_imports)]
pub(crate) use empty;

empty!();
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/useless_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub mod redundant_imports_issue {
() => {};
}

#[expect(redundant_imports)]
#[expect(unused_imports)]
pub(crate) use empty;

empty!();
Expand Down