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

resolve: Fix variant namespacing #30882

Merged
merged 1 commit into from Jan 22, 2016

Conversation

Projects
None yet
@petrochenkov
Copy link
Contributor

petrochenkov commented Jan 13, 2016

Tuple and unit variants from other crates weren't put into type namespace.
Now variant namespacing is aligned with struct namespacing and is not affected by the variant's crate of origin (struct -> type, tuple/unit -> type/value).
Additionally, struct variants from other crates are put into value namespace (struct variants from local crate were already in it). This is not a necessity, but a future proofing measure.

This fix can result in some new shadowing errors in cross-crate scenarios, crater reports three regressions.
[breaking-change]

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 13, 2016

r? @Aatch

(rust_highfive has picked a reviewer for you, use r? to override)

@jonas-schievink

This comment has been minimized.

Copy link
Member

jonas-schievink commented Jan 14, 2016

cc me (this might fix a bug I've encountered)

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 14, 2016

r? @nrc

@rust-highfive rust-highfive assigned nrc and unassigned Aatch Jan 14, 2016

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Jan 14, 2016

I wonder if it is worth leaving struct variants in the value namespace? I don't suppose we'll ever need it, but it is future-proofing (e.g., if we someday get named arguments for functions, then we could make struct variants generate functions like other variants).

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Jan 15, 2016

Should probably decide on the behaviour before we give it a crater run, but it will need one before landing

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Jan 15, 2016

Adding struct variants into the value namespace (including cross-crate) will give us the "maximum breakage mode", best suited for evaluation with crater. I'll add a second commit doing this.

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Jan 15, 2016

Regarding keeping struct variants in the value namespace in the long term, I'm mildly against it.
Correspondence between behavior of {}-structs and {}-variants feels important (especially if variants become types) and we can't put {}-structs into value namespace now.

The pattern

struct S { fields: Fields }
fn S(args: Args) -> S { ... } // Constructor

is not especially idiomatic, but it exists and disallowing it would (presumably) break too much code.
If functions with named arguments become a thing someday, it would be strange to generate them for variants, but not for structs (but maybe it could be considered a "best-effort").

Manishearth added a commit to Manishearth/rust that referenced this pull request Jan 15, 2016

Rollup merge of rust-lang#30896 - petrochenkov:vkindmeta, r=alexcrichton
Also add tests for use of empty structs in cross-crate scenarios

Some tests are commented out, they depend on fixes from  rust-lang#30882
@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Jan 15, 2016

Updated with all variants in both namespaces.

bors added a commit that referenced this pull request Jan 16, 2016

Auto merge of #30896 - petrochenkov:vkindmeta, r=alexcrichton
Also add tests for use of empty structs in cross-crate scenarios

Some tests are commented out, they depend on fixes from  #30882

bors added a commit that referenced this pull request Jan 16, 2016

Auto merge of #30896 - petrochenkov:vkindmeta, r=alexcrichton
Also add tests for use of empty structs in cross-crate scenarios

Some tests are commented out, they depend on fixes from  #30882
@nrc

This comment has been minimized.

Copy link
Member

nrc commented Jan 16, 2016

@brson could you crater this please?

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Jan 16, 2016

@petrochenkov we often have this issue - do we want to be consistent between structs and struct variants or struct variants and other variants? I don't have an opinion in this case, but if we can get away with leaving our options open, I would like that.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 16, 2016

☔️ The latest upstream changes (presumably #30896) made this pull request unmergeable. Please resolve the merge conflicts.

@petrochenkov petrochenkov force-pushed the petrochenkov:varnamesp branch from a21f099 to 8058dbb Jan 16, 2016

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Jan 16, 2016

Rebased.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 16, 2016

Starting a crater run now

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 17, 2016

Looks like there are three regressions (legitimate ones I believe)

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Jan 17, 2016

pnet_macros_plugin-0.1.0 - conflict of struct-struct syntax::ast::Delimited and tuple-variant syntax::ast::TokenTree::Delimited in type namespace (this crate doesn't seem to work on stable).

rotor-http-0.4.0 - conflict of struct-struct server::request::Head and unit-variant hyper::method::Method::Head in type namespace (this crate works on stable).

tiled-0.1.4 - conflict of struct-struct std::io::Error and tuple-variant xml::reader::events::XmlEvent::Error in type namespace (this crate seems to work on stable).

Zero regressions due to future-proofing of struct-variants suggested by @nrc

cc @mrmonday @tailhook @mattyhall

@mrmonday

This comment has been minimized.

Copy link
Contributor

mrmonday commented Jan 17, 2016

Hi, feel free to ping me about the pnet_macros_plugin failure - I don't know what you need from me specifically.

@petrochenkov, you are correct, pnet_macros_plugin will only work on nightly - it's an optional dependency of libpnet, which is only pulled in when the nightly feature is enabled. It is literally a wrapper around pnet_macros but with plugin = true added to the Cargo.toml. By default, libpnet uses syntex, rather than the plugin (I keep it around because build times are 3x faster when using plugins directly rather than syntex).

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Jan 17, 2016

cc @rust-lang/lang

I'd be happy to take this and submit PRs to the breaking crates above. What do the rest of the team think?

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Jan 17, 2016

note: I do think of this as qualifying as a bug fix

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Jan 17, 2016

I'm on board with future-proofing here.

@tailhook

This comment has been minimized.

Copy link

tailhook commented Jan 18, 2016

Thanks to @brson, the bug in rotor-http is fixed now. This case looks more like an oversight rather than a valid use case. And I'm happy that compiler catches it now.

@brson brson added the relnotes label Jan 20, 2016

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 21, 2016

☔️ The latest upstream changes (presumably #31010) made this pull request unmergeable. Please resolve the merge conflicts.

@petrochenkov petrochenkov force-pushed the petrochenkov:varnamesp branch from 8058dbb to ff6b0aa Jan 21, 2016

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Jan 21, 2016

Rebased.

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Jan 21, 2016

@bors: r+

(discussed at lang team meeting today)

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 21, 2016

📌 Commit ff6b0aa has been approved by nrc

bors added a commit that referenced this pull request Jan 21, 2016

Auto merge of #30882 - petrochenkov:varnamesp, r=nrc
Tuple and unit variants from other crates weren't put into type namespace.
Now variant namespacing is aligned with struct namespacing and is not affected by the variant's crate of origin (struct -> type, tuple/unit -> type/value).
Additionally, struct variants from other crates are put into value namespace (struct variants from local crate were already in it). This is not a necessity, but a future proofing measure.

This fix can result in some new shadowing errors in cross-crate scenarios, crater reports [three regressions](#30882 (comment)).
[breaking-change]
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 21, 2016

⌛️ Testing commit ff6b0aa with merge 54475e9...

@bors bors merged commit ff6b0aa into rust-lang:master Jan 22, 2016

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
homu Test successful
Details
@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 31, 2016

Just ran a crate report against nightly, and I wanted to confirm, but the regression of the tiled crate was expected, here, right? This didn't intend to add support to ensure it kept compiling?

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Mar 31, 2016

Yes, this is an expected regression.
A fix to this crate was merged in February, but the published version still isn't updated.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 31, 2016

Ok, thanks @petrochenkov!

@mattyhall

This comment has been minimized.

Copy link

mattyhall commented Mar 31, 2016

I've pushed the new version.

@petrochenkov petrochenkov deleted the petrochenkov:varnamesp branch Sep 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.