Skip to content

Commit 4758247

Browse files
committed
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 <[email protected]>
1 parent 664733e commit 4758247

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

compiler/rustc_error_messages/locales/en-US/typeck.ftl

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

compiler/rustc_typeck/src/errors.rs

+7
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,10 @@ pub struct ManualImplementation {
323323
pub span: Span,
324324
pub trait_name: String,
325325
}
326+
327+
#[derive(SessionDiagnostic)]
328+
#[error(slug = "typeck-substs-on-overridden-impl")]
329+
pub struct SubstsOnOverriddenImpl {
330+
#[primary_span]
331+
pub span: Span,
332+
}

compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
//! on traits with methods can.
6767
6868
use crate::constrained_generic_params as cgp;
69+
use crate::errors::SubstsOnOverriddenImpl;
6970

7071
use rustc_data_structures::fx::FxHashSet;
7172
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -165,7 +166,7 @@ fn get_impl_substs<'tcx>(
165166
let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty());
166167
infcx.resolve_regions_and_report_errors(impl1_def_id, &outlives_env, RegionckMode::default());
167168
let Ok(impl2_substs) = infcx.fully_resolve(impl2_substs) else {
168-
tcx.sess.struct_span_err(span, "could not resolve substs on overridden impl").emit();
169+
tcx.sess.emit_err(SubstsOnOverriddenImpl { span });
169170
return None;
170171
};
171172
Some((impl1_substs, impl2_substs))

0 commit comments

Comments
 (0)