Rollup merge of #110563 - bryangarza:refactor-trait-selection-error-reporting, r=compiler-errors
Break up long function in trait selection error reporting + clean up nearby code - Move blocks of code into their own functions - Replace a few function argument types with their type aliases - Create "AppendConstMessage" enum to replace a nested `Option`.
This commit is contained in:
commit
5f33a8c026
6 changed files with 680 additions and 441 deletions
|
@ -591,7 +591,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
fn evaluate_nested_obligations(
|
||||
&self,
|
||||
ty: Ty<'_>,
|
||||
nested: impl Iterator<Item = Obligation<'tcx, ty::Predicate<'tcx>>>,
|
||||
nested: impl Iterator<Item = PredicateObligation<'tcx>>,
|
||||
computed_preds: &mut FxIndexSet<ty::Predicate<'tcx>>,
|
||||
fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
|
||||
predicates: &mut VecDeque<ty::PolyTraitPredicate<'tcx>>,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -327,7 +327,7 @@ pub struct OnUnimplementedDirective {
|
|||
pub label: Option<OnUnimplementedFormatString>,
|
||||
pub note: Option<OnUnimplementedFormatString>,
|
||||
pub parent_label: Option<OnUnimplementedFormatString>,
|
||||
pub append_const_msg: Option<Option<Symbol>>,
|
||||
pub append_const_msg: Option<AppendConstMessage>,
|
||||
}
|
||||
|
||||
/// For the `#[rustc_on_unimplemented]` attribute
|
||||
|
@ -337,11 +337,21 @@ pub struct OnUnimplementedNote {
|
|||
pub label: Option<String>,
|
||||
pub note: Option<String>,
|
||||
pub parent_label: Option<String>,
|
||||
/// Append a message for `~const Trait` errors. `None` means not requested and
|
||||
/// should fallback to a generic message, `Some(None)` suggests using the default
|
||||
/// appended message, `Some(Some(s))` suggests use the `s` message instead of the
|
||||
/// default one..
|
||||
pub append_const_msg: Option<Option<Symbol>>,
|
||||
// If none, should fall back to a generic message
|
||||
pub append_const_msg: Option<AppendConstMessage>,
|
||||
}
|
||||
|
||||
/// Append a message for `~const Trait` errors.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub enum AppendConstMessage {
|
||||
Default,
|
||||
Custom(Symbol),
|
||||
}
|
||||
|
||||
impl Default for AppendConstMessage {
|
||||
fn default() -> Self {
|
||||
AppendConstMessage::Default
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> OnUnimplementedDirective {
|
||||
|
@ -419,10 +429,10 @@ impl<'tcx> OnUnimplementedDirective {
|
|||
}
|
||||
} else if item.has_name(sym::append_const_msg) && append_const_msg.is_none() {
|
||||
if let Some(msg) = item.value_str() {
|
||||
append_const_msg = Some(Some(msg));
|
||||
append_const_msg = Some(AppendConstMessage::Custom(msg));
|
||||
continue;
|
||||
} else if item.is_word() {
|
||||
append_const_msg = Some(None);
|
||||
append_const_msg = Some(AppendConstMessage::Default);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -386,7 +386,7 @@ pub trait TypeErrCtxtExt<'tcx> {
|
|||
fn maybe_suggest_convert_to_slice(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
candidate_impls: &[ImplCandidate<'tcx>],
|
||||
span: Span,
|
||||
);
|
||||
|
@ -3848,7 +3848,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
fn maybe_suggest_convert_to_slice(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
candidate_impls: &[ImplCandidate<'tcx>],
|
||||
span: Span,
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue