Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 30017c3

Browse files
committed
Auto merge of #145388 - GuillaumeGomez:rollup-hnlt5ov, r=GuillaumeGomez
Rollup of 13 pull requests Successful merges: - #140434 (rustdoc: Allow multiple references to a single footnote) - #142372 (Improve `--remap-path-prefix` documentation) - #142741 (Fix unsoundness in some tests) - #144515 (Implement `ptr_cast_array`) - #144727 (Add tracing to resolve-related functions) - #144959 (fix(unicode-table-generator): fix duplicated unique indices) - #145179 (Avoid abbreviating "numerator" as "numer", to allow catching typo "numer" elsewhere) - #145250 (Add regression test for a former ICE involving helper attributes containing interpolated tokens) - #145266 (Reduce some queries around associated items) - #145299 (doc test: fix mpsc.rs try_send doc test) - #145323 (Port the `#[linkage]` attribute to the new attribute system) - #145361 (Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved) - #145372 (resolve: Miscellaneous cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2c1ac85 + 762b7ec commit 30017c3

File tree

76 files changed

+646
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+646
-361
lines changed

‎compiler/rustc_attr_parsing/src/attributes/link_attrs.rs‎

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_feature::{AttributeTemplate, template};
2-
use rustc_hir::attrs::AttributeKind;
32
use rustc_hir::attrs::AttributeKind::{LinkName, LinkOrdinal, LinkSection};
3+
use rustc_hir::attrs::{AttributeKind, Linkage};
44
use rustc_span::{Span, Symbol, sym};
55

66
use crate::attributes::{
@@ -129,3 +129,77 @@ impl<S: Stage> SingleAttributeParser<S> for LinkOrdinalParser {
129129
Some(LinkOrdinal { ordinal, span: cx.attr_span })
130130
}
131131
}
132+
133+
pub(crate) struct LinkageParser;
134+
135+
impl<S: Stage> SingleAttributeParser<S> for LinkageParser {
136+
const PATH: &[Symbol] = &[sym::linkage];
137+
138+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
139+
140+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
141+
142+
const TEMPLATE: AttributeTemplate = template!(NameValueStr: [
143+
"available_externally",
144+
"common",
145+
"extern_weak",
146+
"external",
147+
"internal",
148+
"linkonce",
149+
"linkonce_odr",
150+
"weak",
151+
"weak_odr",
152+
]);
153+
154+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
155+
let Some(name_value) = args.name_value() else {
156+
cx.expected_name_value(cx.attr_span, Some(sym::linkage));
157+
return None;
158+
};
159+
160+
let Some(value) = name_value.value_as_str() else {
161+
cx.expected_string_literal(name_value.value_span, Some(name_value.value_as_lit()));
162+
return None;
163+
};
164+
165+
// Use the names from src/llvm/docs/LangRef.rst here. Most types are only
166+
// applicable to variable declarations and may not really make sense for
167+
// Rust code in the first place but allow them anyway and trust that the
168+
// user knows what they're doing. Who knows, unanticipated use cases may pop
169+
// up in the future.
170+
//
171+
// ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
172+
// and don't have to be, LLVM treats them as no-ops.
173+
let linkage = match value {
174+
sym::available_externally => Linkage::AvailableExternally,
175+
sym::common => Linkage::Common,
176+
sym::extern_weak => Linkage::ExternalWeak,
177+
sym::external => Linkage::External,
178+
sym::internal => Linkage::Internal,
179+
sym::linkonce => Linkage::LinkOnceAny,
180+
sym::linkonce_odr => Linkage::LinkOnceODR,
181+
sym::weak => Linkage::WeakAny,
182+
sym::weak_odr => Linkage::WeakODR,
183+
184+
_ => {
185+
cx.expected_specific_argument(
186+
name_value.value_span,
187+
vec![
188+
"available_externally",
189+
"common",
190+
"extern_weak",
191+
"external",
192+
"internal",
193+
"linkonce",
194+
"linkonce_odr",
195+
"weak",
196+
"weak_odr",
197+
],
198+
);
199+
return None;
200+
}
201+
};
202+
203+
Some(AttributeKind::Linkage(linkage, cx.attr_span))
204+
}
205+
}

