Skip to content

Commit 16a26f9

Browse files
authored
Merge pull request rust-lang#4123 from rust-lang/rustup-2025-01-05
Automatic Rustup
2 parents ac429bc + 74a13d1 commit 16a26f9

File tree

313 files changed

+2626
-1576
lines changed

Some content is hidden

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

313 files changed

+2626
-1576
lines changed

.mailmap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ boolean_coercion <[email protected]>
8888
8989
bors <[email protected]> bors[bot] <26634292+bors[bot]@users.noreply.github.com>
9090
bors <[email protected]> bors[bot] <bors[bot]@users.noreply.github.com>
91-
91+
92+
9293
Braden Nelson <[email protected]>
9394
Brandon Sanderson <[email protected]> Brandon Sanderson <[email protected]>
9495
Brett Cannon <[email protected]> Brett Cannon <[email protected]>

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ version = "0.1.0"
419419

420420
[[package]]
421421
name = "cc"
422-
version = "1.2.6"
422+
version = "1.2.7"
423423
source = "registry+https://github.com/rust-lang/crates.io-index"
424-
checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333"
424+
checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7"
425425
dependencies = [
426426
"shlex",
427427
]

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
222222
decl,
223223
coroutine_kind,
224224
body.as_deref(),
225+
attrs,
225226
);
226227

