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

Forbid constructing empty identifiers from concat_idents #50406

Merged
merged 3 commits into from
May 3, 2018

Conversation

ExpHP
Copy link
Contributor

@ExpHP ExpHP commented May 3, 2018

The empty identifier is a reserved identifier in rust, apparently used for black magicks like representing the crate root or somesuch... and therefore, being able to construct it is Ungood. Presumably.

...even if the macro that lets you construct it is so useless that you can't actually do any damage with it. (and believe me, I tried)

Fixes #50403.

Note: I noticed that when you try to do something similar with proc_macro::Term, the compiler actually catches it and flags the identifier as reserved. Perhaps a better solution would be to somehow have that same check applied here.

@ExpHP
Copy link
Contributor Author

ExpHP commented May 3, 2018

I think @rust-highfive doesn't like me for some reason.

Is my username triggering some XSS filter or something?

(or perhaps not; it looks like my luck with the robot has been about 50/50 in recent PRs)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:44:02] ....................................................................................................
[00:44:06] ....................................................................................................
[00:44:12] ....................................................................................................
[00:44:18] ....................................................................................................
[00:44:24] ......F.............................................................................................
[00:44:36] ...............i....................................................................................
[00:44:42] ..................................ii................................................................
[00:44:48] ....................................................................................................
oot/lib/rustlib/x86_64-unknown-linux-gnu/lib
---
56088 ./obj/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/bin
55380 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release
53592 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/build
53544 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/incremental/syntax-33ta18b3panbi
53540 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/incremental/syntax-33ta18b3panbi/s-f0oibr7f5m-lnrwd3-1rwn5s4buqcgk
47892 ./obj/build/x86_64-unknown-linux-gnu/stage0-std
46928 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps
46868 ./src/test
46788 ./obj/build/x86_64-unknown-linux-gnu/stage2-tools

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update the patterns in libcore/macros.rs and libstd/macros.rs because they currently imply that 0 idents would be accepted.

macro_rules! concat_idents {
    ($($e:ident),*) => ({ /* compiler built-in */ });
    ($($e:ident,)*) => ({ /* compiler built-in */ });
}

@dtolnay dtolnay self-assigned this May 3, 2018
@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 3, 2018
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay
Copy link
Member

dtolnay commented May 3, 2018

@bors r+

@bors
Copy link
Contributor

bors commented May 3, 2018

📌 Commit 8e38d02 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 3, 2018
kennytm added a commit to kennytm/rust that referenced this pull request May 3, 2018
Forbid constructing empty identifiers from concat_idents

The empty identifier is a [reserved identifier](https://github.com/rust-lang/rust/blob/8a37c75a3a661385cc607d934c70e86a9eaf5fd7/src/libsyntax_pos/symbol.rs#L300-L305) in rust, apparently used for black magicks like representing the crate root or somesuch... and therefore, being able to construct it is Ungood.  Presumably.

...even if the macro that lets you construct it is so useless that you can't actually do any damage with it. (and believe me, I tried)

Fixes rust-lang#50403.

**Note:** I noticed that when you try to do something similar with `proc_macro::Term`, the compiler actually catches it and flags the identifier as reserved.  Perhaps a better solution would be to somehow have that same check applied here.
bors added a commit that referenced this pull request May 3, 2018
Rollup of 12 pull requests

Successful merges:

 - #50302 (Add query search order check)
 - #50320 (Fix invalid path generation in rustdoc search)
 - #50349 (Rename "show type declaration" to "show declaration")
 - #50360 (Clarify wordings of the `unstable_name_collision` lint.)
 - #50365 (Use two vectors in nearest_common_ancestor.)
 - #50393 (Allow unaligned reads in constants)
 - #50401 (Revert "Implement FromStr for PathBuf")
 - #50406 (Forbid constructing empty identifiers from concat_idents)
 - #50407 (Always inline simple BytePos and CharPos methods.)
 - #50416 (check if the token is a lifetime before parsing)
 - #50417 (Update Cargo)
 - #50421 (Fix ICE when using a..=b in a closure.)

Failed merges:
@bors bors merged commit 8e38d02 into rust-lang:master May 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants