Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,17 @@ impl<'tcx> Body<'tcx> {
pub fn typing_env(&self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx> {
if tcx.use_typing_mode_post_typeck_until_borrowck() {
match self.phase {
MirPhase::Built if let Some(def_id) = self.source.def_id().as_local() => {
MirPhase::Built | MirPhase::Analysis(AnalysisPhase::Initial)
if let Some(def_id) = self.source.def_id().as_local() =>
{
TypingEnv::new(
tcx.param_env(self.source.def_id()),
ty::TypingMode::borrowck(tcx, def_id),
)
}
MirPhase::Analysis(_) if let Some(def_id) = self.source.def_id().as_local() => {
MirPhase::Analysis(AnalysisPhase::PostCleanup)
Comment thread
amirHdev marked this conversation as resolved.
if let Some(def_id) = self.source.def_id().as_local() =>
{
TypingEnv::new(
tcx.param_env(self.source.def_id()),
ty::TypingMode::post_borrowck_analysis(tcx, def_id),
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_mir_transform/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
// is annoying. It is harmless enough to just not validate anything
// in that case. We still check this after analysis as all opaque
// types have been revealed at this point.
if pred.has_opaque_types() {
if !self.tcx.next_trait_solver_globally() && pred.has_opaque_types() {
return true;
}

let (infcx, param_env) = self.tcx.infer_ctxt().build_with_typing_env(self.typing_env);
let (infcx, param_env) =
self.tcx.infer_ctxt().ignoring_regions().build_with_typing_env(self.typing_env);
let ocx = ObligationCtxt::new(&infcx);
ocx.register_obligation(Obligation::new(
self.tcx,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_ty_utils/src/common_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ fn is_trait_raw<'tcx>(
query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
item: LangItem,
) -> bool {
let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(query.typing_env);
let (infcx, param_env) =
tcx.infer_ctxt().ignoring_regions().build_with_typing_env(query.typing_env);
let trait_def_id = tcx.require_lang_item(item, DUMMY_SP);
traits::type_known_to_meet_bound_modulo_regions(&infcx, param_env, query.value, trait_def_id)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ revisions: old next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@[next] known-bug: trait-system-refactor-initiative#303
//@[next] check-pass
//@[old] failure-status: 101
//@[old] dont-check-compiler-stderr
//@[old] known-bug: #126680
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
//@ revisions: old next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@[next] known-bug: trait-system-refactor-initiative#303
//@[next] check-pass
//@[old] failure-status: 101
//@[old] dont-check-compiler-stderr
//@[old] known-bug: #131886
//@ compile-flags: -Zvalidate-mir
#![feature(type_alias_impl_trait)]

// This ICEd in MIR validation with the old solver. It's fixed by normalizing
// opaque types with the new solver. This should compile, but currently fails
// with a query cycle error.
// opaque types with the new solver. This should compile without a query cycle.

type Tait = impl Sized;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ revisions: old next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@[next] known-bug: trait-system-refactor-initiative#303
//@[next] check-pass
//@ compile-flags: -Zvalidate-mir
//@[old] check-pass

Expand Down
10 changes: 10 additions & 0 deletions tests/ui/type-alias-impl-trait/typing-env-before-borrowck.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ compile-flags: -Zvalidate-mir -Znext-solver=globally
//@ check-pass

struct Opaque<F: FnOnce()>(F, F::Output);

fn f() -> impl Sized {
Opaque(f, ());
}

fn main() {}
Loading