-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 absolute paths as extern under a feature flag #46613
Conversation
let ImportDirective { ref module_path, span, .. } = *directive; | ||
|
||
// Extern crate mode for absolute paths needs some | ||
// special support for single-segment imports. |
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.
The part about single-segment imports (use my_crate;
/use crate;
) works, but it is kinda hacked into.
Solving it properly requires larger refactoring that would also solve a number of pre-existing problems (#29036 and similar).
@@ -2959,6 +2960,16 @@ impl<'a> Resolver<'a> { | |||
// `$crate::a::b` | |||
module = Some(self.resolve_crate_root(ident.node.ctxt)); | |||
continue | |||
} else if i == 1 && self.session.features.borrow().extern_absolute_paths && | |||
path[0].node.name == keywords::CrateRoot.name() && |
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.
Nit: isn't there some helper function we can use here for this test against keywords::CrateRoot.name()
?
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.
There's no such existing function.
(Also there are too many "crate roots" with different properties now, it's better to be explicit.)
// Extern crate mode for absolute paths needs some | ||
// special support for single-segment imports. | ||
let extern_absolute_paths = self.session.features.borrow().extern_absolute_paths; | ||
if module_path.len() == 1 && module_path[0].node.name == keywords::CrateRoot.name() { |
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.
Nit: as above, helper function?
@bors r+ |
📌 Commit 675581a has been approved by |
⌛ Testing commit 675581a290571ea38141b1f6e202bf66d444122a with merge 4ae1d40e143c9a1a3722d1b921255c4b4e2bdc74... |
💔 Test failed - status-travis |
The new gate test failed on
|
src/libsyntax/feature_gate.rs
Outdated
@@ -430,6 +430,9 @@ declare_features! ( | |||
|
|||
// generic associated types (RFC 1598) | |||
(active, generic_associated_types, "1.23.0", Some(44265)), | |||
|
|||
// Resolve absolute paths as paths from other crates | |||
(active, extern_absolute_paths, "1.23.0", Some(44660)), |
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.
This should be 1.24.0?
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn main() {} |
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.
Something is missing?
@bors r=nikomatsakis |
📌 Commit b07e26e has been approved by |
Resolve absolute paths as extern under a feature flag cc #44660 r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
Support `extern` in paths Implement the primary alternative to #46613 + #45771, achieving the same effect without requiring changes to other imports. Both need to be experimentally evaluated before making further progress. The PR also adds docs for all these related features into the unstable book. cc #44660 r? @nikomatsakis
cc #44660
r? @nikomatsakis