Skip to content

Commit

Permalink
typeck: port "no resolve overridden impl substs"
Browse files Browse the repository at this point in the history
Port "could not resolve substs on overridden impl" diagnostic to use the
diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
  • Loading branch information
davidtwco committed May 12, 2022
1 parent 664733e commit 4758247
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/typeck.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions compiler/rustc_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 4758247

Please sign in to comment.