File tree Expand file tree Collapse file tree 1 file changed +6
-27
lines changed Expand file tree Collapse file tree 1 file changed +6
-27
lines changed Original file line number Diff line number Diff line change @@ -1420,45 +1420,24 @@ fn main() {
14201420"## ,
14211421
14221422E0102 : r##"
1423- You hit this error because the compiler lacks information to
1424- determine a type for this variable. Erroneous code example:
1423+ You hit this error because the compiler lacks the information to
1424+ determine the type of this variable. Erroneous code example:
14251425
14261426```compile_fail
1427- fn demo(devil: fn () -> !) {
1428- let x: &_ = devil();
1429- // error: cannot determine a type for this local variable
1430- }
1431-
1432- fn oh_no() -> ! { panic!("the devil is in the details") }
1433-
14341427fn main() {
1435- demo(oh_no);
1428+ // could be an array of anything
1429+ let x = []; // error: cannot determine a type for this local variable
14361430}
14371431```
14381432
14391433To solve this situation, constrain the type of the variable.
14401434Examples:
14411435
1442- ```no_run
1436+ ```
14431437#![allow(unused_variables)]
14441438
1445- fn some_func(x: &u32) {
1446- // some code
1447- }
1448-
1449- fn demo(devil: fn () -> !) {
1450- let x: &u32 = devil();
1451- // Here we defined the type at the variable creation
1452-
1453- let x: &_ = devil();
1454- some_func(x);
1455- // Here, the type is determined by the function argument type
1456- }
1457-
1458- fn oh_no() -> ! { panic!("the devil is in the details") }
1459-
14601439fn main() {
1461- demo(oh_no) ;
1440+ let x: [u8; 0] = [] ;
14621441}
14631442```
14641443"## ,
You can’t perform that action at this time.
0 commit comments