Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
1af79e9
test `ReturnsVisitor` with weird, nested returns
folkertdev Nov 15, 2026
44568ec
make `ReturnsVisitor` more accurate
folkertdev Nov 15, 2026
8778c7d
Add safety section for intrinsic volatile operations
yilin0518 Nov 24, 2026
966f181
move span out of leaf region constraint
adwinwhite Nov 13, 2026
7cd93b0
Drop references to codebuild
Mark-Simulacrum Nov 22, 2026
3fcb5e1
remove some incorrect docs from volatile intrinsics
RalfJung Nov 24, 2026
5a701ad
Make rigid alias invalidation explicit when transitioning to PostAnal…
bit-aloo Nov 24, 2026
f9b362b
fix test enum-repr-abi
fneddy Nov 24, 2026
f099c5f
Inline some attribute parsing code
JonathanBrouwer Nov 23, 2026
2955ebc
Rollup merge of #166385 - JonathanBrouwer:attrs-perf, r=jdonszelmann
JonathanBrouwer Nov 24, 2026
39d8288
Rollup merge of #166013 - folkertdev:return-visitor, r=JonathanBrouwer
JonathanBrouwer Nov 24, 2026
b46e17b
Rollup merge of #166033 - adwinwhite:abby_move_span, r=khyperia
JonathanBrouwer Nov 24, 2026
c62fcf2
Rollup merge of #166088 - bit-aloo:2026-11-17-split-typing-env-post-a…
JonathanBrouwer Nov 24, 2026
1193d1f
Rollup merge of #166365 - Mark-Simulacrum:remove-codebuild, r=Kobzol
JonathanBrouwer Nov 24, 2026
c51c443
Rollup merge of #166399 - yilin0518:fix_volatile, r=RalfJung
JonathanBrouwer Nov 24, 2026
175cc2d
Rollup merge of #166439 - RalfJung:volatile-intrinsics, r=hanna-kruppe
JonathanBrouwer Nov 24, 2026
3f3c93a
Rollup merge of #166445 - fneddy:fix_enum_repr_abi, r=khyperia
JonathanBrouwer Nov 24, 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
11 changes: 0 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ jobs:
# Check the `calculate_matrix` job to see how is the matrix defined.
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
steps:
- name: Install cargo in AWS CodeBuild
if: matrix.codebuild
run: |
# Check if cargo is installed
if ! command -v cargo &> /dev/null; then
echo "Cargo not found, installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
# Make cargo available in PATH
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
fi

- name: disable git crlf conversion
run: git config --global core.autocrlf false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Those images are pushed to ghcr.io by this job.
#
# While Docker Hub rate limit *shouldn't* be an issue on GitHub Actions,
# it certainly is for AWS codebuild.
# it may be for external self-hosted runners (e.g., EC2 runners).
#
# Note that authenticating to DockerHub or other registries isn't possible
# for PR jobs, because forks can't access secrets.
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl<'sess> AttributeParser<'sess> {
/// with `parse_limited` to be reparsed later during ast lowering where we *do* emit the errors
///
/// Due to this function not taking in `RegisteredTools`, *do not* use this for parsing any lint attributes
#[inline]
pub fn parse_limited(
sess: &'sess Session,
attrs: &[ast::Attribute],
Expand All @@ -87,6 +88,7 @@ impl<'sess> AttributeParser<'sess> {

/// This does the same as `parse_limited`, except that it takes a fixed symbol instead of a
/// filter.
#[inline]
pub fn parse_limited_sym(
sess: &'sess Session,
attrs: &[ast::Attribute],
Expand All @@ -99,6 +101,7 @@ impl<'sess> AttributeParser<'sess> {
/// Usually you want `parse_limited`, which emits no errors.
///
/// Due to this function not taking in `RegisteredTools`, *do not* use this for parsing any lint attributes
#[inline]
pub fn parse_limited_should_emit(
sess: &'sess Session,
attrs: &[ast::Attribute],
Expand All @@ -125,6 +128,7 @@ impl<'sess> AttributeParser<'sess> {

/// This does the same as `parse_limited_should_emit`, except that it takes a fixed symbol
/// instead of a filter.
#[inline]
pub fn parse_limited_sym_should_emit(
sess: &'sess Session,
attrs: &[ast::Attribute],
Expand All @@ -148,6 +152,7 @@ impl<'sess> AttributeParser<'sess> {
///
/// Try to use this as little as possible. Attributes *should* be lowered during
/// `rustc_ast_lowering`.
#[inline]
pub fn parse_limited_all(
sess: &'sess Session,
attrs: &[ast::Attribute],
Expand All @@ -160,6 +165,10 @@ impl<'sess> AttributeParser<'sess> {
attr_tools: Option<&'sess RegisteredTools>,
lint_tools: Option<&'sess RegisteredTools>,
) -> Vec<Attribute> {
if attrs.len() == 0 {
return vec![];
}

// Some attributes require access to features to parse.
// Therefore, if `parse_filter` is None, then features *must* be provided.
assert!(parse_filter.is_some() || features.is_some());
Expand All @@ -179,6 +188,7 @@ impl<'sess> AttributeParser<'sess> {

/// This method parses a single attribute, using `parse_fn`.
/// This is useful if you already know what exact attribute this is, and want to parse it.
#[inline]
pub fn parse_single<T>(
sess: &'sess Session,
attr: &ast::Attribute,
Expand Down Expand Up @@ -225,6 +235,7 @@ impl<'sess> AttributeParser<'sess> {

/// This method is equivalent to `parse_single`, but parses arguments using `parse_fn` using manually created `args`.
/// This is useful when you want to parse other things than attributes using attribute parsers.
#[inline]
pub fn parse_single_args<T, I>(
sess: &'sess Session,
attr_span: Span,
Expand Down
25 changes: 13 additions & 12 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2477,12 +2477,12 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
let mut r = Ok(());

let mut validate_and = |and: &And<TyCtxt<'_>, _>| {
for c in and.iter() {
for (c, span) in and.iter() {
match c {
LeafRegionConstraint::Ambiguity(_)
LeafRegionConstraint::Ambiguity
| LeafRegionConstraint::RegionOutlives(..)
| LeafRegionConstraint::AliasTyOutlivesViaEnv(..) => (), // OK
LeafRegionConstraint::PlaceholderTyOutlives(ty, _, span) => {
LeafRegionConstraint::PlaceholderTyOutlives(ty, _) => {
// we can't check this during lowering, because the ty is a ty::Bound that gets
// instantiated with a placeholder when entering the containing forall.
if let ty::Placeholder(_) | ty::Param(_) = ty.kind() {
Expand Down Expand Up @@ -2606,18 +2606,19 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
expected: &SolverRegionConstraint<'tcx>,
actual: &SolverRegionConstraint<'tcx>,
) {
let span_of_and =
|c: &And<_, _>| c.iter().map(|leaf| leaf.span()).reduce(|span: Span, acc| acc.to(span));
let span_of_and = |c: &And<_, _>| {
c.iter().map(|(_, span)| *span).reduce(|span: Span, acc: Span| acc.to(span))
};

let span_of_or = |c: &Or<_, _>| {
c.iter().flat_map(|and| span_of_and(and)).reduce(|span, acc| acc.to(span))
c.iter().flat_map(|and| span_of_and(and)).reduce(|span, acc: Span| acc.to(span))
};

let check_leaf_constraint =
|expected: &LeafRegionConstraint<_, _>, actual: &LeafRegionConstraint<_, _>| {
if let LeafRegionConstraint::AliasTyOutlivesViaEnv(expected, expected_span) =
expected
&& let LeafRegionConstraint::AliasTyOutlivesViaEnv(actual, actual_span) = actual
|(expected, expected_span): &(LeafRegionConstraint<_>, Span),
(actual, actual_span): &(LeafRegionConstraint<_>, Span)| {
if let LeafRegionConstraint::AliasTyOutlivesViaEnv(expected) = expected
&& let LeafRegionConstraint::AliasTyOutlivesViaEnv(actual) = actual
{
let expected_anon = self.tcx().anonymize_bound_vars(expected.clone());
let actual_anon = self.tcx().anonymize_bound_vars(actual.clone());
Expand All @@ -2627,10 +2628,10 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
Err((Some(*expected_span), Some(*actual_span)))
}
} else {
if expected.clone().without_span() == actual.clone().without_span() {
if expected == actual {
Ok(())
} else {
Err((Some(expected.span()), Some(actual.span())))
Err((Some(*expected_span), Some(*actual_span)))
}
}
};
Expand Down
23 changes: 14 additions & 9 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,10 @@ impl<'tcx> ItemCtxt<'tcx> {
let span = lhs.ident.span.to(rhs.ident.span);
let lhs = self.lowerer().lower_lifetime(lhs, RegionInferReason::RegionPredicate);
let rhs = self.lowerer().lower_lifetime(rhs, RegionInferReason::RegionPredicate);
SolverRegionConstraint::new_leaf(LeafRegionConstraint::RegionOutlives(
lhs, rhs, span,
))
SolverRegionConstraint::new_leaf(
LeafRegionConstraint::RegionOutlives(lhs, rhs),
span,
)
}
hir::TestBinderConstraint::PlaceholderOutlives { lhs, rhs } => {
let span = lhs.span.to(rhs.ident.span);
Expand All @@ -480,9 +481,10 @@ impl<'tcx> ItemCtxt<'tcx> {
// note that we cannot check that lhs is a placeholder at this moment, as at this
// point it is a bound variable that is not yet instantiated with a placeholder.
// instead, we check it when we emit the region constraint.
SolverRegionConstraint::new_leaf(LeafRegionConstraint::PlaceholderTyOutlives(
lhs, rhs, span,
))
SolverRegionConstraint::new_leaf(
LeafRegionConstraint::PlaceholderTyOutlives(lhs, rhs),
span,
)
}
hir::TestBinderConstraint::AliasOutlives {
bound_type_constraint:
Expand All @@ -494,10 +496,13 @@ impl<'tcx> ItemCtxt<'tcx> {
return SolverRegionConstraint::new_true();
};
let rhs = self.lowerer().lower_lifetime(rhs, RegionInferReason::RegionPredicate);
SolverRegionConstraint::new_leaf(LeafRegionConstraint::AliasTyOutlivesViaEnv(
ty::Binder::bind_with_vars((lhs, rhs), bound_vars),
SolverRegionConstraint::new_leaf(
LeafRegionConstraint::AliasTyOutlivesViaEnv(ty::Binder::bind_with_vars(
(lhs, rhs),
bound_vars,
)),
*span,
))
)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ impl<'tcx> InferCtxt<'tcx> {

if constraint.is_false() {
match failing_leafs.first() {
Some(PlaceholderTyOutlives(_a, _b, span)) => {
Some((PlaceholderTyOutlives(_a, _b), span)) => {
self.dcx()
.struct_span_err(
*span,
"unable to satisfy constraints because it cannot be proven",
)
.emit();
}
Some(AliasTyOutlivesViaEnv(_, span)) => {
Some((AliasTyOutlivesViaEnv(_), span)) => {
self.dcx()
.struct_span_err(
*span,
Expand All @@ -303,22 +303,22 @@ impl<'tcx> InferCtxt<'tcx> {
}

// FIXME(-Zassumptions-on-binders): actually implement OR as an OR
for c in constraint.and_constraint.into_iter().chain(
for (c, span) in constraint.and_constraint.into_iter().chain(
constraint
.or_constraint
.into_iter()
.flat_map(|and_constraint| and_constraint.into_iter()),
) {
match c {
Ambiguity(span) => {
Ambiguity => {
self.dcx()
.struct_span_err(
span,
"unable to satisfy constraints involving placeholders due to unknown implied bounds",
)
.emit();
}
RegionOutlives(a, b, span) => {
RegionOutlives(a, b) => {
let origin = SubregionOrigin::SolverRegionConstraint(span);
let category = origin.to_constraint_category();
conversion.push_sub_region_constraint(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/interpret/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'tcx> TyCtxt<'tcx> {
let args = GenericArgs::identity_for_item(self, def_id);
let instance = ty::Instance::new_raw(def_id, args);
let cid = GlobalId { instance, promoted: None };
let typing_env = ty::TypingEnv::post_analysis(self, def_id);
let typing_env = ty::TypingEnv::post_analysis_no_rigid_aliases(self, def_id);
self.const_eval_global_id(typing_env, cid, DUMMY_SP)
}

Expand All @@ -40,7 +40,7 @@ impl<'tcx> TyCtxt<'tcx> {
let args = GenericArgs::identity_for_item(self, def_id);
let instance = ty::Instance::new_raw(def_id, args);
let cid = GlobalId { instance, promoted: None };
let typing_env = ty::TypingEnv::post_analysis(self, def_id);
let typing_env = ty::TypingEnv::post_analysis_no_rigid_aliases(self, def_id);
let inputs = self.erase_and_anonymize_regions(typing_env.as_query_input(cid));
self.eval_to_allocation_raw(inputs)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ impl<'tcx> Body<'tcx> {
)
}
MirPhase::Analysis(AnalysisPhase::PostCleanup) | MirPhase::Runtime(_) => {
TypingEnv::post_analysis(tcx, self.source.def_id())
TypingEnv::post_analysis_no_rigid_aliases(tcx, self.source.def_id())
}
}
} else {
Expand All @@ -438,7 +438,7 @@ impl<'tcx> Body<'tcx> {
ty::TypingMode::non_body_analysis(),
),
MirPhase::Analysis(AnalysisPhase::PostCleanup) | MirPhase::Runtime(_) => {
TypingEnv::post_analysis(tcx, self.source.def_id())
TypingEnv::post_analysis_no_rigid_aliases(tcx, self.source.def_id())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ impl<'tcx> AdtDef<'tcx> {
let repr_type = self.repr().discr_type();
match tcx.const_eval_poly(expr_did) {
Ok(val) => {
let typing_env = ty::TypingEnv::post_analysis(tcx, expr_did);
let typing_env = ty::TypingEnv::post_analysis_no_rigid_aliases(tcx, expr_did);
let ty = repr_type.to_ty(tcx);
if let Some(b) = val.try_to_bits_for_ty(tcx, typing_env, ty) {
trace!("discriminants: {} ({:?})", b, repr_type);
Expand Down
25 changes: 22 additions & 3 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,8 +1249,8 @@ impl<'tcx> rustc_type_ir::inherent::TypingEnv<TyCtxt<'tcx>> for TypingEnv<'tcx>
.size
}

fn post_analysis(tcx: TyCtxt<'tcx>, def_id: DefId) -> TypingEnv<'tcx> {
Self::post_analysis(tcx, def_id)
fn post_analysis_no_rigid_aliases(tcx: TyCtxt<'tcx>, def_id: DefId) -> TypingEnv<'tcx> {
Self::post_analysis_no_rigid_aliases(tcx, def_id)
}
}

Expand Down Expand Up @@ -1311,10 +1311,29 @@ impl<'tcx> TypingEnv<'tcx> {
}
}

pub fn post_analysis(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryKey<DefId>) -> TypingEnv<'tcx> {
/// Use this when you don't have types/consts from an earlier typing env.
/// See [`Self::with_post_analysis_normalized_invalidating_rigid_aliases`].
pub fn post_analysis_no_rigid_aliases(
tcx: TyCtxt<'tcx>,
def_id: impl IntoQueryKey<DefId>,
) -> TypingEnv<'tcx> {
TypingEnv::new(tcx.param_env_normalized_for_post_analysis(def_id), TypingMode::PostAnalysis)
}

/// Use this when you have types/consts from an earlier typing env.
/// See [`Self::with_post_analysis_normalized_invalidating_rigid_aliases`].
pub fn post_analysis_invalidating_rigid_aliases<T>(
tcx: TyCtxt<'tcx>,
def_id: impl IntoQueryKey<DefId>,
value: T,
) -> PseudoCanonicalInput<'tcx, Unnormalized<'tcx, T>>
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
let typing_env = TypingEnv::post_analysis_no_rigid_aliases(tcx, def_id);
typing_env.as_query_input(ty::set_aliases_to_non_rigid(tcx, value))
}

pub fn codegen(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryKey<DefId>) -> TypingEnv<'tcx> {
TypingEnv::new(tcx.param_env_normalized_for_post_analysis(def_id), TypingMode::Codegen)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/inline/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub(crate) fn mir_callgraph_cyclic<'tcx>(
// into the call graph, we're probably not going to find any useful MIR inlining.
let recursion_limit = tcx.recursion_limit() / 8;
let mut involved = FxHashSet::default();
let typing_env = ty::TypingEnv::post_analysis(tcx, root);
let typing_env = ty::TypingEnv::post_analysis_no_rigid_aliases(tcx, root);
let root_instance =
ty::Instance::new_raw(root.to_def_id(), ty::GenericArgs::identity_for_item(tcx, root));
if !should_recurse(tcx, root_instance) {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_mir_transform/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ pub(crate) fn check_liveness<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Den
.iterate_to_fixpoint(tcx, body, None)
.into_results_cursor(body);

let typing_env = ty::TypingEnv::post_analysis(tcx, body.source.def_id());
// FIXME: We could use the rigid alias invalidating variant here, since
// we reset rigidness later, but doing so caused a perf regression.
let typing_env = ty::TypingEnv::post_analysis_no_rigid_aliases(tcx, body.source.def_id());

let mut assignments =
AssignmentResult::find_dead_assignments(tcx, typing_env, &checked_places, &mut live, body);
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_mir_transform/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, shim: ty::ShimKind<'tcx>) -> Body<'tcx> {
return body;
}

build_drop_shim(tcx, def_id, ty, ty::TypingEnv::post_analysis(tcx, def_id))
let ty::PseudoCanonicalInput { typing_env, value: ty } =
ty::TypingEnv::post_analysis_invalidating_rigid_aliases(tcx, def_id, ty);
// We intentionally don't normalize ty here. Any generic parameters it mentions
// belong to the caller, not to drop_glue, so typing_env cannot normalize its
// aliases. The caller normalizes the shim body in its own env instead.
build_drop_shim(tcx, def_id, ty.skip_normalization(), typing_env)
}
ty::ShimKind::ThreadLocal(..) => build_thread_local_shim(tcx, shim),
ty::ShimKind::Clone(def_id, ty) => build_clone_shim(tcx, def_id, ty),
Expand Down Expand Up @@ -1011,7 +1016,7 @@ fn build_call_shim<'tcx>(
pub(super) fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
debug_assert!(tcx.is_constructor(ctor_id));

let typing_env = ty::TypingEnv::post_analysis(tcx, ctor_id);
let typing_env = ty::TypingEnv::post_analysis_no_rigid_aliases(tcx, ctor_id);

// Normalize the sig.
let sig = tcx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ where
// To prevent this we discard all the generic arguments and evalaute with identity args
// and in its own environment instead of the current environment we are normalizing in.
let args = GenericArgs::identity_for_item(cx, def_id.into());
let typing_env = TypingEnv::post_analysis(cx, def_id.into());
let typing_env = TypingEnv::post_analysis_no_rigid_aliases(cx, def_id.into());

Ok((typing_env, args))
}
Expand Down
Loading
Loading