From 74d1bd21c78765712612afdd5eab3efa00757064 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Thu, 3 Jun 2021 19:52:01 +0200 Subject: Use more precise span for E0282 in cast expressions --- src/test/ui/cast/issue-85586.rs | 10 ++++++++++ src/test/ui/cast/issue-85586.stderr | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/test/ui/cast/issue-85586.rs create mode 100644 src/test/ui/cast/issue-85586.stderr (limited to 'src') diff --git a/src/test/ui/cast/issue-85586.rs b/src/test/ui/cast/issue-85586.rs new file mode 100644 index 00000000000..78816582b57 --- /dev/null +++ b/src/test/ui/cast/issue-85586.rs @@ -0,0 +1,10 @@ +// Check that errors for unresolved types in cast expressions are reported +// for the offending subexpression, not the whole cast expression. + +#![allow(unused_variables)] + +fn main() { + let a = [1, 2, 3].iter().sum(); + let b = (a + 1) as usize; + //~^ ERROR: type annotations needed [E0282] +} diff --git a/src/test/ui/cast/issue-85586.stderr b/src/test/ui/cast/issue-85586.stderr new file mode 100644 index 00000000000..271885a133a --- /dev/null +++ b/src/test/ui/cast/issue-85586.stderr @@ -0,0 +1,11 @@ +error[E0282]: type annotations needed + --> $DIR/issue-85586.rs:8:13 + | +LL | let b = (a + 1) as usize; + | ^^^^^^^ cannot infer type + | + = note: type must be known at this point + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. -- cgit 1.4.1-3-g733a5