mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-17 06:26:55 +00:00
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
@ -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)
|
||||
|
@ -2,7 +2,7 @@ error[E0614]: type `{integer}` cannot be dereferenced
|
||||
--> $DIR/deref-non-pointer.rs:2:9
|
||||
|
|
||||
LL | match *1 {
|
||||
| ^^
|
||||
| ^^ can't be dereferenced
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -7,7 +7,7 @@ type C = (B, B, B, B);
|
||||
type D = (C, C, C, C);
|
||||
|
||||
fn foo(x: D) {
|
||||
*x; //~ ERROR type `(
|
||||
*x; //~ ERROR type `(...
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,8 +1,11 @@
|
||||
error[E0614]: type `((((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))))` cannot be dereferenced
|
||||
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
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0614]: type `u32` cannot be dereferenced
|
||||
--> $DIR/E0614.rs:3:5
|
||||
|
|
||||
LL | *y;
|
||||
| ^^
|
||||
| ^^ can't be dereferenced
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0614]: type `!` cannot be dereferenced
|
||||
--> $DIR/issue-17373.rs:2:5
|
||||
|
|
||||
LL | *return
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ can't be dereferenced
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0614]: type `Foo` cannot be dereferenced
|
||||
--> $DIR/issue-9814.rs:7:13
|
||||
|
|
||||
LL | let _ = *Foo::Bar(2);
|
||||
| ^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^ can't be dereferenced
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -133,7 +133,7 @@ error[E0614]: type `{integer}` cannot be dereferenced
|
||||
--> $DIR/expr-as-stmt.rs:25:11
|
||||
|
|
||||
LL | { 3 } * 3
|
||||
| ^^^
|
||||
| ^^^ can't be dereferenced
|
||||
|
|
||||
help: parentheses are required to parse this as an expression
|
||||
|
|
||||
|
@ -2,13 +2,13 @@ error[E0614]: type `{integer}` cannot be dereferenced
|
||||
--> $DIR/nested-binding-modes-ref.rs:4:5
|
||||
|
|
||||
LL | *is_val;
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ can't be dereferenced
|
||||
|
||||
error[E0614]: type `{integer}` cannot be dereferenced
|
||||
--> $DIR/nested-binding-modes-ref.rs:9:5
|
||||
|
|
||||
LL | *is_val;
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ can't be dereferenced
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0614]: type `!` cannot be dereferenced
|
||||
--> $DIR/expr_unary.rs:8:16
|
||||
|
|
||||
LL | let x: ! = * { return; };
|
||||
| ^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^ can't be dereferenced
|
||||
|
||||
error: unreachable expression
|
||||
--> $DIR/expr_unary.rs:8:16
|
||||
|
@ -50,7 +50,7 @@ error[E0614]: type `T` cannot be dereferenced
|
||||
--> $DIR/missing_trait_impl.rs:15:13
|
||||
|
|
||||
LL | let y = *x;
|
||||
| ^^
|
||||
| ^^ can't be dereferenced
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user