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