use the correct span when dealing with inference variables
This commit is contained in:
parent
0abb1abf04
commit
3dbfdb0182
9 changed files with 40 additions and 11 deletions
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/cannot-infer-const-args.rs:12:5
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^ cannot infer the value for const parameter `X` declared on the function `foo`
|
||||
| ^^^ cannot infer the value of const parameter `X` declared on the function `foo`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/cannot-infer-const-args.rs:12:5
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^ cannot infer the value for const parameter `X` declared on the function `foo`
|
||||
| ^^^ cannot infer the value of const parameter `X` declared on the function `foo`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
16
src/test/ui/const-generics/infer/issue-77092.rs
Normal file
16
src/test/ui/const-generics/infer/issue-77092.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#![feature(min_const_generics)]
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
fn take_array_from_mut<T, const N: usize>(data: &mut [T], start: usize) -> &mut [T; N] {
|
||||
(&mut data[start .. start + N]).try_into().unwrap()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut arr = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||
|
||||
for i in 1 .. 4 {
|
||||
println!("{:?}", take_array_from_mut(&mut arr, i));
|
||||
//~^ ERROR type annotations needed
|
||||
}
|
||||
}
|
||||
9
src/test/ui/const-generics/infer/issue-77092.stderr
Normal file
9
src/test/ui/const-generics/infer/issue-77092.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-77092.rs:13:26
|
||||
|
|
||||
LL | println!("{:?}", take_array_from_mut(&mut arr, i));
|
||||
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `{_: usize}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
||||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/method-chain.rs:21:33
|
||||
|
|
||||
LL | Foo.bar().bar().bar().bar().baz();
|
||||
| ^^^ cannot infer the value for const parameter `N` declared on the associated function `baz`
|
||||
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/method-chain.rs:21:33
|
||||
|
|
||||
LL | Foo.bar().bar().bar().bar().baz();
|
||||
| ^^^ cannot infer the value for const parameter `N` declared on the associated function `baz`
|
||||
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/uninferred-consts.rs:14:9
|
||||
|
|
||||
LL | Foo.foo();
|
||||
| ^^^ cannot infer the value for const parameter `N` declared on the associated function `foo`
|
||||
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `foo`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/uninferred-consts.rs:14:9
|
||||
|
|
||||
LL | Foo.foo();
|
||||
| ^^^ cannot infer the value for const parameter `N` declared on the associated function `foo`
|
||||
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `foo`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue