-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Cleanup ty decoder #27851
Merged
Merged
Cleanup ty decoder #27851
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8a6118b
move InlinedItem into librustc, where it belongs
nikomatsakis c9bb5a6
convert tydecode to use a closure for def-id conversion and
nikomatsakis 2a53744
convert tydecode to use an impl, eliminating a lot of boilerplate
nikomatsakis 70e2df5
tydecode: tighten privacy
nikomatsakis 38e6b57
s/PState/TyDecoder/
nikomatsakis b09cf12
astencode: convert code to use TyDecoder directly
nikomatsakis 7a3a1be
remove the last remnants of old interface
nikomatsakis 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use syntax::ast; | ||
use syntax::ast_util::{IdRange, IdRangeComputingVisitor, | ||
IdVisitor, IdVisitingOperation}; | ||
use syntax::ptr::P; | ||
use syntax::visit::Visitor; | ||
use self::InlinedItem::*; | ||
|
||
/// The data we save and restore about an inlined item or method. This is not | ||
/// part of the AST that we parse from a file, but it becomes part of the tree | ||
/// that we trans. | ||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] | ||
pub enum InlinedItem { | ||
Item(P<ast::Item>), | ||
TraitItem(ast::DefId /* impl id */, P<ast::TraitItem>), | ||
ImplItem(ast::DefId /* impl id */, P<ast::ImplItem>), | ||
Foreign(P<ast::ForeignItem>), | ||
} | ||
|
||
/// A borrowed version of `ast::InlinedItem`. | ||
pub enum InlinedItemRef<'a> { | ||
Item(&'a ast::Item), | ||
TraitItem(ast::DefId, &'a ast::TraitItem), | ||
ImplItem(ast::DefId, &'a ast::ImplItem), | ||
Foreign(&'a ast::ForeignItem) | ||
} | ||
|
||
impl InlinedItem { | ||
pub fn visit<'ast,V>(&'ast self, visitor: &mut V) | ||
where V: Visitor<'ast> | ||
{ | ||
match *self { | ||
Item(ref i) => visitor.visit_item(&**i), | ||
Foreign(ref i) => visitor.visit_foreign_item(&**i), | ||
TraitItem(_, ref ti) => visitor.visit_trait_item(ti), | ||
ImplItem(_, ref ii) => visitor.visit_impl_item(ii), | ||
} | ||
} | ||
|
||
pub fn visit_ids<O: IdVisitingOperation>(&self, operation: &mut O) { | ||
let mut id_visitor = IdVisitor { | ||
operation: operation, | ||
pass_through_items: true, | ||
visited_outermost: false, | ||
}; | ||
self.visit(&mut id_visitor); | ||
} | ||
|
||
pub fn compute_id_range(&self) -> IdRange { | ||
let mut visitor = IdRangeComputingVisitor::new(); | ||
self.visit_ids(&mut visitor); | ||
visitor.result() | ||
} | ||
} | ||
|
This file contains 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 |
---|---|---|
|
@@ -19,3 +19,4 @@ pub mod csearch; | |
pub mod loader; | ||
pub mod filesearch; | ||
pub mod macro_import; | ||
pub mod inline; |
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.
Couldn't this be created by a method on
cdata
, providing the translation function toTyDecoder
?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.
@eddyb hmm perhaps -- it's a bit tricky to get lifetime of the closure to work out I think, but I guess now that the closure is stored in a struct, we could give ownership of it instead of passing an
&mut
. Would be kind of nicer anyway. Maybe I should do that.