From baee367d3eedc99c03eff265ca2fa4099c6b494f Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 22 Jun 2024 20:59:00 +0800 Subject: [PATCH] Parse - Handle `$:ty` in `use` --- Notes/UpgradeQuirks.txt | 2 +- src/parse/root.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Notes/UpgradeQuirks.txt b/Notes/UpgradeQuirks.txt index fc6aeeba..5bc93e77 100644 --- a/Notes/UpgradeQuirks.txt +++ b/Notes/UpgradeQuirks.txt @@ -149,4 +149,4 @@ - `TypeVisitable` only implies `Clone`, not `Copy` - So, rustc is skipping the `fn iter` and using the `Deref` impl and ending up at slice's `iter` - mrustc picks the top level one, becuase impl bounds don't restrict method resolution. - +- `use $ty::*;` - where `$ty:ty` in a `macro_rules` diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 763301b1..4e573fc1 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -1531,6 +1531,17 @@ void Parse_Use_Root(TokenStream& lex, ::std::vector& entries) } GET_CHECK_TOK(tok, lex, TOK_DOUBLE_COLON); break; + case TOK_INTERPOLATED_TYPE: { + if( !tok.frag_type().is_path() ) { + throw ParseError::Unexpected(lex, tok); + } + auto& p = tok.frag_type().path(); + if( p.m_class.is_UFCS() ) { + throw ParseError::Unexpected(lex, tok); + } + path = std::move(tok.frag_type().path()); + GET_CHECK_TOK(tok, lex, TOK_DOUBLE_COLON); + } break; case TOK_INTERPOLATED_PATH: path = mv$(tok.frag_path()); GET_CHECK_TOK(tok, lex, TOK_DOUBLE_COLON);