Skip to content

Rollup of 23 pull requests #145142

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

Merged
merged 70 commits into from
Aug 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
1140e90
rustdoc search: prefer stable items in search results
lolbinarycat May 27, 2025
9b107be
Add a mir-opt test for an unneeded drop_in_place
scottmcm Jul 28, 2025
4e81eca
Let `RemoveUnneededDrops` also remove `drop_in_place`
scottmcm Jul 28, 2025
bcefc2e
Add annotations to the graphviz region graph on region origins
amandasystems Aug 6, 2025
61e8869
Proposed format
amandasystems Aug 6, 2025
648e3fc
Track names of existentials
amandasystems Aug 6, 2025
b061932
Change adjust_for_rust_scalar into arg_attrs_for_rust_scalar
bjorn3 Jul 18, 2025
e2acc6c
Avoid using unadjusted ABI for the thread-local shim
bjorn3 Jul 18, 2025
7d88f65
Fix ICE
bjorn3 Aug 6, 2025
0bba9bd
Explicitly disable vector feature on s390x baseline of bad-reg test
pmur Aug 6, 2025
bf50209
Optimize `char::is_alphanumeric`
Kmeakin Aug 6, 2025
064d588
move member-constraints tests
lcnr Aug 7, 2025
8441f95
add opaque type member constraint tests
lcnr Aug 7, 2025
b60f75c
Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being
Fulgen301 May 31, 2025
7e5acb9
Add note mentioning the event log to LinkExeStatusStackBufferOverrun
Fulgen301 Aug 7, 2025
c00881b
update enzyme submodule to handle llvm 21
ZuseZ4 Aug 7, 2025
b4a3d30
Consolidate abs tests
rocurley Jul 14, 2025
83878ea
Consolidate signum tests
rocurley Jul 14, 2025
951ef57
Consolidate is_positive tests
rocurley Jul 14, 2025
71973fc
Consolidate is_sign_negative tests
rocurley Aug 4, 2025
f51f68b
Consolidate test_next_up
rocurley Aug 4, 2025
8a65ce4
Consolidate test_next_down
rocurley Aug 4, 2025
666bfca
Consolidate sqrt_domain tests
rocurley Aug 4, 2025
a5e4e7a
Consolidate clamp tests
rocurley Aug 4, 2025
80bcd1a
Consolidate total_cmp tests
rocurley Aug 4, 2025
57cf40c
Hoist zero and one out into TestableFloat
rocurley Aug 8, 2025
347cd4e
Augment the test.
nnethercote Aug 8, 2025
0239e46
Fix some bad formatting in `-Zmacro-stats` output.
nnethercote Aug 8, 2025
997c6a8
Escape diff strings in graphviz
ashivaram23 Aug 8, 2025
3abe5f9
Add snapshot test for cross-compilation cargo build
Kobzol Aug 8, 2025
9eb9b5a
Build host library when cross-compiling `ToolTarget` tools
Kobzol Aug 8, 2025
7671b5a
coverage: Extract HIR-related helper code out of the main module
Zalathar Aug 2, 2025
db9f0bb
coverage: Remove obsolete comment about hashing HIR
Zalathar Aug 2, 2025
ac862c0
fix typos
lcnr Aug 8, 2025
988569f
remove unnecessary `TypeFoldable` impls
lcnr Aug 8, 2025
c3e504d
Fix wasm target build with atomics feature
Spxg Aug 8, 2025
dbc6f58
rustc_metadata: remove unused private trait impls
fee1-dead Aug 8, 2025
5e8ebd5
rustdoc: IndexItem::{stability -> is_unstable}
lolbinarycat Jun 10, 2025
fdbc8d0
rustdoc search: add performance note about searchIndexUnstable check
lolbinarycat Aug 8, 2025
8b95291
borrowck: move error tainting earlier
lcnr Aug 8, 2025
4eee556
borrowck: defer opaque type errors
lcnr Aug 8, 2025
c44fe70
fix missing parenthesis in pretty discriminant
makai410 Aug 8, 2025
b2d524c
Recover for PAT = EXPR {}
compiler-errors Aug 8, 2025
7670cde
Refactor map_unit_fn lint
camsteffen Aug 7, 2025
eec8585
Reduce indirect assoc parent queries
camsteffen Aug 8, 2025
b39357b
Rank doc aliases lower than equivalently matched items
GuillaumeGomez Aug 8, 2025
a34bd2b
Add regression test for doc alias matching vs equivalently matched items
GuillaumeGomez Aug 8, 2025
48f5929
Rollup merge of #141658 - lolbinarycat:rustdoc-search-stability-rank-…
Zalathar Aug 9, 2025
2053728
Rollup merge of #141828 - Fulgen301:status-stack-buffer-overrun-diagn…
Zalathar Aug 9, 2025
4f80489
Rollup merge of #144823 - Zalathar:hir-info, r=oli-obk
Zalathar Aug 9, 2025
e63e769
Rollup merge of #144883 - scottmcm:remove-unneeded-drop_in_place, r=n…
Zalathar Aug 9, 2025
7f77dfd
Rollup merge of #144923 - rocurley:float_tests_refactor_3, r=tgross35
Zalathar Aug 9, 2025
35f2fb9
Rollup merge of #144988 - amandasystems:more-detailed-region-graph, r…
Zalathar Aug 9, 2025
61e9c6c
Rollup merge of #145010 - bjorn3:couple_abi_cleanups, r=compiler-errors
Zalathar Aug 9, 2025
aa7cb53
Rollup merge of #145017 - pmur:murp/s390x-improve-asm-test, r=nnether…
Zalathar Aug 9, 2025
2a7354e
Rollup merge of #145027 - Kmeakin:km/optimize-char-is-alphanumeric, r…
Zalathar Aug 9, 2025
50ad4c8
Rollup merge of #145050 - lcnr:add-opaque-type-tests, r=lqd
Zalathar Aug 9, 2025
f077257
Rollup merge of #145073 - ZuseZ4:autodiff-llvm-21, r=jieyouxu
Zalathar Aug 9, 2025
354ef54
Rollup merge of #145080 - ashivaram23:graphviz_escape, r=lqd
Zalathar Aug 9, 2025
d0ddeb5
Rollup merge of #145082 - nnethercote:macro-stats-fix-widths, r=petro…
Zalathar Aug 9, 2025
0b28978
Rollup merge of #145083 - Kobzol:fix-cargo-cross-build, r=jieyouxu
Zalathar Aug 9, 2025
f47557c
Rollup merge of #145096 - Spxg:w/wasm_atomic, r=tgross35
Zalathar Aug 9, 2025
e68d621
Rollup merge of #145097 - lcnr:type-foldable-yeet, r=wesleywiser
Zalathar Aug 9, 2025
cd1e82a
Rollup merge of #145100 - GuillaumeGomez:rank-doc-alias-lower, r=lolb…
Zalathar Aug 9, 2025
d0ddce8
Rollup merge of #145103 - fee1-dead-contrib:push-plompruwywvk, r=comp…
Zalathar Aug 9, 2025
9d989bf
Rollup merge of #145115 - lcnr:less-borrowck-tainting, r=compiler-errors
Zalathar Aug 9, 2025
a56142c
Rollup merge of #145119 - makai410:pretty-fix, r=compiler-errors
Zalathar Aug 9, 2025
aea608c
Rollup merge of #145124 - compiler-errors:for-eq, r=lqd
Zalathar Aug 9, 2025
4841410
Rollup merge of #145132 - camsteffen:refactor-map-unit-fn, r=fee1-dead
Zalathar Aug 9, 2025
d88a309
Rollup merge of #145134 - camsteffen:indirect-assoc-parent, r=cjgillot
Zalathar Aug 9, 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
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod conflict_errors;
mod explain_borrow;
mod move_errors;
mod mutability_errors;
mod opaque_suggestions;
mod opaque_types;
mod region_errors;

pub(crate) use bound_region_errors::{ToUniverseInfo, UniverseInfo};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,28 @@ use rustc_trait_selection::errors::impl_trait_overcapture_suggestion;
use crate::MirBorrowckCtxt;
use crate::borrow_set::BorrowData;
use crate::consumers::RegionInferenceContext;
use crate::region_infer::opaque_types::DeferredOpaqueTypeError;
use crate::type_check::Locations;

impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
pub(crate) fn report_opaque_type_errors(&mut self, errors: Vec<DeferredOpaqueTypeError<'tcx>>) {
if errors.is_empty() {
return;
}
let mut guar = None;
for error in errors {
guar = Some(match error {
DeferredOpaqueTypeError::InvalidOpaqueTypeArgs(err) => err.report(self.infcx),
DeferredOpaqueTypeError::LifetimeMismatchOpaqueParam(err) => {
self.infcx.dcx().emit_err(err)
}
});
}
let guar = guar.unwrap();
self.root_cx.set_tainted_by_errors(guar);
self.infcx.set_tainted_by_errors(guar);
}

/// Try to note when an opaque is involved in a borrowck error and that
/// opaque captures lifetimes due to edition 2024.
// FIXME: This code is otherwise somewhat general, and could easily be adapted
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ impl<'tcx> RegionErrors<'tcx> {
) -> impl Iterator<Item = (RegionErrorKind<'tcx>, ErrorGuaranteed)> {
self.0.into_iter()
}
pub(crate) fn has_errors(&self) -> Option<ErrorGuaranteed> {
self.0.get(0).map(|x| x.1)
}
}

