1
Fork 0

Don't repeat AssertParamIs{Clone,Eq} assertions.

It's common to see repeated assertions like this in derived `clone` and
`eq` methods:
```
let _: ::core::clone::AssertParamIsClone<u32>;
let _: ::core::clone::AssertParamIsClone<u32>;
```
This commit avoids them.
This commit is contained in:
Nicholas Nethercote 2022-07-01 16:32:20 +10:00
parent 5762d2385e
commit a7b1d31a9f
4 changed files with 43 additions and 29 deletions

View file

@ -2036,6 +2036,14 @@ impl TyKind {
pub fn is_unit(&self) -> bool {
matches!(self, TyKind::Tup(tys) if tys.is_empty())
}
pub fn is_simple_path(&self) -> Option<Symbol> {
if let TyKind::Path(None, Path { segments, .. }) = &self && segments.len() == 1 {
Some(segments[0].ident.name)
} else {
None
}
}
}
/// Syntax used to declare a trait object.