Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a851949
Rename parameters of `Extend` trait to be more consistent with common…
steffahn Aug 19, 2026
db9ab1a
Rename parameters of `FromIterator` as well
steffahn Aug 19, 2026
81698d2
Preserve normalized alias rigidity in borrowck
Dnreikronos Aug 28, 2026
a7b87de
remove unused `perform_locally_with_next_solver`
adwinwhite Aug 29, 2026
ac73a90
Reuse HIR-normalized types in MIR build
Dnreikronos Aug 29, 2026
dad53fd
Clarify when alias rigidity remains valid
Dnreikronos Aug 29, 2026
44febdf
Emit delayed bug instead of ICEing when `TypeOutlives` goal fails
ShoyuVanilla Aug 30, 2026
9bca736
More consistent use of variable names for trait implementations
steffahn Aug 19, 2026
27f7c65
Remove dead `LLVMOpaquePass`/`LLVMPassRef` decls
nnethercote Aug 31, 2026
1d73758
Make the LLVM version mismatch ICE a fatal error
saethlin Aug 31, 2026
969c1cf
Remove unnecessary `Twine`/`SMDiagnostic` typedefs
nnethercote Aug 31, 2026
f12defb
_ an unused parameter
jnkel Aug 31, 2026
7f0cd46
libcore: expose volatile atomic operations
RalfJung Aug 18, 2026
84eb2cf
Rollup merge of #161301 - RalfJung:volatile-atomic-pub, r=Mark-Simula…
jhpratt Aug 31, 2026
99e83a5
Rollup merge of #161379 - steffahn:extend_trait_param_name, r=JohnTitor
jhpratt Aug 31, 2026
141d9b7
Rollup merge of #161926 - Dnreikronos:borrowck/restore_alias_rigidity…
jhpratt Aug 31, 2026
6d74441
Rollup merge of #161956 - adwinwhite:remove-next-solver-typeop, r=khy…
jhpratt Aug 31, 2026
85eaa63
Rollup merge of #162026 - ShoyuVanilla:issue-161527, r=adwinwhite
jhpratt Aug 31, 2026
51f306c
Rollup merge of #162034 - saethlin:llvm-version-mismatch-error, r=nne…
jhpratt Aug 31, 2026
b243662
Rollup merge of #162037 - nnethercote:llvm-wrapper-cleanups, r=Zalathar
jhpratt Aug 31, 2026
5a41279
Rollup merge of #162043 - jnkel:wasi-dll-path-unused-parameter, r=nne…
jhpratt Aug 31, 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
39 changes: 13 additions & 26 deletions compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@ use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::IndexVec;
use rustc_infer::infer::{NllRegionVariableOrigin, TyCtxtInferExt};
use rustc_infer::traits::ObligationCause;
use rustc_infer::infer::NllRegionVariableOrigin;
use rustc_macros::extension;
use rustc_middle::mir::RETURN_PLACE;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{
self, BoundVariableKind, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts,
List, RegionExt, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingMode,
fold_regions,
List, RegionExt, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, fold_regions,
};
use rustc_middle::{bug, span_bug};
use rustc_span::{ErrorGuaranteed, kw, sym};
use rustc_trait_selection::traits::ObligationCtxt;
use tracing::{debug, instrument};

use crate::BorrowckInferCtxt;
Expand Down Expand Up @@ -136,32 +133,22 @@ pub(crate) enum DefiningTy<'tcx> {
GlobalAsm(DefId),
}

fn normalized_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
let ty = tcx.type_of(def_id).instantiate_identity();
if !tcx.next_trait_solver_globally() {
return ty.skip_normalization();
}

let typing_mode = if tcx.use_typing_mode_post_typeck_until_borrowck() {
TypingMode::borrowck(tcx, def_id)
} else {
TypingMode::analysis_in_body(tcx, def_id)
};
let infcx = tcx.infer_ctxt().build(typing_mode);
let ocx = ObligationCtxt::new(&infcx);
let span = tcx.def_span(def_id);
let cause = ObligationCause::misc(span, def_id);
ocx.deeply_normalize(&cause, tcx.param_env(def_id), ty).unwrap()
}

impl<'tcx> DefiningTy<'tcx> {
#[instrument(level = "debug", skip(tcx), ret)]
pub(crate) fn new(tcx: TyCtxt<'tcx>, body_def_id: LocalDefId) -> DefiningTy<'tcx> {
match tcx.hir_body_owner_kind(body_def_id) {
BodyOwnerKind::Closure | BodyOwnerKind::Fn => {
// Normalize after instantiation so coroutine yield/resume
// types in the args are rigid under the next solver.
let defining_ty = normalized_type_of(tcx, body_def_id);
let defining_ty =
tcx.type_of(body_def_id).instantiate_identity().skip_normalization();
let defining_ty = if tcx.next_trait_solver_globally() {
// Closure types come from HIR typeck results, where they were already
// normalized during writeback. Wrapping them in an `EarlyBinder`
// conservatively makes aliases non-rigid, so restore their rigidness
// instead of normalizing them again during borrowck.
ty::set_aliases_to_rigid(tcx, defining_ty)
} else {
defining_ty
};
match *defining_ty.kind() {
ty::Closure(def_id, args) => DefiningTy::Closure(def_id, args),
ty::Coroutine(def_id, args) => DefiningTy::Coroutine(def_id, args),
Expand Down
14 changes: 13 additions & 1 deletion compiler/rustc_codegen_llvm/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ffi::CString;
use std::ffi::{CString, c_uint};
use std::path::Path;

use rustc_data_structures::small_c_str::SmallCStr;
Expand Down Expand Up @@ -265,3 +265,15 @@ pub(crate) struct IntrinsicWrongArch<'a> {
pub(crate) struct UnknownLlvmTargetFeaturePrefix<'a> {
pub feature: &'a str,
}

#[derive(Diagnostic)]
#[diag(
"LLVM version mismatch: this compiler was built for LLVM {$expected_version}, but LLVM {$llvm_major}.{$llvm_minor}.{$llvm_patch} was found{$dll_loc}"
)]
pub(crate) struct LlvmVersionMismatch<'a> {
pub expected_version: c_uint,
pub llvm_major: c_uint,
pub llvm_minor: c_uint,
pub llvm_patch: c_uint,
pub dll_loc: &'a str,
}
13 changes: 5 additions & 8 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,17 @@ unsafe fn configure_llvm(sess: &Session) {
llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch);
let expected_version = llvm::LLVMRustVersionMajor();
if llvm_major != expected_version {
panic!(
concat!(
"LLVM version mismatch: this compiler was built for LLVM {}, ",
"but LLVM {}.{}.{} was found{}"
),
sess.dcx().emit_fatal(diagnostics::LlvmVersionMismatch {
expected_version,
llvm_major,
llvm_minor,
llvm_patch,
match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _) {
dll_loc: &match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _)
{
Ok(path) => format!(" at {}", path.display()),
Err(_) => String::new(),
}
);
},
})
}
}

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ extern "C" void LLVMRustSetLastError(const char *);
enum class LLVMRustResult { Success, Failure };

typedef struct OpaqueRustString *RustStringRef;
typedef struct LLVMOpaqueTwine *LLVMTwineRef;
typedef struct LLVMOpaqueSMDiagnostic *LLVMSMDiagnosticRef;

extern "C" void LLVMRustStringWriteImpl(RustStringRef buf,
const char *slice_ptr,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ using namespace llvm;

static codegen::RegisterCodeGenFlags CGF;

typedef struct LLVMOpaquePass *LLVMPassRef;
typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef;

DEFINE_STDCXX_CONVERSION_FUNCTIONS(Pass, LLVMPassRef)
DEFINE_STDCXX_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef)

extern "C" void LLVMRustTimeTraceProfilerInitialize() {
Expand Down
20 changes: 8 additions & 12 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,11 +1199,9 @@ extern "C" void LLVMRustWriteValueToString(LLVMValueRef V, RustStringRef Str) {
}
}

DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Twine, LLVMTwineRef)

