1
Fork 0

Add support for using qualified paths with structs in expression and pattern

position.
This commit is contained in:
Ryan Levick 2020-12-10 13:20:07 +01:00 committed by Ryan Levick
parent c5fbcd35a8
commit 6936349233
38 changed files with 374 additions and 187 deletions

View file

@ -275,7 +275,12 @@ impl<'a> ExtCtxt<'a> {
) -> P<ast::Expr> {
self.expr(
span,
ast::ExprKind::Struct(P(ast::StructExpr { path, fields, rest: ast::StructRest::None })),
ast::ExprKind::Struct(P(ast::StructExpr {
qself: None,
path,
fields,
rest: ast::StructRest::None,
})),
)
}
pub fn expr_struct_ident(
@ -405,7 +410,7 @@ impl<'a> ExtCtxt<'a> {
path: ast::Path,
subpats: Vec<P<ast::Pat>>,
) -> P<ast::Pat> {
self.pat(span, PatKind::TupleStruct(path, subpats))
self.pat(span, PatKind::TupleStruct(None, path, subpats))
}
pub fn pat_struct(
&self,
@ -413,7 +418,7 @@ impl<'a> ExtCtxt<'a> {
path: ast::Path,
field_pats: Vec<ast::PatField>,
) -> P<ast::Pat> {
self.pat(span, PatKind::Struct(path, field_pats, false))
self.pat(span, PatKind::Struct(None, path, field_pats, false))
}
pub fn pat_tuple(&self, span: Span, pats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
self.pat(span, PatKind::Tuple(pats))