1
- use culpa:: { throw, try_ } ;
1
+ use culpa:: { throw, try_fn } ;
2
2
3
3
type Error = isize ;
4
4
5
- #[ try_ ]
5
+ #[ try_fn ]
6
6
pub fn unit_fn ( ) -> Result < ( ) , Error > { }
7
7
8
- #[ try_ ]
8
+ #[ try_fn ]
9
9
pub fn returns_fn ( ) -> Result < i32 , Error > {
10
10
return 0 ;
11
11
}
12
12
13
- #[ try_ ]
13
+ #[ try_fn ]
14
14
pub fn returns_unit_fn ( ) -> Result < ( ) , Error > {
15
15
if true {
16
16
return ;
17
17
}
18
18
}
19
19
20
- #[ try_ ]
20
+ #[ try_fn ]
21
21
pub fn tail_returns_value ( ) -> Result < i32 , Error > {
22
22
0
23
23
}
24
24
25
- #[ try_ ]
25
+ #[ try_fn ]
26
26
pub async fn async_fn ( ) -> Result < ( ) , Error > { }
27
27
28
- #[ try_ ]
28
+ #[ try_fn ]
29
29
pub async fn async_fn_with_ret ( ) -> Result < i32 , Error > {
30
30
0
31
31
}
32
32
33
- #[ try_ ]
33
+ #[ try_fn ]
34
34
pub fn throws_error ( ) -> Result < ( ) , i32 > {
35
35
if true {
36
36
throw ! ( 0 ) ;
37
37
}
38
38
}
39
39
40
- #[ try_ ]
40
+ #[ try_fn ]
41
41
pub fn throws_and_has_return_type ( ) -> Result < & ' static str , i32 > {
42
42
if true {
43
43
return "success" ;
@@ -47,16 +47,16 @@ pub fn throws_and_has_return_type() -> Result<&'static str, i32> {
47
47
"okay"
48
48
}
49
49
50
- #[ try_ ]
50
+ #[ try_fn ]
51
51
pub fn throws_generics < E > ( ) -> Result < ( ) , E > { }
52
52
53
53
pub struct Foo ;
54
54
55
55
impl Foo {
56
- #[ try_ ]
56
+ #[ try_fn ]
57
57
pub fn static_method ( ) -> Result < ( ) , Error > { }
58
58
59
- #[ try_ ]
59
+ #[ try_fn ]
60
60
pub fn bar ( & self ) -> Result < i32 , Error > {
61
61
if true {
62
62
return 1 ;
@@ -65,88 +65,88 @@ impl Foo {
65
65
}
66
66
}
67
67
68
- #[ try_ ]
68
+ #[ try_fn ]
69
69
pub fn has_inner_fn ( ) -> Result < ( ) , Error > {
70
70
fn inner_fn ( ) -> i32 {
71
71
0
72
72
}
73
73
let _: i32 = inner_fn ( ) ;
74
74
}
75
75
76
- #[ try_ ]
76
+ #[ try_fn ]
77
77
pub fn has_inner_closure ( ) -> Result < ( ) , Error > {
78
78
let f = || 0 ;
79
79
let _: i32 = f ( ) ;
80
80
}
81
81
82
- #[ try_ ]
82
+ #[ try_fn ]
83
83
pub async fn has_inner_async_block ( ) -> Result < ( ) , Error > {
84
84
let f = async { 0 } ;
85
85
let _: i32 = f. await ;
86
86
}
87
87
88
- #[ try_ ]
88
+ #[ try_fn ]
89
89
pub fn throws_as_result ( ) -> Result < i32 , Error > {
90
90
0
91
91
}
92
92
93
- #[ try_ ]
93
+ #[ try_fn ]
94
94
pub fn throws_as_result_alias ( ) -> std:: io:: Result < i32 > {
95
95
0
96
96
}
97
97
98
- #[ try_ ]
98
+ #[ try_fn ]
99
99
pub fn ommitted_error ( ) -> Result < ( ) , Error > { }
100
100
101
101
pub mod foo {
102
- use culpa:: { throw, try_ } ;
102
+ use culpa:: { throw, try_fn } ;
103
103
104
104
pub type Error = i32 ;
105
105
106
- #[ try_ ]
106
+ #[ try_fn ]
107
107
pub fn throws_integer ( ) -> Result < ( ) , i32 > {
108
108
throw ! ( 0 ) ;
109
109
}
110
110
}
111
111
112
112
pub mod foo_trait_obj {
113
- use culpa:: try_ ;
113
+ use culpa:: try_fn ;
114
114
pub trait FooTrait { }
115
115
116
116
struct FooStruct ;
117
117
118
118
pub struct FooError ;
119
119
impl FooTrait for FooStruct { }
120
120
121
- #[ try_ ]
121
+ #[ try_fn ]
122
122
pub fn foo ( ) -> Result < Box < dyn FooTrait > , FooError > {
123
123
Box :: new ( FooStruct )
124
124
}
125
125
}
126
126
127
- #[ try_ ]
127
+ #[ try_fn ]
128
128
pub fn let_else ( a : Option < u8 > ) -> Result < u8 , Error > {
129
129
let Some ( a) = a else {
130
130
return 0 ;
131
131
} ;
132
132
a
133
133
}
134
134
135
- #[ try_ ]
135
+ #[ try_fn ]
136
136
pub fn impl_trait ( ) -> Result < impl std:: fmt:: Debug , Error > { }
137
137
138
- #[ try_ ]
138
+ #[ try_fn ]
139
139
#[ deny( unreachable_code) ]
140
140
pub fn unreachable ( ) -> Result < ( ) , i32 > {
141
141
todo ! ( )
142
142
}
143
143
144
144
trait Example {
145
- #[ try_ ]
145
+ #[ try_fn ]
146
146
fn foo ( ) -> Result < i32 , Error > ;
147
147
}
148
148
149
- #[ try_ ]
149
+ #[ try_fn ]
150
150
fn as_option ( x : bool ) -> Option < i32 > {
151
151
if x {
152
152
throw ! ( ) ;
0 commit comments