-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add def path data variant #104648
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
Closed
Closed
Add def path data variant #104648
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
876f129
Create def_id for async fns during lowering
spastorino c4dd9a2
Introduce DefPathData::ImplTraitInTrait
spastorino b30be8f
Remove impl_trait_in_trait_parent
spastorino fecf098
Remove Target::ImplTraitPlaceholder
spastorino 7d53d47
Remove DefKind::ImplTraitPlaceholder
spastorino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ | |
//! expressions) that are mostly just leftovers. | ||
|
||
pub use crate::def_id::DefPathHash; | ||
use crate::def_id::{CrateNum, DefIndex, LocalDefId, StableCrateId, CRATE_DEF_INDEX, LOCAL_CRATE}; | ||
use crate::def_id::{ | ||
CrateNum, DefId, DefIndex, LocalDefId, StableCrateId, CRATE_DEF_INDEX, LOCAL_CRATE, | ||
}; | ||
use crate::def_path_hash_map::DefPathHashMap; | ||
|
||
use rustc_data_structures::fx::FxHashMap; | ||
|
@@ -245,6 +247,17 @@ impl DefPath { | |
|
||
s | ||
} | ||
|
||
pub fn get_impl_trait_in_trait_data(&self) -> Option<(DefId, Option<DefId>)> { | ||
if let Some(def_path_data) = self.data.last() | ||
&& let DefPathData::ImplTraitInTrait(fn_def_id, of_trait) = | ||
def_path_data.data | ||
{ | ||
Some((fn_def_id, of_trait)) | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] | ||
|
@@ -281,6 +294,10 @@ pub enum DefPathData { | |
AnonConst, | ||
/// An `impl Trait` type node. | ||
ImplTrait, | ||
/// An `impl Trait` type node inside a `trait` or inside an `impl` of a `trait`. | ||
/// On a `trait` the value is `(trait_fn_def_id, None)`. | ||
/// On an `impl` the value is `(impl_fn_def_id, Some(trait_rpit_def_id))`. | ||
ImplTraitInTrait(DefId, Option<DefId>), | ||
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. This may cause issues with incremental compilation. |
||
} | ||
|
||
impl Definitions { | ||
|
@@ -404,7 +421,7 @@ impl DefPathData { | |
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name), | ||
|
||
Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst | ||
| ImplTrait => None, | ||
| ImplTrait | ImplTraitInTrait(..) => None, | ||
} | ||
} | ||
|
||
|
@@ -424,6 +441,7 @@ impl DefPathData { | |
Ctor => DefPathDataName::Anon { namespace: sym::constructor }, | ||
AnonConst => DefPathDataName::Anon { namespace: sym::constant }, | ||
ImplTrait => DefPathDataName::Anon { namespace: sym::opaque }, | ||
ImplTraitInTrait(..) => DefPathDataName::Anon { namespace: sym::opaque }, | ||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can this be implemented by walking
self.parent
until we find aValueNs
? As forof_trait
I haven't seen it used anywhere, could it be computed fromfn_def_id
?