Make E0614 a structured error
``` error[E0614]: type `(..., ..., ..., ...)` cannot be dereferenced --> $DIR/long-E0614.rs:10:5 | LL | *x; | ^^ can't be dereferenced | = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt' = note: consider using `--verbose` to print the full type name to the console ```
This commit is contained in:
parent
ae3a825faa
commit
7302dc660b
13 changed files with 32 additions and 22 deletions
|
@ -28,6 +28,9 @@ hir_typeck_cannot_cast_to_bool = cannot cast `{$expr_ty}` as `bool`
|
|||
.help = compare with zero instead
|
||||
.label = unsupported cast
|
||||
|
||||
hir_typeck_cant_dereference = type `{$ty}` cannot be dereferenced
|
||||
hir_typeck_cant_dereference_label = can't be dereferenced
|
||||
|
||||
hir_typeck_cast_enum_drop = cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`
|
||||
|
||||
hir_typeck_cast_thin_pointer_to_wide_pointer = cannot cast thin pointer `{$expr_ty}` to wide pointer `{$cast_ty}`
|
||||
|
|
|
@ -454,6 +454,15 @@ impl HelpUseLatestEdition {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(hir_typeck_cant_dereference, code = E0614)]
|
||||
pub(crate) struct CantDereference<'tcx> {
|
||||
#[primary_span]
|
||||
#[label(hir_typeck_cant_dereference_label)]
|
||||
pub(crate) span: Span,
|
||||
pub(crate) ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(hir_typeck_expected_array_or_slice, code = E0529)]
|
||||
pub(crate) struct ExpectedArrayOrSlice<'tcx> {
|
||||
|
|
|
@ -45,9 +45,9 @@ use crate::coercion::{CoerceMany, DynamicCoerceMany};
|
|||
use crate::errors::{
|
||||
AddressOfTemporaryTaken, BaseExpressionDoubleDot, BaseExpressionDoubleDotAddExpr,
|
||||
BaseExpressionDoubleDotEnableDefaultFieldValues, BaseExpressionDoubleDotRemove,
|
||||
FieldMultiplySpecifiedInInitializer, FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition,
|
||||
ReturnLikeStatementKind, ReturnStmtOutsideOfFnBody, StructExprNonExhaustive,
|
||||
TypeMismatchFruTypo, YieldExprOutsideOfCoroutine,
|
||||
CantDereference, FieldMultiplySpecifiedInInitializer, FunctionalRecordUpdateOnNonStruct,
|
||||
HelpUseLatestEdition, ReturnLikeStatementKind, ReturnStmtOutsideOfFnBody,
|
||||
StructExprNonExhaustive, TypeMismatchFruTypo, YieldExprOutsideOfCoroutine,
|
||||
};
|
||||
use crate::{
|
||||
BreakableCtxt, CoroutineTypes, Diverges, FnCtxt, Needs, cast, fatally_break_rust,
|
||||
|
@ -607,13 +607,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if let Some(ty) = self.lookup_derefing(expr, oprnd, oprnd_t) {
|
||||
oprnd_t = ty;
|
||||
} else {
|
||||
let mut err = type_error_struct!(
|
||||
self.dcx(),
|
||||
expr.span,
|
||||
oprnd_t,
|
||||
E0614,
|
||||
"type `{oprnd_t}` cannot be dereferenced",
|
||||
);
|
||||
let mut err =
|
||||
self.dcx().create_err(CantDereference { span: expr.span, ty: oprnd_t });
|
||||
let sp = tcx.sess.source_map().start_point(expr.span).with_parent(None);
|
||||
if let Some(sp) =
|
||||
tcx.sess.psess.ambiguous_block_expr_parse.borrow().get(&sp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue