Uh oh!
There was an error while loading. Please reload this page.
rustc_resolve: refactor NameBindings and fix issue #4952 - #29530
Conversation
rust-highfive
commented
Nov 3, 2015
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Aatch (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
nikomatsakis
commented
Nov 3, 2015
(I saw @Aatch mention on IRC that he did not feel familiar enough with resolve to review) |
nikomatsakis
commented
Nov 11, 2015
Sorry for being slow. I'll try to take a look at this now. I'm also not super familiar with this code, but I figure this is a good time to refresh my memory. :) |
nikomatsakis
commented
Nov 11, 2015
@jseyfried to be clear, this is a pure refactoring, right? That is, it's not supposed to fix any bugs? |
There was a problem hiding this comment.
Some comments here would be good. e.g. what does it mean if both def and module are Some? The function def below seems to suggest that def "takes precedence" -- does this mean that module should always be None when def is Some?
There was a problem hiding this comment.
(edited) see my comment in the main conversation
bors
commented
Nov 11, 2015
☔ The latest upstream changes (presumably #29778) made this pull request unmergeable. Please resolve the merge conflicts. |
jseyfried
commented
Nov 14, 2015
@nikomatsakis Thanks for the feedback. Yes, this is a pure refactoring. |
bors
commented
Nov 16, 2015
☔ The latest upstream changes (presumably #29387) made this pull request unmergeable. Please resolve the merge conflicts. |
Define a newtype `NameBinding` for `Rc<RefCell<Option<NsDef>>>` and refactor `NameBindings` to be a `NameBinding` for each namespace. Replace uses of `NameBindings` with `NameBinding` where only one binding is being used (in `NamespaceResult`, `Target,` etc). Refactor away `resolve_definition_of_name_in_module` and `NameDefinition`.
jseyfried
commented
Nov 16, 2015
Rebased |
jseyfried
commented
Nov 16, 2015
@nikomatsakis Regarding your question about the When I was writing the first commit, I wasn't exactly sure what it meant when the It turns out the meaning of these fields is fairly complex.
The This redundancy seems like a bad idea, so I refactored the Thus ideally exactly one of However, we sometimes allow It looks like it was decided that there would be one warning cycle before the warnings become errors. Once they are errors, I can refactor the The warnings are currently in the beta branch. Does this mean they are ready to be made errors now in nightly? If so I could do that and refactor the fields in this PR. |
Change build_reduced_graph.rs so the fields def and module of NsDef are never both Some unless the NsDef represents a duplicate definition (see issue 26421).
nikomatsakis
commented
Nov 16, 2015
Yes, it does mean that. That'd be nice! |
jseyfried
commented
Nov 17, 2015
@nikomatsakis Done |
There was a problem hiding this comment.
Creative use of Index btw.
There was a problem hiding this comment.
can you add a comment explaining what makes this a "normal" module? I guess this means "a module declared by the user", and not a "pseudo-module" that we create for some other reason?
There was a problem hiding this comment.
Module probably should be named something like Scope since it represents scopes corresponding to traits, enums, and blocks as well as actual mod modules.
In this case a "normal" Module (formerly NormalModuleKind) is a Module that corresponds to a actual module or a foreign module.
nikomatsakis
commented
Nov 18, 2015
@jseyfried ok, I've read this through. I think it looks really nice, definitely seems cleaner, and I like cleaning up the semantics. r+ if you add a comment on |
nikomatsakis
commented
Nov 19, 2015
@bors r+ (I decided insisting on a comment on Thanks @jseyfried, this is nice! |
nikomatsakis
commented
Nov 23, 2015
@jseyfried no. |
nikomatsakis
commented
Nov 23, 2015
@bors r- |
nikomatsakis
commented
Nov 23, 2015
@bors r+ |
bors
commented
Nov 23, 2015
📌 Commit 6a6e1db has been approved by |
bors
commented
Nov 23, 2015
Replace `TypeNsDef` and `ValueNsDef` with a more general type `NsDef`. Define a newtype `NameBinding` for `Rc<RefCell<Option<NsDef>>>` and refactor `NameBindings` to be a `NameBinding` for each namespace. Replace uses of `NameBindings` with `NameBinding` where only one binding is being used (in `NamespaceResult`, `Target,` etc). Refactor away `resolve_definition_of_name_in_module` and `NameDefinition`, fixing issue #4952.
bors
commented
Nov 23, 2015
apoelstra
commented
Dec 9, 2015
This breaks rust-jsonrpc and there isn't any workaround short of me breaking my API to force users to pass garbage to my macros. Why wasn't there a warning? |
apoelstra
commented
Dec 9, 2015
With help from @bluss I was able to find a workaround that does not change the API. However, the warning PR and this PR were merged less than four weeks apart. My crate is publicly available on crates.io and has transitioned from "working" to "not compiling" in such a short period, with no notification other than that one of my users who I know IRL happened to be using nightly with my library. |
mbrubeck
commented
Dec 9, 2015
Some additional detail from @apoelstra on IRC: This breakage wasn't found by the crater run because the error occurs in a macro expansion, and doesn't happen during The code that broke in jsonrpc was using a pattern that may be found in other macros, so there might be other broken crates that were missed by crater for the same reason. Should we try harder to determine the real impact before converting this warning to an error? |
nikomatsakis
commented
Dec 10, 2015
@apoelstra@mbrubeck I am confused. I thought that the warnings had been available for some time. Perhaps I misunderstood what @jseyfried meant by "in the beta branch" -- if the warnings were only available for six hours, that does seem like a policy failure, since you ought to have time to react. |
mbrubeck
commented
Dec 10, 2015
The warning landed in 1.5 and became an error in 1.6, so developers using the stable channel will have one release cycle (six weeks) to react to them. On the nightly channel, developers had four weeks to react. |
mbrubeck
commented
Dec 10, 2015
We could detect this type of breakage in test code by making crater do |
retep998
commented
Dec 11, 2015
@mbrubeck If crater does do |
apoelstra
commented
Dec 11, 2015
@nikomatsakis Sorry, I misunderstood how the release cycle worked. I thought that because nightly had a hard error before stable had even a warning, that stable would not get even the warning. |
nikomatsakis
commented
Dec 14, 2015
@mbrubeck it seems like I misunderstood. Re-reading the comments, I'm not sure where I got the notion that the span-between-warning-and-breakage was 6 hours. In any case, 4 weeks seems like a pretty reasonable span of time (for Nightly), but I don't think we've made a firm policy here. Regarding the crater run, perhaps |
nikomatsakis
commented
Dec 14, 2015
On Thu, Dec 10, 2015 at 06:23:19PM -0800, Andrew Poelstra wrote:
Not to worry. Thanks for raising the point in any case, better safe |
mbrubeck
commented
Dec 15, 2015
As mentioned by bhsausabsha on IRC, |
brson
commented
Jan 19, 2016
Are there any other links relevant to the regression reported here? Maybe an issue? |
brson
commented
Jan 19, 2016
Since #30089 was fixed, I'm assuming it is a different regression than the one reported by @apoelstra. |
Replace
TypeNsDefandValueNsDefwith a more general typeNsDef.Define a newtype
NameBindingforRc<RefCell<Option<NsDef>>>and refactorNameBindingsto be aNameBindingfor each namespace.Replace uses of
NameBindingswithNameBindingwhere only one binding is being used (inNamespaceResult,Target,etc).Refactor away
resolve_definition_of_name_in_moduleandNameDefinition, fixing issue #4952.