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 c65dcca

Browse files
committed
Auto merge of #143233 - dianqk:rollup-lcx3278, r=dianqk
Rollup of 14 pull requests Successful merges: - #142429 (`tests/ui`: A New Order [13/N]) - #142514 (Miri: handling of SNaN inputs in `f*::pow` operations) - #143066 (Use let chains in the new solver) - #143090 (Workaround for memory unsafety in third party DLLs) - #143118 (`tests/ui`: A New Order [15/N]) - #143159 (Do not freshen `ReError`) - #143168 (`tests/ui`: A New Order [16/N]) - #143176 (fix typos and improve clarity in documentation) - #143187 (Add my work email to mailmap) - #143190 (Use the `new` method for `BasicBlockData` and `Statement`) - #143195 (`tests/ui`: A New Order [17/N]) - #143196 (Port #[link_section] to the new attribute parsing infrastructure) - #143199 (Re-disable `tests/run-make/short-ice` on Windows MSVC again) - #143219 (Show auto trait and blanket impls for `!`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ad3b725 + c2904f7 commit c65dcca

File tree

125 files changed

+1361
-1066
lines changed

Some content is hidden

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

125 files changed

+1361
-1066
lines changed

‎.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ Xinye Tao <xy.tao@outlook.com>
690690
Xuefeng Wu <benewu@gmail.com> Xuefeng Wu <xfwu@thoughtworks.com>
691691
Xuefeng Wu <benewu@gmail.com> XuefengWu <benewu@gmail.com>
692692
York Xiang <bombless@126.com>
693+
Yotam Ofek <yotam.ofek@gmail.com> <yotamofek@microsoft.com>
693694
Youngsoo Son <ysson83@gmail.com> <ysoo.son@samsung.com>
694695
Youngsuk Kim <joseph942010@gmail.com>
695696
Yuki Okushi <jtitor@2k36.org>

‎compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ pub enum AttributeKind {
256256
/// Represents `#[link_name]`.
257257
LinkName { name: Symbol, span: Span },
258258

259+
/// Represents [`#[link_section]`](https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute)
260+
LinkSection { name: Symbol, span: Span },
261+
259262
/// Represents `#[loop_match]`.
260263
LoopMatch(Span),
261264

‎compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ impl AttributeKind {
2424
DocComment { .. } => Yes,
2525
ExportName { .. } => Yes,
2626
Inline(..) => No,
27+
LinkSection { .. } => No,
2728
MacroTransparency(..) => Yes,
2829
Repr(..) => No,
2930
Stability { .. } => Yes,

‎compiler/rustc_attr_parsing/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ attr_parsing_non_ident_feature =
9999
100100
attr_parsing_null_on_export = `export_name` may not contain null characters
101101
102+
attr_parsing_null_on_link_section = `link_section` may not contain null characters
103+
102104
attr_parsing_repr_ident =
103105
meta item in `repr` must be an identifier
104106

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use rustc_attr_data_structures::AttributeKind;
2-
use rustc_attr_data_structures::AttributeKind::LinkName;
2+
use rustc_attr_data_structures::AttributeKind::{LinkName,LinkSection};
33
use rustc_feature::{AttributeTemplate, template};
44
use rustc_span::{Symbol, sym};
55

66
use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
77
use crate::context::{AcceptContext, Stage};
88
use crate::parser::ArgParser;
9+
use crate::session_diagnostics::NullOnLinkSection;
910

1011
pub(crate) struct LinkNameParser;
1112

@@ -28,3 +29,31 @@ impl<S: Stage> SingleAttributeParser<S> for LinkNameParser {
2829
Some(LinkName { name, span: cx.attr_span })
2930
}
3031
}
32+
33+
pub(crate) struct LinkSectionParser;
34+
35+
impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
36+
const PATH: &[Symbol] = &[sym::link_section];
37+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
38+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
39+
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
40+
41+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
42+
let Some(nv) = args.name_value() else {
43+
cx.expected_name_value(cx.attr_span, None);
44+
return None;
45+
};
46+
let Some(name) = nv.value_as_str() else {
47+
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
48+
return None;
49+
};
50+
if name.as_str().contains('0円') {
51+
// `#[link_section = ...]` will be converted to a null-terminated string,
52+
// so it may not contain any null characters.
53+
cx.emit_err(NullOnLinkSection { span: cx.attr_span });
54+
return None;
55+
}
56+
57+
Some(LinkSection { name, span: cx.attr_span })
58+
}
59+
}

‎compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::attributes::codegen_attrs::{
2222
use crate::attributes::confusables::ConfusablesParser;
2323
use crate::attributes::deprecation::DeprecationParser;
2424
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
25-
use crate::attributes::link_attrs::LinkNameParser;
25+
use crate::attributes::link_attrs::{LinkNameParser,LinkSectionParser};
2626
use crate::attributes::lint_helpers::{AsPtrParser, PubTransparentParser};
2727
use crate::attributes::loop_match::{ConstContinueParser, LoopMatchParser};
2828
use crate::attributes::must_use::MustUseParser;
@@ -123,6 +123,7 @@ attribute_parsers!(
123123
Single<ExportNameParser>,
124124
Single<InlineParser>,
125125
Single<LinkNameParser>,
126+
Single<LinkSectionParser>,
126127
Single<LoopMatchParser>,
127128
Single<MayDangleParser>,
128129
Single<MustUseParser>,

‎compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,13 @@ pub(crate) struct NullOnExport {
452452
pub span: Span,
453453
}
454454

455+
#[derive(Diagnostic)]
456+
#[diag(attr_parsing_null_on_link_section, code = E0648)]
457+
pub(crate) struct NullOnLinkSection {
458+
#[primary_span]
459+
pub span: Span,
460+
}
461+
455462
#[derive(Diagnostic)]
456463
#[diag(attr_parsing_stability_outside_std, code = E0734)]
457464
pub(crate) struct StabilityOutsideStd {

‎compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
124124
AttributeKind::Naked(_) => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED,
125125
AttributeKind::Align { align, .. } => codegen_fn_attrs.alignment = Some(*align),
126126
AttributeKind::LinkName { name, .. } => codegen_fn_attrs.link_name = Some(*name),
127+
AttributeKind::LinkSection { name, .. } => {
128+
codegen_fn_attrs.link_section = Some(*name)
129+
}
127130
AttributeKind::NoMangle(attr_span) => {
128131
if tcx.opt_item_name(did.to_def_id()).is_some() {
129132
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE;
@@ -253,16 +256,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
253256
}
254257
}
255258
}
256-
sym::link_section => {
257-
if let Some(val) = attr.value_str() {
258-
if val.as_str().bytes().any(|b| b == 0) {
259-
let msg = format!("illegal null byte in link_section value: `{val}`");
260-
tcx.dcx().span_err(attr.span(), msg);
261-
} else {
262-
codegen_fn_attrs.link_section = Some(val);
263-
}
264-
}
265-
}
266259
sym::link_ordinal => {
267260
link_ordinal_span = Some(attr.span());
268261
if let ordinal @ Some(_) = check_link_ordinal(tcx, attr) {

‎compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ fn optimize_use_clone<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
354354

355355
let destination_block = target.unwrap();
356356

357-
bb.statements.push(mir::Statement{
358-
source_info:bb.terminator().source_info,
359-
kind:mir::StatementKind::Assign(Box::new((
357+
bb.statements.push(mir::Statement::new(
358+
bb.terminator().source_info,
359+
mir::StatementKind::Assign(Box::new((
360360
*destination,
361361
mir::Rvalue::Use(mir::Operand::Copy(
362362
arg_place.project_deeper(&[mir::ProjectionElem::Deref], tcx),
363363
)),
364364
))),
365-
});
365+
));
366366

367367
bb.terminator_mut().kind = mir::TerminatorKind::Goto { target: destination_block };
368368
}

‎compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30553055
pub(crate) fn note_unmet_impls_on_type(
30563056
&self,
30573057
err: &mut Diag<'_>,
3058-
errors: Vec<FulfillmentError<'tcx>>,
3058+
errors: &[FulfillmentError<'tcx>],
30593059
suggest_derive: bool,
30603060
) {
30613061
let preds: Vec<_> = errors

0 commit comments

Comments
(0)

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