Skip to content

Commit 6f34f4e

Browse files
committed
Auto merge of #147019 - Zalathar:rollup-boxzbmo, r=Zalathar
Rollup of 14 pull requests Successful merges: - #145067 (RawVecInner: add missing `unsafe` to unsafe fns) - #145277 (Do not materialise X in [X; 0] when X is unsizing a const) - #145973 (Add `std` support for `armv7a-vex-v5`) - #146667 (Add an attribute to check the number of lanes in a SIMD vector after monomorphization) - #146735 (unstably constify float mul_add methods) - #146737 (f16_f128: enable some more tests in Miri) - #146766 (Add attributes for #[global_allocator] functions) - #146905 (llvm: update remarks support on LLVM 22) - #146982 (Remove erroneous normalization step in `tests/run-make/linker-warning`) - #147005 (Small string formatting cleanup) - #147007 (Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`) - #147008 (bootstrap.py: Respect build.jobs while building bootstrap tool) - #147013 (rustdoc: Fix documentation for `--doctest-build-arg`) - #147015 (Use `LLVMDisposeTargetMachine`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7cfd7d3 + 59866ef commit 6f34f4e

File tree

90 files changed

+1670
-319
lines changed

Some content is hidden

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

90 files changed

+1670
-319
lines changed

compiler/rustc_attr_parsing/src/attributes/crate_level.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
1-
use std::num::IntErrorKind;
2-
3-
use rustc_hir::limit::Limit;
4-
51
use super::prelude::*;
6-
use crate::session_diagnostics::LimitInvalid;
7-
8-
impl<S: Stage> AcceptContext<'_, '_, S> {
9-
fn parse_limit_int(&self, nv: &NameValueParser) -> Option<Limit> {
10-
let Some(limit) = nv.value_as_str() else {
11-
self.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
12-
return None;
13-
};
14-
15-
let error_str = match limit.as_str().parse() {
16-
Ok(i) => return Some(Limit::new(i)),
17-
Err(e) => match e.kind() {
18-
IntErrorKind::PosOverflow => "`limit` is too large",
19-
IntErrorKind::Empty => "`limit` must be a non-negative integer",
20-
IntErrorKind::InvalidDigit => "not a valid integer",
21-
IntErrorKind::NegOverflow => {
22-
panic!(
23-
"`limit` should never negatively overflow since we're parsing into a usize and we'd get Empty instead"
24-
)
25-
}
26-
IntErrorKind::Zero => {
27-
panic!("zero is a valid `limit` so should have returned Ok() when parsing")
28-
}
29-
kind => panic!("unimplemented IntErrorKind variant: {:?}", kind),
30-
},
31-
};
32-
33-
self.emit_err(LimitInvalid { span: self.attr_span, value_span: nv.value_span, error_str });
34-
35-
None
36-
}
37-
}
382

393
pub(crate) struct CrateNameParser;
404

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,21 @@ impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser {
4949
Some(AttributeKind::RustcObjectLifetimeDefault)
5050
}
5151
}
52+
53+
pub(crate) struct RustcSimdMonomorphizeLaneLimitParser;
54+
55+
impl<S: Stage> SingleAttributeParser<S> for RustcSimdMonomorphizeLaneLimitParser {
56+
const PATH: &[Symbol] = &[sym::rustc_simd_monomorphize_lane_limit];
57+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
58+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
59+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
60+
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N");
61+
62+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
63+
let ArgParser::NameValue(nv) = args else {
64+
cx.expected_name_value(cx.attr_span, None);
65+
return None;
66+
};
67+
Some(AttributeKind::RustcSimdMonomorphizeLaneLimit(cx.parse_limit_int(nv)?))
68+
}
69+
}

compiler/rustc_attr_parsing/src/attributes/util.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
use std::num::IntErrorKind;
2+
13
use rustc_ast::LitKind;
24
use rustc_ast::attr::AttributeExt;
35
use rustc_feature::is_builtin_attr_name;
46
use rustc_hir::RustcVersion;
7+
use rustc_hir::limit::Limit;
58
use rustc_span::{Symbol, sym};
69

710
use crate::context::{AcceptContext, Stage};
8-
use crate::parser::ArgParser;
11+
use crate::parser::{ArgParser, NameValueParser};
12+
use crate::session_diagnostics::LimitInvalid;
913

1014
/// Parse a rustc version number written inside string literal in an attribute,
1115
/// like appears in `since = "1.0.0"`. Suffixes like "-dev" and "-nightly" are
@@ -85,3 +89,34 @@ pub(crate) fn parse_single_integer<S: Stage>(
8589
};
8690
Some(num.0)
8791
}
92+
93+
impl<S: Stage> AcceptContext<'_, '_, S> {
94+
pub(crate) fn parse_limit_int(&self, nv: &NameValueParser) -> Option<Limit> {
95+
let Some(limit) = nv.value_as_str() else {
96+
self.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
97+
return None;
98+
};
99+
100+
let error_str = match limit.as_str().parse() {
101+
Ok(i) => return Some(Limit::new(i)),
102+
Err(e) => match e.kind() {
103+
IntErrorKind::PosOverflow => "`limit` is too large",
104+
IntErrorKind::Empty => "`limit` must be a non-negative integer",
105+
IntErrorKind::InvalidDigit => "not a valid integer",
106+
IntErrorKind::NegOverflow => {
107+
panic!(
108+
"`limit` should never negatively overflow since we're parsing into a usize and we'd get Empty instead"
109+
)
110+
}
111+
IntErrorKind::Zero => {
112+
panic!("zero is a valid `limit` so should have returned Ok() when parsing")
113+
}
114+
kind => panic!("unimplemented IntErrorKind variant: {:?}", kind),
115+
},
116+
};
117+
118+
self.emit_err(LimitInvalid { span: self.attr_span, value_span: nv.value_span, error_str });
119+
120+
None
121+
}
122+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use crate::attributes::prototype::CustomMirParser;
5353
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
5454
use crate::attributes::rustc_internal::{
5555
RustcLayoutScalarValidRangeEnd, RustcLayoutScalarValidRangeStart,
56-
RustcObjectLifetimeDefaultParser,
56+
RustcObjectLifetimeDefaultParser, RustcSimdMonomorphizeLaneLimitParser,
5757
};
5858
use crate::attributes::semantics::MayDangleParser;
5959
use crate::attributes::stability::{
@@ -198,6 +198,7 @@ attribute_parsers!(
198198
Single<RustcLayoutScalarValidRangeEnd>,
199199
Single<RustcLayoutScalarValidRangeStart>,
200200
Single<RustcObjectLifetimeDefaultParser>,
201+
Single<RustcSimdMonomorphizeLaneLimitParser>,
201202
Single<SanitizeParser>,
202203
Single<ShouldPanicParser>,
203204
Single<SkipDuringMethodDispatchParser>,

compiler/rustc_builtin_macros/src/global_allocator.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl AllocFnFactory<'_, '_> {
8585
body,
8686
define_opaque: None,
8787
}));
88-
let item = self.cx.item(self.span, self.attrs(), kind);
88+
let item = self.cx.item(self.span, self.attrs(method), kind);
8989
self.cx.stmt_item(self.ty_span, item)
9090
}
9191

@@ -100,8 +100,18 @@ impl AllocFnFactory<'_, '_> {
100100
self.cx.expr_call(self.ty_span, method, args)
101101
}
102102

103-
fn attrs(&self) -> AttrVec {
104-
thin_vec![self.cx.attr_word(sym::rustc_std_internal_symbol, self.span)]
103+
fn attrs(&self, method: &AllocatorMethod) -> AttrVec {
104+
let alloc_attr = match method.name {
105+
sym::alloc => sym::rustc_allocator,
106+
sym::dealloc => sym::rustc_deallocator,
107+
sym::realloc => sym::rustc_reallocator,
108+
sym::alloc_zeroed => sym::rustc_allocator_zeroed,
109+
_ => unreachable!("Unknown allocator method!"),
110+
};
111+
thin_vec![
112+
self.cx.attr_word(sym::rustc_std_internal_symbol, self.span),
113+
self.cx.attr_word(alloc_attr, self.span)
114+
]
105115
}
106116

107117
fn arg_ty(&self, input: &AllocatorMethodInput, args: &mut ThinVec<Param>) -> Box<Expr> {

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,10 @@ pub(crate) struct FullyMonomorphizedLayoutCx<'tcx>(pub(crate) TyCtxt<'tcx>);
439439
impl<'tcx> LayoutOfHelpers<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
440440
#[inline]
441441
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
442-
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
442+
if let LayoutError::SizeOverflow(_)
443+
| LayoutError::InvalidSimd { .. }
444+
| LayoutError::ReferencesError(_) = err
445+
{
443446
self.0.sess.dcx().span_fatal(span, err.to_string())
444447
} else {
445448
self.0
@@ -458,7 +461,9 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
458461
span: Span,
459462
fn_abi_request: FnAbiRequest<'tcx>,
460463
) -> ! {
461-
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
464+
if let FnAbiError::Layout(LayoutError::SizeOverflow(_) | LayoutError::InvalidSimd { .. }) =
465+
err
466+
{
462467
self.0.sess.dcx().emit_fatal(Spanned { span, node: err })
463468
} else {
464469
match fn_abi_request {

compiler/rustc_codegen_cranelift/src/global_asm.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ impl<'tcx> AsmCodegenMethods<'tcx> for GlobalAsmContext<'_, 'tcx> {
4242
impl<'tcx> LayoutOfHelpers<'tcx> for GlobalAsmContext<'_, 'tcx> {
4343
#[inline]
4444
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
45-
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
45+
if let LayoutError::SizeOverflow(_)
46+
| LayoutError::InvalidSimd { .. }
47+
| LayoutError::ReferencesError(_) = err
48+
{
4649
self.tcx.sess.dcx().span_fatal(span, err.to_string())
4750
} else {
4851
self.tcx

compiler/rustc_codegen_gcc/src/context.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,10 @@ impl<'gcc, 'tcx> HasX86AbiOpt for CodegenCx<'gcc, 'tcx> {
529529
impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
530530
#[inline]
531531
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
532-
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
532+
if let LayoutError::SizeOverflow(_)
533+
| LayoutError::InvalidSimd { .. }
534+
| LayoutError::ReferencesError(_) = err
535+
{
533536
self.tcx.dcx().emit_fatal(respan(span, err.into_diagnostic()))
534537
} else {
535538
self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
@@ -545,7 +548,9 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
545548
span: Span,
546549
fn_abi_request: FnAbiRequest<'tcx>,
547550
) -> ! {
548-
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
551+
if let FnAbiError::Layout(LayoutError::SizeOverflow(_) | LayoutError::InvalidSimd { .. }) =
552+
err
553+
{
549554
self.tcx.dcx().emit_fatal(respan(span, err))
550555
} else {
551556
match fn_abi_request {

compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ impl Drop for OwnedTargetMachine {
9595
// SAFETY: constructing ensures we have a valid pointer created by
9696
// llvm::LLVMRustCreateTargetMachine OwnedTargetMachine is not copyable so there is no
9797
// double free or use after free.
98-
unsafe {
99-
llvm::LLVMRustDisposeTargetMachine(self.tm_unique.as_ptr());
100-
}
98+
unsafe { llvm::LLVMDisposeTargetMachine(self.tm_unique) };
10199
}
102100
}

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,10 @@ impl<'tcx, 'll> HasTypingEnv<'tcx> for CodegenCx<'ll, 'tcx> {
10441044
impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
10451045
#[inline]
10461046
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
1047-
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
1047+
if let LayoutError::SizeOverflow(_)
1048+
| LayoutError::ReferencesError(_)
1049+
| LayoutError::InvalidSimd { .. } = err
1050+
{
10481051
self.tcx.dcx().emit_fatal(Spanned { span, node: err.into_diagnostic() })
10491052
} else {
10501053
self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
@@ -1061,7 +1064,11 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
10611064
fn_abi_request: FnAbiRequest<'tcx>,
10621065
) -> ! {
10631066
match err {
1064-
FnAbiError::Layout(LayoutError::SizeOverflow(_) | LayoutError::Cycle(_)) => {
1067+
FnAbiError::Layout(
1068+
LayoutError::SizeOverflow(_)
1069+
| LayoutError::Cycle(_)
1070+
| LayoutError::InvalidSimd { .. },
1071+
) => {
10651072
self.tcx.dcx().emit_fatal(Spanned { span, node: err });
10661073
}
10671074
_ => match fn_abi_request {

0 commit comments

Comments
 (0)