Skip to content

Commit 6d35f2a

Browse files
committed
Auto merge of rust-lang#140161 - ChrisDenton:rollup-krbf3er, r=ChrisDenton
Rollup of 8 pull requests Successful merges: - rust-lang#139309 (make abi_unsupported_vector_types a hard error) - rust-lang#139617 (Use posix_spawn on cygwin) - rust-lang#140072 (handle function alignment in miri) - rust-lang#140104 (Fix auto diff failing on inherent impl blocks) - rust-lang#140124 (Update books) - rust-lang#140144 (Handle another negated literal in `eat_token_lit`.) - rust-lang#140146 (Update `compiler_builtins` to 0.1.156) - rust-lang#140149 (test_nan: ensure the NAN contant is quiet) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6bc57c6 + 6864ec4 commit 6d35f2a

Some content is hidden

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

49 files changed

+315
-1017
lines changed

compiler/rustc_builtin_macros/src/autodiff.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,12 @@ mod llvm_enzyme {
217217
ast::StmtKind::Item(iitem) => extract_item_info(iitem),
218218
_ => None,
219219
},
220-
Annotatable::AssocItem(assoc_item, Impl { of_trait: false }) => {
221-
match &assoc_item.kind {
222-
ast::AssocItemKind::Fn(box ast::Fn { sig, ident, .. }) => {
223-
Some((assoc_item.vis.clone(), sig.clone(), ident.clone()))
224-
}
225-
_ => None,
220+
Annotatable::AssocItem(assoc_item, Impl { .. }) => match &assoc_item.kind {
221+
ast::AssocItemKind::Fn(box ast::Fn { sig, ident, .. }) => {
222+
Some((assoc_item.vis.clone(), sig.clone(), ident.clone()))
226223
}
227-
}
224+
_ => None,
225+
},
228226
_ => None,
229227
}) else {
230228
dcx.emit_err(errors::AutoDiffInvalidApplication { span: item.span() });
@@ -365,7 +363,7 @@ mod llvm_enzyme {
365363
}
366364
Annotatable::Item(iitem.clone())
367365
}
368-
Annotatable::AssocItem(ref mut assoc_item, i @ Impl { of_trait: false }) => {
366+
Annotatable::AssocItem(ref mut assoc_item, i @ Impl { .. }) => {
369367
if !assoc_item.attrs.iter().any(|a| same_attribute(&a.kind, &attr.kind)) {
370368
assoc_item.attrs.push(attr);
371369
}

compiler/rustc_codegen_cranelift/example/std_example.rs

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
unboxed_closures
99
)]
1010
#![allow(internal_features)]
11-
// FIXME once abi_unsupported_vector_types is a hard error disable the foo test when the respective
12-
// target feature is not enabled.
13-
#![allow(abi_unsupported_vector_types)]
1411

1512
#[cfg(target_arch = "x86_64")]
1613
use std::arch::x86_64::*;

compiler/rustc_const_eval/src/interpret/memory.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,21 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
872872

873873
// # Function pointers
874874
// (both global from `alloc_map` and local from `extra_fn_ptr_map`)
875-
if self.get_fn_alloc(id).is_some() {
876-
return AllocInfo::new(Size::ZERO, Align::ONE, AllocKind::Function, Mutability::Not);
875+
if let Some(fn_val) = self.get_fn_alloc(id) {
876+
let align = match fn_val {
877+
FnVal::Instance(instance) => {
878+
// Function alignment can be set globally with the `-Zmin-function-alignment=<n>` flag;
879+
// the alignment from a `#[repr(align(<n>))]` is used if it specifies a higher alignment.
880+
let fn_align = self.tcx.codegen_fn_attrs(instance.def_id()).alignment;
881+
let global_align = self.tcx.sess.opts.unstable_opts.min_function_alignment;
882+
883+
Ord::max(global_align, fn_align).unwrap_or(Align::ONE)
884+
}
885+
// Machine-specific extra functions currently do not support alignment restrictions.
886+
FnVal::Other(_) => Align::ONE,
887+
};
888+
889+
return AllocInfo::new(Size::ZERO, align, AllocKind::Function, Mutability::Not);
877890
}
878891

879892
// # Global allocations

compiler/rustc_lint/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,11 @@ fn register_builtins(store: &mut LintStore) {
608608
"converted into hard error, see PR #139001 \
609609
<https://github.com/rust-lang/rust/issues/139001> for more information",
610610
);
611+
store.register_removed(
612+
"abi_unsupported_vector_types",
613+
"converted into hard error, \
614+
see <https://github.com/rust-lang/rust/issues/116558> for more information",
615+
);
611616
}
612617

613618
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint_defs/src/builtin.rs

-69
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ declare_lint_pass! {
1616
/// that are used by other parts of the compiler.
1717
HardwiredLints => [
1818
// tidy-alphabetical-start
19-
ABI_UNSUPPORTED_VECTOR_TYPES,
2019
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
2120
AMBIGUOUS_ASSOCIATED_ITEMS,
2221
AMBIGUOUS_GLOB_IMPORTS,
@@ -5027,74 +5026,6 @@ declare_lint! {
50275026
crate_level_only
50285027
}
50295028

5030-
declare_lint! {
5031-
/// The `abi_unsupported_vector_types` lint detects function definitions and calls
5032-
/// whose ABI depends on enabling certain target features, but those features are not enabled.
5033-
///
5034-
/// ### Example
5035-
///
5036-
/// ```rust,ignore (fails on non-x86_64)
5037-
/// extern "C" fn missing_target_feature(_: std::arch::x86_64::__m256) {
5038-
/// todo!()
5039-
/// }
5040-
///
5041-
/// #[target_feature(enable = "avx")]
5042-
/// unsafe extern "C" fn with_target_feature(_: std::arch::x86_64::__m256) {
5043-
/// todo!()
5044-
/// }
5045-
///
5046-
/// fn main() {
5047-
/// let v = unsafe { std::mem::zeroed() };
5048-
/// unsafe { with_target_feature(v); }
5049-
/// }
5050-
/// ```
5051-
///
5052-
/// This will produce:
5053-
///
5054-
/// ```text
5055-
/// warning: ABI error: this function call uses a avx vector type, which is not enabled in the caller
5056-
/// --> lint_example.rs:18:12
5057-
/// |
5058-
/// | unsafe { with_target_feature(v); }
5059-
/// | ^^^^^^^^^^^^^^^^^^^^^^ function called here
5060-
/// |
5061-
/// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5062-
/// = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
5063-
/// = help: consider enabling it globally (-C target-feature=+avx) or locally (#[target_feature(enable="avx")])
5064-
/// = note: `#[warn(abi_unsupported_vector_types)]` on by default
5065-
///
5066-
///
5067-
/// warning: ABI error: this function definition uses a avx vector type, which is not enabled
5068-
/// --> lint_example.rs:3:1
5069-
/// |
5070-
/// | pub extern "C" fn with_target_feature(_: std::arch::x86_64::__m256) {
5071-
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
5072-
/// |
5073-
/// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5074-
/// = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
5075-
/// = help: consider enabling it globally (-C target-feature=+avx) or locally (#[target_feature(enable="avx")])
5076-
/// ```
5077-
///
5078-
///
5079-
///
5080-
/// ### Explanation
5081-
///
5082-
/// The C ABI for `__m256` requires the value to be passed in an AVX register,
5083-
/// which is only possible when the `avx` target feature is enabled.
5084-
/// Therefore, `missing_target_feature` cannot be compiled without that target feature.
5085-
/// A similar (but complementary) message is triggered when `with_target_feature` is called
5086-
/// by a function that does not enable the `avx` target feature.
5087-
///
5088-
/// Note that this lint is very similar to the `-Wpsabi` warning in `gcc`/`clang`.
5089-
pub ABI_UNSUPPORTED_VECTOR_TYPES,
5090-
Warn,
5091-
"this function call or definition uses a vector type which is not enabled",
5092-
@future_incompatible = FutureIncompatibleInfo {
5093-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
5094-
reference: "issue #116558 <https://github.com/rust-lang/rust/issues/116558>",
5095-
};
5096-
}
5097-
50985029
declare_lint! {
50995030
/// The `wasm_c_abi` lint detects usage of the `extern "C"` ABI of wasm that is affected
51005031
/// by a planned ABI change that has the goal of aligning Rust with the standard C ABI

compiler/rustc_monomorphize/src/errors.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ pub(crate) struct UnknownCguCollectionMode<'a> {
7070
pub mode: &'a str,
7171
}
7272

73-
#[derive(LintDiagnostic)]
73+
#[derive(Diagnostic)]
7474
#[diag(monomorphize_abi_error_disabled_vector_type)]
7575
#[help]
7676
pub(crate) struct AbiErrorDisabledVectorType<'a> {
77+
#[primary_span]
7778
#[label]
7879
pub span: Span,
7980
pub required_feature: &'a str,
@@ -82,9 +83,10 @@ pub(crate) struct AbiErrorDisabledVectorType<'a> {
8283
pub is_call: bool,
8384
}
8485

85-
#[derive(LintDiagnostic)]
86+
#[derive(Diagnostic)]
8687
#[diag(monomorphize_abi_error_unsupported_vector_type)]
8788
pub(crate) struct AbiErrorUnsupportedVectorType<'a> {
89+
#[primary_span]
8890
#[label]
8991
pub span: Span,
9092
pub ty: Ty<'a>,

compiler/rustc_monomorphize/src/mono_checks/abi_check.rs

+12-22
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::{CRATE_HIR_ID, HirId};
55
use rustc_middle::mir::{self, Location, traversal};
66
use rustc_middle::ty::layout::LayoutCx;
77
use rustc_middle::ty::{self, Instance, InstanceKind, Ty, TyCtxt, TypingEnv};
8-
use rustc_session::lint::builtin::{ABI_UNSUPPORTED_VECTOR_TYPES, WASM_C_ABI};
8+
use rustc_session::lint::builtin::WASM_C_ABI;
99
use rustc_span::def_id::DefId;
1010
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
1111
use rustc_target::callconv::{ArgAbi, Conv, FnAbi, PassMode};
@@ -50,34 +50,24 @@ fn do_check_simd_vector_abi<'tcx>(
5050
let feature = match feature_def.iter().find(|(bits, _)| size.bits() <= *bits) {
5151
Some((_, feature)) => feature,
5252
None => {
53-
let (span, hir_id) = loc();
54-
tcx.emit_node_span_lint(
55-
ABI_UNSUPPORTED_VECTOR_TYPES,
56-
hir_id,
53+
let (span, _hir_id) = loc();
54+
tcx.dcx().emit_err(errors::AbiErrorUnsupportedVectorType {
5755
span,
58-
errors::AbiErrorUnsupportedVectorType {
59-
span,
60-
ty: arg_abi.layout.ty,
61-
is_call,
62-
},
63-
);
56+
ty: arg_abi.layout.ty,
57+
is_call,
58+
});
6459
continue;
6560
}
6661
};
6762
if !have_feature(Symbol::intern(feature)) {
6863
// Emit error.
69-
let (span, hir_id) = loc();
70-
tcx.emit_node_span_lint(
71-
ABI_UNSUPPORTED_VECTOR_TYPES,
72-
hir_id,
64+
let (span, _hir_id) = loc();
65+
tcx.dcx().emit_err(errors::AbiErrorDisabledVectorType {
7366
span,
74-
errors::AbiErrorDisabledVectorType {
75-
span,
76-
required_feature: feature,
77-
ty: arg_abi.layout.ty,
78-
is_call,
79-
},
80-
);
67+
required_feature: feature,
68+
ty: arg_abi.layout.ty,
69+
is_call,
70+
});
8171
}
8272
}
8373
}

compiler/rustc_parse/src/parser/expr.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -2146,6 +2146,17 @@ impl<'a> Parser<'a> {
21462146
/// Keep this in sync with `Token::can_begin_literal_maybe_minus` and
21472147
/// `Lit::from_token` (excluding unary negation).
21482148
fn eat_token_lit(&mut self) -> Option<token::Lit> {
2149+
let check_expr = |expr: P<Expr>| {
2150+
if let ast::ExprKind::Lit(token_lit) = expr.kind {
2151+
Some(token_lit)
2152+
} else if let ast::ExprKind::Unary(UnOp::Neg, inner) = &expr.kind
2153+
&& let ast::Expr { kind: ast::ExprKind::Lit(_), .. } = **inner
2154+
{
2155+
None
2156+
} else {
2157+
panic!("unexpected reparsed expr/literal: {:?}", expr.kind);
2158+
}
2159+
};
21492160
match self.token.uninterpolate().kind {
21502161
token::Ident(name, IdentIsRaw::No) if name.is_bool_lit() => {
21512162
self.bump();
@@ -2159,26 +2170,15 @@ impl<'a> Parser<'a> {
21592170
let lit = self
21602171
.eat_metavar_seq(MetaVarKind::Literal, |this| this.parse_literal_maybe_minus())
21612172
.expect("metavar seq literal");
2162-
let ast::ExprKind::Lit(token_lit) = lit.kind else {
2163-
panic!("didn't reparse a literal");
2164-
};
2165-
Some(token_lit)
2173+
check_expr(lit)
21662174
}
21672175
token::OpenInvisible(InvisibleOrigin::MetaVar(
21682176
mv_kind @ MetaVarKind::Expr { can_begin_literal_maybe_minus: true, .. },
21692177
)) => {
21702178
let expr = self
21712179
.eat_metavar_seq(mv_kind, |this| this.parse_expr())
21722180
.expect("metavar seq expr");
2173-
if let ast::ExprKind::Lit(token_lit) = expr.kind {
2174-
Some(token_lit)
2175-
} else if let ast::ExprKind::Unary(UnOp::Neg, inner) = &expr.kind
2176-
&& let ast::Expr { kind: ast::ExprKind::Lit(_), .. } = **inner
2177-
{
2178-
None
2179-
} else {
2180-
panic!("unexpected reparsed expr: {:?}", expr.kind);
2181-
}
2181+
check_expr(expr)
21822182
}
21832183
_ => None,
21842184
}

compiler/rustc_target/src/target_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ const RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[
775775
(32768, "zvl32768b"),
776776
(65536, "zvl65536b"),
777777
];
778-
// Always warn on SPARC, as the necessary target features cannot be enabled in Rust at the moment.
778+
// Always error on SPARC, as the necessary target features cannot be enabled in Rust at the moment.
779779
const SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[/*(64, "vis")*/];
780780

781781
const HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] =

library/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ dependencies = [
6767

6868
[[package]]
6969
name = "compiler_builtins"
70-
version = "0.1.155"
70+
version = "0.1.156"
7171
source = "registry+https://github.com/rust-lang/crates.io-index"
72-
checksum = "341e0830ca6170a4fcf02e92e57daf4b6f10142d48da32a547023867a6c8b35e"
72+
checksum = "c1ffbd2789fe5bb95b96a2e22cbe3128239dc46ff0374e0d38e9f102062d7055"
7373
dependencies = [
7474
"cc",
7575
"rustc-std-workspace-core",

library/alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bench = false
1616

1717
[dependencies]
1818
core = { path = "../core", public = true }
19-
compiler_builtins = { version = "=0.1.155", features = ['rustc-dep-of-std'] }
19+
compiler_builtins = { version = "=0.1.156", features = ['rustc-dep-of-std'] }
2020

2121
[features]
2222
compiler-builtins-mem = ['compiler_builtins/mem']

library/core/src/num/f128.rs

+3
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ impl f128 {
145145
pub const RADIX: u32 = 2;
146146

147147
/// Number of significant digits in base 2.
148+
///
149+
/// Note that the size of the mantissa in the bitwise representation is one
150+
/// smaller than this since the leading 1 is not stored explicitly.
148151
#[unstable(feature = "f128", issue = "116909")]
149152
pub const MANTISSA_DIGITS: u32 = 113;
150153

library/core/src/num/f16.rs

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ impl f16 {
140140
pub const RADIX: u32 = 2;
141141

142142
/// Number of significant digits in base 2.
143+
///
144+
/// Note that the size of the mantissa in the bitwise representation is one
145+
/// smaller than this since the leading 1 is not stored explicitly.
143146
#[unstable(feature = "f16", issue = "116909")]
144147
pub const MANTISSA_DIGITS: u32 = 11;
145148

library/core/src/num/f32.rs

+3
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ impl f32 {
390390
pub const RADIX: u32 = 2;
391391

392392
/// Number of significant digits in base 2.
393+
///
394+
/// Note that the size of the mantissa in the bitwise representation is one
395+
/// smaller than this since the leading 1 is not stored explicitly.
393396
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
394397
pub const MANTISSA_DIGITS: u32 = 24;
395398

library/core/src/num/f64.rs

+3
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ impl f64 {
390390
pub const RADIX: u32 = 2;
391391

392392
/// Number of significant digits in base 2.
393+
///
394+
/// Note that the size of the mantissa in the bitwise representation is one
395+
/// smaller than this since the leading 1 is not stored explicitly.
393396
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
394397
pub const MANTISSA_DIGITS: u32 = 53;
395398
/// Approximate number of significant digits in base 10.

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1818
panic_unwind = { path = "../panic_unwind", optional = true }
1919
panic_abort = { path = "../panic_abort" }
2020
core = { path = "../core", public = true }
21-
compiler_builtins = { version = "=0.1.155" }
21+
compiler_builtins = { version = "=0.1.156" }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.15", default-features = false, features = [
2424
'rustc-dep-of-std',

library/std/src/sys/process/unix/unix.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ impl Command {
415415
all(target_os = "linux", target_env = "musl"),
416416
target_os = "nto",
417417
target_vendor = "apple",
418+
target_os = "cygwin",
418419
)))]
419420
fn posix_spawn(
420421
&mut self,
@@ -433,6 +434,7 @@ impl Command {
433434
all(target_os = "linux", target_env = "musl"),
434435
target_os = "nto",
435436
target_vendor = "apple",
437+
target_os = "cygwin",
436438
))]
437439
fn posix_spawn(
438440
&mut self,
@@ -584,7 +586,7 @@ impl Command {
584586
/// Some platforms can set a new working directory for a spawned process in the
585587
/// `posix_spawn` path. This function looks up the function pointer for adding
586588
/// such an action to a `posix_spawn_file_actions_t` struct.
587-
#[cfg(not(all(target_os = "linux", target_env = "musl")))]
589+
#[cfg(not(any(all(target_os = "linux", target_env = "musl"), target_os = "cygwin")))]
588590
fn get_posix_spawn_addchdir() -> Option<PosixSpawnAddChdirFn> {
589591
use crate::sys::weak::weak;
590592

@@ -618,7 +620,9 @@ impl Command {
618620
/// Weak symbol lookup doesn't work with statically linked libcs, so in cases
619621
/// where static linking is possible we need to either check for the presence
620622
/// of the symbol at compile time or know about it upfront.
621-
#[cfg(all(target_os = "linux", target_env = "musl"))]
623+
///
624+
/// Cygwin doesn't support weak symbol, so just link it.
625+
#[cfg(any(all(target_os = "linux", target_env = "musl"), target_os = "cygwin"))]
622626
fn get_posix_spawn_addchdir() -> Option<PosixSpawnAddChdirFn> {
623627
// Our minimum required musl supports this function, so we can just use it.
624628
Some(libc::posix_spawn_file_actions_addchdir_np)

0 commit comments

Comments
 (0)