Skip to content

! is not a valid ty token in macros #8104

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

Closed
alexcrichton opened this issue Jul 29, 2013 · 3 comments
Closed

! is not a valid ty token in macros #8104

alexcrichton opened this issue Jul 29, 2013 · 3 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@alexcrichton
Copy link
Member

This program:

macro_rules! foo(($t:ty) => ()) 

foo!(!)                         

fn main() {}                    

fails with

foo.rs:3:5: 3:6 error: expected type, found token NOT
foo.rs:3 foo!(!)
              ^

I ran into this when creating a condition which returned ! (not sure if that's even the right use of conditions...)

@alexcrichton
Copy link
Member Author

Oh it appears you also can't do

type Bot = !;

Now seeing that, is this intentional?

@brson
Copy link
Contributor

brson commented Jul 29, 2013

Yes, ! is not a type, just a special token that says a function doesn't return.

@alexcrichton
Copy link
Member Author

Oh, ok, that makes sense to me.

flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 17, 2021
Remind users of separate `rustc` lint groups

changelog: none

fixes rust-lang#8104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants