Skip to content

Commit cbceb29

Browse files
committed
Auto merge of rust-lang#130265 - Zalathar:rollup-cm4x04z, r=Zalathar
Rollup of 8 pull requests Successful merges: - rust-lang#129367 (Fix default/minimum deployment target for Aarch64 simulator targets) - rust-lang#129992 (Update compiler-builtins to 0.1.125) - rust-lang#130052 (Don't leave debug locations for constants sitting on the builder indefinitely) - rust-lang#130156 (Add test for S_OBJNAME & update test for LF_BUILDINFO cl and cmd) - rust-lang#130160 (Fix `slice::first_mut` docs) - rust-lang#130250 (Fix `clippy::useless_conversion`) - rust-lang#130252 (Properly report error on `const gen fn`) - rust-lang#130256 (Re-run coverage tests if `coverage-dump` was modified) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7c7372b + 81cba5e commit cbceb29

File tree

39 files changed

+245
-98
lines changed

39 files changed

+245
-98
lines changed

compiler/rustc_ast/src/ast.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -2602,12 +2602,12 @@ impl CoroutineKind {
26022602
}
26032603
}
26042604

2605-
pub fn is_async(self) -> bool {
2606-
matches!(self, CoroutineKind::Async { .. })
2607-
}
2608-
2609-
pub fn is_gen(self) -> bool {
2610-
matches!(self, CoroutineKind::Gen { .. })
2605+
pub fn as_str(self) -> &'static str {
2606+
match self {
2607+
CoroutineKind::Async { .. } => "async",
2608+
CoroutineKind::Gen { .. } => "gen",
2609+
CoroutineKind::AsyncGen { .. } => "async gen",
2610+
}
26112611
}
26122612

