Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
835975a
alloc: make VecDeque partial equality symmetric with vec/slice/array
iAeternus Feb 22, 2026
b50d79a
resolve too_generic_eval_ice stderr conflict
iAeternus Feb 23, 2026
8cdd010
update assert-ne-no-invalid-help-issue-146204.stderr for VecDeque Par…
iAeternus Aug 25, 2026
3d3f2f8
update VecDeque PartialEq stability metadata
iAeternus Sep 18, 2026
9942d36
fix stability attributes for VecDeque PartialEq impls
iAeternus Sep 19, 2026
73bafeb
Add regression tests for import module typo suggestions
chenyukang Sep 13, 2026
02db8ad
Suggest similarly named modules in import paths
chenyukang Sep 13, 2026
b799651
add workaround to read `Rc` strong/weak counts
Walnut356 Sep 21, 2026
b2894fa
ci: make musl.sh look for patches next to the script
lambdageek Sep 21, 2026
398b396
Document safety requirements for intrinsic fallbacks
yilin0518 Sep 22, 2026
391ff91
Add regression test for lock guard must-use suggestions
chenyukang Sep 25, 2026
e473975
Remove `rustc_codegen_ssa::back::write::Diagnostic`
nnethercote Sep 25, 2026
f01eea5
Remove the `SpanData` in `InlineAsmError`
nnethercote Sep 25, 2026
d35f696
fix unused_must_use suggestion for scenario which may need to keep value
chenyukang Sep 25, 2026
8f40c2a
Filter with accessbility before find match for name
chenyukang Sep 21, 2026
46d3d7e
introduce `generic_param_to_arg` helper
cyrgani Sep 26, 2026
284af39
Use a let-chain
ada4a Sep 26, 2026
d2b3f9b
Remove needless laziness
ada4a Sep 26, 2026
6c333a9
Move complex clauses to the where clause
ada4a Sep 26, 2026
12f4d4e
remove the `path!` macro
cyrgani Sep 26, 2026
345eb2c
add `generics_without_defaults` helper
cyrgani Sep 26, 2026
d9b202f
add `item_trait_impl` helper
cyrgani Sep 26, 2026
d2ed22f
remove redundant span argument
cyrgani Sep 24, 2026
dc45d5d
remove entirely unused `cx` methods
cyrgani Sep 24, 2026
e1dfc38
Add `layout_of_` prefix to all the layout-calculating methods
ada4a Sep 26, 2026
fe4b0c6
utilize the `cx` helpers where possible
cyrgani Sep 26, 2026
063fab4
rename "lambda" to "closure"
cyrgani Sep 25, 2026
7698a86
remove trivial type annotations
cyrgani Sep 26, 2026
fe9b2e9
move `std_path` to `build.rs`, remove unused `def_site_path`
cyrgani Sep 26, 2026
529a0ae
cleanup some `Vec`s in autodiff.rs
cyrgani Sep 27, 2026
94685f0
Implement Default for NumBuffer
tyilo Sep 27, 2026
37c0ed5
Add docs
ada4a Sep 26, 2026
0858ecd
`layout_of_struct`: rename the `present_first` param
ada4a Sep 26, 2026
6668485
introduce `NicheOptimizations`
ada4a Sep 26, 2026
dfa855c
mailmap: add Matilde Morrone
rosymati Sep 27, 2026
5f7b6be
Rollup merge of #163085 - chenyukang:yukang-fix-131366-import-module-…
jhpratt Sep 28, 2026
682cbc4
Rollup merge of #163098 - Walnut356:rc_usize, r=Mark-Simulacrum
jhpratt Sep 28, 2026
41e63a3
Rollup merge of #163120 - lambdageek:dont-hardcode-docker-layout, r=M…
jhpratt Sep 28, 2026
2b42eed
Rollup merge of #163301 - chenyukang:yukang-fix-162843-unused-must-us…
jhpratt Sep 28, 2026
1d6d8b8
Rollup merge of #163307 - nnethercote:less-SpanData-in-diagnostics, r…
jhpratt Sep 28, 2026
2382266
Rollup merge of #163389 - cyrgani:builtin-macros-7, r=nnethercote
jhpratt Sep 28, 2026
3d54fac
Rollup merge of #152972 - iAeternus:fix-vecdeque-partialeq-symmetry, …
jhpratt Sep 28, 2026
22c22b5
Rollup merge of #162536 - tyilo:num-buffer-default, r=Mark-Simulacrum
jhpratt Sep 28, 2026
1c3acf1
Rollup merge of #163141 - yilin0518:fallback-safety-docs, r=Mark-Simu…
jhpratt Sep 28, 2026
66ea879
Rollup merge of #163384 - ada4a:push-xlkootrrlxkt, r=nnethercote
jhpratt Sep 28, 2026
f53ebb9
Rollup merge of #163413 - rosymati:mailmap-matilde-morrone, r=Jonatha…
jhpratt Sep 28, 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
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ Mateusz Mikuła <oss@mateuszmikula.dev>
Mateusz Mikuła <oss@mateuszmikula.dev> <mati865@gmail.com>
Mateusz Mikuła <oss@mateuszmikula.dev> <mati865@users.noreply.github.com>
Mateusz Mikuła <oss@mateuszmikula.dev> <matti@marinelayer.io>
Matilde Morrone <contact@rosymati.com> <contact@matilde.pet>
Matilde Morrone <contact@rosymati.com> <contact@morrone.dev>
Matt Brubeck <mbrubeck@limpet.net> <mbrubeck@cs.hmc.edu>
Matthew Auld <matthew.auld@intel.com>
Matthew Jasper <mjjasper1@gmail.com>
Expand Down
261 changes: 130 additions & 131 deletions compiler/rustc_abi/src/layout.rs

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions compiler/rustc_abi/src/layout/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,20 @@ fn coroutine_saved_local_eligibility<VariantIdx: Idx, FieldIdx: Idx, LocalIdx: I
}

/// Compute the full coroutine layout.
pub(super) fn layout<
'a,
F: core::ops::Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + core::fmt::Debug + Copy,
VariantIdx: Idx,
FieldIdx: Idx,
LocalIdx: Idx,
>(
pub(super) fn layout<'a, F, VariantIdx, FieldIdx, LocalIdx>(
calc: &super::LayoutCalculator<impl HasDataLayout>,
local_layouts: &IndexSlice<LocalIdx, F>,
mut prefix_layouts: IndexVec<FieldIdx, F>,
variant_fields: &IndexSlice<VariantIdx, IndexVec<FieldIdx, LocalIdx>>,
storage_conflicts: &BitMatrix<LocalIdx, LocalIdx>,
tag_to_layout: impl Fn(Scalar) -> F,
) -> super::LayoutCalculatorResult<FieldIdx, VariantIdx, F> {
) -> super::LayoutCalculatorResult<FieldIdx, VariantIdx, F>
where
F: core::ops::Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + core::fmt::Debug + Copy,
VariantIdx: Idx,
FieldIdx: Idx,
LocalIdx: Idx,
{
use SavedLocalEligibility::*;

let (ineligible_locals, assignments) =
Expand All @@ -171,8 +171,11 @@ pub(super) fn layout<
let promoted_layouts = ineligible_locals.iter().map(|local| local_layouts[local]);
prefix_layouts.push(tag_to_layout(tag));
prefix_layouts.extend(promoted_layouts);
let prefix =
calc.univariant(&prefix_layouts, &ReprOptions::default(), StructKind::AlwaysSized)?;
let prefix = calc.layout_of_univariant(
&prefix_layouts,
&ReprOptions::default(),
StructKind::AlwaysSized,
)?;

let (prefix_size, prefix_align) = (prefix.size, prefix.align);

Expand Down Expand Up @@ -225,7 +228,7 @@ pub(super) fn layout<
})
.map(|local| local_layouts[*local]);

let mut variant = calc.univariant(
let mut variant = calc.layout_of_univariant(
&variant_only_tys.collect::<IndexVec<_, _>>(),
&ReprOptions::default(),
StructKind::Prefixed(prefix_size, prefix_align.abi),
Expand Down
16 changes: 14 additions & 2 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2027,10 +2027,10 @@ pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {
/// 2. the never type
Empty,

/// The type has a single valid variant.
/// The type has a single valid variant. Such types are called "univariant".
///
/// This is the case for:
/// 1. enums with a single inhabited variant
/// 1. enums with a single inhabited variant, aka. "univariant enums"
/// 2. structs, unions, and non-ADTs (except coroutines; see below),
/// as those can't have multiple variants
Single {
Expand Down Expand Up @@ -2195,6 +2195,18 @@ impl Niche {
}
}

/// Whether niche optimizations should be performed during layout calculation.
///
/// [`UnsafeCell`] and [`UnsafePinned`] both disable niche optimizations.
///
/// [`UnsafeCell`]: std::cell::UnsafeCell
/// [`UnsafePinned`]: std::pin::UnsafePinned
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum NicheOptimizations {
Enabled,
Disabled,
}

// NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage.
#[derive(PartialEq, Eq, Hash, Clone)]
#[cfg_attr(feature = "nightly", derive(StableHash))]
Expand Down
32 changes: 7 additions & 25 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,7 @@ pub(super) fn expand_asm<'cx>(
return ExpandResult::Retry(());
};
let expr = match mac {
Ok(inline_asm) => Box::new(ast::Expr {
id: ast::DUMMY_NODE_ID,
kind: ast::ExprKind::InlineAsm(Box::new(inline_asm)),
span: sp,
attrs: ast::AttrVec::new(),
tokens: None,
}),
Ok(inline_asm) => ecx.expr(sp, ast::ExprKind::InlineAsm(Box::new(inline_asm))),
Err(guar) => DummyResult::raw_expr(sp, Some(guar)),
};
MacEager::expr(expr)
Expand All @@ -618,13 +612,7 @@ pub(super) fn expand_naked_asm<'cx>(
return ExpandResult::Retry(());
};
let expr = match mac {
Ok(inline_asm) => Box::new(ast::Expr {
id: ast::DUMMY_NODE_ID,
kind: ast::ExprKind::InlineAsm(Box::new(inline_asm)),
span: sp,
attrs: ast::AttrVec::new(),
tokens: None,
}),
Ok(inline_asm) => ecx.expr(sp, ast::ExprKind::InlineAsm(Box::new(inline_asm))),
Err(guar) => DummyResult::raw_expr(sp, Some(guar)),
};
MacEager::expr(expr)
Expand All @@ -648,17 +636,11 @@ pub(super) fn expand_global_asm<'cx>(
return ExpandResult::Retry(());
};
match mac {
Ok(inline_asm) => MacEager::items(smallvec![Box::new(ast::Item {
attrs: ast::AttrVec::new(),
id: ast::DUMMY_NODE_ID,
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
vis: ast::Visibility {
span: sp.shrink_to_lo(),
kind: ast::VisibilityKind::Inherited,
},
span: sp,
tokens: None,
})]),
Ok(inline_asm) => MacEager::items(smallvec![ecx.item(
sp,
ast::AttrVec::new(),
ast::ItemKind::GlobalAsm(Box::new(inline_asm))
)]),
Err(guar) => DummyResult::any(sp, guar),
}
}
Expand Down
24 changes: 5 additions & 19 deletions compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mod context;

