Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #137985

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2c752bc
Undeprecate env::home_dir
arlosi Feb 20, 2025
b340545
[illumos] attempt to use posix_spawn to spawn processes
sunshowers Feb 11, 2025
a7bd4a3
Add DWARF test case for non-C-like `repr128` enums
beetrees Feb 25, 2025
c4d6426
Set target_vendor = "openwrt"
madsmtm Mar 1, 2025
ea13ff7
add exclude to config.toml
Shourya742 Feb 16, 2025
d9ceab9
add test for exclude feature
Shourya742 Feb 16, 2025
9206960
Add change info to change tracker
Shourya742 Feb 16, 2025
86aae8e
uefi: Add Service Binding Protocol abstraction
Ayush1325 Feb 23, 2025
3998690
compiletest: remove legacy `Makefile`-based `run-make` support
jieyouxu Feb 5, 2025
413b824
run-make: remove `tools.mk`
jieyouxu Feb 5, 2025
9b17c98
run-make: update test suite README
jieyouxu Feb 5, 2025
ed168e7
run-make-support: remove outdated comments
jieyouxu Mar 1, 2025
efec638
tidy: remove legacy `Makefile` checks
jieyouxu Feb 5, 2025
b0d6a84
rustc-dev-guide: remove mentions of legacy `Makefile` run-make infra
jieyouxu Feb 5, 2025
95b030f
triagebot: stop backlinking to the test porting tracking issue
jieyouxu Feb 5, 2025
c97225b
`librustdoc`: 2024 edition! 🎊
yotamofek Feb 27, 2025
74c783c
Adapt `librustdoc` to 2024 edition lifetieme capture rules
yotamofek Feb 27, 2025
7e0a2fc
compiletest: change `TEST_BUILD_DIR` to maximally normalize
jieyouxu Feb 11, 2025
8342914
tests: remove explicit long type filename hash normalization from som…
jieyouxu Feb 11, 2025
12cd0f1
tests: rebless some tests as a side-effect of `TEST_BUILD_DIR` changes
jieyouxu Feb 11, 2025
4f2a3dc
tests: manually rebless `tests/ui-fulldeps/codegen-backend/hotplug.rs`
jieyouxu Feb 11, 2025
133705c
[rustdoc] hide item that is not marked as doc(inline) and whose src i…
xizheyin Feb 27, 2025
53ee696
Update MSVC INSTALL.md instructions to recommend VS 2022 + recent Win…
jieyouxu Mar 3, 2025
ab31129
Point of macro expansion from call expr if it involves macro var
compiler-errors Feb 24, 2025
e4dfca8
Point out macro expansion ident in resolver errors too
compiler-errors Feb 24, 2025
0607246
Fix associated type errors too
compiler-errors Feb 24, 2025
4fdc1b5
Construct MIR error body for global_asm correctly
compiler-errors Feb 23, 2025
dc9d559
Exclude global_asm from mir_keys
compiler-errors Feb 23, 2025
09e5846
Also note struct access, and fix macro expansion from foreign crates
compiler-errors Feb 24, 2025
f5bc2a9
Rollup merge of #136581 - jieyouxu:makefile-be-gone, r=Kobzol
jhpratt Mar 4, 2025
85642e0
Rollup merge of #136865 - jieyouxu:long-type-path-compare-mode, r=lqd
jhpratt Mar 4, 2025
6299dc6
Rollup merge of #137147 - Shourya742:2025-02-16-support-exclude-in-co…
jhpratt Mar 4, 2025
da4245f
Rollup merge of #137327 - arlosi:home-dir, r=Mark-Simulacrum
jhpratt Mar 4, 2025
8c7ad4d
Rollup merge of #137463 - sunshowers:illumos-posix-spawn, r=Mark-Simu…
jhpratt Mar 4, 2025
41faffc
Rollup merge of #137477 - Ayush1325:uefi-service-binding, r=Noratrieb
jhpratt Mar 4, 2025
129b5bd
Rollup merge of #137502 - compiler-errors:global-asm-aint-mir-body, r…
jhpratt Mar 4, 2025
db71de0
Rollup merge of #137534 - xizheyin:issue-137342, r=GuillaumeGomez
jhpratt Mar 4, 2025
ccb019a
Rollup merge of #137565 - compiler-errors:macro-ex, r=estebank
jhpratt Mar 4, 2025
175d191
Rollup merge of #137643 - beetrees:repr128-dwarf-variant-test, r=jiey…
jhpratt Mar 4, 2025
d9a357e
Rollup merge of #137722 - yotamofek:pr/rustdoc/edition-2024, r=notriddle
jhpratt Mar 4, 2025
ac73454
Rollup merge of #137836 - madsmtm:openwrt-target-vendor, r=jieyouxu
jhpratt Mar 4, 2025
d254423
Rollup merge of #137949 - jieyouxu:update-install, r=ChrisDenton
jhpratt Mar 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,13 @@ itself back on after some time).

