Skip to content

Commit 23d8b82

Browse files
committed
Auto merge of rust-lang#137985 - jhpratt:rollup-rv437bl, r=jhpratt
Rollup of 13 pull requests Successful merges: - rust-lang#136581 (Retire the legacy `Makefile`-based `run-make` test infra) - rust-lang#136865 (Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes) - rust-lang#137147 (Add exclude to config.toml) - rust-lang#137327 (Undeprecate env::home_dir) - rust-lang#137463 ([illumos] attempt to use posix_spawn to spawn processes) - rust-lang#137477 (uefi: Add Service Binding Protocol abstraction) - rust-lang#137502 (Don't include global asm in `mir_keys`, fix error body synthesis) - rust-lang#137534 ([rustdoc] hide item that is not marked as doc(inline) and whose src is doc(hidden)) - rust-lang#137565 (Try to point of macro expansion from resolver and method errors if it involves macro var) - rust-lang#137643 (Add DWARF test case for non-C-like `repr128` enums) - rust-lang#137722 (`librustdoc`: 2024 edition! 🎊) - rust-lang#137836 (Set `target_vendor = "openwrt"` on `mips64-openwrt-linux-musl`) - rust-lang#137949 (Update MSVC INSTALL.md instructions to recommend VS 2022 + recent Windows 10/11 SDK) Failed merges: - rust-lang#137798 (ci: use ubuntu 24 on arm large runner) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fd17dea + d254423 commit 23d8b82

File tree

147 files changed

+1046
-1453
lines changed

Some content is hidden

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

147 files changed

+1046
-1453
lines changed

INSTALL.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,13 @@ itself back on after some time).
210210

211211
### MSVC
212212

213-
MSVC builds of Rust additionally require an installation of Visual Studio 2017
214-
(or later) so `rustc` can use its linker. The simplest way is to get
215-
[Visual Studio], check the "C++ build tools" and "Windows 10 SDK" workload.
213+
MSVC builds of Rust additionally requires an installation of:
214+
215+
- Visual Studio 2022 (or later) build tools so `rustc` can use its linker. Older
216+
Visual Studio versions such as 2019 *may* work but aren't actively tested.
217+
- A recent Windows 10 or 11 SDK.
218+
219+
The simplest way is to get [Visual Studio], check the "C++ build tools".
216220

217221
[Visual Studio]: https://visualstudio.microsoft.com/downloads/
218222

compiler/rustc_data_structures/src/captures.rs

-8
This file was deleted.

compiler/rustc_data_structures/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub use rustc_index::static_assert_size;
4848
pub mod aligned;
4949
pub mod base_n;
5050
pub mod binary_search_util;
51-
pub mod captures;
5251
pub mod fingerprint;
5352
pub mod flat_map_in_place;
5453
pub mod flock;

compiler/rustc_hir_analysis/messages.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ hir_analysis_variances_of = {$variances}
620620
hir_analysis_where_clause_on_main = `main` function is not allowed to have a `where` clause
621621
.label = `main` cannot have a `where` clause
622622
623+
hir_analysis_within_macro = due to this macro variable
624+
623625
hir_analysis_wrong_number_of_generic_arguments_to_intrinsic =
624626
intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected}
625627
.label = expected {$expected} {$descr} {$expected ->

compiler/rustc_hir_analysis/src/errors.rs

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ pub(crate) struct AssocItemNotFound<'a> {
8484
pub label: Option<AssocItemNotFoundLabel<'a>>,
8585
#[subdiagnostic]
8686
pub sugg: Option<AssocItemNotFoundSugg<'a>>,
87+
#[label(hir_analysis_within_macro)]
88+
pub within_macro_span: Option<Span>,
8789
}
8890

8991
#[derive(Subdiagnostic)]

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

+3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
151151
qself: &qself_str,
152152
label: None,
153153
sugg: None,
154+
// Try to get the span of the identifier within the path's syntax context
155+
// (if that's different).
156+
within_macro_span: assoc_name.span.within_macro(span, tcx.sess.source_map()),
154157
};
155158

156159
if is_dummy {

compiler/rustc_hir_typeck/src/expr.rs

+23-12
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30693069
"ban_nonexisting_field: field={:?}, base={:?}, expr={:?}, base_ty={:?}",
30703070
ident, base, expr, base_ty
30713071
);
3072-
let mut err = self.no_such_field_err(ident, base_ty, base.hir_id);
3072+
let mut err = self.no_such_field_err(ident, base_ty, expr);
30733073