use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp, token};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{Expr, ExprKind, Path, UnOp, token};
use rustc_ast_pretty::pprust;
use rustc_errors::PResult;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
Expand Down Expand Up @@ -34,14 +34,7 @@ pub(crate) fn expand_assert<'cx>(
let panic_path = || {
if use_panic_2021(span) {
// On edition 2021, we always call `$crate::panic::panic_2021!()`.
Path {
span: call_site_span,
segments: cx
.std_path(&[sym::panic, sym::panic_2021])
.into_iter()
.map(PathSegment::from_ident)
.collect(),
}
cx.path(call_site_span, cx.std_path(&[sym::panic, sym::panic_2021]))
} else {
// Before edition 2021, we call `panic!()` unqualified,
// such that it calls either `std::panic!()` or `core::panic!()`.
Expand All @@ -51,16 +44,9 @@ pub(crate) fn expand_assert<'cx>(

// Simply uses the user provided message instead of generating custom outputs
let expr = if let Some(tokens) = custom_message {
let then = cx.expr(
let then = cx.expr_macro_call(
call_site_span,
ExprKind::MacCall(Box::new(MacCall {
path: panic_path(),
args: Box::new(DelimArgs {
dspan: DelimSpan::from_single(call_site_span),
delim: Delimiter::Parenthesis,
tokens,
}),
})),
cx.macro_call(call_site_span, panic_path(), Delimiter::Parenthesis, tokens),
);
expr_if_not(cx, call_site_span, cond_expr, then, None)
}
Expand Down
31 changes: 6 additions & 25 deletions compiler/rustc_builtin_macros/src/assert/context.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use rustc_ast::token::{self, Delimiter, IdentKind};
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
use rustc_ast::{
BinOpKind, BorrowKind, DUMMY_NODE_ID, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall,
Mutability, Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeAndId, UseTreeKind,
BinOpKind, BorrowKind, DUMMY_NODE_ID, DelimArgs, Expr, ExprKind, ItemKind, MacCall, Mutability,
Path, Stmt, StructRest, UnOp, UseTree, UseTreeAndId, UseTreeKind,
};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
Expand Down Expand Up @@ -382,20 +382,15 @@ impl<'cx, 'a> Context<'cx, 'a> {
);
let try_capture_call = self
.cx
.stmt_expr(expr_method_call(
self.cx,
PathSegment {
args: None,
id: DUMMY_NODE_ID,
ident: Ident::new(sym::try_capture, self.span),
},
expr_paren(self.cx, self.span, self.cx.expr_addr_of(self.span, wrapper)),
.stmt_expr(self.cx.expr_method_call(
self.span,
self.cx.expr_paren(self.span, self.cx.expr_addr_of(self.span, wrapper)),
Ident::new(sym::try_capture, self.span),
thin_vec![expr_addr_of_mut(
self.cx,
self.span,
self.cx.expr_path(Path::from_ident(capture)),
)],
self.span,
))
.add_trailing_semicolon();
let local_bind_path = self.cx.expr_path(Path::from_ident(local_bind));
Expand Down Expand Up @@ -448,17 +443,3 @@ fn escape_to_fmt(s: &str) -> String {
fn expr_addr_of_mut(cx: &ExtCtxt<'_>, sp: Span, e: Box<Expr>) -> Box<Expr> {
cx.expr(sp, ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, e))
}

fn expr_method_call(
cx: &ExtCtxt<'_>,
seg: PathSegment,
receiver: Box<Expr>,
args: ThinVec<Box<Expr>>,
span: Span,
) -> Box<Expr> {
cx.expr(span, ExprKind::MethodCall(Box::new(MethodCall { seg, receiver, args, span })))
}

fn expr_paren(cx: &ExtCtxt<'_>, sp: Span, e: Box<Expr>) -> Box<Expr> {
cx.expr(sp, ExprKind::Paren(e))
}
Loading
Loading