Rollup merge of #137206 - estebank:e0599-structured, r=jieyouxu
Make E0599 a structured error
This commit is contained in:
commit
a66ef2f40e
5 changed files with 25 additions and 18 deletions
|
@ -1417,6 +1417,15 @@ pub(crate) struct CrossCrateTraitsDefined {
|
|||
pub traits: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(hir_analysis_no_variant_named, code = E0599)]
|
||||
pub struct NoVariantNamed<'tcx> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub ident: Ident,
|
||||
pub ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
// FIXME(fmease): Deduplicate:
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
|
@ -53,7 +53,9 @@ use rustc_type_ir::Upcast;
|
|||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::check::check_abi_fn_ptr;
|
||||
use crate::errors::{AmbiguousLifetimeBound, BadReturnTypeNotation, InvalidBaseType};
|
||||
use crate::errors::{
|
||||
AmbiguousLifetimeBound, BadReturnTypeNotation, InvalidBaseType, NoVariantNamed,
|
||||
};
|
||||
use crate::hir_ty_lowering::errors::{GenericsArgsErrExtend, prohibit_assoc_item_constraint};
|
||||
use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args};
|
||||
use crate::middle::resolve_bound_vars as rbv;
|
||||
|
@ -1205,14 +1207,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
let msg = format!("expected type, found variant `{assoc_ident}`");
|
||||
self.dcx().span_err(span, msg)
|
||||
} else if qself_ty.is_enum() {
|
||||
let mut err = struct_span_code_err!(
|
||||
self.dcx(),
|
||||
assoc_ident.span,
|
||||
E0599,
|
||||
"no variant named `{}` found for enum `{}`",
|
||||
assoc_ident,
|
||||
qself_ty,
|
||||
);
|
||||
let mut err = self.dcx().create_err(NoVariantNamed {
|
||||
span: assoc_ident.span,
|
||||
ident: assoc_ident,
|
||||
ty: qself_ty,
|
||||
});
|
||||
|
||||
let adt_def = qself_ty.ty_adt_def().expect("enum is not an ADT");
|
||||
if let Some(variant_name) = find_best_match_for_name(
|
||||
|
|
|
@ -92,6 +92,7 @@ mod impl_wf_check;
|
|||
mod outlives;
|
||||
mod variance;
|
||||
|
||||
pub use errors::NoVariantNamed;
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue