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

Many feature gates are not checked in macros #18102

Closed
brson opened this Issue Oct 16, 2014 · 6 comments

Comments

Projects
None yet
6 participants
@brson
Copy link
Contributor

brson commented Oct 16, 2014

Feature gates are generally checked before expansion so feature gates are defeated by code inside macros.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 16, 2014

Notably, this compiles today when it shouldn't:

fn main() {
    let a = ('a', 1u);
    println!("{}", a.0);
}
@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Oct 16, 2014

P-backcompat-lang, 1.0

@pnkfelix pnkfelix added this to the 1.0 milestone Oct 16, 2014

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Oct 16, 2014

Note that we may be able to use a technique similar to that for the stability lint: #17286

@japaric

This comment has been minimized.

Copy link
Member

japaric commented Oct 16, 2014

This is a duplicate of #12122

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 16, 2014

While somewhat similar I don't think that this is a dupe of #12122. The definition of a macro should be subject to the feature gates in the defining crate, but the usage of a macro should be subject to the feature gates in the consumer crate.

#12122 indicates that we don't check macro definitions, and this indicates that we don't check macro invocations.

@cmr

This comment has been minimized.

Copy link
Member

cmr commented Dec 23, 2014

I think the best we can do right now is check after the expansion of macros, in the stable channel. Outside of the stable channel, this might cause some undesirable noise when the used features are supposed to be "internal implementation details" of a lib, but I think that sort of claim is baloney because the feature could disappear at any moment. It ought to require work on the macro user's part if it could stop working at any moment due to a compiler upgrade.

bors added a commit that referenced this issue Jan 1, 2015

auto merge of #20190 : cmr/rust/gate-macro-args, r=alexcrichton
Uses the same approach as #17286 (and
subsequent changes making it more correct), where the visitor will skip any
pieces of the AST that are from "foreign code", where the spans don't line up,
indicating that that piece of code is due to a macro expansion.

If this breaks your code, read the error message to determine which feature
gate you should add to your crate.

Closes #18102

[breaking-change]

bors added a commit that referenced this issue Jan 1, 2015

auto merge of #20190 : cmr/rust/gate-macro-args, r=alexcrichton
Uses the same approach as #17286 (and
subsequent changes making it more correct), where the visitor will skip any
pieces of the AST that are from "foreign code", where the spans don't line up,
indicating that that piece of code is due to a macro expansion.

If this breaks your code, read the error message to determine which feature
gate you should add to your crate.

Closes #18102

[breaking-change]

bors added a commit that referenced this issue Jan 1, 2015

auto merge of #20190 : cmr/rust/gate-macro-args, r=alexcrichton
Uses the same approach as #17286 (and
subsequent changes making it more correct), where the visitor will skip any
pieces of the AST that are from "foreign code", where the spans don't line up,
indicating that that piece of code is due to a macro expansion.

If this breaks your code, read the error message to determine which feature
gate you should add to your crate.

Closes #18102

[breaking-change]

@bors bors closed this in #20190 Jan 1, 2015

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.