Skip to content

Rollup of 13 pull requests #145388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
eb2913b
Fix unsoundness in some tests
a1phyr Jun 19, 2025
7ead576
Implement `ptr_cast_array`
scottmcm Jul 26, 2025
51b0416
Use `cast_array` in core
scottmcm Jul 26, 2025
f7e46f9
fix(unicode-table-generator): fix duplicated unique indices
Marcondiro Aug 5, 2025
c503487
Avoid abbreviating "numerator" as "numer", to allow catching typo "nu…
joshtriplett Aug 9, 2025
99769bc
Add tracing to resolve-related functions
Stypox Jul 31, 2025
a0eea23
doc test: fix mpsc.rs try_send doc test
eval-exec Aug 12, 2025
d4eb094
Cleanup assoc parent utils
camsteffen Aug 12, 2025
12d1665
Add test suggest-add-wrapper-issue-145294
xizheyin Aug 13, 2025
e0cc2be
Suppress wrapper suggestion when expected and actual ty are the same …
xizheyin Aug 13, 2025
7b5d9ef
Improve `--remap-path-prefix` documentation
Urgau Jun 11, 2025
d435197
Port the `#[linkage]` attribute to the new attribute system
scrabsha Aug 12, 2025
8f472e8
Add regression test for a former ICE involving helper attributes cont…
fmease Aug 14, 2025
74aca53
rustdoc: Allow multiple references to a single footnote
a4lg Aug 14, 2025
51eb5ed
resolve: Do not call `resolve_macro_path` from late resolution
petrochenkov Aug 8, 2025
d682943
resolve: Do not show deprecated helper attributes in typo recommendat…
petrochenkov Aug 8, 2025
9b797b9
resolve: Improve code reuse in typo candidate collection
petrochenkov Aug 13, 2025
f676dd8
Rollup merge of #140434 - a4lg:rustdoc-multi-footnote-refs, r=fmease,…
GuillaumeGomez Aug 14, 2025
90a5e62
Rollup merge of #142372 - Urgau:improve-remap_path_prefix-doc, r=wesl…
GuillaumeGomez Aug 14, 2025
4bc1eb7
Rollup merge of #142741 - a1phyr:fix_unsoundness, r=Mark-Simulacrum
GuillaumeGomez Aug 14, 2025
31d8277
Rollup merge of #144515 - scottmcm:ptr_cast_array, r=Mark-Simulacrum
GuillaumeGomez Aug 14, 2025
6ac5c28
Rollup merge of #144727 - Stypox:add-tracing-to-resolve, r=RalfJung
GuillaumeGomez Aug 14, 2025
7d91d20
Rollup merge of #144959 - Marcondiro:master, r=Mark-Simulacrum
GuillaumeGomez Aug 14, 2025
c1f9e2a
Rollup merge of #145179 - joshtriplett:number, r=RalfJung
GuillaumeGomez Aug 14, 2025
9525849
Rollup merge of #145250 - fmease:regr-test-for-attr-meta-ice, r=jdons…
GuillaumeGomez Aug 14, 2025
ad21c6d
Rollup merge of #145266 - camsteffen:reduce-queries, r=petrochenkov
GuillaumeGomez Aug 14, 2025
f493f80
Rollup merge of #145299 - eval-exec:exec-fix-145293, r=tgross35
GuillaumeGomez Aug 14, 2025
44d3217
Rollup merge of #145323 - scrabsha:push-pqwvmznzzmpr, r=jdonszelmann
GuillaumeGomez Aug 14, 2025
707e956
Rollup merge of #145361 - xizheyin:145294, r=compiler-errors
GuillaumeGomez Aug 14, 2025
762b7ec
Rollup merge of #145372 - petrochenkov:noresmacpath, r=jackh726
GuillaumeGomez Aug 14, 2025
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
76 changes: 75 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/link_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_feature::{AttributeTemplate, template};
use rustc_hir::attrs::AttributeKind;
use rustc_hir::attrs::AttributeKind::{LinkName, LinkOrdinal, LinkSection};
use rustc_hir::attrs::{AttributeKind, Linkage};
use rustc_span::{Span, Symbol, sym};

use crate::attributes::{
Expand Down Expand Up @@ -129,3 +129,77 @@ impl<S: Stage> SingleAttributeParser<S> for LinkOrdinalParser {
Some(LinkOrdinal { ordinal, span: cx.attr_span })
}
}

pub(crate) struct LinkageParser;

impl<S: Stage> SingleAttributeParser<S> for LinkageParser {
const PATH: &[Symbol] = &[sym::linkage];

const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;

const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;

const TEMPLATE: AttributeTemplate = template!(NameValueStr: [
"available_externally",
"common",
"extern_weak",
"external",
"internal",
"linkonce",
"linkonce_odr",
"weak",
"weak_odr",
]);

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let Some(name_value) = args.name_value() else {
cx.expected_name_value(cx.attr_span, Some(sym::linkage));
return None;
};

let Some(value) = name_value.value_as_str() else {
cx.expected_string_literal(name_value.value_span, Some(name_value.value_as_lit()));
return None;
};

// Use the names from src/llvm/docs/LangRef.rst here. Most types are only
// applicable to variable declarations and may not really make sense for
// Rust code in the first place but allow them anyway and trust that the
// user knows what they're doing. Who knows, unanticipated use cases may pop
// up in the future.
//
// ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
// 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,
sym::weak_odr => Linkage::WeakODR,

_ => {
cx.expected_specific_argument(
name_value.value_span,
vec![
"available_externally",
"common",
"extern_weak",
"external",
"internal",
"linkonce",
"linkonce_odr",
"weak",
"weak_odr",
],
);
return None;
}
};

Some(AttributeKind::Linkage(linkage, cx.attr_span))
}
}
3 changes: 2 additions & 1 deletion compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::attributes::dummy::DummyParser;
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
use crate::attributes::link_attrs::{
ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser,
LinkSectionParser, StdInternalSymbolParser,
LinkSectionParser, LinkageParser, StdInternalSymbolParser,
};
use crate::attributes::lint_helpers::{
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
Expand Down Expand Up @@ -167,6 +167,7 @@ attribute_parsers!(
Single<LinkNameParser>,
Single<LinkOrdinalParser>,
Single<LinkSectionParser>,
Single<LinkageParser>,
Single<MustUseParser>,
Single<OptimizeParser>,
Single<PathAttributeParser>,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// - is the trait from the local crate? If not, we can't suggest changing signatures
/// - `Span` of the argument in the trait definition
fn is_error_in_trait(&self, local: Local) -> (bool, bool, Option<Span>) {
let tcx = self.infcx.tcx;
if self.body.local_kind(local) != LocalKind::Arg {
return (false, false, None);
}
let my_def = self.body.source.def_id();
let Some(td) =
self.infcx.tcx.impl_of_assoc(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
tcx.trait_impl_of_assoc(my_def).and_then(|id| self.infcx.tcx.trait_id_of_impl(id))
else {
return (false, false, None);
};
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1773,10 +1773,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
locations,
);

assert!(!matches!(
tcx.impl_of_assoc(def_id).map(|imp| tcx.def_kind(imp)),
Some(DefKind::Impl { of_trait: true })
));
assert_eq!(tcx.trait_impl_of_assoc(def_id), None);
self.prove_predicates(
args.types().map(|ty| ty::ClauseKind::WellFormed(ty.into())),
locations,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ fn data_id_for_static(
.abi
.bytes();

let linkage = if import_linkage == rustc_middle::mir::mono::Linkage::ExternalWeak
|| import_linkage == rustc_middle::mir::mono::Linkage::WeakAny
let linkage = if import_linkage == rustc_hir::attrs::Linkage::ExternalWeak
|| import_linkage == rustc_hir::attrs::Linkage::WeakAny
{
Linkage::Preemptible
} else {
Expand Down Expand Up @@ -332,8 +332,8 @@ fn data_id_for_static(

let linkage = if definition {
crate::linkage::get_static_linkage(tcx, def_id)
} else if attrs.linkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak)
|| attrs.linkage == Some(rustc_middle::mir::mono::Linkage::WeakAny)
} else if attrs.linkage == Some(rustc_hir::attrs::Linkage::ExternalWeak)
|| attrs.linkage == Some(rustc_hir::attrs::Linkage::WeakAny)
{
Linkage::Preemptible
} else {
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_cranelift/src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ use rustc_codegen_ssa::{
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
use rustc_hir::attrs::Linkage as RLinkage;
use rustc_metadata::fs::copy_to_stdout;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::mono::{
CodegenUnit, Linkage as RLinkage, MonoItem, MonoItemData, Visibility,
};
use rustc_middle::mir::mono::{CodegenUnit, MonoItem, MonoItemData, Visibility};
use rustc_session::Session;
use rustc_session::config::{DebugInfo, OutFileName, OutputFilenames, OutputType};

Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_cranelift/src/linkage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility};
use rustc_hir::attrs::Linkage as RLinkage;
use rustc_middle::mir::mono::{MonoItem, Visibility};

use crate::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use rustc_codegen_ssa::ModuleCodegen;
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
use rustc_codegen_ssa::mono_item::MonoItemExt;
use rustc_codegen_ssa::traits::DebugInfoCodegenMethods;
use rustc_hir::attrs::Linkage;
use rustc_middle::dep_graph;
use rustc_middle::mir::mono::Linkage;
#[cfg(feature = "master")]
use rustc_middle::mir::mono::Visibility;
use rustc_middle::ty::TyCtxt;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use rustc_abi::{self as abi, Align, HasDataLayout, Primitive, Size, WrappingRang
use rustc_codegen_ssa::traits::{
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
};
use rustc_hir::attrs::Linkage;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::interpret::{
self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint,
};
use rustc_middle::mir::mono::Linkage;
use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::ty::{self, Instance};
use rustc_middle::{bug, span_bug};
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_gcc/src/mono_item.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#[cfg(feature = "master")]
use gccjit::{FnAttribute, VarAttribute};
use rustc_codegen_ssa::traits::PreDefineCodegenMethods;
use rustc_hir::attrs::Linkage;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::bug;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::mono::{Linkage, Visibility};
use rustc_middle::mir::mono::Visibility;
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf};
use rustc_middle::ty::{self, Instance, TypeVisitableExt};

Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
use rustc_codegen_ssa::mono_item::MonoItemExt;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::attrs::Linkage;
use rustc_middle::dep_graph;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::mir::mono::{Linkage, Visibility};
use rustc_middle::mir::mono::Visibility;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::DebugInfo;
use rustc_span::Symbol;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ use rustc_abi::{Align, HasDataLayout, Primitive, Scalar, Size, WrappingRange};
use rustc_codegen_ssa::common;
use rustc_codegen_ssa::traits::*;
use rustc_hir::LangItem;
use rustc_hir::attrs::Linkage;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::interpret::{
Allocation, ConstAllocation, ErrorHandled, InitChunk, Pointer, Scalar as InterpScalar,
read_target_uint,
};
use rustc_middle::mir::mono::{Linkage, MonoItem};
use rustc_middle::mir::mono::MonoItem;
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
use rustc_middle::ty::{self, Instance};
use rustc_middle::{bug, span_bug};
Expand Down
43 changes: 19 additions & 24 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,31 +533,26 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
// First, let's see if this is a method within an inherent impl. Because
// if yes, we want to make the result subroutine DIE a child of the
// subroutine's self-type.
if let Some(impl_def_id) = cx.tcx.impl_of_assoc(instance.def_id()) {
// If the method does *not* belong to a trait, proceed
if cx.tcx.trait_id_of_impl(impl_def_id).is_none() {
let impl_self_ty = cx.tcx.instantiate_and_normalize_erasing_regions(
instance.args,
cx.typing_env(),
cx.tcx.type_of(impl_def_id),
);

// Only "class" methods are generally understood by LLVM,
// so avoid methods on other types (e.g., `<*mut T>::null`).
if let ty::Adt(def, ..) = impl_self_ty.kind()
&& !def.is_box()
{
// Again, only create type information if full debuginfo is enabled
if cx.sess().opts.debuginfo == DebugInfo::Full && !impl_self_ty.has_param()
{
return (type_di_node(cx, impl_self_ty), true);
} else {
return (namespace::item_namespace(cx, def.did()), false);
}
// For trait method impls we still use the "parallel namespace"
// strategy
if let Some(imp_def_id) = cx.tcx.inherent_impl_of_assoc(instance.def_id()) {
let impl_self_ty = cx.tcx.instantiate_and_normalize_erasing_regions(
instance.args,
cx.typing_env(),
cx.tcx.type_of(imp_def_id),
);

// Only "class" methods are generally understood by LLVM,
// so avoid methods on other types (e.g., `<*mut T>::null`).
if let ty::Adt(def, ..) = impl_self_ty.kind()
&& !def.is_box()
{
// Again, only create type information if full debuginfo is enabled
if cx.sess().opts.debuginfo == DebugInfo::Full && !impl_self_ty.has_param() {
return (type_di_node(cx, impl_self_ty), true);
} else {
return (namespace::item_namespace(cx, def.did()), false);
}
} else {
// For trait method impls we still use the "parallel namespace"
// strategy
}
}

Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/src/mono_item.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use rustc_codegen_ssa::traits::*;
use rustc_hir::attrs::Linkage;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::bug;
use rustc_middle::mir::mono::{Linkage, Visibility};
use rustc_middle::mir::mono::Visibility;
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf};
use rustc_middle::ty::{self, Instance, TypeVisitableExt};
use rustc_session::config::CrateType;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ fn exported_generic_symbols_provider_local<'tcx>(
let mut symbols: Vec<_> = vec![];

if tcx.local_crate_exports_generics() {
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
use rustc_hir::attrs::Linkage;
use rustc_middle::mir::mono::{MonoItem, Visibility};
use rustc_middle::ty::InstanceKind;

// Normally, we require that shared monomorphizations are not hidden,
Expand Down
Loading
Loading