-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fix the span of generated #[derive_*]
attributes
#33926
Conversation
c.f. #32791 (specifically this commit), which caused #33571. |
// | ||
// See tests src/run-pass/rfc1445 for | ||
// examples. --nmatsakis | ||
let span = Span { expn_id: cx.backtrace(), .. span }; |
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.
Why is it still necessary to have a special case for the PartialEq
and Eq
traits? Is the span generated in the loop above not sufficient?
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.
Good point, fixed.
// originate not from the deriving call but from | ||
// text outside the deriving call, and hence would | ||
// be forbidden from using unstable | ||
// content. |
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.
Oh, uh, forget what I just said. This comment explains why this case indeed needs a special span.
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.
Errmmm... Or maybe not, since the span taht we compute in the loop has allow_internal_unstable
set? I must admit I'm a bit confused.
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.
Well okay, no, now that you eplicitly set allow_internal_unstable
, which wasn't the case before I think, it should be okay. But you should definitely add a test like what the comment suggests and make sure it compiles. Something like:
macro_rules! foo() (
($attr:tt) => (
#[deriving($attr, PartialEq)] struct S;
)
);
foo!(Eq);
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.
@LeoTestard c.f. this test
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.
Ok fine. Looks good to me then. :)
@bors: r+ |
📌 Commit a0e606c has been approved by |
Fix the span of generated `#[derive_*]` attributes Fixes rust-lang#33571. r? @nrc
Fixes #33571.
r? @nrc