### MSVC

MSVC builds of Rust additionally require an installation of Visual Studio 2017
(or later) so `rustc` can use its linker. The simplest way is to get
[Visual Studio], check the "C++ build tools" and "Windows 10 SDK" workload.
MSVC builds of Rust additionally requires an installation of:

- Visual Studio 2022 (or later) build tools so `rustc` can use its linker. Older
Visual Studio versions such as 2019 *may* work but aren't actively tested.
- A recent Windows 10 or 11 SDK.

The simplest way is to get [Visual Studio], check the "C++ build tools".

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

Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_data_structures/src/captures.rs

This file was deleted.

1 change: 0 additions & 1 deletion compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub use rustc_index::static_assert_size;
pub mod aligned;
pub mod base_n;
pub mod binary_search_util;
pub mod captures;
pub mod fingerprint;
pub mod flat_map_in_place;
pub mod flock;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ hir_analysis_variances_of = {$variances}
hir_analysis_where_clause_on_main = `main` function is not allowed to have a `where` clause
.label = `main` cannot have a `where` clause

hir_analysis_within_macro = due to this macro variable

hir_analysis_wrong_number_of_generic_arguments_to_intrinsic =
intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected}
.label = expected {$expected} {$descr} {$expected ->
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ pub(crate) struct AssocItemNotFound<'a> {
pub label: Option<AssocItemNotFoundLabel<'a>>,
#[subdiagnostic]
pub sugg: Option<AssocItemNotFoundSugg<'a>>,
#[label(hir_analysis_within_macro)]
pub within_macro_span: Option<Span>,
}

#[derive(Subdiagnostic)]
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
qself: &qself_str,
label: None,
sugg: None,
// Try to get the span of the identifier within the path's syntax context
// (if that's different).
within_macro_span: assoc_name.span.within_macro(span, tcx.sess.source_map()),
};

if is_dummy {
Expand Down
35 changes: 23 additions & 12 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3069,7 +3069,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
"ban_nonexisting_field: field={:?}, base={:?}, expr={:?}, base_ty={:?}",
ident, base, expr, base_ty
);
let mut err = self.no_such_field_err(ident, base_ty, base.hir_id);
let mut err = self.no_such_field_err(ident, base_ty, expr);

