Skip to content

Commit e6371c9

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 0c3c9e4 + c3fb7d1 commit e6371c9

File tree

344 files changed

+4270
-2479
lines changed

Some content is hidden

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

344 files changed

+4270
-2479
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_cranelift/example/mini_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ pub mod intrinsics {
660660
#[rustc_intrinsic]
661661
pub unsafe fn ctlz_nonzero<T>(x: T) -> u32;
662662
#[rustc_intrinsic]
663-
pub fn needs_drop<T: ?::Sized>() -> bool;
663+
pub const fn needs_drop<T: ?::Sized>() -> bool;
664664
#[rustc_intrinsic]
665665
pub fn bitreverse<T>(x: T) -> T;
666666
#[rustc_intrinsic]

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, repr_simd)]
1+
#![feature(
2+
no_core,
3+
lang_items,
4+
never_type,
5+
linkage,
6+
extern_types,
7+
thread_local,
8+
repr_simd,
9+
rustc_private
10+
)]
211
#![no_core]
312
#![allow(dead_code, non_camel_case_types, internal_features)]
413

@@ -207,10 +216,14 @@ fn main() {
207216
assert_eq!(intrinsics::align_of::<u16>() as u8, 2);
208217
assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8);
209218

210-
assert!(!intrinsics::needs_drop::<u8>());
211-
assert!(!intrinsics::needs_drop::<[u8]>());
212-
assert!(intrinsics::needs_drop::<NoisyDrop>());
213-
assert!(intrinsics::needs_drop::<NoisyDropUnsized>());
219+
let u8_needs_drop = const { intrinsics::needs_drop::<u8>() };
220+
assert!(!u8_needs_drop);
221+
let slice_needs_drop = const { intrinsics::needs_drop::<[u8]>() };
222+
assert!(!slice_needs_drop);
223+
let noisy_drop = const { intrinsics::needs_drop::<NoisyDrop>() };
224+
assert!(noisy_drop);
225+
let noisy_unsized_drop = const { intrinsics::needs_drop::<NoisyDropUnsized>() };
226+
assert!(noisy_unsized_drop);
214227

215228
Unique { pointer: NonNull(1 as *mut &str), _marker: PhantomData } as Unique<dyn SomeTrait>;
216229

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub(crate) fn codegen_const_value<'tcx>(
133133
}
134134
}
135135
Scalar::Ptr(ptr, _size) => {
136-
let (prov, offset) = ptr.into_parts(); // we know the `offset` is relative
136+
let (prov, offset) = ptr.prov_and_relative_offset();
137137
let alloc_id = prov.alloc_id();
138138
let base_addr = match fx.tcx.global_alloc(alloc_id) {
139139
GlobalAlloc::Memory(alloc) => {

0 commit comments

Comments
 (0)