-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Tweak DefPathData
#139662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak DefPathData
#139662
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,9 +271,8 @@ pub enum DefPathData { | |
Use, | ||
/// A global asm item. | ||
GlobalAsm, | ||
/// Something in the type namespace. Will be empty for RPITIT associated | ||
/// types, which are given a synthetic name later, if necessary. | ||
TypeNs(Option<Symbol>), | ||
/// Something in the type namespace. | ||
TypeNs(Symbol), | ||
/// Something in the value namespace. | ||
ValueNs(Symbol), | ||
/// Something in the macro namespace. | ||
|
@@ -291,6 +290,8 @@ pub enum DefPathData { | |
/// An existential `impl Trait` type node. | ||
/// Argument position `impl Trait` have a `TypeNs` with their pretty-printed name. | ||
OpaqueTy, | ||
/// An anonymous associated type from an RPITIT. | ||
AnonAssocTy, | ||
/// A synthetic body for a coroutine's by-move body. | ||
SyntheticCoroutineBody, | ||
} | ||
|
@@ -413,9 +414,7 @@ impl DefPathData { | |
pub fn get_opt_name(&self) -> Option<Symbol> { | ||
use self::DefPathData::*; | ||
match *self { | ||
TypeNs(name) => name, | ||
|
||
ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name), | ||
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name), | ||
|
||
Impl | ||
| ForeignMod | ||
|
@@ -426,21 +425,17 @@ impl DefPathData { | |
| Ctor | ||
| AnonConst | ||
| OpaqueTy | ||
| AnonAssocTy | ||
| SyntheticCoroutineBody => None, | ||
} | ||
} | ||
|
||
pub fn name(&self) -> DefPathDataName { | ||
use self::DefPathData::*; | ||
match *self { | ||
TypeNs(name) => { | ||
if let Some(name) = name { | ||
DefPathDataName::Named(name) | ||
} else { | ||
DefPathDataName::Anon { namespace: sym::synthetic } | ||
} | ||
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => { | ||
DefPathDataName::Named(name) | ||
} | ||
ValueNs(name) | MacroNs(name) | LifetimeNs(name) => DefPathDataName::Named(name), | ||
// Note that this does not show up in user print-outs. | ||
CrateRoot => DefPathDataName::Anon { namespace: kw::Crate }, | ||
Impl => DefPathDataName::Anon { namespace: kw::Impl }, | ||
|
@@ -451,6 +446,7 @@ impl DefPathData { | |
Ctor => DefPathDataName::Anon { namespace: sym::constructor }, | ||
AnonConst => DefPathDataName::Anon { namespace: sym::constant }, | ||
OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque }, | ||
AnonAssocTy => DefPathDataName::Anon { namespace: sym::anon_assoc }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% certain about the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a huge fan of the name, but not enough to try to think of a new name. Ideally we wouldn't render this at all in diagnostics, but special casing all diagnostics that render paths would be difficult b/c we'd need to work out an alternative to rendering the path of the anonymous GAT. |
||
SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic }, | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's a matter of taste, but I find the following more compact and as readable,feel free to ignore:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the
if
statement