impl std::fmt::Debug for RegionErrors<'_> {
Expand Down
15 changes: 2 additions & 13 deletions compiler/rustc_borrowck/src/handle_placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn region_definitions<'tcx>(
for info in var_infos.iter() {
let origin = match info.origin {
RegionVariableOrigin::Nll(origin) => origin,
_ => NllRegionVariableOrigin::Existential { from_forall: false },
_ => NllRegionVariableOrigin::Existential { from_forall: false, name: None },
};

let definition = RegionDefinition { origin, universe: info.universe, external_name: None };
Expand Down Expand Up @@ -216,22 +216,11 @@ pub(crate) fn compute_sccs_applying_placeholder_outlives_constraints<'tcx>(
placeholder_index_to_region: _,
liveness_constraints,
mut outlives_constraints,
mut member_constraints,
member_constraints,
universe_causes,
type_tests,
} = constraints;

if let Some(guar) = universal_regions.tainted_by_errors() {
debug!("Universal regions tainted by errors; removing constraints!");
// Suppress unhelpful extra errors in `infer_opaque_types` by clearing out all
// outlives bounds that we may end up checking.
outlives_constraints = Default::default();
member_constraints = Default::default();

// Also taint the entire scope.
infcx.set_tainted_by_errors(guar);
}

let fr_static = universal_regions.fr_static;
let compute_sccs =
|constraints: &OutlivesConstraintSet<'tcx>,
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ fn do_mir_borrowck<'tcx>(
polonius_context,
);

regioncx.infer_opaque_types(root_cx, &infcx, opaque_type_values);
let opaque_type_errors = regioncx.infer_opaque_types(root_cx, &infcx, opaque_type_values);

// Dump MIR results into a file, if that is enabled. This lets us
// write unit-tests, as well as helping with debugging.
Expand Down Expand Up @@ -471,7 +471,11 @@ fn do_mir_borrowck<'tcx>(
};

// Compute and report region errors, if any.
mbcx.report_region_errors(nll_errors);
if nll_errors.is_empty() {
mbcx.report_opaque_type_errors(opaque_type_errors);
} else {
mbcx.report_region_errors(nll_errors);
}

let (mut flow_analysis, flow_entry_states) =
get_flow_results(tcx, body, &move_data, &borrow_set, &regioncx);
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ pub(crate) fn compute_regions<'tcx>(
let (closure_region_requirements, nll_errors) =
regioncx.solve(infcx, body, polonius_output.clone());

if let Some(guar) = nll_errors.has_errors() {
// Suppress unhelpful extra errors in `infer_opaque_types`.
infcx.set_tainted_by_errors(guar);
}

NllOutput {
regioncx,
polonius_input: polonius_facts.map(Box::new),
Expand Down
17 changes: 16 additions & 1 deletion compiler/rustc_borrowck/src/region_infer/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,22 @@ fn render_region_vid<'tcx>(
"".to_string()
};

format!("{:?}{universe_str}{external_name_str}", rvid)
let extra_info = match regioncx.region_definition(rvid).origin {
NllRegionVariableOrigin::FreeRegion => "".to_string(),
NllRegionVariableOrigin::Placeholder(p) => match p.bound.kind {
ty::BoundRegionKind::Named(def_id) => {
format!(" (for<{}>)", tcx.item_name(def_id))
}
ty::BoundRegionKind::ClosureEnv | ty::BoundRegionKind::Anon => " (for<'_>)".to_string(),
ty::BoundRegionKind::NamedAnon(_) => {
bug!("only used for pretty printing")
}
},
NllRegionVariableOrigin::Existential { name: Some(name), .. } => format!(" (ex<{name}>)"),
NllRegionVariableOrigin::Existential { .. } => format!(" (ex<'_>)"),
};

format!("{:?}{universe_str}{external_name_str}{extra_info}", rvid)
}

impl<'tcx> RegionInferenceContext<'tcx> {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::{

mod dump_mir;
mod graphviz;
mod opaque_types;
pub(crate) mod opaque_types;
mod reverse_sccs;

pub(crate) mod values;
Expand Down Expand Up @@ -1940,9 +1940,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// and here we prefer to blame the source (the y = x statement).
let blame_source = match from_region_origin {
NllRegionVariableOrigin::FreeRegion
| NllRegionVariableOrigin::Existential { from_forall: false } => true,
| NllRegionVariableOrigin::Existential { from_forall: false, name: _ } => true,
NllRegionVariableOrigin::Placeholder(_)
| NllRegionVariableOrigin::Existential { from_forall: true } => false,
| NllRegionVariableOrigin::Existential { from_forall: true, name: _ } => false,
};

// To pick a constraint to blame, we organize constraints by how interesting we expect them
Expand Down
78 changes: 43 additions & 35 deletions compiler/rustc_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ use rustc_middle::ty::{
TypeVisitableExt, fold_regions,
};
use rustc_span::Span;
use rustc_trait_selection::opaque_types::check_opaque_type_parameter_valid;
use rustc_trait_selection::opaque_types::{
InvalidOpaqueTypeArgs, check_opaque_type_parameter_valid,
};
use tracing::{debug, instrument};

use super::RegionInferenceContext;
use crate::BorrowCheckRootCtxt;
use crate::session_diagnostics::LifetimeMismatchOpaqueParam;
use crate::universal_regions::RegionClassification;

pub(crate) enum DeferredOpaqueTypeError<'tcx> {
InvalidOpaqueTypeArgs(InvalidOpaqueTypeArgs<'tcx>),
LifetimeMismatchOpaqueParam(LifetimeMismatchOpaqueParam<'tcx>),
}

impl<'tcx> RegionInferenceContext<'tcx> {
/// Resolve any opaque types that were encountered while borrow checking
/// this item. This is then used to get the type in the `type_of` query.
Expand Down Expand Up @@ -58,13 +65,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
///
/// [rustc-dev-guide chapter]:
/// https://rustc-dev-guide.rust-lang.org/opaque-types-region-infer-restrictions.html
#[instrument(level = "debug", skip(self, root_cx, infcx), ret)]
#[instrument(level = "debug", skip(self, root_cx, infcx))]
pub(crate) fn infer_opaque_types(
&self,
root_cx: &mut BorrowCheckRootCtxt<'tcx>,
infcx: &InferCtxt<'tcx>,
opaque_ty_decls: FxIndexMap<OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>>,
) {
) -> Vec<DeferredOpaqueTypeError<'tcx>> {
let mut errors = Vec::new();
let mut decls_modulo_regions: FxIndexMap<OpaqueTypeKey<'tcx>, (OpaqueTypeKey<'tcx>, Span)> =
FxIndexMap::default();

Expand Down Expand Up @@ -124,8 +132,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
});
debug!(?concrete_type);

let ty =
infcx.infer_opaque_definition_from_instantiation(opaque_type_key, concrete_type);
let ty = match infcx
.infer_opaque_definition_from_instantiation(opaque_type_key, concrete_type)
{
Ok(ty) => ty,
Err(err) => {
errors.push(DeferredOpaqueTypeError::InvalidOpaqueTypeArgs(err));
continue;
}
};

// Sometimes, when the hidden type is an inference variable, it can happen that
// the hidden type becomes the opaque type itself. In this case, this was an opaque
Expand All @@ -149,25 +164,27 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// non-region parameters. This is necessary because within the new solver we perform
// various query operations modulo regions, and thus could unsoundly select some impls
// that don't hold.
if !ty.references_error()
&& let Some((prev_decl_key, prev_span)) = decls_modulo_regions.insert(
infcx.tcx.erase_regions(opaque_type_key),
(opaque_type_key, concrete_type.span),
)
&& let Some((arg1, arg2)) = std::iter::zip(
prev_decl_key.iter_captured_args(infcx.tcx).map(|(_, arg)| arg),
opaque_type_key.iter_captured_args(infcx.tcx).map(|(_, arg)| arg),
)
.find(|(arg1, arg2)| arg1 != arg2)
if let Some((prev_decl_key, prev_span)) = decls_modulo_regions.insert(
infcx.tcx.erase_regions(opaque_type_key),
(opaque_type_key, concrete_type.span),
) && let Some((arg1, arg2)) = std::iter::zip(
prev_decl_key.iter_captured_args(infcx.tcx).map(|(_, arg)| arg),
opaque_type_key.iter_captured_args(infcx.tcx).map(|(_, arg)| arg),
)
.find(|(arg1, arg2)| arg1 != arg2)
{
infcx.dcx().emit_err(LifetimeMismatchOpaqueParam {
arg: arg1,
prev: arg2,
span: prev_span,
prev_span: concrete_type.span,
});
errors.push(DeferredOpaqueTypeError::LifetimeMismatchOpaqueParam(
LifetimeMismatchOpaqueParam {
arg: arg1,
prev: arg2,
span: prev_span,
prev_span: concrete_type.span,
},
));
}
}

errors
}

/// Map the regions in the type to named regions. This is similar to what
Expand Down Expand Up @@ -260,19 +277,13 @@ impl<'tcx> InferCtxt<'tcx> {
&self,
opaque_type_key: OpaqueTypeKey<'tcx>,
instantiated_ty: OpaqueHiddenType<'tcx>,
) -> Ty<'tcx> {
if let Some(e) = self.tainted_by_errors() {
return Ty::new_error(self.tcx, e);
}

if let Err(err) = check_opaque_type_parameter_valid(
) -> Result<Ty<'tcx>, InvalidOpaqueTypeArgs<'tcx>> {
check_opaque_type_parameter_valid(
self,
opaque_type_key,
instantiated_ty.span,
DefiningScopeKind::MirBorrowck,
) {
return Ty::new_error(self.tcx, err.report(self));
}
)?;

let definition_ty = instantiated_ty
.remap_generic_params_to_declaration_params(
Expand All @@ -282,10 +293,7 @@ impl<'tcx> InferCtxt<'tcx> {
)
.ty;

if let Err(e) = definition_ty.error_reported() {
return Ty::new_error(self.tcx, e);
}

definition_ty
definition_ty.error_reported()?;
Ok(definition_ty)
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/renumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a, 'tcx> RegionRenumberer<'a, 'tcx> {
T: TypeFoldable<TyCtxt<'tcx>>,
F: Fn() -> RegionCtxt,
{
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
let origin = NllRegionVariableOrigin::Existential { from_forall: false, name: None };
fold_regions(self.infcx.tcx, value, |_region, _depth| {
self.infcx.next_nll_region_var(origin, || region_ctxt_fn())
})
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ pub(crate) fn type_check<'tcx>(
)
});

// In case type check encountered an error region, we suppress unhelpful extra
// errors in by clearing out all outlives bounds that we may end up checking.
if let Some(guar) = universal_region_relations.universal_regions.encountered_re_error() {
debug!("encountered an error region; removing constraints!");
constraints.outlives_constraints = Default::default();
constraints.member_constraints = Default::default();
constraints.type_tests = Default::default();
root_cx.set_tainted_by_errors(guar);
infcx.set_tainted_by_errors(guar);
}

MirTypeckResults {
constraints,
universal_region_relations,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
from_forall: bool,
name: Option<Symbol>,
) -> ty::Region<'tcx> {
let origin = NllRegionVariableOrigin::Existential { from_forall };
let origin = NllRegionVariableOrigin::Existential { name, from_forall };

let reg_var =
self.type_checker.infcx.next_nll_region_var(origin, || RegionCtxt::Existential(name));
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ struct UniversalRegionIndices<'tcx> {

/// Whether we've encountered an error region. If we have, cancel all
/// outlives errors, as they are likely bogus.
pub tainted_by_errors: Cell<Option<ErrorGuaranteed>>,
pub encountered_re_error: Cell<Option<ErrorGuaranteed>>,
}

#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -442,8 +442,8 @@ impl<'tcx> UniversalRegions<'tcx> {
self.fr_fn_body
}

pub(crate) fn tainted_by_errors(&self) -> Option<ErrorGuaranteed> {
self.indices.tainted_by_errors.get()
pub(crate) fn encountered_re_error(&self) -> Option<ErrorGuaranteed> {
self.indices.encountered_re_error.get()
}
}

Expand Down Expand Up @@ -706,7 +706,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
UniversalRegionIndices {
indices: global_mapping.chain(arg_mapping).collect(),
fr_static,
tainted_by_errors: Cell::new(None),
encountered_re_error: Cell::new(None),
}
}

Expand Down Expand Up @@ -916,7 +916,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
match r.kind() {
ty::ReVar(..) => r.as_var(),
ty::ReError(guar) => {
self.tainted_by_errors.set(Some(guar));
self.encountered_re_error.set(Some(guar));
// We use the `'static` `RegionVid` because `ReError` doesn't actually exist in the
// `UniversalRegionIndices`. This is fine because 1) it is a fallback only used if
// errors are being emitted and 2) it leaves the happy path unaffected.
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ codegen_ssa_ld64_unimplemented_modifier = `as-needed` modifier not implemented y

codegen_ssa_lib_def_write_failure = failed to write lib.def file: {$error}

codegen_ssa_link_exe_status_stack_buffer_overrun = 0xc0000409 is `STATUS_STACK_BUFFER_OVERRUN`
.abort_note = this may have been caused by a program abort and not a stack buffer overrun
.event_log_note = consider checking the Application Event Log for Windows Error Reporting events to see the fail fast error code

codegen_ssa_link_exe_unexpected_error = `link.exe` returned an unexpected error

codegen_ssa_link_script_unavailable = can only use link script when linking with GNU-like linker
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,14 @@ fn link_natively(
windows_registry::find_tool(&sess.target.arch, "link.exe").is_some();

sess.dcx().emit_note(errors::LinkExeUnexpectedError);

// STATUS_STACK_BUFFER_OVERRUN is also used for fast abnormal program termination, e.g. abort().
// Emit a special diagnostic to let people know that this most likely doesn't indicate a stack buffer overrun.
const STATUS_STACK_BUFFER_OVERRUN: i32 = 0xc0000409u32 as _;
if code == STATUS_STACK_BUFFER_OVERRUN {
sess.dcx().emit_note(errors::LinkExeStatusStackBufferOverrun);
}

if is_vs_installed && has_linker {
// the linker is broken
sess.dcx().emit_note(errors::RepairVSBuildTools);
Expand Down
Loading
Loading