Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a4bd5f5
compiler: suggest `.collect()` when `String` is expected and `Iterato…
thiago-fealves May 3, 2026
e1941ff
Update compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
thiago-fealves May 4, 2026
31e0383
rustfmt matches with comments in or-patterns
estebank May 13, 2026
701e494
Remove a bunch of stray backticks
estebank May 13, 2026
19c6365
Inline and remove `late_lint_crate_inner`
nnethercote May 15, 2026
4033268
Remove an unnecessary `push` argument
nnethercote May 15, 2026
379caad
Remove driver_lint_caps
bjorn3 Feb 19, 2026
124126e
Test EII UI tests with prefer-dynamic
AsakuraMizu May 14, 2026
5cd51c0
Place comment in the right place
estebank May 16, 2026
87821d9
Add regression test for issue 41261
eval-exec May 16, 2026
22cf1fb
Split `LintExpectationId`
nnethercote May 15, 2026
36738a1
Remove some low-value method wrappers
nnethercote May 15, 2026
6c9d519
Add some comments to `ShallowLintLevelMap`
nnethercote May 15, 2026
967f43d
Rollup merge of #152852 - bjorn3:remove_driver_lint_caps, r=notriddle
GuillaumeGomez May 16, 2026
4090d33
Rollup merge of #156121 - thiago-fealves:suggest-collect-string, r=es…
GuillaumeGomez May 16, 2026
f4773ce
Rollup merge of #156518 - estebank:match-rustfmt, r=mejrs
GuillaumeGomez May 16, 2026
0571ef0
Rollup merge of #156596 - nnethercote:split-LintExpectation, r=Guilla…
GuillaumeGomez May 16, 2026
94a1b09
Rollup merge of #156577 - AsakuraMizu:eii-default-dynamic, r=mejrs
GuillaumeGomez May 16, 2026
069fdd2
Rollup merge of #156633 - eval-exec:issue-41261-regression-test, r=mu…
GuillaumeGomez May 16, 2026
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
20 changes: 8 additions & 12 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,12 +1557,10 @@ impl Expr {
}

match &self.kind {
ExprKind::Closure(closure) => {
match closure.fn_decl.output {
FnRetTy::Default(_) => ExprPrecedence::Jump,
FnRetTy::Ty(_) => prefix_attrs_precedence(&self.attrs),
}
}
ExprKind::Closure(closure) => match closure.fn_decl.output {
FnRetTy::Default(_) => ExprPrecedence::Jump,
FnRetTy::Ty(_) => prefix_attrs_precedence(&self.attrs),
},

ExprKind::Break(_ /*label*/, value)
| ExprKind::Ret(value)
Expand All @@ -1584,18 +1582,16 @@ impl Expr {
ExprKind::Binary(op, ..) => op.node.precedence(),
ExprKind::Cast(..) => ExprPrecedence::Cast,

ExprKind::Assign(..) |
ExprKind::AssignOp(..) => ExprPrecedence::Assign,
ExprKind::Assign(..) | ExprKind::AssignOp(..) => ExprPrecedence::Assign,

// Unary, prefix
ExprKind::AddrOf(..)
ExprKind::AddrOf(..) => ExprPrecedence::Prefix,

// Here `let pats = expr` has `let pats =` as a "unary" prefix of `expr`.
// However, this is not exactly right. When `let _ = a` is the LHS of a binop we
// need parens sometimes. E.g. we can print `(let _ = a) && b` as `let _ = a && b`
// but we need to print `(let _ = a) < b` as-is with parens.
| ExprKind::Let(..)
| ExprKind::Move(..)
| ExprKind::Unary(..) => ExprPrecedence::Prefix,
ExprKind::Let(..) | ExprKind::Move(..) | ExprKind::Unary(..) => ExprPrecedence::Prefix,

// Need parens if and only if there are prefix attributes.
ExprKind::Array(_)
Expand Down
47 changes: 23 additions & 24 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,10 @@ impl Token {
Lifetime(..) | // labeled loop
Pound => true, // expression attributes
OpenInvisible(InvisibleOrigin::MetaVar(
MetaVarKind::Block |
MetaVarKind::Expr { .. } |
MetaVarKind::Literal |
MetaVarKind::Path
MetaVarKind::Block
| MetaVarKind::Expr { .. }
| MetaVarKind::Literal
| MetaVarKind::Path,
)) => true,
_ => false,
}
Expand All @@ -717,12 +717,12 @@ impl Token {
Shl => true, // path (double UFCS)
Or => matches!(pat_kind, PatWithOr), // leading vert `|` or-pattern
OpenInvisible(InvisibleOrigin::MetaVar(
MetaVarKind::Expr { .. } |
MetaVarKind::Literal |
MetaVarKind::Meta { .. } |
MetaVarKind::Pat(_) |
MetaVarKind::Path |
MetaVarKind::Ty { .. }
MetaVarKind::Expr { .. }
| MetaVarKind::Literal
| MetaVarKind::Meta { .. }
| MetaVarKind::Pat(_)
| MetaVarKind::Path
| MetaVarKind::Ty { .. },
)) => true,
_ => false,
}
Expand All @@ -733,20 +733,19 @@ impl Token {
match self.uninterpolate().kind {
Ident(name, is_raw) =>
ident_can_begin_type(name, self.span, is_raw), // type name or keyword
OpenParen | // tuple
OpenBracket | // array
Bang | // never
Star | // raw pointer
And | // reference
AndAnd | // double reference
Question | // maybe bound in trait object
Lifetime(..) | // lifetime bound in trait object
Lt | Shl | // associated path
PathSep => true, // global path
OpenInvisible(InvisibleOrigin::MetaVar(
MetaVarKind::Ty { .. } |
MetaVarKind::Path
)) => true,
OpenParen // tuple
| OpenBracket // array
| Bang // never
| Star // raw pointer
| And // reference
| AndAnd // double reference
| Question // maybe bound in trait object
| Lifetime(..) // lifetime bound in trait object
| Lt | Shl // associated path
| PathSep => true, // global path
OpenInvisible(InvisibleOrigin::MetaVar(MetaVarKind::Ty { .. } | MetaVarKind::Path)) => {
true
}
// For anonymous structs or unions, which only appear in specific positions
// (type of struct fields or union fields), we don't consider them as regular types
_ => false,
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_borrowck/src/def_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ pub(crate) fn categorize(context: PlaceContext) -> Option<DefUse> {
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) |
PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) |
PlaceContext::MutatingUse(MutatingUseContext::Retag) =>
Some(DefUse::Use),
PlaceContext::MutatingUse(MutatingUseContext::Retag) => Some(DefUse::Use),

///////////////////////////////////////////////////////////////////////////
// DROP USES
Expand All @@ -70,9 +69,7 @@ pub(crate) fn categorize(context: PlaceContext) -> Option<DefUse> {
// call to `std::mem::drop()`). For the purposes of NLL,
// uses in drop are special because `#[may_dangle]`
// attributes can affect whether lifetimes must be live.

