Skip to content

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

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
jdm opened this issue Jul 31, 2013 · 1 comment
Closed
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically A-syntaxext Area: Syntax extensions

Comments

@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
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 as completed Feb 23, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 30, 2021
fix an ICE on unwrapping a None

This very likely fixes rust-lang#8166 though I wasn't able to meaningfully reduce a test case. This line is the only call to `unwrap` within that function, which was the one in the stack trace that triggered the ICE, so I think we'll be OK.

`@hackmad` can you pull and build this branch and check if it indeed fixes your problem?

---

changelog: Fixed ICE in [`unnecessary_cast`]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically A-syntaxext Area: Syntax extensions
Projects
None yet
Development

No branches or pull requests

2 participants