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

Fix global path parsing #2668

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gcc/rust/lex/rust-token.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ Token::as_string () const
return "b'" + escape_special_chars (get_str (), Context::Char) + "'";
case LIFETIME:
return "'" + get_str ();
case SCOPE_RESOLUTION:
return "::";
case INT_LITERAL:
if (get_type_hint () == CORETYPE_UNKNOWN)
return get_str ();
Expand Down
3 changes: 2 additions & 1 deletion gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3093,7 +3093,7 @@ Parser<ManagedTokenSource>::parse_generic_param (EndTokenPred is_end_token)
// FIXME: Can we clean this last call with a method call?
rust_error_at (token->get_locus (),
"unexpected token when parsing generic parameters: %qs",
token->get_str ().c_str ());
token->as_string ().c_str ());
return nullptr;
}

Expand Down Expand Up @@ -3886,6 +3886,7 @@ Parser<ManagedTokenSource>::parse_type_param_bound ()
case SELF_ALIAS:
case CRATE:
case DOLLAR_SIGN:
case SCOPE_RESOLUTION:
return parse_trait_bound ();
default:
// don't error - assume this is fine TODO
Expand Down
4 changes: 4 additions & 0 deletions gcc/testsuite/rust/compile/parse_global_path_generic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// { dg-additional-options "-frust-compile-until=ast" }
pub fn foo<D: ::std::fmt::Debug>(_d: D) -> u32 {
0
}