From a7b1d31a9f358747221e8eb9986bb8303d5d6586 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 Jul 2022 16:32:20 +1000 Subject: 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; let _: ::core::clone::AssertParamIsClone; ``` This commit avoids them. --- compiler/rustc_ast/src/ast.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/rustc_ast/src') diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index e5b61d7000a..bb0b8121cac 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -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 { + 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. -- cgit 1.4.1-3-g733a5