‎compiler/rustc_attr_parsing/src/context.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::attributes::dummy::DummyParser;
2727
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
2828
use crate::attributes::link_attrs::{
2929
ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser,
30-
LinkSectionParser, StdInternalSymbolParser,
30+
LinkSectionParser, LinkageParser,StdInternalSymbolParser,
3131
};
3232
use crate::attributes::lint_helpers::{
3333
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
@@ -167,6 +167,7 @@ attribute_parsers!(
167167
Single<LinkNameParser>,
168168
Single<LinkOrdinalParser>,
169169
Single<LinkSectionParser>,
170+
Single<LinkageParser>,
170171
Single<MustUseParser>,
171172
Single<OptimizeParser>,
172173
Single<PathAttributeParser>,

‎compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,12 +677,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
677677
/// - is the trait from the local crate? If not, we can't suggest changing signatures
678678
/// - `Span` of the argument in the trait definition
679679
fn is_error_in_trait(&self, local: Local) -> (bool, bool, Option<Span>) {
680+
let tcx = self.infcx.tcx;
680681
if self.body.local_kind(local) != LocalKind::Arg {
681682
return (false, false, None);
682683
}
683684
let my_def = self.body.source.def_id();
684685
let Some(td) =
685-
self.infcx.tcx.impl_of_assoc(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
686+
tcx.trait_impl_of_assoc(my_def).and_then(|id| self.infcx.tcx.trait_id_of_impl(id))
686687
else {
687688
return (false, false, None);
688689
};

‎compiler/rustc_borrowck/src/type_check/mod.rs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,10 +1773,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
17731773
locations,
17741774
);
17751775

1776-
assert!(!matches!(
1777-
tcx.impl_of_assoc(def_id).map(|imp| tcx.def_kind(imp)),
1778-
Some(DefKind::Impl { of_trait: true })
1779-
));
1776+
assert_eq!(tcx.trait_impl_of_assoc(def_id), None);
17801777
self.prove_predicates(
17811778
args.types().map(|ty| ty::ClauseKind::WellFormed(ty.into())),
17821779
locations,

‎compiler/rustc_codegen_cranelift/src/constant.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ fn data_id_for_static(
281281
.abi
282282
.bytes();
283283

284-
let linkage = if import_linkage == rustc_middle::mir::mono::Linkage::ExternalWeak
285-
|| import_linkage == rustc_middle::mir::mono::Linkage::WeakAny
284+
let linkage = if import_linkage == rustc_hir::attrs::Linkage::ExternalWeak
285+
|| import_linkage == rustc_hir::attrs::Linkage::WeakAny
286286
{
287287
Linkage::Preemptible
288288
} else {
@@ -332,8 +332,8 @@ fn data_id_for_static(
332332

333333
let linkage = if definition {
334334
crate::linkage::get_static_linkage(tcx, def_id)
335-
} else if attrs.linkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak)
336-
|| attrs.linkage == Some(rustc_middle::mir::mono::Linkage::WeakAny)
335+
} else if attrs.linkage == Some(rustc_hir::attrs::Linkage::ExternalWeak)
336+
|| attrs.linkage == Some(rustc_hir::attrs::Linkage::WeakAny)
337337
{
338338
Linkage::Preemptible
339339
} else {

‎compiler/rustc_codegen_cranelift/src/driver/aot.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ use rustc_codegen_ssa::{
1818
use rustc_data_structures::profiling::SelfProfilerRef;
1919
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2020
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
21+
use rustc_hir::attrs::Linkage as RLinkage;
2122
use rustc_metadata::fs::copy_to_stdout;
2223
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
2324
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
24-
use rustc_middle::mir::mono::{
25-
CodegenUnit, Linkage as RLinkage, MonoItem, MonoItemData, Visibility,
26-
};
25+
use rustc_middle::mir::mono::{CodegenUnit, MonoItem, MonoItemData, Visibility};
2726
use rustc_session::Session;
2827
use rustc_session::config::{DebugInfo, OutFileName, OutputFilenames, OutputType};
2928

‎compiler/rustc_codegen_cranelift/src/linkage.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility};
1+
use rustc_hir::attrs::Linkage as RLinkage;
2+
use rustc_middle::mir::mono::{MonoItem, Visibility};
23

34
use crate::prelude::*;
45

‎compiler/rustc_codegen_gcc/src/base.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use rustc_codegen_ssa::ModuleCodegen;
88
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
99
use rustc_codegen_ssa::mono_item::MonoItemExt;
1010
use rustc_codegen_ssa::traits::DebugInfoCodegenMethods;
11+
use rustc_hir::attrs::Linkage;
1112
use rustc_middle::dep_graph;
12-
use rustc_middle::mir::mono::Linkage;
1313
#[cfg(feature = "master")]
1414
use rustc_middle::mir::mono::Visibility;
1515
use rustc_middle::ty::TyCtxt;

‎compiler/rustc_codegen_gcc/src/consts.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use rustc_abi::{self as abi, Align, HasDataLayout, Primitive, Size, WrappingRang
55
use rustc_codegen_ssa::traits::{
66
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
77
};
8+
use rustc_hir::attrs::Linkage;
89
use rustc_hir::def::DefKind;
910
use rustc_hir::def_id::LOCAL_CRATE;
1011
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
1112
use rustc_middle::mir::interpret::{
1213
self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint,
1314
};
14-
use rustc_middle::mir::mono::Linkage;
1515
use rustc_middle::ty::layout::LayoutOf;
1616
use rustc_middle::ty::{self, Instance};
1717
use rustc_middle::{bug, span_bug};

‎compiler/rustc_codegen_gcc/src/mono_item.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#[cfg(feature = "master")]
22
use gccjit::{FnAttribute, VarAttribute};
33
use rustc_codegen_ssa::traits::PreDefineCodegenMethods;
4+
use rustc_hir::attrs::Linkage;
45
use rustc_hir::def::DefKind;
56
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
67
use rustc_middle::bug;
78
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
8-
use rustc_middle::mir::mono::{Linkage,Visibility};
9+
use rustc_middle::mir::mono::Visibility;
910
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf};
1011
use rustc_middle::ty::{self, Instance, TypeVisitableExt};
1112

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /