Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0d0aaa1
Some arena macro tweaks.
nnethercote Apr 20, 2026
cdefdd0
Fix a metadata table name.
nnethercote Apr 22, 2026
3b5dd18
Fix some comments.
nnethercote Apr 24, 2026
e283cb3
remove param_env from HasTypingEnv
jdonszelmann May 1, 2026
feee5f6
use the right typing mode for each mir phase
jdonszelmann May 1, 2026
ab63680
use the right typing mode in lints
jdonszelmann May 4, 2026
3c83d3a
llvm: Use correct type for splat mask
maurer May 5, 2026
411a932
ImproperCTypes: merge outer_ty information into VisitorState
niacdoial Sep 10, 2025
6839797
ImproperCTypes: Use more `Unnormalized` type wrappers
niacdoial Apr 24, 2026
803c7ba
Some fold/visit tweaks.
nnethercote Apr 24, 2026
da70164
move drop bomb from OpaqueTypeStorage into InferCtxt's Drop
jdonszelmann May 5, 2026
814fc17
Deny warnings in rustc crates on stable
jdonszelmann Apr 29, 2026
0afe083
Avoid some global `node_id_to_def_id` lookups in import resolution
oli-obk May 5, 2026
191cda5
Avoid using `id` followed by `local_def_id` if we can just call `def_…
oli-obk May 5, 2026
400240a
Avoid hitting the global node_id_to_def_id table for unused macros
oli-obk May 5, 2026
a082567
Follow-up cleanups reusing the now-available `LocalDefId`s
oli-obk May 5, 2026
b8e547a
fix warnings in rustc_type_ir
jdonszelmann Apr 29, 2026
1982734
Rollup merge of #146273 - niacdoial:improperctypes-refactor2, r=petro…
JonathanBrouwer May 6, 2026
9a85287
Rollup merge of #156173 - oli-obk:fewer-global-lookups, r=petrochenkov
JonathanBrouwer May 6, 2026
6d0b841
Rollup merge of #155961 - jdonszelmann:deny-warnings-stable, r=mejrs
JonathanBrouwer May 6, 2026
51cfe21
Rollup merge of #156130 - nnethercote:fold-visit-tweaks, r=WaffleLapkin
JonathanBrouwer May 6, 2026
ca6f18a
Rollup merge of #156131 - nnethercote:rm-unnecessary-decode, r=Zalathar
JonathanBrouwer May 6, 2026
4f4138a
Rollup merge of #156141 - jdonszelmann:use-right-typingmode, r=lcnr
JonathanBrouwer May 6, 2026
ca8b4bf
Rollup merge of #156202 - maurer:splat, r=nikic
JonathanBrouwer May 6, 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
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
}

if name == sym::simd_splat {
let (_out_len, out_ty) = require_simd!(ret_ty, SimdReturn);
let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn);

require!(
args[0].layout.ty == out_ty,
Expand All @@ -2105,7 +2105,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(

// `shufflevector <N x elem> v0, <N x elem> poison, <N x i32> zeroinitializer`
// The masks is all zeros, so this splats lane 0 (which has our element in it).
let splat = bx.shuffle_vector(v0, poison_vec, bx.const_null(llret_ty));
let mask_ty = bx.type_vector(bx.type_i32(), out_len);
let splat = bx.shuffle_vector(v0, poison_vec, bx.const_null(mask_ty));

return Ok(splat);
}
Expand Down
17 changes: 9 additions & 8 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_errors::ErrorGuaranteed;
use rustc_hir::LangItem;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::mir::*;
use rustc_middle::ty::{self, AdtDef, Ty};
use rustc_middle::ty::{self, AdtDef, Ty, TypingMode};
use rustc_middle::{bug, mir};
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
use tracing::instrument;
Expand Down Expand Up @@ -100,13 +100,14 @@ impl Qualif for HasMutInterior {
// Instead we invoke an obligation context manually, and provide the opaque type inference settings
// that allow the trait solver to just error out instead of cycling.
let freeze_def_id = cx.tcx.require_lang_item(LangItem::Freeze, cx.body.span);
// FIXME(#132279): Once we've got a typing mode which reveals opaque types using the HIR
// typeck results without causing query cycles, we should use this here instead of defining
// opaque types.
let typing_env = ty::TypingEnv::new(
cx.typing_env.param_env,
ty::TypingMode::analysis_in_body(cx.tcx, cx.body.source.def_id().expect_local()),
);
let did = cx.body.source.def_id().expect_local();

let typing_env = if cx.tcx.use_typing_mode_borrowck() {
cx.typing_env
} else {
ty::TypingEnv::new(cx.typing_env.param_env, TypingMode::analysis_in_body(cx.tcx, did))
};

let (infcx, param_env) = cx.tcx.infer_ctxt().build_with_typing_env(typing_env);
let ocx = ObligationCtxt::new(&infcx);
let obligation = Obligation::new(
Expand Down
27 changes: 27 additions & 0 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,33 @@ pub struct InferCtxt<'tcx> {
pub obligation_inspector: Cell<Option<ObligationInspector<'tcx>>>,
}

impl<'tcx> Drop for InferCtxt<'tcx> {
fn drop(&mut self) {
let mut inner = self.inner.borrow_mut();
let opaque_type_storage = &mut inner.opaque_type_storage;

// No need for the drop bomb when we're in TypingMode::Borrowck, and the InferCtxt doesn't consider regions.
// This is okay since in `Borrowck`, the only reason we care about opaques is in relation to regions.
// In some places *after* typeck, like in lints we use `TypingMode::Borrowck`
// to prevent defining opaque types and we simply don't care about regions.
match self.typing_mode() {
TypingMode::Coherence
| TypingMode::Analysis { .. }
| TypingMode::PostBorrowckAnalysis { .. }
| TypingMode::PostAnalysis => {}
TypingMode::Borrowck { .. } => {
if !self.considering_regions {
return;
}
}
}

if !opaque_type_storage.is_empty() {
ty::tls::with(|tcx| tcx.dcx().delayed_bug(format!("{opaque_type_storage:?}")));
}
}
}

/// See the `error_reporting` module for more details.
#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable, TypeVisitable)]
pub enum ValuePairs<'tcx> {
Expand Down
10 changes: 1 addition & 9 deletions compiler/rustc_infer/src/infer/opaque_types/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::Deref;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::bug;
use rustc_middle::ty::{self, OpaqueTypeKey, ProvisionalHiddenType, Ty};
use rustc_middle::ty::{OpaqueTypeKey, ProvisionalHiddenType, Ty};
use tracing::instrument;

use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog};
Expand Down Expand Up @@ -121,14 +121,6 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
}
}

impl<'tcx> Drop for OpaqueTypeStorage<'tcx> {
fn drop(&mut self) {
if !self.is_empty() {
ty::tls::with(|tcx| tcx.dcx().delayed_bug(format!("{:?}", self.opaque_types)));
}
}
}

pub struct OpaqueTypeTable<'a, 'tcx> {
storage: &'a mut OpaqueTypeStorage<'tcx>,

Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,14 @@ impl<'tcx> LateContext<'tcx> {
/// The typing mode of the currently visited node. Use this when
/// building a new `InferCtxt`.
pub fn typing_mode(&self) -> TypingMode<'tcx> {
// FIXME(#132279): In case we're in a body, we should use a typing
// mode which reveals the opaque types defined by that body.
TypingMode::non_body_analysis()
if let Some(body_id) = self.enclosing_body
&& self.tcx.use_typing_mode_borrowck()
{
let def_id = self.tcx.hir_enclosing_body_owner(body_id.hir_id);
TypingMode::borrowck(self.tcx, def_id)
} else {
TypingMode::non_body_analysis()
}
}

pub fn typing_env(&self) -> TypingEnv<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
}

let def_id = opaque.def_id.to_def_id();
let infcx = &cx.tcx.infer_ctxt().build(cx.typing_mode());
let infcx = &cx.tcx.infer_ctxt().ignoring_regions().build(cx.typing_mode());
// For every projection predicate in the opaque type's explicit bounds,
// check that the type that we're assigning actually satisfies the bounds
// of the associated type.
Expand Down
Loading
Loading