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

Calling a function within a module derived from concat_idents fails to resolve #8167

Closed
jdm opened this Issue Jul 31, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@jdm
Copy link
Contributor

jdm commented Jul 31, 2013

mod barfoo {
  fn foo() {}
}

fn main() {
  concat_idents!(bar, foo)::foo();
}
<anon>:5:37: 5:63 error: unresolved name `barfoo`.
<anon>:5          mod barfoo { fn foo() {} }; concat_idents!(bar, foo)::foo()
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
note: in expansion of concat_idents!
<anon>:5:37: 5:63 note: expansion site
<anon>:5:61: 5:66 error: unresolved name `foo`.
<anon>:5          mod barfoo { fn foo() {} }; concat_idents!(bar, foo)::foo()
                                                                      ^~~~~
error: aborting due to 2 previous errors
application terminated with error code 101
@huonw

This comment has been minimized.

Copy link
Member

huonw commented Feb 23, 2014

This is a dupe of #5941 and (implicitly) #12249. That is, as written, it's parsing as:

mod barfoo {
  fn foo() {}
}

fn main() {
  concat_idents!(bar, foo);

  ::foo();
}

Fixing this by writing (concat_idents!(bar, foo)::foo()) to force it to be a single expression triggers:

8167.rs:6:28: 6:30 error: expected one of `,`, `)` but found `::`
8167.rs:6   (concat_idents!(bar, foo)::foo());
                                     ^~

which is the similarity to #12249: can't use a macro in purely ident position.

@huonw huonw closed this Feb 23, 2014

@huonw huonw added the A-syntaxext label Feb 23, 2014

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.