PlaceContext::MutatingUse(MutatingUseContext::Drop) =>
Some(DefUse::Drop),
PlaceContext::MutatingUse(MutatingUseContext::Drop) => Some(DefUse::Drop),

// Debug info is neither def nor use.
PlaceContext::NonUse(NonUseContext::VarDebugInfo) => None,
Expand Down
45 changes: 26 additions & 19 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,19 +833,21 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
NonDivergingIntrinsic::CopyNonOverlapping(..) => span_bug!(
span,
"Unexpected CopyNonOverlapping, should only appear after lower_intrinsics",
)
}
),
},
// Only relevant for mir typeck
StatementKind::AscribeUserType(..)
StatementKind::AscribeUserType(..) => {}
// Only relevant for liveness and unsafeck
| StatementKind::PlaceMention(..)
StatementKind::PlaceMention(..) => {}
// Doesn't have any language semantics
| StatementKind::Coverage(..)
StatementKind::Coverage(..) => {}
// These do not actually affect borrowck
| StatementKind::ConstEvalCounter
| StatementKind::StorageLive(..) => {}
StatementKind::ConstEvalCounter | StatementKind::StorageLive(..) => {}
// This does not affect borrowck
StatementKind::BackwardIncompatibleDropHint { place, reason: BackwardIncompatibleDropReason::Edition2024 } => {
StatementKind::BackwardIncompatibleDropHint {
place,
reason: BackwardIncompatibleDropReason::Edition2024,
} => {
self.check_backward_incompatible_drop(location, **place, state);
}
StatementKind::StorageDead(local) => {
Expand All @@ -857,8 +859,7 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
state,
);
}
StatementKind::Nop
| StatementKind::SetDiscriminant { .. } => {
StatementKind::Nop | StatementKind::SetDiscriminant { .. } => {
bug!("Statement not allowed in this MIR phase")
}
}
Expand Down Expand Up @@ -2238,15 +2239,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
// None case => assigning to `x` does not require `x` be initialized.
for (place_base, elem) in place.iter_projections().rev() {
match elem {
ProjectionElem::Index(_/*operand*/) |
ProjectionElem::OpaqueCast(_) |
ProjectionElem::ConstantIndex { .. } |
ProjectionElem::Index(_/*operand*/)
| ProjectionElem::OpaqueCast(_)
// assigning to P[i] requires P to be valid.
ProjectionElem::Downcast(_/*adt_def*/, _/*variant_idx*/) =>
| ProjectionElem::ConstantIndex { .. }
// assigning to (P->variant) is okay if assigning to `P` is okay
//
// FIXME: is this true even if P is an adt with a dtor?
{ }
| ProjectionElem::Downcast(_/*adt_def*/, _/*variant_idx*/) =>
{}

ProjectionElem::UnwrapUnsafeBinder(_) => {
check_parent_of_field(self, location, place_base, span, state);
Expand All @@ -2255,8 +2256,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
// assigning to (*P) requires P to be initialized
ProjectionElem::Deref => {
self.check_if_full_path_is_moved(
location, InitializationRequiringAction::Use,
(place_base, span), state);
location,
InitializationRequiringAction::Use,
(place_base, span),
state,
);
// (base initialized; no need to
// recur further)
break;
Expand All @@ -2275,8 +2279,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
match base_ty.kind() {
ty::Adt(def, _) if def.has_dtor(tcx) => {
self.check_if_path_or_subpath_is_moved(
location, InitializationRequiringAction::Assignment,
(place_base, span), state);
location,
InitializationRequiringAction::Assignment,
(place_base, span),
state,
);

// (base initialized; no need to
// recur further)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'a, 'tcx> {
StatementKind::Intrinsic(NonDivergingIntrinsic::Assume(op)) => {
self.consume_operand(location, op);
}
StatementKind::Intrinsic(NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
src,
dst,
count,
})) => {
StatementKind::Intrinsic(NonDivergingIntrinsic::CopyNonOverlapping(
CopyNonOverlapping { src, dst, count },
)) => {
self.consume_operand(location, src);
self.consume_operand(location, dst);
self.consume_operand(location, count);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use rustc_lint_defs::builtin::LINKER_INFO;
use rustc_macros::{Decodable, Encodable};
use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::lint::LevelSpec;
use rustc_middle::lint::StableLevelSpec;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Dependencies;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
Expand Down Expand Up @@ -342,8 +342,8 @@ impl CompiledModules {
/// Instead, encode exactly the information we need.
#[derive(Copy, Clone, Debug, Encodable, Decodable)]
pub struct CodegenLintLevelSpecs {
linker_messages: LevelSpec,
linker_info: LevelSpec,
linker_messages: StableLevelSpec,
linker_info: StableLevelSpec,
}

impl CodegenLintLevelSpecs {
Expand Down
33 changes: 23 additions & 10 deletions compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
OperandValue::Pair(lldata, llextra)
}
mir::CastKind::PointerCoercion(
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer, _
PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer,
_,
) => {
bug!("{kind:?} is for borrowck, and should never appear in codegen");
}
mir::CastKind::PtrToPtr
if bx.cx().is_backend_scalar_pair(operand.layout) =>
{
mir::CastKind::PtrToPtr if bx.cx().is_backend_scalar_pair(operand.layout) => {
if let OperandValue::Pair(data_ptr, meta) = operand.val {
if bx.cx().is_backend_scalar_pair(cast) {
OperandValue::Pair(data_ptr, meta)
Expand All @@ -483,7 +482,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// path as the other integer-to-X casts.
| mir::CastKind::PointerWithExposedProvenance => {
let imm = operand.immediate();
let abi::BackendRepr::Scalar(from_scalar) = operand.layout.backend_repr else {
let abi::BackendRepr::Scalar(from_scalar) = operand.layout.backend_repr
else {
bug!("Found non-scalar for operand {operand:?}");
};
let from_backend_ty = bx.cx().immediate_backend_type(operand.layout);
Expand All @@ -498,11 +498,18 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
bug!("Found non-scalar for cast {cast:?}");
};

self.cast_immediate(bx, imm, from_scalar, from_backend_ty, to_scalar, to_backend_ty)
.map(OperandValue::Immediate)
.unwrap_or_else(|| {
bug!("Unsupported cast of {operand:?} to {cast:?}");
})
self.cast_immediate(
bx,
imm,
from_scalar,
from_backend_ty,
to_scalar,
to_backend_ty,
)
.map(OperandValue::Immediate)
.unwrap_or_else(|| {
bug!("Unsupported cast of {operand:?} to {cast:?}");
})
}
mir::CastKind::Transmute | mir::CastKind::Subtype => {
self.codegen_transmute_operand(bx, operand, cast)
Expand Down Expand Up @@ -553,6 +560,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
move_annotation: None,
}
}

mir::Rvalue::BinaryOp(op, (ref lhs, ref rhs)) => {
let lhs = self.codegen_operand(bx, lhs);
let rhs = self.codegen_operand(bx, rhs);
Expand Down Expand Up @@ -666,7 +674,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
};
OperandRef { val: OperandValue::Immediate(static_), layout, move_annotation: None }
}

mir::Rvalue::Use(ref operand, _) => self.codegen_operand(bx, operand),

mir::Rvalue::Repeat(ref elem, len_const) => {
// All arrays have `BackendRepr::Memory`, so only the ZST cases
// end up here. Anything else forces the destination local to be
Expand All @@ -682,6 +692,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
move_annotation: None,
}
}

mir::Rvalue::Aggregate(ref kind, ref fields) => {
let (variant_index, active_field_index) = match **kind {
mir::AggregateKind::Adt(_, variant_index, _, _, active_field_index) => {
Expand Down Expand Up @@ -719,12 +730,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}
}

mir::Rvalue::WrapUnsafeBinder(ref operand, binder_ty) => {
let operand = self.codegen_operand(bx, operand);
let binder_ty = self.monomorphize(binder_ty);
let layout = bx.cx().layout_of(binder_ty);
OperandRef { val: operand.val, layout, move_annotation: None }
}

mir::Rvalue::CopyForDeref(_) => bug!("`CopyForDeref` in codegen"),
}
}
Expand Down
Loading
Loading