]> git.lizzy.rs Git - rust.git/blob - tests/ui/never_type/defaulted-never-note.rs
Rollup merge of #106446 - bzEq:fix-unwind-lsda, r=Amanieu
[rust.git] / tests / ui / never_type / defaulted-never-note.rs
1 // revisions: nofallback fallback
2 //[nofallback] run-pass
3 //[fallback] check-fail
4
5 // We need to opt into the `never_type_fallback` feature
6 // to trigger the requirement that this is testing.
7 #![cfg_attr(fallback, feature(never_type, never_type_fallback))]
8
9 #![allow(unused)]
10
11 trait Deserialize: Sized {
12     fn deserialize() -> Result<Self, String>;
13 }
14
15 impl Deserialize for () {
16     fn deserialize() -> Result<(), String> {
17         Ok(())
18     }
19 }
20
21 trait ImplementedForUnitButNotNever {}
22
23 impl ImplementedForUnitButNotNever for () {}
24
25 fn foo<T: ImplementedForUnitButNotNever>(_t: T) {}
26 //[fallback]~^ NOTE required by this bound in `foo`
27 //[fallback]~| NOTE required by a bound in `foo`
28 fn smeg() {
29     let _x = return;
30     foo(_x);
31     //[fallback]~^ ERROR the trait bound
32     //[fallback]~| NOTE the trait `ImplementedForUnitButNotNever` is not implemented
33     //[fallback]~| HELP trait `ImplementedForUnitButNotNever` is implemented for `()`
34     //[fallback]~| NOTE this error might have been caused
35     //[fallback]~| NOTE required by a bound introduced by this call
36     //[fallback]~| HELP did you intend
37 }
38
39 fn main() {
40     smeg();
41 }