extern "C" void LLVMRustWriteTwineToString(LLVMTwineRef T, RustStringRef Str) {
extern "C" void LLVMRustWriteTwineToString(const Twine *T, RustStringRef Str) {
auto OS = RawRustStringOstream(Str);
unwrap(T)->print(OS);
T->print(OS);
}

extern "C" void LLVMRustUnpackOptimizationDiagnostic(
Expand Down Expand Up @@ -1239,13 +1237,13 @@ enum class LLVMRustDiagnosticLevel {

extern "C" void LLVMRustUnpackInlineAsmDiagnostic(
LLVMDiagnosticInfoRef DI, LLVMRustDiagnosticLevel *LevelOut,
uint64_t *CookieOut, LLVMTwineRef *MessageOut) {
uint64_t *CookieOut, const Twine **MessageOut) {
// Undefined to call this not on an inline assembly diagnostic!
llvm::DiagnosticInfoInlineAsm *IA =
static_cast<llvm::DiagnosticInfoInlineAsm *>(unwrap(DI));

*CookieOut = IA->getLocCookie();
*MessageOut = wrap(&IA->getMsgStr());
*MessageOut = &IA->getMsgStr();

switch (IA->getSeverity()) {
case DS_Error:
Expand Down Expand Up @@ -1334,22 +1332,20 @@ LLVMRustGetDiagInfoKind(LLVMDiagnosticInfoRef DI) {
return toRust((DiagnosticKind)unwrap(DI)->getKind());
}

DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SMDiagnostic, LLVMSMDiagnosticRef)

extern "C" LLVMSMDiagnosticRef LLVMRustGetSMDiagnostic(LLVMDiagnosticInfoRef DI,
extern "C" const SMDiagnostic *LLVMRustGetSMDiagnostic(LLVMDiagnosticInfoRef DI,
uint64_t *Cookie) {
llvm::DiagnosticInfoSrcMgr *SM =
static_cast<llvm::DiagnosticInfoSrcMgr *>(unwrap(DI));
*Cookie = SM->getLocCookie();
return wrap(&SM->getSMDiag());
return &SM->getSMDiag();
}

extern "C" bool
LLVMRustUnpackSMDiagnostic(LLVMSMDiagnosticRef DRef, RustStringRef MessageOut,
LLVMRustUnpackSMDiagnostic(const SMDiagnostic *DRef, RustStringRef MessageOut,
RustStringRef BufferOut,
LLVMRustDiagnosticLevel *LevelOut, unsigned *LocOut,
unsigned *RangesOut, size_t *NumRanges) {
SMDiagnostic &D = *unwrap(DRef);
const SMDiagnostic &D = *DRef;
auto MessageOS = RawRustStringOstream(MessageOut);
MessageOS << D.getMessage();

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_macros/src/diagnostics/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[
"Cargo",
"Ferris",
"GCC",
"LLVM",
"MIR",
"NaNs",
"OK",
Expand Down
26 changes: 11 additions & 15 deletions compiler/rustc_mir_build/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ use rustc_hir::{self as hir, BindingMode, ByRef, HirId, ItemLocalId, Node, find_
use rustc_index::bit_set::GrowableBitSet;
use rustc_index::{Idx, IndexSlice, IndexVec};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::ObligationCause;
use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
use rustc_middle::middle::region;
use rustc_middle::mir::*;
use rustc_middle::thir::{self, ExprId, LocalVarId, Param, ParamId, PatKind, Thir};
use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt, TypeVisitableExt, TypingMode};
use rustc_middle::{bug, span_bug};
use rustc_span::{Span, Symbol};
use rustc_trait_selection::traits::ObligationCtxt;

use crate::builder::expr::as_place::PlaceBuilder;
use crate::builder::scope::LintLevel;
Expand Down Expand Up @@ -508,7 +506,17 @@ fn construct_fn<'tcx>(

let infcx = tcx.infer_ctxt().build(typing_mode);

let coroutine = match normalized_type_of(&infcx, fn_def).kind() {
let defining_ty = tcx.type_of(fn_def).instantiate_identity().skip_normalization();
let defining_ty = if infcx.next_trait_solver() {
// Closure types come from HIR typeck results, where they were already
// normalized during writeback. Wrapping them in an `EarlyBinder`
// conservatively makes aliases non-rigid, so restore their rigidness
// instead of normalizing them again during MIR build.
ty::set_aliases_to_rigid(tcx, defining_ty)
} else {
defining_ty
};
let coroutine = match defining_ty.kind() {
ty::Coroutine(_, args) => Some(Box::new(CoroutineInfo::initial(
tcx.coroutine_kind(fn_def).unwrap(),
args.as_coroutine().yield_ty(),
Expand Down Expand Up @@ -566,18 +574,6 @@ fn construct_fn<'tcx>(
body
}

fn normalized_type_of<'tcx>(infcx: &InferCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
let tcx = infcx.tcx;
let ty = tcx.type_of(def_id).instantiate_identity();
if !infcx.next_trait_solver() {
return ty.skip_normalization();
}

let ocx = ObligationCtxt::new(infcx);
let cause = ObligationCause::misc(tcx.def_span(def_id), def_id);
ocx.deeply_normalize(&cause, tcx.param_env(def_id), ty).unwrap()
}

fn construct_const<'a, 'tcx>(
tcx: TyCtxt<'tcx>,
def: LocalDefId,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub unsafe fn dll_path(function: *mut std::ffi::c_void) -> Result<PathBuf, Strin
}

#[cfg(target_os = "wasi")]
pub unsafe fn dll_path(function: *mut std::ffi::c_void) -> Result<PathBuf, String> {
pub unsafe fn dll_path(_function: *mut std::ffi::c_void) -> Result<PathBuf, String> {
Err("dll_path is not supported on WASI".to_string())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
}

ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..))
if self.next_trait_solver() =>
{
// We normalize `TypeOutlives` in the next solver, which is fallible
return self.dcx().span_delayed_bug(
span,
"type outlives claues errored outside borrowck without any other error",
);
}
ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..))
| ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..)) => {
span_bug!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ impl<'tcx> QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
tcx.implied_outlives_bounds((canonicalized, false))
}

fn perform_locally_with_next_solver(
ocx: &ObligationCtxt<'_, 'tcx>,
key: ParamEnvAnd<'tcx, Self>,
_span: Span,
) -> Result<Self::QueryResponse, NoSolution> {
query_compute_implied_outlives_bounds(ocx, key.param_env, key.value.ty, false)
}
}

pub fn compute_implied_outlives_bounds_inner<'tcx>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
tcx.type_op_ascribe_user_type(canonicalized)
}

fn perform_locally_with_next_solver(
ocx: &ObligationCtxt<'_, 'tcx>,
key: ParamEnvAnd<'tcx, Self>,
span: Span,
) -> Result<Self::QueryResponse, NoSolution> {
type_op_ascribe_user_type_with_span(ocx, key, span)
}
}

/// The core of the `type_op_ascribe_user_type` query: for diagnostics purposes in NLL HRTB errors,
Expand Down
14 changes: 1 addition & 13 deletions compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::infer::canonical::{
QueryRegionConstraints,
};
use crate::infer::{InferCtxt, InferOk};
use crate::traits::{ObligationCause, ObligationCtxt};
use crate::traits::ObligationCause;

pub mod ascribe_user_type;
pub mod custom;
Expand Down Expand Up @@ -83,18 +83,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution>;

/// In the new trait solver, we already do caching in the solver itself,
/// so there's no need to canonicalize and cache via the query system.
/// Additionally, even if we were to canonicalize, we'd still need to
/// make sure to feed it predefined opaque types and the defining anchor
/// and that would require duplicating all of the tcx queries. Instead,
/// just perform these ops locally.
fn perform_locally_with_next_solver(
ocx: &ObligationCtxt<'_, 'tcx>,
key: ParamEnvAnd<'tcx, Self>,
span: Span,
) -> Result<Self::QueryResponse, NoSolution>;

fn fully_perform_into(
query_key: ParamEnvAnd<'tcx, Self>,
infcx: &InferCtxt<'tcx>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use std::fmt;

use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::NoSolution;
pub use rustc_middle::traits::query::type_op::Normalize;
use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
use rustc_span::Span;

use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
use crate::traits::ObligationCtxt;

impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<'tcx, T>
where
Expand All @@ -29,19 +26,6 @@ where
) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
T::type_op_method(tcx, canonicalized)
}

fn perform_locally_with_next_solver(
ocx: &ObligationCtxt<'_, 'tcx>,
key: ParamEnvAnd<'tcx, Self>,
span: Span,
) -> Result<Self::QueryResponse, NoSolution> {
ocx.deeply_normalize(
&ObligationCause::dummy_with_span(span),
key.param_env,
key.value.value,
)
.map_err(|_| NoSolution)
}
}

pub trait Normalizable<'tcx>:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution};
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
use rustc_span::Span;

use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
use crate::traits::ObligationCtxt;
use crate::traits::query::dropck_outlives::{
compute_dropck_outlives_inner, trivial_dropck_outlives,
};
use crate::traits::query::dropck_outlives::trivial_dropck_outlives;
use crate::traits::query::type_op::DropckOutlives;

impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
Expand All @@ -25,12 +21,4 @@ impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
tcx.dropck_outlives(canonicalized)
}

fn perform_locally_with_next_solver(
ocx: &ObligationCtxt<'_, 'tcx>,
key: ParamEnvAnd<'tcx, Self>,
span: Span,
) -> Result<Self::QueryResponse, NoSolution> {
compute_dropck_outlives_inner(ocx, key.param_env.and(key.value), span)
}
}
Loading
Loading