227228
let itctx = ImplTraitContext::Universal;
@@ -233,7 +234,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
233234
header: this.lower_fn_header(*header, hir::Safety::Safe),
234235
span: this.lower_span(*fn_sig_span),
235236
};
236-
hir::ItemKind::Fn(sig, generics, body_id)
237+
hir::ItemKind::Fn { sig, generics, body: body_id, has_body: body.is_some() }
237238
})
238239
}
239240
ItemKind::Mod(_, mod_kind) => match mod_kind {
@@ -435,11 +436,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
435436
}
436437
ItemKind::Delegation(box delegation) => {
437438
let delegation_results = self.lower_delegation(delegation, id);
438-
hir::ItemKind::Fn(
439-
delegation_results.sig,
440-
delegation_results.generics,
441-
delegation_results.body_id,
442-
)
439+
hir::ItemKind::Fn {
440+
sig: delegation_results.sig,
441+
generics: delegation_results.generics,
442+
body: delegation_results.body_id,
443+
has_body: true,
444+
}
443445
}
444446
ItemKind::MacCall(..) | ItemKind::DelegationMac(..) => {
445447
panic!("macros should have been expanded by now")
@@ -747,7 +749,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
747749

748750
fn lower_trait_item(&mut self, i: &AssocItem) -> &'hir hir::TraitItem<'hir> {
749751
let hir_id = hir::HirId::make_owner(self.current_hir_id_owner.def_id);
750-
self.lower_attrs(hir_id, &i.attrs);
752+
let attrs = self.lower_attrs(hir_id, &i.attrs);
751753
let trait_item_def_id = hir_id.expect_owner();
752754

753755
let (generics, kind, has_default) = match &i.kind {
@@ -785,6 +787,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
785787
&sig.decl,
786788
sig.header.coroutine_kind,
787789
Some(body),
790+
attrs,
788791
);
789792
let (generics, sig) = self.lower_method_sig(
790793
generics,
@@ -877,7 +880,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
877880
let has_value = true;
878881
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
879882
let hir_id = hir::HirId::make_owner(self.current_hir_id_owner.def_id);
880-
self.lower_attrs(hir_id, &i.attrs);
883+
let attrs = self.lower_attrs(hir_id, &i.attrs);
881884

882885
let (generics, kind) = match &i.kind {
883886
AssocItemKind::Const(box ConstItem { generics, ty, expr, .. }) => self.lower_generics(
@@ -900,6 +903,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
900903
&sig.decl,
901904
sig.header.coroutine_kind,
902905
body.as_deref(),
906+
attrs,
903907
);
904908
let (generics, sig) = self.lower_method_sig(
905909
generics,
@@ -1054,20 +1058,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
10541058
})
10551059
}
10561060

1057-
fn lower_fn_body_block(
1058-
&mut self,
1059-
span: Span,
1060-
decl: &FnDecl,
1061-
body: Option<&Block>,
1062-
) -> hir::BodyId {
1063-
self.lower_fn_body(decl, |this| this.lower_block_expr_opt(span, body))
1064-
}
1065-
1066-
fn lower_block_expr_opt(&mut self, span: Span, block: Option<&Block>) -> hir::Expr<'hir> {
1067-
match block {
1068-
Some(block) => self.lower_block_expr(block),
1069-
None => self.expr_err(span, self.dcx().has_errors().unwrap()),
1070-
}
1061+
fn lower_fn_body_block(&mut self, decl: &FnDecl, body: &Block) -> hir::BodyId {
1062+
self.lower_fn_body(decl, |this| this.lower_block_expr(body))
10711063
}
10721064

10731065
pub(super) fn lower_const_body(&mut self, span: Span, expr: Option<&Expr>) -> hir::BodyId {
@@ -1089,9 +1081,37 @@ impl<'hir> LoweringContext<'_, 'hir> {
10891081
decl: &FnDecl,
10901082
coroutine_kind: Option<CoroutineKind>,
10911083
body: Option<&Block>,
1084+
attrs: &'hir [hir::Attribute],
10921085
) -> hir::BodyId {
1093-
let (Some(coroutine_kind), Some(body)) = (coroutine_kind, body) else {
1094-
return self.lower_fn_body_block(span, decl, body);
1086+
let Some(body) = body else {
1087+
// Functions without a body are an error, except if this is an intrinsic. For those we
1088+
// create a fake body so that the entire rest of the compiler doesn't have to deal with
1089+
// this as a special case.
1090+
return self.lower_fn_body(decl, |this| {
1091+
if attrs.iter().any(|a| a.name_or_empty() == sym::rustc_intrinsic) {
1092+
let empty_block = hir::Block {
1093+
hir_id: this.next_id(),
1094+
stmts: &[],
1095+
expr: None,
1096+
rules: hir::BlockCheckMode::DefaultBlock,
1097+
span,
1098+
targeted_by_break: false,
1099+
};
1100+
let loop_ = hir::ExprKind::Loop(
1101+
this.arena.alloc(empty_block),
1102+
None,
1103+
hir::LoopSource::Loop,
1104+
span,
1105+
);
1106+
hir::Expr { hir_id: this.next_id(), kind: loop_, span }
1107+
} else {
1108+
this.expr_err(span, this.dcx().has_errors().unwrap())
1109+
}
1110+
});
1111+
};
1112+
let Some(coroutine_kind) = coroutine_kind else {
1113+
// Typical case: not a coroutine.
1114+
return self.lower_fn_body_block(decl, body);
10951115
};
10961116
self.lower_body(|this| {
10971117
let (parameters, expr) = this.lower_coroutine_body_with_moved_arguments(

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,20 +2031,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20312031
fn lower_array_length_to_const_arg(&mut self, c: &AnonConst) -> &'hir hir::ConstArg<'hir> {
20322032
match c.value.kind {
20332033
ExprKind::Underscore => {
2034-
if self.tcx.features().generic_arg_infer() {
2035-
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span));
2036-
self.arena
2037-
.alloc(hir::ConstArg { hir_id: self.lower_node_id(c.id), kind: ct_kind })
2038-
} else {
2034+
if !self.tcx.features().generic_arg_infer() {
20392035
feature_err(
20402036
&self.tcx.sess,
20412037
sym::generic_arg_infer,
20422038
c.value.span,
20432039
fluent_generated::ast_lowering_underscore_array_length_unstable,
20442040
)
20452041
.stash(c.value.span, StashKey::UnderscoreForArrayLengths);
2046-
self.lower_anon_const_to_const_arg(c)
20472042
}
2043+
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span));
2044+
self.arena.alloc(hir::ConstArg { hir_id: self.lower_node_id(c.id), kind: ct_kind })
20482045
}
20492046
_ => self.lower_anon_const_to_const_arg(c),
20502047
}

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
920920
ItemKind::Fn(box Fn { defaultness, sig, generics, body }) => {
921921
self.check_defaultness(item.span, *defaultness);
922922

923-
if body.is_none() {
923+
let is_intrinsic =
924+
item.attrs.iter().any(|a| a.name_or_empty() == sym::rustc_intrinsic);
925+
if body.is_none() && !is_intrinsic {
924926
self.dcx().emit_err(errors::FnWithoutBody {
925927
span: item.span,
926928
replace_span: self.ending_semi_or_hi(item.span),

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
981981

982982
let arg = match hir.get_if_local(callee_def_id) {
983983
Some(
984-
hir::Node::Item(hir::Item { ident, kind: hir::ItemKind::Fn(sig, ..), .. })
984+
hir::Node::Item(hir::Item {
985+
ident, kind: hir::ItemKind::Fn { sig, .. }, ..
986+
})
985987
| hir::Node::TraitItem(hir::TraitItem {
986988
ident,
987989
kind: hir::TraitItemKind::Fn(sig, _),
@@ -1020,7 +1022,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
10201022
// ...otherwise we are probably in the tail expression of the function, point at the
10211023
// return type.
10221024
match self.infcx.tcx.hir_node_by_def_id(hir.get_parent_item(fn_call_id).def_id) {
1023-
hir::Node::Item(hir::Item { ident, kind: hir::ItemKind::Fn(sig, ..), .. })
1025+
hir::Node::Item(hir::Item {
1026+
ident, kind: hir::ItemKind::Fn { sig, .. }, ..
1027+
})
10241028
| hir::Node::TraitItem(hir::TraitItem {
10251029
ident,
10261030
kind: hir::TraitItemKind::Fn(sig, _),

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ const DW_ATE_unsigned: c_uint = 0x07;
7373
#[allow(non_upper_case_globals)]
7474
const DW_ATE_UTF: c_uint = 0x10;
7575

76+
#[allow(non_upper_case_globals)]
77+
const DW_TAG_const_type: c_uint = 0x26;
78+
7679
pub(super) const UNKNOWN_LINE_NUMBER: c_uint = 0;
7780
pub(super) const UNKNOWN_COLUMN_NUMBER: c_uint = 0;
7881

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use crate::common::{AsCCharPtr, CodegenCx};
1515
use crate::debuginfo::metadata::enums::DiscrResult;
1616
use crate::debuginfo::metadata::type_map::{self, Stub, UniqueTypeId};
1717
use crate::debuginfo::metadata::{
18-
DINodeCreationResult, NO_GENERICS, NO_SCOPE_METADATA, SmallVec, UNKNOWN_LINE_NUMBER,
19-
build_field_di_node, file_metadata, file_metadata_from_def_id, size_and_align_of, type_di_node,
20-
unknown_file_metadata, visibility_di_flags,
18+
DINodeCreationResult, DW_TAG_const_type, NO_GENERICS, NO_SCOPE_METADATA, SmallVec,
19+
UNKNOWN_LINE_NUMBER, build_field_di_node, file_metadata, file_metadata_from_def_id,
20+
size_and_align_of, type_di_node, unknown_file_metadata, visibility_di_flags,
2121
};
2222
use crate::debuginfo::utils::DIB;
2323
use crate::llvm::debuginfo::{DIFile, DIFlags, DIType};
@@ -566,22 +566,39 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
566566
None,
567567
));
568568

569-
let build_assoc_const =
570-
|name: &str, type_di_node: &'ll DIType, value: u64, align: Align| unsafe {
571-
llvm::LLVMRustDIBuilderCreateStaticMemberType(
572-
DIB(cx),
573-
wrapper_struct_type_di_node,
574-
name.as_c_char_ptr(),
575-
name.len(),
576-
unknown_file_metadata(cx),
577-
UNKNOWN_LINE_NUMBER,
578-
type_di_node,
579-
DIFlags::FlagZero,
580-
Some(cx.const_u64(value)),
581-
align.bits() as u32,
582-
)
569+
let build_assoc_const = |name: &str,
570+
type_di_node_: &'ll DIType,
571+
value: u64,
572+
align: Align| unsafe {
573+
// FIXME: Currently we force all DISCR_* values to be u64's as LLDB seems to have
574+
// problems inspecting other value types. Since DISCR_* is typically only going to be
575+
// directly inspected via the debugger visualizer - which compares it to the `tag` value
576+
// (whose type is not modified at all) it shouldn't cause any real problems.
577+
let (t_di, align) = if name == ASSOC_CONST_DISCR_NAME {
578+
(type_di_node_, align.bits() as u32)
579+
} else {
580+
let ty_u64 = Ty::new_uint(cx.tcx, ty::UintTy::U64);
581+
(type_di_node(cx, ty_u64), Align::EIGHT.bits() as u32)
583582
};
584583

584+
// must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
585+
let field_type =
586+
llvm::LLVMRustDIBuilderCreateQualifiedType(DIB(cx), DW_TAG_const_type, t_di);
587+
588+
llvm::LLVMRustDIBuilderCreateStaticMemberType(
589+
DIB(cx),
590+
wrapper_struct_type_di_node,
591+
name.as_c_char_ptr(),
592+
name.len(),
593+
unknown_file_metadata(cx),
594+
UNKNOWN_LINE_NUMBER,
595+
field_type,
596+
DIFlags::FlagZero,
597+
Some(cx.const_u64(value)),
598+
align,
599+
)
600+
};
601+
585602
// We also always have an associated constant for the discriminant value
586603
// of the variant.
587604
fields.push(build_assoc_const(

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,12 @@ unsafe extern "C" {
20082008
AlignInBits: u32,
20092009
) -> &'a DIDerivedType;
20102010

2011+
pub fn LLVMRustDIBuilderCreateQualifiedType<'a>(
2012+
Builder: &DIBuilder<'a>,
2013+
Tag: c_uint,
2014+
Type: &'a DIType,
2015+
) -> &'a DIDerivedType;
2016+
20112017
pub fn LLVMRustDIBuilderCreateLexicalBlock<'a>(
20122018
Builder: &DIBuilder<'a>,
20132019
Scope: &'a DIScope,

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ arrayvec = { version = "0.7", default-features = false }
1010
bitflags = "2.4.1"
1111
# Pinned so `cargo update` bumps don't cause breakage. Please also update the
1212
# `cc` in `rustc_llvm` if you update the `cc` here.
13-
cc = "=1.2.6"
13+
cc = "=1.2.7"
1414
either = "1.5.0"
1515
itertools = "0.12"
1616
pathdiff = "0.2.0"

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,12 +1008,8 @@ fn link_natively(
10081008
&& (code < 1000 || code > 9999)
10091009
{
10101010
let is_vs_installed = windows_registry::find_vs_version().is_ok();
1011-
// FIXME(cc-rs#1265) pass only target arch to find_tool()
1012-
let has_linker = windows_registry::find_tool(
1013-
sess.opts.target_triple.tuple(),
1014-
"link.exe",
1015-
)
1016-
.is_some();
1011+
let has_linker =
1012+
windows_registry::find_tool(&sess.target.arch, "link.exe").is_some();
10171013

10181014
sess.dcx().emit_note(errors::LinkExeUnexpectedError);
10191015
if is_vs_installed && has_linker {
@@ -1104,14 +1100,14 @@ fn link_natively(
11041100
let stripcmd = "rust-objcopy";
11051101
match (strip, crate_type) {
11061102
(Strip::Debuginfo, _) => {
1107-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-S"])
1103+
strip_with_external_utility(sess, stripcmd, out_filename, &["--strip-debug"])
11081104
}
11091105
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
11101106
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
1111-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-x"])
1107+
strip_with_external_utility(sess, stripcmd, out_filename, &["-x"])
11121108
}
11131109
(Strip::Symbols, _) => {
1114-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &[])
1110+
strip_with_external_utility(sess, stripcmd, out_filename, &["--strip-all"])
11151111
}
11161112
(Strip::None, _) => {}
11171113
}
@@ -1127,9 +1123,7 @@ fn link_natively(
11271123
let stripcmd = if !sess.host.is_like_solaris { "rust-objcopy" } else { "/usr/bin/strip" };
11281124
match strip {
11291125
// Always preserve the symbol table (-x).
1130-
Strip::Debuginfo => {
1131-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-x"])
1132-
}
1126+
Strip::Debuginfo => strip_with_external_utility(sess, stripcmd, out_filename, &["-x"]),
11331127
// Strip::Symbols is handled via the --strip-all linker option.
11341128
Strip::Symbols => {}
11351129
Strip::None => {}
@@ -1145,15 +1139,11 @@ fn link_natively(
11451139
match strip {
11461140
Strip::Debuginfo => {
11471141
// FIXME: AIX's strip utility only offers option to strip line number information.
1148-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &[
1149-
"-X32_64", "-l",
1150-
])
1142+
strip_with_external_utility(sess, stripcmd, out_filename, &["-X32_64", "-l"])
11511143
}
11521144
Strip::Symbols => {
11531145
// Must be noted this option might remove symbol __aix_rust_metadata and thus removes .info section which contains metadata.
1154-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &[
1155-
"-X32_64", "-r",
1156-
])
1146+
strip_with_external_utility(sess, stripcmd, out_filename, &["-X32_64", "-r"])
11571147
}
11581148
Strip::None => {}
11591149
}
@@ -1166,12 +1156,7 @@ fn link_natively(
11661156
}
11671157
}
11681158

1169-
fn strip_symbols_with_external_utility(
1170-
sess: &Session,
1171-
util: &str,
1172-
out_filename: &Path,
1173-
options: &[&str],
1174-
) {
1159+
fn strip_with_external_utility(sess: &Session, util: &str, out_filename: &Path, options: &[&str]) {
11751160
let mut cmd = Command::new(util);
11761161
cmd.args(options);
11771162

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ pub(crate) fn get_linker<'a>(
5050
self_contained: bool,
5151
target_cpu: &'a str,
5252
) -> Box<dyn Linker + 'a> {
53-
// FIXME(cc-rs#1265) pass only target arch to find_tool()
54-
let msvc_tool = windows_registry::find_tool(sess.opts.target_triple.tuple(), "link.exe");
53+
let msvc_tool = windows_registry::find_tool(&sess.target.arch, "link.exe");
5554

5655
// If our linker looks like a batch script on Windows then to execute this
5756
// we'll need to spawn `cmd` explicitly. This is primarily done to handle

0 commit comments

Comments
 (0)