(&self, ty: TypeId)
| 309 | } |
| 310 | |
| 311 | fn modes_of(&self, ty: TypeId) -> Vec<(String, TypeMode)> { |
| 312 | let info = self.info(ty); |
| 313 | // Info only populated for types that are passed to and from functions. For |
| 314 | // types which are not, default to the ownership setting. |
| 315 | if !info.owned && !info.borrowed { |
| 316 | return vec![( |
| 317 | self.param_name(ty), |
| 318 | match self.ownership() { |
| 319 | Ownership::Owning => TypeMode::Owned, |
| 320 | Ownership::Borrowing { .. } => TypeMode::AllBorrowed("'a"), |
| 321 | }, |
| 322 | )]; |
| 323 | } |
| 324 | let mut result = Vec::new(); |
| 325 | let first_mode = |
| 326 | if info.owned || !info.borrowed || matches!(self.ownership(), Ownership::Owning) { |
| 327 | TypeMode::Owned |
| 328 | } else { |
| 329 | assert!(!self.uses_two_names(&info)); |
| 330 | TypeMode::AllBorrowed("'a") |
| 331 | }; |
| 332 | result.push((self.result_name(ty), first_mode)); |
| 333 | if self.uses_two_names(&info) { |
| 334 | result.push((self.param_name(ty), TypeMode::AllBorrowed("'a"))); |
| 335 | } |
| 336 | result |
| 337 | } |
| 338 | |
| 339 | fn param_name(&self, ty: TypeId) -> String { |
| 340 | let info = self.info(ty); |
no test coverage detected