Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 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
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
e1dfc38
Add `layout_of_` prefix to all the layout-calculating methods
ada4a Sep 26, 2026
cbe62ad
Remove #[linkage = "internal"]
bjorn3 Sep 27, 2026
94685f0
Implement Default for NumBuffer
tyilo Sep 27, 2026
e2badb9
Remove #[linkage = "external"]
bjorn3 Sep 27, 2026
cd52149
Remove #[linkage = "common"]
bjorn3 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
cabaab9
Rollup merge of #163085 - chenyukang:yukang-fix-131366-import-module-…
jhpratt Sep 27, 2026
15c3943
Rollup merge of #163098 - Walnut356:rc_usize, r=Mark-Simulacrum
jhpratt Sep 27, 2026
b479221
Rollup merge of #163120 - lambdageek:dont-hardcode-docker-layout, r=M…
jhpratt Sep 27, 2026
b5da342
Rollup merge of #163301 - chenyukang:yukang-fix-162843-unused-must-us…
jhpratt Sep 27, 2026
e3267e3
Rollup merge of #163307 - nnethercote:less-SpanData-in-diagnostics, r…
jhpratt Sep 27, 2026
74ff633
Rollup merge of #152972 - iAeternus:fix-vecdeque-partialeq-symmetry, …
jhpratt Sep 27, 2026
dd2c18d
Rollup merge of #162536 - tyilo:num-buffer-default, r=Mark-Simulacrum
jhpratt Sep 27, 2026
786cf04
Rollup merge of #163141 - yilin0518:fallback-safety-docs, r=Mark-Simu…
jhpratt Sep 27, 2026
f1f2384
Rollup merge of #163384 - ada4a:push-xlkootrrlxkt, r=nnethercote
jhpratt Sep 27, 2026
f6f68a9
Rollup merge of #163405 - bjorn3:less_linkage_options, r=lqd
jhpratt Sep 27, 2026
9c4968d
Rollup merge of #163413 - rosymati:mailmap-matilde-morrone, r=Jonatha…
jhpratt Sep 27, 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
1 change: 0 additions & 1 deletion compiler/rustc_attr_ir/src/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ impl<ScopeId> StrippedCfgItem<ScopeId> {
#[derive(StableHash, PrintAttribute)]
pub enum Linkage {
AvailableExternally,
Common,
ExternalWeak,
External,
Internal,
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_attr_parsing/src/attributes/link_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,7 @@ impl SingleAttributeParser for LinkageParser {
]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: [
"available_externally",
"common",
"extern_weak",
"external",
"internal",
"linkonce",
"linkonce_odr",
"weak",
Expand All @@ -686,10 +683,7 @@ impl SingleAttributeParser for LinkageParser {
// and don't have to be, LLVM treats them as no-ops.
let linkage = match value {
sym::available_externally => Linkage::AvailableExternally,
sym::common => Linkage::Common,
sym::extern_weak => Linkage::ExternalWeak,
sym::external => Linkage::External,
sym::internal => Linkage::Internal,
sym::linkonce => Linkage::LinkOnceAny,
sym::linkonce_odr => Linkage::LinkOnceODR,
sym::weak => Linkage::WeakAny,
Expand All @@ -700,10 +694,7 @@ impl SingleAttributeParser for LinkageParser {
name_value.value_span,
&[
sym::available_externally,
sym::common,
sym::extern_weak,
sym::external,
sym::internal,
sym::linkonce,
sym::linkonce_odr,
sym::weak,
Expand Down
19 changes: 4 additions & 15 deletions compiler/rustc_codegen_gcc/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,14 @@ pub fn global_linkage_to_gcc(linkage: Linkage) -> GlobalKind {
| Linkage::LinkOnceODR
| Linkage::WeakAny
| Linkage::WeakODR
| Linkage::ExternalWeak
| Linkage::Common => GlobalKind::Exported,
| Linkage::ExternalWeak => GlobalKind::Exported,
}
}

/// The attribute a global *definition* needs on top of its [`GlobalKind`] to get this linkage.
#[cfg(feature = "master")]
pub fn global_linkage_attribute<'gcc>(linkage: Linkage) -> Option<VarAttribute<'gcc>> {
match linkage {
Linkage::Common => Some(VarAttribute::Common),
_ if linkage_needs_weak_attribute(linkage) => Some(VarAttribute::Weak),
_ => None,
}
if linkage_needs_weak_attribute(linkage) { Some(VarAttribute::Weak) } else { None }
}

/// The type of a function *definition* with an explicit `#[linkage]`.
Expand All @@ -85,26 +80,20 @@ pub fn linkage_to_gcc(linkage: Linkage) -> FunctionType {
| Linkage::LinkOnceODR
| Linkage::WeakAny
| Linkage::WeakODR
| Linkage::ExternalWeak
| Linkage::Common => FunctionType::Exported,
| Linkage::ExternalWeak => FunctionType::Exported,
}
}

/// Whether a definition with this linkage must carry the `weak` attribute, so that a strong
/// definition in another object file wins over it instead of clashing with it.
///
/// `common` is in here for functions only: GCC honours that attribute on a variable, but drops it
/// on a function, so a common function falls back to weak. Globals go through
/// `global_linkage_attribute` instead.
#[cfg(feature = "master")]
pub fn linkage_needs_weak_attribute(linkage: Linkage) -> bool {
match linkage {
Linkage::LinkOnceAny
| Linkage::LinkOnceODR
| Linkage::WeakAny
| Linkage::WeakODR
| Linkage::ExternalWeak
| Linkage::Common => true,
| Linkage::ExternalWeak => true,
Linkage::External | Linkage::AvailableExternally | Linkage::Internal => false,
}
}
Expand Down
21 changes: 2 additions & 19 deletions compiler/rustc_codegen_gcc/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use rustc_hir::def_id::LOCAL_CRATE;
use rustc_log::tracing::trace;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::interpret::{
self, Allocation, ConstAllocation, CtfeProvenance, ErrorHandled, Scalar as InterpScalar,
read_target_uint,
self, ConstAllocation, CtfeProvenance, ErrorHandled, Scalar as InterpScalar, read_target_uint,
};
use rustc_middle::mono::MonoItem;
use rustc_middle::ty::layout::LayoutOf;
Expand Down Expand Up @@ -113,12 +112,7 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
// NOTE: Alignment from attributes has already been applied to the allocation.
set_global_alignment(self, global, alloc.align);

// A common symbol is storage the linker allocates and zero-fills, so giving the definition
// an initializer — even an all-zero one — takes it back out of `.comm`. A non-zero one is
// kept: the symbol is then an ordinary definition, which is what GCC does with it too.
if attrs.linkage != Some(Linkage::Common) || !is_zero_initializer(alloc) {
global.global_set_initializer_rvalue(value);
}
global.global_set_initializer_rvalue(value);

// As an optimization, all shared statics which do not have interior
// mutability are placed into read-only memory.
Expand Down Expand Up @@ -458,17 +452,6 @@ pub(crate) fn const_alloc_to_gcc_uncached<'gcc>(
cx.const_struct(&llvals, true)
}

/// Whether this allocation is all zeroes, and so needs no initializer to be spelled out.
fn is_zero_initializer(alloc: &Allocation) -> bool {
alloc.provenance().ptrs().is_empty()
// This `inspect` is okay: it is within the bounds of the allocation, there is no provenance
// to misread, and it does not affect interpreter execution.
&& alloc
.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.size().bytes_usize())
.iter()
.all(|&byte| byte == 0)
}

fn codegen_static_initializer<'gcc, 'tcx>(
cx: &CodegenCx<'gcc, 'tcx>,
def_id: DefId,
Expand Down
17 changes: 7 additions & 10 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_fs_util::{link_or_copy, path_to_c_string};
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_session::config::{self, Lto, OutputType, Passes, SplitDwarfKind, SwitchWithOptPath};
use rustc_span::{BytePos, InnerSpan, Pos, RemapPathScopeComponents, SpanData, SyntaxContext};
use rustc_span::{BytePos, DUMMY_SP, InnerSpan, Pos, RemapPathScopeComponents};
use rustc_target::spec::{CodeModel, FloatAbi, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel};
use tracing::{debug, trace};

Expand Down Expand Up @@ -406,23 +406,20 @@ fn report_inline_asm(
// In LTO build we may get srcloc values from other crates which are invalid
// since they use a different source map. To be safe we just suppress these
// in LTO builds.
let span = if cookie == 0 || matches!(cgcx.lto, Lto::Fat | Lto::Thin) {
SpanData::default()
let (lo, hi) = if cookie == 0 || matches!(cgcx.lto, Lto::Fat | Lto::Thin) {
(DUMMY_SP.lo(), DUMMY_SP.hi())
} else {
SpanData {
lo: BytePos::from_u32(cookie as u32),
hi: BytePos::from_u32((cookie >> 32) as u32),
ctxt: SyntaxContext::root(),
parent: None,
}
let lo = BytePos::from_u32(cookie as u32);
let hi = BytePos::from_u32((cookie >> 32) as u32);
(lo, hi)
};
let level = match level {
llvm::DiagnosticLevel::Error => Level::Error,
llvm::DiagnosticLevel::Warning => Level::Warning(None),
llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note,
};
let msg = msg.trim_prefix("error: ").to_string();
InlineAsmError { span, msg, level, source }
InlineAsmError { lo, hi, msg, level, source }
}

unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ pub(crate) fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
Linkage::WeakODR => llvm::Linkage::WeakODRLinkage,
Linkage::Internal => llvm::Linkage::InternalLinkage,
Linkage::ExternalWeak => llvm::Linkage::ExternalWeakLinkage,
Linkage::Common => llvm::Linkage::CommonLinkage,
}
}

Expand Down
Loading
Loading