30743074
match *base_ty.peel_refs().kind() {
30753075
ty::Array(_, len) => {
@@ -3282,29 +3282,38 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32823282
);
32833283
}
32843284

3285-
fn no_such_field_err(&self, field: Ident, expr_t: Ty<'tcx>, id: HirId) -> Diag<'_> {
3285+
fn no_such_field_err(
3286+
&self,
3287+
field: Ident,
3288+
base_ty: Ty<'tcx>,
3289+
expr: &hir::Expr<'tcx>,
3290+
) -> Diag<'_> {
32863291
let span = field.span;
3287-
debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t);
3292+
debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, base_ty);
32883293

3289-
let mut err = self.dcx().create_err(NoFieldOnType { span, ty: expr_t, field });
3290-
if expr_t.references_error() {
3294+
let mut err = self.dcx().create_err(NoFieldOnType { span, ty: base_ty, field });
3295+
if base_ty.references_error() {
32913296
err.downgrade_to_delayed_bug();
32923297
}
32933298

3299+
if let Some(within_macro_span) = span.within_macro(expr.span, self.tcx.sess.source_map()) {
3300+
err.span_label(within_macro_span, "due to this macro variable");
3301+
}
3302+
32943303
// try to add a suggestion in case the field is a nested field of a field of the Adt
3295-
let mod_id = self.tcx.parent_module(id).to_def_id();
3296-
let (ty, unwrap) = if let ty::Adt(def, args) = expr_t.kind()
3304+
let mod_id = self.tcx.parent_module(expr.hir_id).to_def_id();
3305+
let (ty, unwrap) = if let ty::Adt(def, args) = base_ty.kind()
32973306
&& (self.tcx.is_diagnostic_item(sym::Result, def.did())
32983307
|| self.tcx.is_diagnostic_item(sym::Option, def.did()))
32993308
&& let Some(arg) = args.get(0)
33003309
&& let Some(ty) = arg.as_type()
33013310
{
33023311
(ty, "unwrap().")
33033312
} else {
3304-
(expr_t, "")
3313+
(base_ty, "")
33053314
};
33063315
for (found_fields, args) in
3307-
self.get_field_candidates_considering_privacy_for_diag(span, ty, mod_id, id)
3316+
self.get_field_candidates_considering_privacy_for_diag(span, ty, mod_id, expr.hir_id)
33083317
{
33093318
let field_names = found_fields.iter().map(|field| field.name).collect::<Vec<_>>();
33103319
let mut candidate_fields: Vec<_> = found_fields
@@ -3317,7 +3326,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33173326
args,
33183327
vec![],
33193328
mod_id,
3320-
id,
3329+
expr.hir_id,
33213330
)
33223331
})
33233332
.map(|mut field_path| {
@@ -3328,7 +3337,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33283337
candidate_fields.sort();
33293338

33303339
let len = candidate_fields.len();
3331-
if len > 0 {
3340+
// Don't suggest `.field` if the base expr is from a different
3341+
// syntax context than the field.
3342+
if len > 0 && expr.span.eq_ctxt(field.span) {
33323343
err.span_suggestions(
33333344
field.span.shrink_to_lo(),
33343345
format!(
@@ -3963,7 +3974,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
39633974
_ => (),
39643975
};
39653976

3966-
self.no_such_field_err(field, container, expr.hir_id).emit();
3977+
self.no_such_field_err(field, container, expr).emit();
39673978

39683979
break;
39693980
}

compiler/rustc_hir_typeck/src/method/suggest.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
158158
self.typeck_results.borrow_mut().used_trait_imports.insert(import_id);
159159
}
160160

161-
let (span, sugg_span, source, item_name, args) = match self.tcx.hir_node(call_id) {
161+
let (span, expr_span, source, item_name, args) = match self.tcx.hir_node(call_id) {
162162
hir::Node::Expr(&hir::Expr {
163163
kind: hir::ExprKind::MethodCall(segment, rcvr, args, _),
164164
span,
@@ -194,6 +194,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
194194
node => unreachable!("{node:?}"),
195195
};
196196

197+
// Try to get the span of the identifier within the expression's syntax context
198+
// (if that's different).
199+
let within_macro_span = span.within_macro(expr_span, self.tcx.sess.source_map());
200+
197201
// Avoid suggestions when we don't know what's going on.
198202
if let Err(guar) = rcvr_ty.error_reported() {
199203
return guar;
@@ -207,10 +211,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
207211
call_id,
208212
source,
209213
args,
210-
sugg_span,
214+
expr_span,
211215
&mut no_match_data,
212216
expected,
213217
trait_missing_method,
218+
within_macro_span,
214219
),
215220

216221
MethodError::Ambiguity(mut sources) => {
@@ -221,6 +226,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
221226
"multiple applicable items in scope"
222227
);
223228
err.span_label(item_name.span, format!("multiple `{item_name}` found"));
229+
if let Some(within_macro_span) = within_macro_span {
230+
err.span_label(within_macro_span, "due to this macro variable");
231+
}
224232

225233
self.note_candidates_on_method_error(
226234
rcvr_ty,
@@ -230,7 +238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
230238
span,
231239
&mut err,
232240
&mut sources,
233-
Some(sugg_span),
241+
Some(expr_span),
234242
);
235243
err.emit()
236244
}
@@ -252,6 +260,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
252260
.span_if_local(def_id)
253261
.unwrap_or_else(|| self.tcx.def_span(def_id));
254262
err.span_label(sp, format!("private {kind} defined here"));
263+
if let Some(within_macro_span) = within_macro_span {
264+
err.span_label(within_macro_span, "due to this macro variable");
265+
}
255266
self.suggest_valid_traits(&mut err, item_name, out_of_scope_traits, true);
256267
err.emit()
257268
}
@@ -268,6 +279,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
268279
if !needs_mut {
269280
err.span_label(bound_span, "this has a `Sized` requirement");
270281
}
282+
if let Some(within_macro_span) = within_macro_span {
283+
err.span_label(within_macro_span, "due to this macro variable");
284+
}
271285
if !candidates.is_empty() {
272286
let help = format!(
273287
"{an}other candidate{s} {were} found in the following trait{s}",
@@ -581,6 +595,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
581595
no_match_data: &mut NoMatchData<'tcx>,
582596
expected: Expectation<'tcx>,
583597
trait_missing_method: bool,
598+
within_macro_span: Option<Span>,
584599
) -> ErrorGuaranteed {
585600
let mode = no_match_data.mode;
586601
let tcx = self.tcx;
@@ -721,6 +736,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
721736
if tcx.sess.source_map().is_multiline(sugg_span) {
722737
err.span_label(sugg_span.with_hi(span.lo()), "");
723738
}
739+
if let Some(within_macro_span) = within_macro_span {
740+
err.span_label(within_macro_span, "due to this macro variable");
741+
}
724742

725743
if short_ty_str.len() < ty_str.len() && ty_str.len() > 10 {
726744
ty_str = short_ty_str;

compiler/rustc_mir_build/src/builder/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
612612
| DefKind::AssocConst
613613
| DefKind::AnonConst
614614
| DefKind::InlineConst
615-
| DefKind::Static { .. } => (vec![], tcx.type_of(def_id).instantiate_identity(), None),
615+
| DefKind::Static { .. }
616+
| DefKind::GlobalAsm => (vec![], tcx.type_of(def_id).instantiate_identity(), None),
616617
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => {
617618
let sig = tcx.liberate_late_bound_regions(
618619
def_id.to_def_id(),

compiler/rustc_mir_transform/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
316316
// All body-owners have MIR associated with them.
317317
let mut set: FxIndexSet<_> = tcx.hir_body_owners().collect();
318318

319+
// Remove the fake bodies for `global_asm!`, since they're not useful
320+
// to be emitted (`--emit=mir`) or encoded (in metadata).
321+
set.retain(|&def_id| !matches!(tcx.def_kind(def_id), DefKind::GlobalAsm));
322+
319323
// Coroutine-closures (e.g. async closures) have an additional by-move MIR
320324
// body that isn't in the HIR.
321325
for body_owner in tcx.hir_body_owners() {

compiler/rustc_resolve/src/late/diagnostics.rs

+8
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,14 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
429429
let mut err = self.r.dcx().struct_span_err(base_error.span, base_error.msg.clone());
430430
err.code(code);
431431

432+
// Try to get the span of the identifier within the path's syntax context
433+
// (if that's different).
434+
if let Some(within_macro_span) =
435+
base_error.span.within_macro(span, self.r.tcx.sess.source_map())
436+
{
437+
err.span_label(within_macro_span, "due to this macro variable");
438+
}
439+
432440
self.detect_missing_binding_available_from_pattern(&mut err, path, following_seg);
433441
self.suggest_at_operator_in_slice_pat_with_range(&mut err, path);
434442
self.suggest_swapping_misplaced_self_ty_and_trait(&mut err, source, res, base_error.span);

compiler/rustc_span/src/lib.rs

+31
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,37 @@ impl Span {
10571057
}
10581058
}
10591059

1060+
/// Returns the `Span` within the syntax context of "within". This is useful when
1061+
/// "self" is an expansion from a macro variable, since this can be used for
1062+
/// providing extra macro expansion context for certain errors.
1063+
///
1064+
/// ```text
1065+
/// macro_rules! m {
1066+
/// ($ident:ident) => { ($ident,) }
1067+
/// }
1068+
///
1069+
/// m!(outer_ident);
1070+
/// ```
1071+
///
1072+
/// If "self" is the span of the outer_ident, and "within" is the span of the `($ident,)`
1073+
/// expr, then this will return the span of the `$ident` macro variable.
1074+
pub fn within_macro(self, within: Span, sm: &SourceMap) -> Option<Span> {
1075+
match Span::prepare_to_combine(self, within) {
1076+
// Only return something if it doesn't overlap with the original span,
1077+
// and the span isn't "imported" (i.e. from unavailable sources).
1078+
// FIXME: This does limit the usefulness of the error when the macro is
1079+
// from a foreign crate; we could also take into account `-Zmacro-backtrace`,
1080+
// which doesn't redact this span (but that would mean passing in even more
1081+
// args to this function, lol).
1082+
Ok((self_, _, parent))
1083+
if self_.hi < self.lo() || self.hi() < self_.lo && !sm.is_imported(within) =>
1084+
{
1085+
Some(Span::new(self_.lo, self_.hi, self_.ctxt, parent))
1086+
}
1087+
_ => None,
1088+
}
1089+
}
1090+
10601091
pub fn from_inner(self, inner: InnerSpan) -> Span {
10611092
let span = self.data();
10621093
Span::new(

compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) fn target() -> Target {
2323
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
2424
arch: "mips64".into(),
2525
options: TargetOptions {
26+
vendor: "openwrt".into(),
2627
abi: "abi64".into(),
2728
endian: Endian::Big,
2829
mcount: "_mcount".into(),

config.example.toml

+4
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@
425425
# a specific version.
426426
#ccache = false
427427

428+
# List of paths to exclude from the build and test processes.
429+
# For example, exclude = ["tests/ui", "src/tools/tidy"].
430+
#exclude = []
431+
428432
# =============================================================================
429433
# General install configuration options
430434
# =============================================================================

library/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ dependencies = [
151151

152152
[[package]]
153153
name = "libc"
154-
version = "0.2.169"
154+
version = "0.2.170"
155155
source = "registry+https://github.com./rust-lang/crates.io-index"
156-
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
156+
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
157157
dependencies = [
158158
"rustc-std-workspace-core",
159159
]

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
3535
addr2line = { version = "0.24.0", optional = true, default-features = false }
3636

3737
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
38-
libc = { version = "0.2.169", default-features = false, features = [
38+
libc = { version = "0.2.170", default-features = false, features = [
3939
'rustc-dep-of-std',
4040
], public = true }
4141

library/std/src/env.rs

-5
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,6 @@ impl Error for JoinPathsError {
641641
/// None => println!("Impossible to get your home dir!"),
642642
/// }
643643
/// ```
644-
#[deprecated(
645-
since = "1.29.0",
646-
note = "This function's behavior may be unexpected on Windows. \
647-
Consider using a crate from crates.io instead."
648-
)]
649644
#[must_use]
650645
#[stable(feature = "env", since = "1.0.0")]
651646
pub fn home_dir() -> Option<PathBuf> {

0 commit comments

Comments
 (0)