26132613
pub fn closure_id(self) -> NodeId {
@@ -3486,7 +3486,7 @@ impl From<ForeignItemKind> for ItemKind {
34863486
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
34873487
match foreign_item_kind {
34883488
ForeignItemKind::Static(box static_foreign_item) => {
3489-
ItemKind::Static(Box::new(static_foreign_item.into()))
3489+
ItemKind::Static(Box::new(static_foreign_item))
34903490
}
34913491
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
34923492
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
@@ -3500,9 +3500,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
35003500

35013501
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
35023502
Ok(match item_kind {
3503-
ItemKind::Static(box static_item) => {
3504-
ForeignItemKind::Static(Box::new(static_item.into()))
3505-
}
3503+
ItemKind::Static(box static_item) => ForeignItemKind::Static(Box::new(static_item)),
35063504
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
35073505
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
35083506
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),

compiler/rustc_ast_passes/messages.ftl

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block
4040
4141
ast_passes_bound_in_context = bounds on `type`s in {$ctx} have no effect
4242
43-
ast_passes_const_and_async = functions cannot be both `const` and `async`
44-
.const = `const` because of this
45-
.async = `async` because of this
46-
.label = {""}
47-
4843
ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic
4944
.const = `const` because of this
5045
.variadic = C-variadic because of this
5146
47+
ast_passes_const_and_coroutine = functions cannot be both `const` and `{$coroutine_kind}`
48+
.const = `const` because of this
49+
.coroutine = `{$coroutine_kind}` because of this
50+
.label = {""}
51+
5252
ast_passes_const_bound_trait_object = const trait bounds are not allowed in trait object types
5353
5454
ast_passes_const_without_body =

compiler/rustc_ast_passes/src/ast_validation.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -1418,21 +1418,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14181418

14191419
// Functions cannot both be `const async` or `const gen`
14201420
if let Some(&FnHeader {
1421-
constness: Const::Yes(cspan),
1421+
constness: Const::Yes(const_span),
14221422
coroutine_kind: Some(coroutine_kind),
14231423
..
14241424
}) = fk.header()
14251425
{
1426-
let aspan = match coroutine_kind {
1427-
CoroutineKind::Async { span: aspan, .. }
1428-
| CoroutineKind::Gen { span: aspan, .. }
1429-
| CoroutineKind::AsyncGen { span: aspan, .. } => aspan,
1430-
};
1431-
// FIXME(gen_blocks): Report a different error for `const gen`
1432-
self.dcx().emit_err(errors::ConstAndAsync {
1433-
spans: vec![cspan, aspan],
1434-
cspan,
1435-
aspan,
1426+
self.dcx().emit_err(errors::ConstAndCoroutine {
1427+
spans: vec![coroutine_kind.span(), const_span],
1428+
const_span,
1429+
coroutine_span: coroutine_kind.span(),
1430+
coroutine_kind: coroutine_kind.as_str(),
14361431
span,
14371432
});
14381433
}

compiler/rustc_ast_passes/src/errors.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -657,16 +657,17 @@ pub(crate) enum TildeConstReason {
657657
}
658658

659659
#[derive(Diagnostic)]
660-
#[diag(ast_passes_const_and_async)]
661-
pub(crate) struct ConstAndAsync {
660+
#[diag(ast_passes_const_and_coroutine)]
661+
pub(crate) struct ConstAndCoroutine {
662662
#[primary_span]
663663
pub spans: Vec<Span>,
664664
#[label(ast_passes_const)]
665-
pub cspan: Span,
666-
#[label(ast_passes_async)]
667-
pub aspan: Span,
665+
pub const_span: Span,
666+
#[label(ast_passes_coroutine)]
667+
pub coroutine_span: Span,
668668
#[label]
669669
pub span: Span,
670+
pub coroutine_kind: &'static str,
670671
}
671672

672673
#[derive(Diagnostic)]

compiler/rustc_codegen_gcc/src/debuginfo.rs

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
4848
fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation) {
4949
self.location = Some(dbg_loc);
5050
}
51+
52+
fn clear_dbg_loc(&mut self) {
53+
self.location = None;
54+
}
5155
}
5256

5357
/// Generate the `debug_context` in an MIR Body.

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![doc = include_str!("doc.md")]
22

33
use std::cell::{OnceCell, RefCell};
4-
use std::iter;
54
use std::ops::Range;
5+
use std::{iter, ptr};
66

77
use libc::c_uint;
88
use rustc_codegen_ssa::debuginfo::type_names;
@@ -209,6 +209,12 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
209209
}
210210
}
211211

212+
fn clear_dbg_loc(&mut self) {
213+
unsafe {
214+
llvm::LLVMSetCurrentDebugLocation2(self.llbuilder, ptr::null());
215+
}
216+
}
217+
212218
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
213219
gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
214220
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ unsafe extern "C" {
10411041
pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
10421042

10431043
// Metadata
1044-
pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: &'a Metadata);
1044+
pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: *const Metadata);
10451045

10461046
// Terminators
10471047
pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

+1
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
547547
self.set_debug_loc(bx, var.source_info);
548548
let base =
549549
Self::spill_operand_to_stack(operand, Some(var.name.to_string()), bx);
550+
bx.clear_dbg_loc();
550551

551552
bx.dbg_var_addr(
552553
dbg_var,

compiler/rustc_codegen_ssa/src/traits/debuginfo.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub trait DebugInfoBuilderMethods: BackendTypes {
8080
fragment: Option<Range<Size>>,
8181
);
8282
fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation);
83+
fn clear_dbg_loc(&mut self);
8384
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
8485
fn set_var_name(&mut self, value: Self::Value, name: &str);
8586
}

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
7575

7676
// This can't use `init_stack_frame` since `body` is not a function,
7777
// so computing its ABI would fail. It's also not worth it since there are no arguments to pass.
78-
ecx.push_stack_frame_raw(
79-
cid.instance,
80-
body,
81-
&ret.clone().into(),
82-
StackPopCleanup::Root { cleanup: false },
83-
)?;
78+
ecx.push_stack_frame_raw(cid.instance, body, &ret, StackPopCleanup::Root { cleanup: false })?;
8479
ecx.storage_live_for_always_live_locals()?;
8580

8681
// The main interpreter loop.

compiler/rustc_const_eval/src/interpret/call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
823823
(Abi::Rust, fn_abi),
824824
&[FnArg::Copy(arg.into())],
825825
false,
826-
&ret.into(),
826+
&ret,
827827
Some(target),
828828
unwind,
829829
)

compiler/rustc_errors/src/diagnostic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,10 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
681681
" ".repeat(expected_padding),
682682
expected_label
683683
))];
684-
msg.extend(expected.0.into_iter());
684+
msg.extend(expected.0);
685685
msg.push(StringPart::normal(format!("`{expected_extra}\n")));
686686
msg.push(StringPart::normal(format!("{}{} `", " ".repeat(found_padding), found_label)));
687-
msg.extend(found.0.into_iter());
687+
msg.extend(found.0);
688688
msg.push(StringPart::normal(format!("`{found_extra}")));
689689

690690
// For now, just attach these as notes.

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ fn check_fn_or_method<'tcx>(
16021602
function: def_id,
16031603
// Note that the `param_idx` of the output type is
16041604
// one greater than the index of the last input type.
1605-
param_idx: idx.try_into().unwrap(),
1605+
param_idx: idx,
16061606
}),
16071607
ty,
16081608
)
@@ -1611,7 +1611,7 @@ fn check_fn_or_method<'tcx>(
16111611
for (idx, ty) in sig.inputs_and_output.iter().enumerate() {
16121612
wfcx.register_wf_obligation(
16131613
arg_span(idx),
1614-
Some(WellFormedLoc::Param { function: def_id, param_idx: idx.try_into().unwrap() }),
1614+
Some(WellFormedLoc::Param { function: def_id, param_idx: idx }),
16151615
ty.into(),
16161616
);
16171617
}

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2565,7 +2565,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25652565
other_generic_param.name.ident() == generic_param.name.ident()
25662566
},
25672567
) {
2568-
idxs_matched.push(other_idx.into());
2568+
idxs_matched.push(other_idx);
25692569
}
25702570

25712571
if idxs_matched.is_empty() {

compiler/rustc_middle/src/ty/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl<'tcx> Const<'tcx> {
396396
Ok((tcx.type_of(unevaluated.def).instantiate(tcx, unevaluated.args), c))
397397
}
398398
Ok(Err(bad_ty)) => Err(Either::Left(bad_ty)),
399-
Err(err) => Err(Either::Right(err.into())),
399+
Err(err) => Err(Either::Right(err)),
400400
}
401401
}
402402
ConstKind::Value(ty, val) => Ok((ty, val)),

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
15261526

15271527
let precedence = |binop: rustc_middle::mir::BinOp| {
15281528
use rustc_ast::util::parser::AssocOp;
1529-
AssocOp::from_ast_binop(binop.to_hir_binop().into()).precedence()
1529+
AssocOp::from_ast_binop(binop.to_hir_binop()).precedence()
15301530
};
15311531
let op_precedence = precedence(op);
15321532
let formatted_op = op.to_hir_binop().as_str();

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

-1
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@ where
883883
.into_iter()
884884
.chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| {
885885
elaborate::supertrait_def_ids(self.cx(), principal_def_id)
886-
.into_iter()
887886
.filter(|def_id| self.cx().trait_is_auto(*def_id))
888887
}))
889888
.collect();

compiler/rustc_parse/src/parser/attr_wrapper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'a> Parser<'a> {
383383
self.capture_state
384384
.parser_replacements
385385
.drain(parser_replacements_start..parser_replacements_end)
386-
.chain(inner_attr_parser_replacements.into_iter())
386+
.chain(inner_attr_parser_replacements)
387387
.map(|(parser_range, data)| {
388388
(NodeRange::new(parser_range, collect_pos.start_pos), data)
389389
})

compiler/rustc_parse/src/parser/item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ impl<'a> Parser<'a> {
15881588
(thin_vec![], Recovered::Yes(guar))
15891589
}
15901590
};
1591-
VariantData::Struct { fields, recovered: recovered.into() }
1591+
VariantData::Struct { fields, recovered }
15921592
} else if this.check(&token::OpenDelim(Delimiter::Parenthesis)) {
15931593
let body = match this.parse_tuple_struct_body() {
15941594
Ok(body) => body,
@@ -1672,7 +1672,7 @@ impl<'a> Parser<'a> {
16721672
class_name.span,
16731673
generics.where_clause.has_where_token,
16741674
)?;
1675-
VariantData::Struct { fields, recovered: recovered.into() }
1675+
VariantData::Struct { fields, recovered }
16761676
}
16771677
// No `where` so: `struct Foo<T>;`
16781678
} else if self.eat(&token::Semi) {
@@ -1684,7 +1684,7 @@ impl<'a> Parser<'a> {
16841684
class_name.span,
16851685
generics.where_clause.has_where_token,
16861686
)?;
1687-
VariantData::Struct { fields, recovered: recovered.into() }
1687+
VariantData::Struct { fields, recovered }
16881688
// Tuple-style struct definition with optional where-clause.
16891689
} else if self.token == token::OpenDelim(Delimiter::Parenthesis) {
16901690
let body = VariantData::Tuple(self.parse_tuple_struct_body()?, DUMMY_NODE_ID);
@@ -1713,14 +1713,14 @@ impl<'a> Parser<'a> {
17131713
class_name.span,
17141714
generics.where_clause.has_where_token,
17151715
)?;
1716-
VariantData::Struct { fields, recovered: recovered.into() }
1716+
VariantData::Struct { fields, recovered }
17171717
} else if self.token == token::OpenDelim(Delimiter::Brace) {
17181718
let (fields, recovered) = self.parse_record_struct_body(
17191719
"union",
17201720
class_name.span,
17211721
generics.where_clause.has_where_token,
17221722
)?;
1723-
VariantData::Struct { fields, recovered: recovered.into() }
1723+
VariantData::Struct { fields, recovered }
17241724
} else {
17251725
let token_str = super::token_descr(&self.token);
17261726
let msg = format!("expected `where` or `{{` after union name, found {token_str}");

compiler/rustc_symbol_mangling/src/v0.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
381381
let consts = [
382382
start.unwrap_or(self.tcx.consts.unit),
383383
end.unwrap_or(self.tcx.consts.unit),
384-
ty::Const::from_bool(self.tcx, include_end).into(),
384+
ty::Const::from_bool(self.tcx, include_end),
385385
];
386386
// HACK: Represent as tuple until we have something better.
387387
// HACK: constants are used in arrays, even if the types don't match.

compiler/rustc_target/src/spec/base/apple/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,18 @@ fn deployment_target(os: &str, arch: Arch, abi: TargetAbi) -> (u16, u8, u8) {
351351
};
352352

353353
// On certain targets it makes sense to raise the minimum OS version.
354+
//
355+
// This matches what LLVM does, see:
356+
// <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932>
354357
let min = match (os, arch, abi) {
355-
// Use 11.0 on Aarch64 as that's the earliest version with M1 support.
356358
("macos", Arch::Arm64 | Arch::Arm64e, _) => (11, 0, 0),
357-
("ios", Arch::Arm64e, _) => (14, 0, 0),
359+
("ios", Arch::Arm64 | Arch::Arm64e, TargetAbi::MacCatalyst) => (14, 0, 0),
360+
("ios", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (14, 0, 0),
361+
("ios", Arch::Arm64e, TargetAbi::Normal) => (14, 0, 0),
358362
// Mac Catalyst defaults to 13.1 in Clang.
359363
("ios", _, TargetAbi::MacCatalyst) => (13, 1, 0),
364+
("tvos", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (14, 0, 0),
365+
("watchos", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (7, 0, 0),
360366
_ => os_min,
361367
};
362368

compiler/rustc_trait_selection/src/traits/project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
408408
debug!("opt_normalize_projection_type: found error");
409409
let result = normalize_to_error(selcx, param_env, projection_term, cause, depth);
410410
obligations.extend(result.obligations);
411-
return Ok(Some(result.value.into()));
411+
return Ok(Some(result.value));
412412
}
413413
}
414414

@@ -478,7 +478,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
478478
}
479479
let result = normalize_to_error(selcx, param_env, projection_term, cause, depth);
480480
obligations.extend(result.obligations);
481-
Ok(Some(result.value.into()))
481+
Ok(Some(result.value))
482482
}
483483
}
484484
}

library/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ dependencies = [
5858

5959
[[package]]
6060
name = "compiler_builtins"
61-
version = "0.1.123"
61+
version = "0.1.125"
6262
source = "registry+https://github.com/rust-lang/crates.io-index"
63-
checksum = "b47fcbecb558bdad78c7d3a998523c60a50dd6cd046d5fe74163e309e878fff7"
63+
checksum = "bd02a01d7bc069bed818e956600fe437ee222dd1d6ad92bfb9db87b43b71fd87"
6464
dependencies = [
6565
"cc",
6666
"rustc-std-workspace-core",

library/alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2021"
1010

1111
[dependencies]
1212
core = { path = "../core" }
13-
compiler_builtins = { version = "0.1.123", features = ['rustc-dep-of-std'] }
13+
compiler_builtins = { version = "0.1.125", features = ['rustc-dep-of-std'] }
1414

1515
[dev-dependencies]
1616
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

library/core/src/slice/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<T> [T] {
156156
if let [first, ..] = self { Some(first) } else { None }
157157
}
158158

159-
/// Returns a mutable pointer to the first element of the slice, or `None` if it is empty.
159+
/// Returns a mutable reference to the first element of the slice, or `None` if it is empty.
160160
///
161161
/// # Examples
162162
///

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1717
panic_unwind = { path = "../panic_unwind", optional = true }
1818
panic_abort = { path = "../panic_abort" }
1919
core = { path = "../core", public = true }
20-
compiler_builtins = { version = "0.1.123" }
20+
compiler_builtins = { version = "0.1.125" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.14", default-features = false, features = [

0 commit comments

Comments
 (0)