diff options
| author | bors <bors@rust-lang.org> | 2022-07-08 12:44:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-08 12:44:14 +0000 |
| commit | fbdb07f4e7f4666085aec4b1ed2fd05817dc42cf (patch) | |
| tree | 30cf3d42b6fd9da4a7e83598c4b72ee6ab2b6734 /compiler/rustc_ast/src | |
| parent | 1dcff2d5077244f49687ea25070958f23bd9edc6 (diff) | |
| parent | 0da063c9916fc3ce1330ac14e28ea7bca002ac89 (diff) | |
| download | rust-fbdb07f4e7f4666085aec4b1ed2fd05817dc42cf.tar.gz rust-fbdb07f4e7f4666085aec4b1ed2fd05817dc42cf.zip | |
Auto merge of #98758 - nnethercote:more-derive-output-improvements, r=Mark-Simulacrum
More derive output improvements This PR includes: - Some test improvements. - Some cosmetic changes to derive output that make the code look more like what a human would write. - Some more fundamental improvements to `cmp` and `partial_cmp` generation. r? `@Mark-Simulacrum`
Diffstat (limited to 'compiler/rustc_ast/src')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 2820d5e6e0c..f705d004422 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<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. |
