Skip to content

Commit 500f4b2

Browse files
committed
Implement flags::add_const and build::const_ident
1 parent 29578e0 commit 500f4b2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/librustc/ty/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl FlagComputation {
240240
self.add_flags(TypeFlags::HAS_PROJECTION);
241241
self.add_substs(substs);
242242
}
243-
ConstVal::Param(_) => {
243+
ConstValue::Param(_) => {
244244
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES);
245245
self.add_flags(TypeFlags::HAS_PARAMS);
246246
}

src/libsyntax/ext/build.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub trait AstBuilder {
5353
fn ty(&self, span: Span, ty: ast::TyKind) -> P<ast::Ty>;
5454
fn ty_path(&self, path: ast::Path) -> P<ast::Ty>;
5555
fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>;
56+
fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst;
5657
fn const_ident(&self, span: Span, idents: ast::Ident) -> ast::AnonConst;
5758

5859
fn ty_rptr(&self, span: Span,
@@ -402,8 +403,20 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
402403
self.ty_path(self.path_ident(span, ident))
403404
}
404405

405-
fn const_ident(&self, _span: Span, _ident: ast::Ident) -> ast::AnonConst {
406-
unimplemented!() // TODO(const_generics)
406+
fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst {
407+
ast::AnonConst {
408+
id: ast::DUMMY_NODE_ID,
409+
value: P(ast::Expr {
410+
id: ast::DUMMY_NODE_ID,
411+
node: expr,
412+
span,
413+
attrs: ast::ThinVec::new(),
414+
})
415+
}
416+
}
417+
418+
fn const_ident(&self, span: Span, ident: ast::Ident) -> ast::AnonConst {
419+
self.anon_const(span, ast::ExprKind::Path(None, self.path_ident(span, ident)))
407420
}
408421

409422
fn ty_rptr(&self,

0 commit comments

Comments
 (0)