match *base_ty.peel_refs().kind() {
ty::Array(_, len) => {
Expand Down Expand Up @@ -3282,29 +3282,38 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}

fn no_such_field_err(&self, field: Ident, expr_t: Ty<'tcx>, id: HirId) -> Diag<'_> {
fn no_such_field_err(
&self,
field: Ident,
base_ty: Ty<'tcx>,
expr: &hir::Expr<'tcx>,
) -> Diag<'_> {
let span = field.span;
debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t);
debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, base_ty);

let mut err = self.dcx().create_err(NoFieldOnType { span, ty: expr_t, field });
if expr_t.references_error() {
let mut err = self.dcx().create_err(NoFieldOnType { span, ty: base_ty, field });
if base_ty.references_error() {
err.downgrade_to_delayed_bug();
}

if let Some(within_macro_span) = span.within_macro(expr.span, self.tcx.sess.source_map()) {
err.span_label(within_macro_span, "due to this macro variable");
}

// try to add a suggestion in case the field is a nested field of a field of the Adt
let mod_id = self.tcx.parent_module(id).to_def_id();
let (ty, unwrap) = if let ty::Adt(def, args) = expr_t.kind()
let mod_id = self.tcx.parent_module(expr.hir_id).to_def_id();
let (ty, unwrap) = if let ty::Adt(def, args) = base_ty.kind()
&& (self.tcx.is_diagnostic_item(sym::Result, def.did())
|| self.tcx.is_diagnostic_item(sym::Option, def.did()))
&& let Some(arg) = args.get(0)
&& let Some(ty) = arg.as_type()
{
(ty, "unwrap().")
} else {
(expr_t, "")
(base_ty, "")
};
for (found_fields, args) in
self.get_field_candidates_considering_privacy_for_diag(span, ty, mod_id, id)
self.get_field_candidates_considering_privacy_for_diag(span, ty, mod_id, expr.hir_id)
{
let field_names = found_fields.iter().map(|field| field.name).collect::<Vec<_>>();
let mut candidate_fields: Vec<_> = found_fields
Expand All @@ -3317,7 +3326,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
args,
vec![],
mod_id,
id,
expr.hir_id,
)
})
.map(|mut field_path| {
Expand All @@ -3328,7 +3337,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
candidate_fields.sort();

let len = candidate_fields.len();
if len > 0 {
// Don't suggest `.field` if the base expr is from a different
// syntax context than the field.
if len > 0 && expr.span.eq_ctxt(field.span) {
err.span_suggestions(
field.span.shrink_to_lo(),
format!(
Expand Down Expand Up @@ -3963,7 +3974,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => (),
};

self.no_such_field_err(field, container, expr.hir_id).emit();
self.no_such_field_err(field, container, expr).emit();

break;
}
Expand Down
24 changes: 21 additions & 3 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.typeck_results.borrow_mut().used_trait_imports.insert(import_id);
}

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

// Try to get the span of the identifier within the expression's syntax context
// (if that's different).
let within_macro_span = span.within_macro(expr_span, self.tcx.sess.source_map());

// Avoid suggestions when we don't know what's going on.
if let Err(guar) = rcvr_ty.error_reported() {
return guar;
Expand All @@ -207,10 +211,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call_id,
source,
args,
sugg_span,
expr_span,
&mut no_match_data,
expected,
trait_missing_method,
within_macro_span,
),

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

self.note_candidates_on_method_error(
rcvr_ty,
Expand All @@ -230,7 +238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
span,
&mut err,
&mut sources,
Some(sugg_span),
Some(expr_span),
);
err.emit()
}
Expand All @@ -252,6 +260,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.span_if_local(def_id)
.unwrap_or_else(|| self.tcx.def_span(def_id));
err.span_label(sp, format!("private {kind} defined here"));
if let Some(within_macro_span) = within_macro_span {
err.span_label(within_macro_span, "due to this macro variable");
}
self.suggest_valid_traits(&mut err, item_name, out_of_scope_traits, true);
err.emit()
}
Expand All @@ -268,6 +279,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if !needs_mut {
err.span_label(bound_span, "this has a `Sized` requirement");
}
if let Some(within_macro_span) = within_macro_span {
err.span_label(within_macro_span, "due to this macro variable");
}
if !candidates.is_empty() {
let help = format!(
"{an}other candidate{s} {were} found in the following trait{s}",
Expand Down Expand Up @@ -581,6 +595,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
no_match_data: &mut NoMatchData<'tcx>,
expected: Expectation<'tcx>,
trait_missing_method: bool,
within_macro_span: Option<Span>,
) -> ErrorGuaranteed {
let mode = no_match_data.mode;
let tcx = self.tcx;
Expand Down Expand Up @@ -721,6 +736,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if tcx.sess.source_map().is_multiline(sugg_span) {
err.span_label(sugg_span.with_hi(span.lo()), "");
}
if let Some(within_macro_span) = within_macro_span {
err.span_label(within_macro_span, "due to this macro variable");
}

if short_ty_str.len() < ty_str.len() && ty_str.len() > 10 {
ty_str = short_ty_str;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_mir_build/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
| DefKind::AssocConst
| DefKind::AnonConst
| DefKind::InlineConst
| DefKind::Static { .. } => (vec![], tcx.type_of(def_id).instantiate_identity(), None),
| DefKind::Static { .. }
| DefKind::GlobalAsm => (vec![], tcx.type_of(def_id).instantiate_identity(), None),
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => {
let sig = tcx.liberate_late_bound_regions(
def_id.to_def_id(),
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
// All body-owners have MIR associated with them.
let mut set: FxIndexSet<_> = tcx.hir_body_owners().collect();

// Remove the fake bodies for `global_asm!`, since they're not useful
// to be emitted (`--emit=mir`) or encoded (in metadata).
set.retain(|&def_id| !matches!(tcx.def_kind(def_id), DefKind::GlobalAsm));

// Coroutine-closures (e.g. async closures) have an additional by-move MIR
// body that isn't in the HIR.
for body_owner in tcx.hir_body_owners() {
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,14 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
let mut err = self.r.dcx().struct_span_err(base_error.span, base_error.msg.clone());
err.code(code);

// Try to get the span of the identifier within the path's syntax context
// (if that's different).
if let Some(within_macro_span) =
base_error.span.within_macro(span, self.r.tcx.sess.source_map())
{
err.span_label(within_macro_span, "due to this macro variable");
}

self.detect_missing_binding_available_from_pattern(&mut err, path, following_seg);
self.suggest_at_operator_in_slice_pat_with_range(&mut err, path);
self.suggest_swapping_misplaced_self_ty_and_trait(&mut err, source, res, base_error.span);
Expand Down
31 changes: 31 additions & 0 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,37 @@ impl Span {
}
}

/// Returns the `Span` within the syntax context of "within". This is useful when
/// "self" is an expansion from a macro variable, since this can be used for
/// providing extra macro expansion context for certain errors.
///
/// ```text
/// macro_rules! m {
/// ($ident:ident) => { ($ident,) }
/// }
///
/// m!(outer_ident);
/// ```
///
/// If "self" is the span of the outer_ident, and "within" is the span of the `($ident,)`
/// expr, then this will return the span of the `$ident` macro variable.
pub fn within_macro(self, within: Span, sm: &SourceMap) -> Option<Span> {
match Span::prepare_to_combine(self, within) {
// Only return something if it doesn't overlap with the original span,
// and the span isn't "imported" (i.e. from unavailable sources).
// FIXME: This does limit the usefulness of the error when the macro is
// from a foreign crate; we could also take into account `-Zmacro-backtrace`,
// which doesn't redact this span (but that would mean passing in even more
// args to this function, lol).
Ok((self_, _, parent))
if self_.hi < self.lo() || self.hi() < self_.lo && !sm.is_imported(within) =>
{
Some(Span::new(self_.lo, self_.hi, self_.ctxt, parent))
}
_ => None,
}
}

pub fn from_inner(self, inner: InnerSpan) -> Span {
let span = self.data();
Span::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) fn target() -> Target {
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "mips64".into(),
options: TargetOptions {
vendor: "openwrt".into(),
abi: "abi64".into(),
endian: Endian::Big,
mcount: "_mcount".into(),
Expand Down
4 changes: 4 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@
# a specific version.
#ccache = false

# List of paths to exclude from the build and test processes.
# For example, exclude = ["tests/ui", "src/tools/tidy"].
#exclude = []

# =============================================================================
# General install configuration options
# =============================================================================
Expand Down
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.169"
version = "0.2.170"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
addr2line = { version = "0.24.0", optional = true, default-features = false }

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

Expand Down
5 changes: 0 additions & 5 deletions library/std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,6 @@ impl Error for JoinPathsError {
/// None => println!("Impossible to get your home dir!"),
/// }
/// ```
#[deprecated(
since = "1.29.0",
note = "This function's behavior may be unexpected on Windows. \
Consider using a crate from crates.io instead."
)]
#[must_use]
#[stable(feature = "env", since = "1.0.0")]
pub fn home_dir() -> Option<PathBuf> {
Expand Down
Loading
Loading