Skip to content

Commit 1a5bf12

Browse files
committed
Auto merge of rust-lang#140165 - ChrisDenton:rollup-on2dpr5, r=ChrisDenton
Rollup of 8 pull requests Successful merges: - rust-lang#139617 (Use posix_spawn on cygwin) - rust-lang#139921 (improve diagnostic for raw pointer field access with ->) - rust-lang#140031 (compiletest: Fix deadline bugs in new executor) - 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#140149 (test_nan: ensure the NAN contant is quiet) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6bc57c6 + 2d8264f commit 1a5bf12

File tree

34 files changed

+326
-85
lines changed

34 files changed

+326
-85
lines changed

compiler/rustc_builtin_macros/src/autodiff.rs

Lines changed: 6 additions & 8 deletions
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_const_eval/src/interpret/memory.rs

Lines changed: 15 additions & 2 deletions
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_hir_typeck/src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,8 +3289,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32893289
err.multipart_suggestion(
32903290
format!("{val} is a raw pointer; try dereferencing it"),
32913291
vec![
3292-
(base.span.shrink_to_lo(), "(*".to_string()),
3293-
(base.span.shrink_to_hi(), ")".to_string()),
3292+
(base.span.shrink_to_lo(), "(*".into()),
3293+
(base.span.between(field.span), format!(").")),
32943294
],
32953295
Applicability::MaybeIncorrect,
32963296
);

compiler/rustc_parse/messages.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ parse_expected_struct_field = expected one of `,`, `:`, or `{"}"}`, found `{$tok
246246
247247
parse_expected_trait_in_trait_impl_found_type = expected a trait, found type
248248
249-
parse_expr_rarrow_call = `->` used for field access or method call
249+
parse_expr_rarrow_call = `->` is not valid syntax for field accesses and method calls
250250
.suggestion = try using `.` instead
251-
.help = the `.` operator will dereference the value if needed
251+
.help = the `.` operator will automatically dereference the value, except if the value is a raw pointer
252252
253253
parse_extern_crate_name_with_dashes = crate name using dashes are not valid in `extern crate` statements
254254
.label = dash-separated idents are not valid

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 13 additions & 13 deletions
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
}

library/core/src/num/f128.rs

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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/src/sys/process/unix/unix.rs

Lines changed: 6 additions & 2 deletions
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)