-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Functions/modules using unstable *syntax* (e.g., impl Trait
) can't be CFGed out on stable
#36478
Comments
Or implement the module in another file. I think this is a fundamental limitation -- you can't skip forward over an item if you don't understand the syntax that the item is using. The only way we could solve it is with time travel, i.e., doing a point release of stable that knows the |
That's actually what I'm doing in my project (still the same problem). That is, I have the following in my #[cfg(feature="unstable")]
mod unstable; And a module, fn foo() -> impl Foo {} |
Modules are parsed before |
Dupe of #27873. cc @jseyfried ( |
Though this'll be fixed by the above PR, the workaround for current stable is #[cfg_attr(feature="nightly", path="nightly_stuff.rs")]
#[cfg_attr(not(feature="nightly"), path="stable_stuff.rs")]
mod stuff; |
This fails on stable because rust still parses the unstable module:
It's possible to work around this by conditionally defining a macro and then having the macro define the module but that's a bit messy:
The text was updated successfully, but these errors were encountered: