]> git.lizzy.rs Git - rust.git/blob - src/test/ui/range/issue-54505-no-std.rs
Rollup merge of #105843 - compiler-errors:sugg-const, r=lcnr
[rust.git] / src / test / ui / range / issue-54505-no-std.rs
1 // Regression test for #54505 - range borrowing suggestion had
2 // incorrect syntax (missing parentheses).
3
4 // This test doesn't use std
5 // (so all Ranges resolve to core::ops::Range...)
6
7 #![no_std]
8 #![feature(lang_items)]
9
10 use core::ops::RangeBounds;
11
12 #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
13 #[lang = "eh_personality"]
14 extern "C" fn eh_personality() {}
15 #[cfg(target_os = "emscripten")]
16 #[lang = "eh_catch_typeinfo"]
17 static EH_CATCH_TYPEINFO: u8 = 0;
18
19 #[panic_handler]
20 fn panic_handler() {}
21 //~^ ERROR return type should be `!`
22 //~| ERROR function should have one argument
23
24 // take a reference to any built-in range
25 fn take_range(_r: &impl RangeBounds<i8>) {}
26
27
28 fn main() {
29     take_range(0..1);
30     //~^ ERROR mismatched types [E0308]
31     //~| HELP consider borrowing here
32     //~| SUGGESTION &(0..1)
33
34     take_range(1..);
35     //~^ ERROR mismatched types [E0308]
36     //~| HELP consider borrowing here
37     //~| SUGGESTION &(1..)
38
39     take_range(..);
40     //~^ ERROR mismatched types [E0308]
41     //~| HELP consider borrowing here
42     //~| SUGGESTION &(..)
43
44     take_range(0..=1);
45     //~^ ERROR mismatched types [E0308]
46     //~| HELP consider borrowing here
47     //~| SUGGESTION &(0..=1)
48
49     take_range(..5);
50     //~^ ERROR mismatched types [E0308]
51     //~| HELP consider borrowing here
52     //~| SUGGESTION &(..5)
53
54     take_range(..=42);
55     //~^ ERROR mismatched types [E0308]
56     //~| HELP consider borrowing here
57     //~| SUGGESTION &(..=42)
58 }