@@ -1211,8 +1211,22 @@ impl Ty {
1211
1211
}
1212
1212
}
1213
1213
1214
- pub fn parse_method_return ( ty : Type < ' _ > , context : & Context < ' _ > ) -> Self {
1215
- let ty = Inner :: parse ( ty, Lifetime :: Unspecified , context) ;
1214
+ pub fn parse_method_return ( ty : Type < ' _ > , default_nonnull : bool , context : & Context < ' _ > ) -> Self {
1215
+ let mut ty = Inner :: parse ( ty, Lifetime :: Unspecified , context) ;
1216
+
1217
+ // As in `parse_property_return`, the nullability is not guaranteed by
1218
+ // the method, and can also fail in OOM situations, but that is
1219
+ // handled by `#[method_id(...)]`
1220
+ if default_nonnull {
1221
+ match & mut ty {
1222
+ Inner :: Id { nullability, .. } => {
1223
+ if * nullability == Nullability :: Unspecified {
1224
+ * nullability = Nullability :: NonNull ;
1225
+ }
1226
+ }
1227
+ _ => warn ! ( ?ty, "`default_nonnull` which is not an object" ) ,
1228
+ }
1229
+ }
1216
1230
1217
1231
ty. visit_lifetime ( |lifetime| {
1218
1232
if lifetime != Lifetime :: Unspecified {
@@ -1233,7 +1247,7 @@ impl Ty {
1233
1247
}
1234
1248
1235
1249
pub fn parse_function_return ( ty : Type < ' _ > , context : & Context < ' _ > ) -> Self {
1236
- let mut this = Self :: parse_method_return ( ty, context) ;
1250
+ let mut this = Self :: parse_method_return ( ty, false , context) ;
1237
1251
this. kind = TyKind :: FnReturn ;
1238
1252
this
1239
1253
}
0 commit comments