]> git.lizzy.rs Git - rust.git/blob - tests/ui/range/issue-54505.rs
Rollup merge of #103800 - danielhenrymantilla:stabilize-pin-macro, r=dtolnay
[rust.git] / tests / ui / range / issue-54505.rs
1 // run-rustfix
2
3 // Regression test for #54505 - range borrowing suggestion had
4 // incorrect syntax (missing parentheses).
5
6 use std::ops::RangeBounds;
7
8
9 // take a reference to any built-in range
10 fn take_range(_r: &impl RangeBounds<i8>) {}
11
12
13 fn main() {
14     take_range(0..1);
15     //~^ ERROR mismatched types [E0308]
16     //~| HELP consider borrowing here
17     //~| SUGGESTION &(0..1)
18
19     take_range(1..);
20     //~^ ERROR mismatched types [E0308]
21     //~| HELP consider borrowing here
22     //~| SUGGESTION &(1..)
23
24     take_range(..);
25     //~^ ERROR mismatched types [E0308]
26     //~| HELP consider borrowing here
27     //~| SUGGESTION &(..)
28
29     take_range(0..=1);
30     //~^ ERROR mismatched types [E0308]
31     //~| HELP consider borrowing here
32     //~| SUGGESTION &(0..=1)
33
34     take_range(..5);
35     //~^ ERROR mismatched types [E0308]
36     //~| HELP consider borrowing here
37     //~| SUGGESTION &(..5)
38
39     take_range(..=42);
40     //~^ ERROR mismatched types [E0308]
41     //~| HELP consider borrowing here
42     //~| SUGGESTION &(..=42)
43 }