Make `feature(effects)` require `-Znext-solver`

This commit is contained in:
Deadbeef 2024-06-30 17:08:10 +00:00
parent 6c3485512f
commit 34ae56de35
6 changed files with 40 additions and 0 deletions

View File

@ -120,6 +120,10 @@ hir_analysis_drop_impl_reservation = reservation `Drop` impls are not supported
hir_analysis_duplicate_precise_capture = cannot capture parameter `{$name}` twice hir_analysis_duplicate_precise_capture = cannot capture parameter `{$name}` twice
.label = parameter captured again here .label = parameter captured again here
hir_analysis_effects_without_next_solver = using `#![feature(effects)]` without enabling next trait solver globally
.note = the next trait solver must be enabled globally for the effects feature to work correctly
.help = use `-Znext-solver` to enable
hir_analysis_empty_specialization = specialization impl does not specialize any associated items hir_analysis_empty_specialization = specialization impl does not specialize any associated items
.note = impl is a specialization of this impl .note = impl is a specialization of this impl

View File

@ -1699,3 +1699,9 @@ pub struct InvalidReceiverTy<'tcx> {
pub span: Span, pub span: Span,
pub receiver_ty: Ty<'tcx>, pub receiver_ty: Ty<'tcx>,
} }
#[derive(Diagnostic)]
#[diag(hir_analysis_effects_without_next_solver)]
#[note]
#[help]
pub struct EffectsWithoutNextSolver;

View File

@ -151,6 +151,12 @@ pub fn provide(providers: &mut Providers) {
pub fn check_crate(tcx: TyCtxt<'_>) { pub fn check_crate(tcx: TyCtxt<'_>) {
let _prof_timer = tcx.sess.timer("type_check_crate"); let _prof_timer = tcx.sess.timer("type_check_crate");
// FIXME(effects): remove once effects is implemented in old trait solver
// or if the next solver is stabilized.
if tcx.features().effects && !tcx.next_trait_solver_globally() {
tcx.dcx().emit_err(errors::EffectsWithoutNextSolver);
}
tcx.sess.time("coherence_checking", || { tcx.sess.time("coherence_checking", || {
tcx.hir().par_for_each_module(|module| { tcx.hir().par_for_each_module(|module| {
let _ = tcx.ensure().check_mod_type_wf(module); let _ = tcx.ensure().check_mod_type_wf(module);

View File

@ -0,0 +1,7 @@
error: using `#![feature(effects)]` without enabling next trait solver globally
|
= note: the next trait solver must be enabled globally for the effects feature to work correctly
= help: use `-Znext-solver` to enable
error: aborting due to 1 previous error

View File

@ -0,0 +1,10 @@
// test that we error correctly when effects is used without the next-solver flag.
//@ revisions: stock coherence full
//@[coherence] compile-flags: -Znext-solver=coherence
//@[full] compile-flags: -Znext-solver
//@[full] check-pass
#![feature(effects)]
#![allow(incomplete_features)]
fn main() {}

View File

@ -0,0 +1,7 @@
error: using `#![feature(effects)]` without enabling next trait solver globally
|
= note: the next trait solver must be enabled globally for the effects feature to work correctly
= help: use `-Znext-solver` to enable
error: aborting due to 1 previous error