Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
621507f
Partially revert previous wrong fix and do some hack instead
ShoyuVanilla Sep 14, 2026
d7cf3cb
only rerun const eval if the const actually references opaques
sjwang05 Aug 16, 2026
550132c
run replace-version-placeholder
Mark-Simulacrum Sep 27, 2026
3b3eeb4
bump-stage0 to 1.100 beta
Mark-Simulacrum Sep 29, 2026
4c11abb
Step cfg(bootstrap)
Mark-Simulacrum Sep 29, 2026
1161c07
Some refactorings around metadata encoding
aerooneqq Sep 30, 2026
7c35df5
Remove #[linkage = "internal"]
bjorn3 Sep 27, 2026
6d02b77
Remove #[linkage = "external"]
bjorn3 Sep 27, 2026
d731eda
Remove #[linkage = "common"]
bjorn3 Sep 27, 2026
3c67da6
Cover macro export on macro_rules definitions
darkraider01 Sep 30, 2026
7f542b6
Check declarative macro exports during attribute finalization
darkraider01 Sep 30, 2026
bf2b89c
Format macro export finalization check
darkraider01 Sep 30, 2026
daa2432
Re-bless tests / adjust for new Cargo lints
Mark-Simulacrum Sep 29, 2026
1ea0af2
Skip deferred attribute checks when not emitting
darkraider01 Sep 30, 2026
82366d5
Provide better doc code example for UnixDatagram::bind_addr and UnixL…
asder8215 Oct 1, 2026
0e70786
ping me for debugger visualizer changes
Walnut356 Oct 1, 2026
1dae79f
add test for overcapture suggestion inside attribute macro expansion
Albab-Hasan Oct 1, 2026
057e810
do not suggest precise capturing when the opaque span is inside a mac…
Albab-Hasan Oct 1, 2026
212c962
Rollup merge of #163483 - Mark-Simulacrum:bootstrap-bump, r=oli-obk
JonathanBrouwer Oct 1, 2026
571f880
Rollup merge of #161380 - sjwang05:retry-consteval-less, r=jdonszelmann
JonathanBrouwer Oct 1, 2026
01c0698
Rollup merge of #162900 - aerooneqq:record-tables-through-macros, r=p…
JonathanBrouwer Oct 1, 2026
5818707
Rollup merge of #163580 - asder8215:unix_sockets_bind_addr_docs, r=Da…
JonathanBrouwer Oct 1, 2026
168bc0b
Rollup merge of #163584 - Walnut356:ping, r=lqd
JonathanBrouwer Oct 1, 2026
26cc99d
Rollup merge of #162782 - ShoyuVanilla:issue-162557, r=lcnr
JonathanBrouwer Oct 1, 2026
8a05bc0
Rollup merge of #163314 - darkraider01:check-macro-export, r=Jonathan…
JonathanBrouwer Oct 1, 2026
6726513
Rollup merge of #163405 - bjorn3:less_linkage_options, r=lqd
JonathanBrouwer Oct 1, 2026
1af6efa
Rollup merge of #163581 - Albab-Hasan:no-use-bound-suggestion-in-macr…
JonathanBrouwer Oct 1, 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: 0 additions & 2 deletions compiler/rustc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`.
#![feature(rustc_private)]
// Several crates are depended upon but unused so that they are present in the sysroot
#![expect(unused_crate_dependencies)]

use std::process::ExitCode;

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// tidy-alphabetical-start
#![allow(clippy::mut_from_ref)] // Arena allocators are one place where this pattern is fine.
#![allow(internal_features)]
#![cfg_attr(bootstrap, feature(never_type))]
#![cfg_attr(bootstrap, feature(unwrap_infallible))]
#![cfg_attr(test, feature(test))]
#![deny(unsafe_op_in_unsafe_fn)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

// tidy-alphabetical-start
#![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", cfg_attr(bootstrap, feature(never_type)))]
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
// tidy-alphabetical-end

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_ir/src/attribute_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ macro_rules! include_example {
};
}

#[cfg_attr(not(bootstrap), doc(attribute = "rustc_dump_clauses"))]
#[doc(attribute = "rustc_dump_clauses")]
/// Dumps the list of [`ty::Clause`]s as computed by the [`clauses_of`] query.
///
/// See [`AttributeKind::RustcDumpClauses`] for the internal representation of this attribute.
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
1 change: 0 additions & 1 deletion compiler/rustc_attr_ir/src/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ impl AttributeKind {
Linkage(linkage, _) => match *linkage {
crate::Linkage::Internal => false,
crate::Linkage::AvailableExternally
| crate::Linkage::Common
| crate::Linkage::External
| crate::Linkage::ExternalWeak
| crate::Linkage::LinkOnceAny
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 @@ -685,10 +685,7 @@ impl SingleAttributeParser for LinkageParser {
]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: [
"available_externally",
"common",
"extern_weak",
"external",
"internal",
"linkonce",
"linkonce_odr",
"weak",
Expand All @@ -711,10 +708,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 @@ -725,10 +719,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: 17 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use rustc_ast::ItemKind;
use rustc_attr_ir::{MacroUseArgs, find_attr};
use rustc_feature::AttributeStability;
use rustc_lint_defs::builtin::INVALID_MACRO_EXPORT_ARGUMENTS;
use rustc_lint_defs::builtin::{INVALID_MACRO_EXPORT_ARGUMENTS, UNUSED_ATTRIBUTES};
use rustc_structures::CollapseMacroDebuginfo;

use super::prelude::*;
use crate::diagnostics::MacroOnlyAttribute;
use crate::diagnostics::{MacroExport, MacroOnlyAttribute};

pub(crate) struct MacroEscapeParser;
impl NoArgsAttributeParser for MacroEscapeParser {
Expand Down Expand Up @@ -175,8 +176,22 @@ impl SingleAttributeParser for MacroExportParser {
return None;
}
};

Some(AttributeKind::MacroExport { span: cx.attr_span, local_inner_macros })
}

fn finalize_check(cx: &mut FinalizeCheckContext<'_, '_>, attr_span: Span) {
if cx.target != Target::MacroDef {
return;
}

let item = cx.target_item.unwrap();
if let ItemKind::MacroDef(_, macro_def) = &item.kind
&& !macro_def.macro_rules
{
cx.emit_lint(UNUSED_ATTRIBUTES, MacroExport::OnDeclMacro, attr_span);
}
}
}

pub(crate) struct CollapseDebugInfoParser;
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2070,3 +2070,10 @@ pub(crate) struct UnusedDuplicate {
)]
pub warning: bool,
}

#[derive(Diagnostic)]
pub(crate) enum MacroExport {
#[diag("`#[macro_export]` has no effect on declarative macro definitions")]
#[note("declarative macros follow the same exporting rules as regular items")]
OnDeclMacro,
}
34 changes: 18 additions & 16 deletions compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,23 +510,25 @@ impl<'sess> AttributeParser<'sess> {

// Now that all attributes have been parsed, run the deferred checks. These can
// inspect the fully parsed attributes via `FinalizeCheckContext::parsed_attrs`.
for (check, attr_span) in deferred_checks {
check(
&mut FinalizeCheckContext {
shared: SharedContext {
cx: self,
target_span,
target,
emit_lint: &mut emit_lint,
#[cfg(debug_assertions)]
has_lint_been_emitted: AtomicBool::new(false),
if !matches!(self.should_emit, ShouldEmit::Nothing) {
for (check, attr_span) in deferred_checks {
check(
&mut FinalizeCheckContext {
shared: SharedContext {
cx: self,
target_span,
target,
emit_lint: &mut emit_lint,
#[cfg(debug_assertions)]
has_lint_been_emitted: AtomicBool::new(false),
},
all_attrs: &attr_paths,
parsed_attrs: &attributes,
target_item,
},
all_attrs: &attr_paths,
parsed_attrs: &attributes,
target_item,
},
attr_span,
);
attr_span,
);
}
}

if !matches!(self.should_emit, ShouldEmit::Nothing) && target == Target::WherePredicate {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(default_field_values)]
#![feature(deref_patterns)]
#![feature(file_buffered)]
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
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_gcc/tests/c/import_linkage.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

#include <stdint.h>

int32_t external_value = 1;
int32_t available_externally_value = 2;
int32_t linkonce_value = 3;
int32_t linkonce_odr_value = 4;
int32_t weak_value = 5;
int32_t weak_odr_value = 6;
int32_t common_value = 7;
int32_t extern_weak_value = 8;
int32_t internal_value = 9;
11 changes: 1 addition & 10 deletions compiler/rustc_codegen_gcc/tests/c/static_linkage.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
/* Strong definitions of the statics that `tests/run/static_linkage.rs` also defines, but weakly.
* The linker has to keep these and drop the Rust ones; a backend that emits the Rust definitions
* as ordinary global symbols fails the link with a duplicate definition instead.
*
* `internal_static` is the opposite case: the Rust side keeps its own, and the two definitions
* coexist because the Rust one is local. */
* as ordinary global symbols fails the link with a duplicate definition instead. */

#include <stdint.h>

int32_t weak_static = 1;
int32_t weak_odr_static = 2;
int32_t linkonce_static = 3;
int32_t linkonce_odr_static = 4;
int32_t common_static = 5;
int32_t internal_static = 200;

/* `available_externally` promises the real definition lives elsewhere: a backend may read this one
* or emit an equivalent copy of the Rust initializer, so the two have to hold the same value. */
Expand All @@ -29,9 +24,5 @@ int32_t c_read_all(void)
return 13;
if (linkonce_odr_static != 4)
return 14;
if (common_static != 5)
return 15;
if (internal_static != 200)
return 16;
return 0;
}
18 changes: 0 additions & 18 deletions compiler/rustc_codegen_gcc/tests/run/import_linkage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ extern crate mini_core;
use mini_core::*;

extern "C" {
#[linkage = "external"]
static external_value: *const i32;
#[linkage = "available_externally"]
static available_externally_value: *const i32;
#[linkage = "linkonce"]
Expand All @@ -31,15 +29,8 @@ extern "C" {
static weak_value: *const i32;
#[linkage = "weak_odr"]
static weak_odr_value: *const i32;
#[linkage = "common"]
static common_value: *const i32;
#[linkage = "extern_weak"]
static extern_weak_value: *const i32;
// An import is an undefined reference whatever the flavour says. Upstream bug: rustc lowers
// this one to an internal declaration, which LLVM's verifier rejects ("Global is external, but
// doesn't have external or weak linkage!") and which crashes cg_llvm at -O3.
#[linkage = "internal"]
static internal_value: *const i32;

// Nothing defines this one, so it stays null instead of breaking the link.
#[linkage = "extern_weak"]
Expand All @@ -49,9 +40,6 @@ extern "C" {
#[no_mangle]
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
unsafe {
if *external_value != 1 {
return 1;
}
if *available_externally_value != 2 {
return 2;
}
Expand All @@ -67,15 +55,9 @@ extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
if *weak_odr_value != 6 {
return 6;
}
if *common_value != 7 {
return 7;
}
if *extern_weak_value != 8 {
return 8;
}
if *internal_value != 9 {
return 9;
}
if undefined_value as usize != 0 {
return 10;
}
Expand Down
Loading
Loading