Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRevamp symbol names for impls (and make them deterministic, etc) #32293
Conversation
rust-highfive
assigned
eddyb
Mar 16, 2016
This comment has been minimized.
This comment has been minimized.
|
Note that the review is technically only for my comments, not mw's, but of course feel free to comment on those too and I'll patch up any nits or whatever. |
eddyb
reviewed
Mar 16, 2016
| /// the original crate but also its def-id. This is kind of an | ||
| /// augmented version of a `DefPath` that includes a `DefId`. This is | ||
| /// all sort of ugly but the hope is that inlined items will be going | ||
| /// away soon anyway. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
arielb1
Mar 22, 2016
Contributor
We could pass the original id in the trans::inline path just like MIR.
eddyb
reviewed
Mar 16, 2016
| @@ -486,7 +487,7 @@ pub fn build_session_(sopts: config::Options, | |||
| plugin_attributes: RefCell::new(Vec::new()), | |||
| crate_types: RefCell::new(Vec::new()), | |||
| dependency_formats: RefCell::new(FnvHashMap()), | |||
| crate_disambiguator: RefCell::new(String::new()), | |||
| crate_disambiguator: Cell::new(token::intern("")), | |||
This comment has been minimized.
This comment has been minimized.
eddyb
reviewed
Mar 16, 2016
| pub data: Vec<DisambiguatedDefPathData>, | ||
|
|
||
| /// what krate root is this path relative to? | ||
| pub krate: ast::CrateNum, |
This comment has been minimized.
This comment has been minimized.
eddyb
Mar 16, 2016
Member
Does DefId still need to hold a CrateNum, or is removing that too expensive?
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 16, 2016
Author
Contributor
@eddyb at the moment, DefId does need a CrateNum, because we don't put all the ids from all crates together. e.g. if you compute the def-path from a def-id, we first look at def_id.krate to find the krate, then go lookup the index in the appropriate place based on that.
This comment has been minimized.
This comment has been minimized.
eddyb
reviewed
Mar 16, 2016
| let def_path = DefPath { | ||
| data: vec![], | ||
| krate: cstore::LOCAL_CRATE, | ||
| }; |
This comment has been minimized.
This comment has been minimized.
eddyb
Mar 16, 2016
Member
In the long term we should move to <T as Trait>::method, at least for trait-related shims.
eddyb
reviewed
Mar 16, 2016
| /// we can omit including the path to the impl itself. This | ||
| /// function tries to find a "characteristic def-id" for a | ||
| /// type. It's just a heuristic so it makes some questionable | ||
| /// decisions and we may want to adjust it later. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
arielb1
Mar 22, 2016
Contributor
I am not sure that this is better than treating all impls as local. For example, structural_impls would use the ugly way - that's it, middle::structural_impls::<impl TypeFoldable for Vec<T>>::fold_ty rather than <Vec<T> as TypeFoldable>::fold_ty.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 22, 2016
Author
Contributor
On Tue, Mar 22, 2016 at 05:54:48AM -0700, arielb1 wrote:
I am not sure that this is better than treating all impls as local. For example,
structural_implswould use the ugly way - that's it,middle::structural_impls::<impl TypeFoldable for Vec<T>>::fold_tyrather than<Vec<T> as TypeFoldable>::fold_ty.
Yeah, I don't know what's best. One could also imagine some heuristic
based on "submodules". But I guess one could argue that for
structural_impls it'd be useful to be told that the impl is in that
module, rather than the module for Vec. I'm totally amenable to
follow-up PRs that tweak these heuristics -- probably at some point we
would want to RFC this, but I guess that's a long way in the future.
This comment has been minimized.
This comment has been minimized.
arielb1
Mar 23, 2016
Contributor
The orphan rules guarantee that the impl is at least in the same crate as TypeFoldable (seeing that it depends on Vec, not vice-versa) - that would also happen if TypeFoldable was in structural_impls. grep within a crate is not that much of a problem.
eddyb
reviewed
Mar 17, 2016
| compile_lib_path: matches.opt_str("compile-lib-path").unwrap(), | ||
| run_lib_path: matches.opt_str("run-lib-path").unwrap(), | ||
| compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")), | ||
| run_lib_path: make_absolute(opt_path(matches, "run-lib-path")), |
This comment has been minimized.
This comment has been minimized.
eddyb
Mar 17, 2016
Member
If this fixes run-pass/command-before-exec, I think a revert of the static linking hack @alexcrichton suggested and I merged, is in order.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 17, 2016
Author
Contributor
If this fixes run-pass/command-before-exec, I think a revert of the static linking hack @alexcrichton suggested and I merged, is in order.
Actually I have no real idea what the purpose of this change is. :) @michaelwoerister, care to comment? :)
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Mar 19, 2016
Contributor
Yes, this change is solely for run-pass/command-before-exec.
eddyb
reviewed
Mar 17, 2016
| let symbol = mangle_internal_name_by_path_and_seq(path, "closure"); | ||
| let symbol = symbol_names::exported_name(ccx, | ||
| mono_id.def, | ||
| mono_id.params.as_slice()); |
This comment has been minimized.
This comment has been minimized.
eddyb
Mar 17, 2016
Member
Sweet, although I'm not sure whether my PR or this should come first - also, maybe exported_name should take an Instance (here still called MonoId)?
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 17, 2016
Author
Contributor
also, maybe exported_name should take an Instance (here still called MonoId)?
Yeah, I noticed at some point recently that it takes a &[Ty<'tcx>], which just seems wrong. It ought to take a Substs clearly. I'll see if I can easily address that.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 17, 2016
Author
Contributor
although I'm not sure whether my PR or this should come first
It's a race! No, but seriously -- do you think they'll conflict much?
Also, I was just looking at callers of exported_name. The code in get_item_val seems a bit dubious. Not wrong, but dubious -- it calls exported_name with the id of (e.g.) an enum or function but a single type T where T is basically lookup_item_type(id).ty. This seems to ... mostly be used only for non-generic items, but in that case the type parameter should be altogether unnecessary I would think. Not sure if you refactored this at all? I remember some changes in that direction, so I suspect so. Seems like taking a mono_id would force the question and clean it up.
This comment has been minimized.
This comment has been minimized.
|
LGTM, except for the nits, some of which GitHub is marking as being on an outdated diff. |
alexcrichton
reviewed
Mar 17, 2016
| pub struct Foo { x: u32 } | ||
|
|
||
| impl Foo { | ||
| #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
michaelwoerister
reviewed
Mar 19, 2016
|
|
||
| #[rustc_symbol_name] //~ ERROR _ZN5basic4main |
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Mar 19, 2016
Contributor
This name and others should end with an 'E' to close the nested name that was started with the 'N'.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Mar 21, 2016
Author
Contributor
On Sat, Mar 19, 2016 at 04:01:27PM -0700, Michael Woerister wrote:
+#[rustc_symbol_name] //~ ERROR _ZN5basic4main
This name and others should end with an 'E' to close the
nested namethat was started with the 'N'.
The names do end with E. I just left that out of the test because I didn't want to put the hash in there.
This comment has been minimized.
This comment has been minimized.
|
Looks good to me too. Consolidating path rendering into its own module is a good idea and it's great that we'll be testing symbol names from now on. Looking forward to tinkering with the name mangling scheme. |
nikomatsakis
force-pushed the
nikomatsakis:incr-comp-def-path-munging
branch
2 times, most recently
from
3214c33
to
bdfc0b4
Mar 21, 2016
This comment has been minimized.
This comment has been minimized.
|
Rebased. Some of the poor @michaelwoerister's beautifully clean commit history got a bit messed up (I suspect the individual commits no longer build), but seems to build locally. Not yet finished with |
This comment has been minimized.
This comment has been minimized.
|
@bors r=eddyb |
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis
force-pushed the
nikomatsakis:incr-comp-def-path-munging
branch
from
8786477
to
09574bd
Mar 21, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors r- |
This comment has been minimized.
This comment has been minimized.
Does this just mean removing the comment on the test? If so, I did that in the most recent commit. |
This comment has been minimized.
This comment has been minimized.
|
@bors r=eddyb |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 22, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors r=eddyb |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
question to @alexcrichton -- do you know if the windows builders have |
nikomatsakis
added some commits
Mar 25, 2016
nikomatsakis
force-pushed the
nikomatsakis:incr-comp-def-path-munging
branch
from
8cfc003
to
726ba66
Mar 25, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors r=alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors p=1 |
This comment has been minimized.
This comment has been minimized.
|
(This PR has been hanging around way too long.) |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 25, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors r=alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors force |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 25, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors r=alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis commentedMar 16, 2016
This builds on @michaelwoerister's epic PR #31539 (note that his PR never landed, so I just incorporated it into this one). The main change here is that we remove the "name" from
DefPathDatafor impls, since that name is synthetic and not sufficiently predictable for incr comp. However, just doing that would cause bad symbol names since those are based on theDefPath. Therefore, I introduce a new mechanism for getting symbol names (and also paths for user display) calleditem_path. This is kind of simplistic for now (based on strings) but I expect to expand it later to support richer types, hopefully generating C++-mangled names that gdb etc can understand. Along the way I cleaned up how we track the path that leads to an extern crate.There is still some cleanup left undone here. Notably, I didn't remove the impl names altogether -- that would probably make sense. I also didn't try to remove the
item_symbolsvector. Mostly I want to unblock my other incr. comp. work. =)r? @eddyb
cc @eddyb @alexcrichton @michaelwoerister