Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2e46fb4
Merge commit 'ffb7eef504d4d9507583825e8e411d283c4e357e'
GuillaumeGomez Sep 24, 2026
176156b
Merge branch 'master' into sync_from_rust_2026_09_24
antoyo Sep 24, 2026
48cd117
Merge pull request #985 from rust-lang/sync_from_rust_2026_09_24
antoyo Sep 24, 2026
1ff212e
Support -Z merge-functions with gcc and add stack-protector asm tests
Sep 24, 2026
26c112b
address comments by bjorn3
Sep 24, 2026
bab2d83
compiler: remove rustc_hir attr re-exports
mejrs Sep 24, 2026
4b77474
Rollup merge of #163250 - mejrs:hir_imports3, r=JonathanBrouwer
JonathanBrouwer Sep 27, 2026
a048dfd
chore: use r-l/r zulip linkifier for r-l/r rustfmt backport nominations
jieyouxu Sep 29, 2026
e2809b4
Remove #[linkage = "internal"]
bjorn3 Sep 27, 2026
561aa2d
Remove #[linkage = "external"]
bjorn3 Sep 27, 2026
7cf9480
Remove #[linkage = "common"]
bjorn3 Sep 27, 2026
e054cb5
Update gccjit.rs version
antoyo Sep 29, 2026
ef0c7b7
Merge pull request #986 from rust-lang/update-gccjit
antoyo Sep 29, 2026
768500b
Add support for span context to `derive(Diagnostic)`
estebank Sep 27, 2026
c5f17f6
Point at enclosing item(s) on unexpected item type
estebank Sep 27, 2026
1ab22ea
Show trait/impl for duplicate impl associated items
estebank Sep 27, 2026
be0d432
Point at trait/impl on associated item mismatch
estebank Sep 27, 2026
246eb14
On `impl` item signature mismatch, point at impl and trait
estebank Sep 27, 2026
9adacb1
Merge branch 'master' into sync-2026-09-29
GuillaumeGomez Sep 29, 2026
852ac9e
Update rust-toolchain version needed
GuillaumeGomez Sep 29, 2026
99055ee
Revert "Rollup merge of #120589 - devnexen:cpuaff_fbsd_upd, r=clarfon…
devnexen Sep 29, 2026
10448a3
Fix panic when casting from i128 to f16
antoyo Sep 29, 2026
b3cf6a5
Install rustfmt stdarch CI workflow
antoyo Sep 29, 2026
0317026
impl std::fs::{Home|Media}Dirs
CAD97 Aug 31, 2026
7d0907e
arch::breakpoint: update documentation
RalfJung Sep 29, 2026
8c858fb
Merge pull request #987 from GuillaumeGomez/sync
antoyo Sep 29, 2026
707f1c5
update breakpoint asm test
RalfJung Sep 29, 2026
71d1c02
Merge commit '8c858fb5fbb077eaa776302b9601cf084f12aa46' into HEAD
GuillaumeGomez Sep 29, 2026
86c9cc2
Rollup merge of #158936 - CAD97:dirs, r=aapoalas
tgross35 Sep 30, 2026
98aac66
Rollup merge of #163414 - estebank:derive-diagnostic-context, r=petro…
tgross35 Sep 30, 2026
8483000
Rollup merge of #163481 - jieyouxu:jieyouxu/rustfmt-backport-nom, r=y…
tgross35 Sep 30, 2026
7fbca0c
Rollup merge of #163502 - RalfJung:breakpoint, r=tgross35
tgross35 Sep 30, 2026
8fd18a6
Rollup merge of #163505 - GuillaumeGomez:sync-2026-09-29, r=antoyo
tgross35 Sep 30, 2026
80b296f
Rollup merge of #163405 - bjorn3:less_linkage_options, r=lqd
tgross35 Sep 30, 2026
0de9155
Rollup merge of #163498 - devnexen:revert_120589, r=clarfonthey
tgross35 Sep 30, 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
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
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_gcc/.github/workflows/stdarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
- name: Setup rust toolchain
run: rustup show

# The stdarch-gen-common tests run rustfmt.
- name: Install rustfmt
run: rustup component add rustfmt

- name: Setup rust cache
uses: Swatinem/rust-cache@v2

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ dependencies = [

[[package]]
name = "gccjit"
version = "6.1.0"
version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d85b5754389edaad832ba320709a25086b3081a8c6c0fab2322965e5fb512b3"
checksum = "dfdb84ba432f6679794790de652bfbed86201893a30c03dc669c2bfe7424f472"
dependencies = [
"gccjit_sys",
]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default = ["master"]
[dependencies]
object = { version = "0.39.0", default-features = false, features = ["std", "read"] }
tempfile = "3.20"
gccjit = { version = "6.1.0", features = ["dlopen"] }
gccjit = { version = "7.0.0", features = ["dlopen"] }
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs", branch = "error-dlopen", features = ["dlopen"] }

# Local copy.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2026-09-24"
channel = "nightly-2026-09-29"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
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
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_gcc/src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,10 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {

debug_assert!(value_type.dyncast_array().is_some());
let name_suffix = match self.type_kind(dest_typ) {
TypeKind::Half if dest_typ.is_compatible_with(self.type_f16()) => {
let value = self.int_to_float_cast(signed, value, self.float_type);
return self.context.new_cast(None, value, dest_typ);
}
// cSpell:disable
TypeKind::Float => "tisf",
TypeKind::Double => "tidf",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl CodegenBackend for GccCodegenBackend {
lto_supported: gccjit::is_lto_supported(),
});

gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
gccjit::set_global_personality_function_name(c"rust_eh_personality");
}

#[cfg(not(feature = "master"))]
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
1 change: 0 additions & 1 deletion compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ fn prefix_and_suffix<'tcx>(
// LTO can fail when internal linkage is used.
emit_fatal("naked functions may not have internal linkage")
}
Linkage::Common => emit_fatal("Functions may not have common linkage"),
Linkage::AvailableExternally => {
// this would make the function equal an extern definition
emit_fatal("Functions may not have available_externally linkage")
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_hir_analysis/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ pub(crate) struct AssocKindMismatch {
#[primary_span]
#[label("unexpected {$got}")]
pub span: Span,
#[context]
pub item_span: Span,
#[context]
pub enclosing_span: Option<Span>,
pub expected: &'static str,
pub got: &'static str,
#[label("expected a {$expected} because of this associated {$expected}")]
Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,31 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
(ident.span, None, assoc_tag, assoc_item.tag())
};

let def_kind = tcx.def_kind(self.item_def_id());
let item_span = tcx.def_span(self.item_def_id()).shrink_to_lo();
let (item_span, enclosing_span) = match def_kind {
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => (
item_span,
Some(tcx.def_span(tcx.parent(self.item_def_id().into())).shrink_to_lo()),
),
DefKind::OpaqueTy => {
let item_span = tcx.def_span(tcx.parent(self.item_def_id().into())).shrink_to_lo();
let enclosing_span =
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy =
tcx.def_kind(tcx.parent(self.item_def_id().into()))
{
Some(tcx.def_span(tcx.parent(self.item_def_id().into())).shrink_to_lo())
} else {
None
};
(item_span, enclosing_span)
}
_ => (item_span, None),
};
self.dcx().emit_err(diagnostics::AssocKindMismatch {
span,
item_span,
enclosing_span,
expected: assoc_tag_str(expected),
got: assoc_tag_str(got),
expected_because_label,
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,16 @@ impl DiagnosticDeriveVariantBuilder {
match (&attr.meta, name.as_str()) {
(Meta::Path(_), "primary_span") => {
report_error_if_not_applied_to_span(attr, &info)?;

return Ok(quote! {
diag.span(#binding);
});
}
(Meta::Path(_), "context") => {
report_error_if_not_applied_to_span(attr, &info)?;
return Ok(quote! {
diag.span_context(#binding);
});
}
(Meta::Path(_), "subdiagnostic") => {
return Ok(quote! { diag.subdiagnostic(#binding); });
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ decl_derive!(
// field attributes
primary_span,
label,
context,
subdiagnostic,
suggestion)] =>
#[doc = "See <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html#derivediagnostic>"]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,6 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
Linkage::WeakODR => "WeakODR",
Linkage::Internal => "Internal",
Linkage::ExternalWeak => "ExternalWeak",
Linkage::Common => "Common",
};

output.push('[');
Expand Down
26 changes: 18 additions & 8 deletions compiler/rustc_resolve/src/diagnostics/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
code,
trait_item_span,
trait_path,
trait_span,
impl_span,
} => self
.dcx()
.create_err(diagnostics::TraitImplMismatch {
Expand All @@ -1407,16 +1409,24 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
kind,
trait_path,
trait_item_span,
trait_span,
impl_span,
})
.with_code(code),
ResolutionError::TraitImplDuplicate { name, trait_item_span, old_span } => {
self.dcx().create_err(diagnostics::TraitImplDuplicate {
span,
name,
trait_item_span,
old_span,
})
}
ResolutionError::TraitImplDuplicate {
name,
trait_item_span,
old_span,
trait_span,
impl_span,
} => self.dcx().create_err(diagnostics::TraitImplDuplicate {
span,
name,
trait_item_span,
trait_span,
impl_span,
old_span,
}),
ResolutionError::InvalidAsmSym => {
self.dcx().create_err(diagnostics::InvalidAsmSym { span })
}
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_resolve/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ pub(crate) struct TraitImplDuplicate {
pub(crate) old_span: Span,
#[label("item in trait")]
pub(crate) trait_item_span: Span,
#[context]
pub(crate) trait_span: Span,
#[context]
pub(crate) impl_span: Span,
pub(crate) name: Ident,
}

Expand Down Expand Up @@ -1410,6 +1414,10 @@ pub(crate) struct TraitImplMismatch {
pub(crate) trait_path: String,
#[label("item in trait")]
pub(crate) trait_item_span: Span,
#[context]
pub(crate) trait_span: Span,
#[context]
pub(crate) impl_span: Span,
}

#[derive(Diagnostic)]
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3902,12 +3902,16 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {

match seen_trait_items.entry(id_in_trait) {
Entry::Occupied(entry) => {
let trait_span = decl.parent_module.unwrap().span.shrink_to_lo();
let impl_span = self.current_trait_ref.as_ref().unwrap().1.path.span;
self.report_error(
span,
ResolutionError::TraitImplDuplicate {
name: ident,
old_span: *entry.get(),
trait_item_span: decl.span,
trait_span,
impl_span,
},
);
return;
Expand Down Expand Up @@ -3940,6 +3944,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
}
};
let trait_path = path_names_to_string(path);
let trait_span = decl.parent_module.unwrap().span.shrink_to_lo();
let impl_span = self.current_trait_ref.as_ref().unwrap().1.path.span;
self.report_error(
span,
ResolutionError::TraitImplMismatch {
Expand All @@ -3948,6 +3954,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
code,
trait_path,
trait_item_span: decl.span,
trait_span,
impl_span,
},
);
}
Expand Down
Loading
Loading