1
Fork 0

typeck: port "no resolve overridden impl substs"

Port "could not resolve substs on overridden impl" diagnostic to use the
diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-05-07 08:14:48 +01:00
parent 664733efd5
commit 47582471c6
3 changed files with 11 additions and 1 deletions

View file

@ -127,3 +127,5 @@ typeck-manual-implementation =
manual implementations of `{$trait_name}` are experimental
.label = manual implementations of `{$trait_name}` are experimental
.help = add `#![feature(unboxed_closures)]` to the crate attributes to enable
typeck-substs-on-overridden-impl = could not resolve substs on overridden impl

View file

@ -323,3 +323,10 @@ pub struct ManualImplementation {
pub span: Span,
pub trait_name: String,
}
#[derive(SessionDiagnostic)]
#[error(slug = "typeck-substs-on-overridden-impl")]
pub struct SubstsOnOverriddenImpl {
#[primary_span]
pub span: Span,
}

View file

@ -66,6 +66,7 @@
//! on traits with methods can.
use crate::constrained_generic_params as cgp;
use crate::errors::SubstsOnOverriddenImpl;
use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def_id::{DefId, LocalDefId};
@ -165,7 +166,7 @@ fn get_impl_substs<'tcx>(
let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty());
infcx.resolve_regions_and_report_errors(impl1_def_id, &outlives_env, RegionckMode::default());
let Ok(impl2_substs) = infcx.fully_resolve(impl2_substs) else {
tcx.sess.struct_span_err(span, "could not resolve substs on overridden impl").emit();
tcx.sess.emit_err(SubstsOnOverriddenImpl { span });
return None;
};
Some((impl1_substs, impl2_substs))