Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
eb2ba7d
fix ICE in supertrait_vtable_slot when supertrait has missing generics
TaKO8Ki Feb 9, 2026
41e0e06
Move `inline_fluent` to a proc macro
JonathanBrouwer Feb 9, 2026
6eb2a8f
Reformat existing error messages
JonathanBrouwer Feb 9, 2026
c750a1f
Add regression test for type_const with unit struct ctor under mGCA
AprilNEA Feb 9, 2026
11e4873
Fix typos and grammar in compiler and build documentation
him2him2 Feb 10, 2026
9448bdf
bootstrap: add explicit UTF-8 encoding to text-mode open() calls
Feb 12, 2026
42a3c86
Remove `deprecated_safe` and its corresponding feature gate
JonathanBrouwer Feb 12, 2026
be82877
doc: move riscv64a23-unknown-linux-gnu to tier 2
Feb 12, 2026
a07f837
Remove unused features in compiler
mu001999 Feb 7, 2026
0dc1556
Remove unused features in library
mu001999 Feb 12, 2026
a318a20
Remove unused features in librustdoc
mu001999 Feb 12, 2026
73c42c1
Remove or allow unused features in library doc and tests
mu001999 Feb 12, 2026
7d7b381
Fix ICE in borrowck when recovering `fn_sig` for `-> _`
JohnTitor Feb 8, 2026
45bc47e
Apply review suggestions
JohnTitor Feb 12, 2026
20c46d6
report unconstrained region in hidden types lazily
adwinwhite Jan 31, 2026
b0f2ac8
Return Binder
JohnTitor Feb 13, 2026
4c10efb
Replace "bug" with "issue" in triagebot ping messages
SpriteOvO Feb 13, 2026
cbc6610
Port `#[rustc_diagnostic_item]` to the new attribute parsers
JonathanBrouwer Feb 12, 2026
f63007c
fix missleading error for tuple ctor
Kivooeo Feb 13, 2026
1d6ef95
Extract `DepKindVTable` constructors to their own module
Zalathar Feb 10, 2026
9d662b5
Rollup merge of #152323 - JohnTitor:issue-135845-2, r=lcnr
JonathanBrouwer Feb 13, 2026
65d982a
Rollup merge of #152469 - mu001999-contrib:cleanup/unused-features, r…
JonathanBrouwer Feb 13, 2026
6fa5694
Rollup merge of #152515 - Zalathar:dep-kind-vtables, r=nnethercote
JonathanBrouwer Feb 13, 2026
a211e2f
Rollup merge of #152555 - JonathanBrouwer:port_diagnostic_item, r=jdo…
JonathanBrouwer Feb 13, 2026
98e8f99
Rollup merge of #152218 - adwinwhite:fix-mir-borrowck-opaque-handling…
JonathanBrouwer Feb 13, 2026
f1b935d
Rollup merge of #152356 - JonathanBrouwer:inline_diag4, r=jdonszelmann
JonathanBrouwer Feb 13, 2026
e91d02a
Rollup merge of #152392 - TaKO8Ki:missing-generics-in-traits-used-in-…
JonathanBrouwer Feb 13, 2026
7ea8f5b
Rollup merge of #152407 - AprilNEA:test/issue-148953-type-const-ctor,…
JonathanBrouwer Feb 13, 2026
fd598eb
Rollup merge of #152440 - him2him2:fix-typos-compiler, r=Kivooeo,Kobzol
JonathanBrouwer Feb 13, 2026
9ca0ebb
Rollup merge of #152536 - ozankenangungor:bootstrap-explicit-open-enc…
JonathanBrouwer Feb 13, 2026
1944af6
Rollup merge of #152554 - JonathanBrouwer:remove_deprecated_safe, r=j…
JonathanBrouwer Feb 13, 2026
c3b53f7
Rollup merge of #152556 - ozankenangungor:docs-riscv64a23-tier2, r=ji…
JonathanBrouwer Feb 13, 2026
6638db6
Rollup merge of #152563 - SpriteOvO:triagebot-ping-messages, r=jieyouxu
JonathanBrouwer Feb 13, 2026
d93a38a
Rollup merge of #152565 - Kivooeo:ctor-diag, r=BoxyUwU
JonathanBrouwer Feb 13, 2026
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_abi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// tidy-alphabetical-start
#![cfg_attr(all(feature = "nightly", bootstrap), feature(assert_matches))]
#![cfg_attr(all(feature = "nightly", bootstrap, test), feature(assert_matches))]
#![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
#![cfg_attr(feature = "nightly", feature(step_trait))]
Expand Down
39 changes: 39 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,45 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcEffectiveVisibilityParser {
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEffectiveVisibility;
}

pub(crate) struct RustcDiagnosticItemParser;

impl<S: Stage> SingleAttributeParser<S> for RustcDiagnosticItemParser {
const PATH: &[Symbol] = &[sym::rustc_diagnostic_item];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Trait),
Allow(Target::Struct),
Allow(Target::Enum),
Allow(Target::MacroDef),
Allow(Target::TyAlias),
Allow(Target::AssocTy),
Allow(Target::AssocConst),
Allow(Target::Fn),
Allow(Target::Const),
Allow(Target::Mod),
Allow(Target::Impl { of_trait: false }),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Crate),
]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
let Some(nv) = args.name_value() else {
cx.expected_name_value(cx.attr_span, None);
return None;
};
let Some(value) = nv.value_as_str() else {
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
return None;
};
Some(AttributeKind::RustcDiagnosticItem(value))
}
}

pub(crate) struct RustcSymbolName;

impl<S: Stage> SingleAttributeParser<S> for RustcSymbolName {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ attribute_parsers!(
Single<RustcBuiltinMacroParser>,
Single<RustcDefPath>,
Single<RustcDeprecatedSafe2024Parser>,
Single<RustcDiagnosticItemParser>,
Single<RustcForceInlineParser>,
Single<RustcIfThisChangedParser>,
Single<RustcLayoutScalarValidRangeEndParser>,
Expand Down
100 changes: 89 additions & 11 deletions compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use tracing::{debug, instrument};

use super::reverse_sccs::ReverseSccGraph;
use crate::BorrowckInferCtxt;
use crate::consumers::RegionInferenceContext;
use crate::session_diagnostics::LifetimeMismatchOpaqueParam;
use crate::type_check::canonical::fully_perform_op_raw;
use crate::type_check::free_region_relations::UniversalRegionRelations;
use crate::type_check::{Locations, MirTypeckRegionConstraints};
use crate::universal_regions::{RegionClassification, UniversalRegions};
use crate::{BorrowckInferCtxt, CollectRegionConstraintsResult};

mod member_constraints;
mod region_ctxt;
Expand Down Expand Up @@ -126,6 +126,31 @@ fn nll_var_to_universal_region<'tcx>(
}
}

/// Record info needed to report the same name error later.
#[derive(Copy, Clone, Debug)]
pub(crate) struct UnexpectedHiddenRegion<'tcx> {
// The def_id of the body where this error occurs.
// Needed to handle region vars with their corresponding `infcx`.
def_id: LocalDefId,
opaque_type_key: OpaqueTypeKey<'tcx>,
hidden_type: ProvisionalHiddenType<'tcx>,
member_region: Region<'tcx>,
}

impl<'tcx> UnexpectedHiddenRegion<'tcx> {
pub(crate) fn to_error(self) -> (LocalDefId, DeferredOpaqueTypeError<'tcx>) {
let UnexpectedHiddenRegion { def_id, opaque_type_key, hidden_type, member_region } = self;
(
def_id,
DeferredOpaqueTypeError::UnexpectedHiddenRegion {
opaque_type_key,
hidden_type,
member_region,
},
)
}
}

/// Collect all defining uses of opaque types inside of this typeck root. This
/// expects the hidden type to be mapped to the definition parameters of the opaque
/// and errors if we end up with distinct hidden types.
Expand Down Expand Up @@ -176,11 +201,13 @@ struct DefiningUse<'tcx> {
/// It also means that this whole function is not really soundness critical as we
/// recheck all uses of the opaques regardless.
pub(crate) fn compute_definition_site_hidden_types<'tcx>(
def_id: LocalDefId,
infcx: &BorrowckInferCtxt<'tcx>,
universal_region_relations: &Frozen<UniversalRegionRelations<'tcx>>,
constraints: &MirTypeckRegionConstraints<'tcx>,
location_map: Rc<DenseLocationMap>,
hidden_types: &mut FxIndexMap<LocalDefId, ty::DefinitionSiteHiddenType<'tcx>>,
unconstrained_hidden_type_errors: &mut Vec<UnexpectedHiddenRegion<'tcx>>,
opaque_types: &[(OpaqueTypeKey<'tcx>, ProvisionalHiddenType<'tcx>)],
) -> Vec<DeferredOpaqueTypeError<'tcx>> {
let mut errors = Vec::new();
Expand All @@ -204,8 +231,10 @@ pub(crate) fn compute_definition_site_hidden_types<'tcx>(
// up equal to one of their choice regions and compute the actual hidden type of
// the opaque type definition. This is stored in the `root_cx`.
compute_definition_site_hidden_types_from_defining_uses(
def_id,
&rcx,
hidden_types,
unconstrained_hidden_type_errors,
&defining_uses,
&mut errors,
);
Expand Down Expand Up @@ -274,8 +303,10 @@ fn collect_defining_uses<'tcx>(

#[instrument(level = "debug", skip(rcx, hidden_types, defining_uses, errors))]
fn compute_definition_site_hidden_types_from_defining_uses<'tcx>(
def_id: LocalDefId,
rcx: &RegionCtxt<'_, 'tcx>,
hidden_types: &mut FxIndexMap<LocalDefId, ty::DefinitionSiteHiddenType<'tcx>>,
unconstrained_hidden_type_errors: &mut Vec<UnexpectedHiddenRegion<'tcx>>,
defining_uses: &[DefiningUse<'tcx>],
errors: &mut Vec<DeferredOpaqueTypeError<'tcx>>,
) {
Expand All @@ -293,16 +324,29 @@ fn compute_definition_site_hidden_types_from_defining_uses<'tcx>(
Ok(hidden_type) => hidden_type,
Err(r) => {
debug!("UnexpectedHiddenRegion: {:?}", r);
errors.push(DeferredOpaqueTypeError::UnexpectedHiddenRegion {
hidden_type,
opaque_type_key,
member_region: ty::Region::new_var(tcx, r),
});
let guar = tcx.dcx().span_delayed_bug(
hidden_type.span,
"opaque type with non-universal region args",
);
ty::ProvisionalHiddenType::new_error(tcx, guar)
// If we're using the next solver, the unconstrained region may be resolved by a
// fully defining use from another body.
// So we don't generate error eagerly here.
if rcx.infcx.tcx.use_typing_mode_borrowck() {
unconstrained_hidden_type_errors.push(UnexpectedHiddenRegion {
def_id,
hidden_type,
opaque_type_key,
member_region: ty::Region::new_var(tcx, r),
});
continue;
} else {
errors.push(DeferredOpaqueTypeError::UnexpectedHiddenRegion {
hidden_type,
opaque_type_key,
member_region: ty::Region::new_var(tcx, r),
});
let guar = tcx.dcx().span_delayed_bug(
hidden_type.span,
"opaque type with non-universal region args",
);
ty::ProvisionalHiddenType::new_error(tcx, guar)
}
}
};

Expand Down Expand Up @@ -570,6 +614,40 @@ pub(crate) fn apply_definition_site_hidden_types<'tcx>(
errors
}

/// We handle `UnexpectedHiddenRegion` error lazily in the next solver as
/// there may be a fully defining use in another body.
///
/// In case such a defining use does not exist, we register an error here.
pub(crate) fn handle_unconstrained_hidden_type_errors<'tcx>(
tcx: TyCtxt<'tcx>,
hidden_types: &mut FxIndexMap<LocalDefId, ty::DefinitionSiteHiddenType<'tcx>>,
unconstrained_hidden_type_errors: &mut Vec<UnexpectedHiddenRegion<'tcx>>,
collect_region_constraints_results: &mut FxIndexMap<
LocalDefId,
CollectRegionConstraintsResult<'tcx>,
>,
) {
let mut unconstrained_hidden_type_errors = std::mem::take(unconstrained_hidden_type_errors);
unconstrained_hidden_type_errors
.retain(|unconstrained| !hidden_types.contains_key(&unconstrained.opaque_type_key.def_id));

unconstrained_hidden_type_errors.iter().for_each(|t| {
tcx.dcx()
.span_delayed_bug(t.hidden_type.span, "opaque type with non-universal region args");
});

// `UnexpectedHiddenRegion` error contains region var which only makes sense in the
// corresponding `infcx`.
// So we need to insert the error to the body where it originates from.
for error in unconstrained_hidden_type_errors {
let (def_id, error) = error.to_error();
let Some(result) = collect_region_constraints_results.get_mut(&def_id) else {
unreachable!("the body should depend on opaques type if it has opaque use");
};
result.deferred_opaque_type_errors.push(error);
}
}

/// In theory `apply_definition_site_hidden_types` could introduce new uses of opaque types.
/// We do not check these new uses so this could be unsound.
///
Expand Down
20 changes: 18 additions & 2 deletions compiler/rustc_borrowck/src/root_cx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use smallvec::SmallVec;
use crate::consumers::BorrowckConsumer;
use crate::nll::compute_closure_requirements_modulo_opaques;
use crate::region_infer::opaque_types::{
apply_definition_site_hidden_types, clone_and_resolve_opaque_types,
UnexpectedHiddenRegion, apply_definition_site_hidden_types, clone_and_resolve_opaque_types,
compute_definition_site_hidden_types, detect_opaque_types_added_while_handling_opaque_types,
handle_unconstrained_hidden_type_errors,
};
use crate::type_check::{Locations, constraint_conversion};
use crate::{
Expand All @@ -26,7 +27,12 @@ use crate::{
pub(super) struct BorrowCheckRootCtxt<'tcx> {
pub tcx: TyCtxt<'tcx>,
root_def_id: LocalDefId,
/// This contains fully resolved hidden types or `ty::Error`.
hidden_types: FxIndexMap<LocalDefId, ty::DefinitionSiteHiddenType<'tcx>>,
/// This contains unconstrained regions in hidden types.
/// Only used for deferred error reporting. See
/// [`crate::region_infer::opaque_types::handle_unconstrained_hidden_type_errors`]
unconstrained_hidden_type_errors: Vec<UnexpectedHiddenRegion<'tcx>>,
/// The region constraints computed by [borrowck_collect_region_constraints]. This uses
/// an [FxIndexMap] to guarantee that iterating over it visits nested bodies before
/// their parents.
Expand All @@ -49,6 +55,7 @@ impl<'tcx> BorrowCheckRootCtxt<'tcx> {
tcx,
root_def_id,
hidden_types: Default::default(),
unconstrained_hidden_type_errors: Default::default(),
collect_region_constraints_results: Default::default(),
propagated_borrowck_results: Default::default(),
tainted_by_errors: None,
Expand Down Expand Up @@ -84,23 +91,32 @@ impl<'tcx> BorrowCheckRootCtxt<'tcx> {

fn handle_opaque_type_uses(&mut self) {
let mut per_body_info = Vec::new();
for input in self.collect_region_constraints_results.values_mut() {
for (def_id, input) in &mut self.collect_region_constraints_results {
let (num_entries, opaque_types) = clone_and_resolve_opaque_types(
&input.infcx,
&input.universal_region_relations,
&mut input.constraints,
);
input.deferred_opaque_type_errors = compute_definition_site_hidden_types(
*def_id,
&input.infcx,
&input.universal_region_relations,
&input.constraints,
Rc::clone(&input.location_map),
&mut self.hidden_types,
&mut self.unconstrained_hidden_type_errors,
&opaque_types,
);
per_body_info.push((num_entries, opaque_types));
}

handle_unconstrained_hidden_type_errors(
self.tcx,
&mut self.hidden_types,
&mut self.unconstrained_hidden_type_errors,
&mut self.collect_region_constraints_results,
);

for (input, (opaque_types_storage_num_entries, opaque_types)) in
self.collect_region_constraints_results.values_mut().zip(per_body_info)
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Note: please avoid adding other feature gates where possible
#![feature(rustc_private)]
// Only used to define intrinsics in `compiler_builtins.rs`.
#![feature(f16)]
#![feature(f128)]
#![cfg_attr(feature = "jit", feature(f16))]
#![cfg_attr(feature = "jit", feature(f128))]
// Note: please avoid adding other feature gates where possible
#![warn(rust_2018_idioms)]
#![warn(unreachable_pub)]
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_llvm/src/debuginfo/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module to generate correct metadata and insert it into the LLVM IR.
As the exact format of metadata trees may change between different LLVM
versions, we now use LLVM
[DIBuilder](https://llvm.org/docs/doxygen/html/classllvm_1_1DIBuilder.html)
to create metadata where possible. This will hopefully ease the adaption of
to create metadata where possible. This will hopefully ease the adaptation of
this module to future LLVM versions.

The public API of the module is a set of functions that will insert the
Expand Down Expand Up @@ -87,19 +87,19 @@ describe the type anew. This behavior is encapsulated in the
## Source Locations and Line Information

In addition to data type descriptions the debugging information must also
allow to map machine code locations back to source code locations in order
allow mapping machine code locations back to source code locations in order
to be useful. This functionality is also handled in this module. The
following functions allow to control source mappings:
following functions allow controlling source mappings:

+ `set_source_location()`
+ `clear_source_location()`
+ `start_emitting_source_locations()`

`set_source_location()` allows to set the current source location. All IR
`set_source_location()` allows setting the current source location. All IR
instructions created after a call to this function will be linked to the
given source location, until another location is specified with
`set_source_location()` or the source location is cleared with
`clear_source_location()`. In the later case, subsequent IR instruction
`clear_source_location()`. In the latter case, subsequent IR instructions
will not be linked to any source location. As you can see, this is a
stateful API (mimicking the one in LLVM), so be careful with source
locations set by previous calls. It's probably best to not rely on any
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_const_eval/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ fn report_eval_error<'tcx>(
span,
inline_fluent!(
"evaluation of `{$instance}` failed {$num_frames ->
[0] here
*[other] inside this call
}"
[0] here
*[other] inside this call
}"
),
);
for frame in frames {
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,10 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
Err(err) => throw_ub_custom!(
inline_fluent!(
"invalid align passed to `{$name}`: {$align} is {$err_kind ->
[not_power_of_two] not a power of 2
[too_large] too large
*[other] {\"\"}
}"
[not_power_of_two] not a power of 2
[too_large] too large
*[other] {\"\"}
}"
),
name = "const_allocate",
err_kind = err.diag_ident(),
Expand All @@ -521,10 +521,10 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
Err(err) => throw_ub_custom!(
inline_fluent!(
"invalid align passed to `{$name}`: {$align} is {$err_kind ->
[not_power_of_two] not a power of 2
[too_large] too large
*[other] {\"\"}
}"
[not_power_of_two] not a power of 2
[too_large] too large
*[other] {\"\"}
}"
),
name = "const_deallocate",
err_kind = err.diag_ident(),
Expand Down
Loading
Loading