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

assert! allows invalid trailing tokens in expression #60024

Closed
adlerd opened this issue Apr 16, 2019 · 5 comments · Fixed by #60039
Closed

assert! allows invalid trailing tokens in expression #60024

adlerd opened this issue Apr 16, 2019 · 5 comments · Fixed by #60039
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@adlerd
Copy link

adlerd commented Apr 16, 2019

fn main() {
    assert!(true some extra junk, "whatever");  
    assert!(true some extra junk);                    
}

(Playground)

Output:

   Compiling playground v0.0.1 (/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.54s
     Running `target/debug/playground`

Version:

  • 1.34.0
  • 1.35.0 2019-04-15 nightly (2975a3c)

Expected:

error: expected one of `.`, `;`, `?`, or an operator, found `some`
 --> src/main.rs:2:18
  |
2 |     assert!(true some extra junk, "whatever");
  |                  ^^^^ expected one of `.`, `;`, `?`, or an operator here

Original report:
https://www.reddit.com/r/rust/comments/bdbtpr/hey_rustaceans_got_an_easy_question_ask_here/el1gm0h/

@jonas-schievink jonas-schievink added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. I-nominated regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Apr 16, 2019
@jonas-schievink
Copy link
Contributor

1.26.0 is the first version that accepts this. 1.25.0 rejects it with:

error: no rules expected the token `some`
 --> test.rs:2:18
  |
2 |     assert!(true some extra junk, "whatever");  
  |                  ^^^^

error: no rules expected the token `some`
 --> test.rs:3:18
  |
3 |     assert!(true some extra junk);                    
  |                  ^^^^

error: aborting due to 2 previous errors

@jonas-schievink jonas-schievink removed the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Apr 16, 2019
@jonas-schievink
Copy link
Contributor

(not really a regression since more code now compiles)

@Centril Centril added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 16, 2019
@Centril
Copy link
Contributor

Centril commented Apr 16, 2019

Adding T-compiler since assert! is a built-in.

@rasendubi
Copy link
Contributor

rasendubi commented Apr 17, 2019

Opened #60039—it should fix the issue.

@pnkfelix
Copy link
Member

triage: P-medium. I'm going to assume we don't need any future-compat machinery for a bug of this nature, unless the crater run on PR #60039 indicates that there are occurrences of this mis-use of assert! in the wild.

@pnkfelix pnkfelix added P-medium Medium priority and removed I-nominated labels Apr 18, 2019
rasendubi added a commit to rasendubi/bluenrg that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to remove extra tokens.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/cargo-generate that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to remove extra tokens.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/q1tsim that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to add missing comma.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/rs-static-linkedlist that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to remove extra tokens.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/carrier-legacy that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to add missing comma.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/passwords that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to remove extra tokens.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/wrench that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to remove extra tokens.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/cody that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to add missing comma.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/bonaventure that referenced this issue Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to add missing comma.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
bors added a commit that referenced this issue Apr 29, 2019
Make assert! ensure the macro is parsed completely

Fixes #60024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants