Skip to content
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

Refactored ast_map and friends, mainly to have Paths without storing them. #12162

Merged
merged 1 commit into from Feb 14, 2014

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Feb 10, 2014

No description provided.

@alexcrichton
Copy link
Member

Could you also add rationale for why this was done and the direction it's going in? I'm mostly just curious, I'm not really sure what the impetus for this was.

@eddyb
Copy link
Member Author

eddyb commented Feb 11, 2014

I wanted to remove all the cloning associated with ast_map::Path, and I've found a pretty good way to retrieve paths without storing them (apart from the base paths of inlined items), by having "parent" NodeIds on each node, referring to its inner-most enclosing item/method node.

In the process of adapting the codebase to that model, I've come across the inefficient and deprecated methods on Session, related to the token interner, and I've ripped them out. It might be possible to split those changes into a separate commit, but they've become quite entangled.

@huonw
Copy link
Member

huonw commented Feb 11, 2014

In the process of adapting the codebase to that model, I've come across the inefficient and deprecated methods on Session, related to the token interner, and I've ripped them out. It might be possible to split those changes into a separate commit, but they've become quite entangled.

FWIW, it's much easier to review when things are not just a single monolithic 4500 line commit, so it's generally good practice to avoid the temptation to do too many things at once (which I'm not very good at either...). In any case, a longer commit message describing what's changing and why (so that it's possible to deduce it from the git history/git blame) is something that should be possible now.

@alexcrichton
Copy link
Member

by having "parent" NodeIds on each node, referring to its inner-most enclosing item/method node

This seems like a fairly large change to the code base, and I just wanna make sure that you've talked it over with others first (it's certainly fine if you have already).

@nikomatsakis
Copy link
Contributor

cc me (I want to read over)

@nikomatsakis
Copy link
Contributor

I've been skimming at a high-level. This mostly makes sense, I think, but I'm not a fan of the <PI:PathIter> that is littered everywhere -- it's verbose and will generate a lot of monomorphized instances. Though perhaps that is precisely the point of this patch, to avoid the overhead of collecting.

Anyway, my biggest concern is that I fear the interaction with #12158 -- in particular, lazy iterators often cause borrow checker conflicts, since their closures claim the data they touch for the entirety of the iteration.

This means that if you have foo.iter().filter(|| expr1).map(|| expr2) and so on, expr1 and expr2 cannot mutate the same state etc. Anyway, I'm not sure if there'll be a negative interaction or not -- we'll have to see. Quite possibly it'll be fine since path iteration is mostly touching the ast_map, which is (I think) stored in a a RefCell and hence sharable.

But i'd request that PR #12158 land first, since I think closing up soundness holes takes higher precedence and I have no desire to undo work this PR does.

@eddyb
Copy link
Member Author

eddyb commented Feb 12, 2014

PathIter includes Clone, to reduce vebosity (I originally had Iterator<PathElem> + Clone in a few bounds), so iter::Map wouldn't even work.
We can remove monomorphization completely by using FullPathIter (a chained vector value iterator and a stack linked list iterator) everywhere, there's definitely less composition now in metadata and whatnot.

@nikomatsakis
Copy link
Contributor

I was wondering whether we could remove the <PI> generics and replace them with a specific type. I'd prefer to do that, I think, though I might prefer a shorter name than FullPathIter (maybe PathIter or even Path?). Actually, following our new convention I guess the appropriate thing would be some sort of pluralized noun like Names or Ids.

@eddyb
Copy link
Member Author

eddyb commented Feb 12, 2014

I've renamed FullPathIter to PathElems, and now only 3 (terminal) functions are generic over <PI: Iterator<PathElem>.

@cmr has been nice enough to send my branch to try, yielding this interesting test failure.
I'm surprised to see we output these ugly "pretty" impl paths in errors.
Those changed in this PR, foo$$UP$$VEC$uint::foo is now ~[uint].foo::foo (trans doesn't have any problems because it mangles paths itself).


// See comment in `encode_side_tables_for_ii` in astencode
let ecx_ptr : *int = unsafe { cast::transmute(ecx) };
let ecx_ptr: *int = unsafe { cast::transmute(ecx) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing, but this is ... goofy! We should be able to remove this by now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought so myself, then forgot about it.

@bors bors closed this Feb 14, 2014
@bors bors merged commit a02b10a into rust-lang:master Feb 14, 2014
@eddyb eddyb deleted the ast-map-cheap-path branch February 14, 2014 08:17
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jan 25, 2024
blocks_in_conditions: do not warn if condition comes from macro

changelog: [`blocks_in_conditions`]: do not warn if condition comes from macro

Fix rust-lang#12162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants