Skip to content

Commit 2cdc86c

Browse files
committed
syntax: add fully qualified UFCS expressions.
1 parent 1c78ad9 commit 2cdc86c

File tree

25 files changed

+89
-42
lines changed

25 files changed

+89
-42
lines changed

src/librustc/lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ impl LintPass for Stability {
17311731
let mut span = e.span;
17321732

17331733
let id = match e.node {
1734-
ast::ExprPath(..) | ast::ExprStruct(..) => {
1734+
ast::ExprPath(..) | ast::ExprQPath(..) | ast::ExprStruct(..) => {
17351735
match cx.tcx.def_map.borrow().get(&e.id) {
17361736
Some(&def) => def.def_id(),
17371737
None => return

src/librustc/middle/cfg/construct.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
495495
ast::ExprMac(..) |
496496
ast::ExprClosure(..) |
497497
ast::ExprLit(..) |
498-
ast::ExprPath(..) => {
498+
ast::ExprPath(..) |
499+
ast::ExprQPath(..) => {
499500
self.straightline(expr, pred, None::<ast::Expr>.iter())
500501
}
501502
}

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &ast::Expr) {
111111
expression");
112112
}
113113
}
114-
ast::ExprPath(_) => {
114+
ast::ExprPath(_) | ast::ExprQPath(_) => {
115115
match v.tcx.def_map.borrow()[e.id] {
116116
DefStatic(..) | DefConst(..) |
117117
DefFn(..) | DefStaticMethod(..) | DefMethod(..) |

src/librustc/middle/check_static.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
228228
"{} are not allowed to have custom pointers",
229229
self.msg());
230230
}
231-
ast::ExprPath(..) => {
231+
ast::ExprPath(_) | ast::ExprQPath(_) => {
232232
match ty::resolve_expr(self.tcx, e) {
233233
def::DefStatic(..) if self.mode == InConstant => {
234234
let msg = "constants cannot refer to other statics, \

src/librustc/middle/check_static_recursion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
9393

9494
fn visit_expr(&mut self, e: &ast::Expr) {
9595
match e.node {
96-
ast::ExprPath(..) => {
96+
ast::ExprPath(_) | ast::ExprQPath(_) => {
9797
match self.def_map.borrow().get(&e.id) {
9898
Some(&DefStatic(def_id, _)) |
9999
Some(&DefConst(def_id)) if

src/librustc/middle/const_eval.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<'a, 'tcx> ConstEvalVisitor<'a, 'tcx> {
244244

245245
// FIXME: (#3728) we can probably do something CCI-ish
246246
// surrounding nonlocal constants. But we don't yet.
247-
ast::ExprPath(_) => self.lookup_constness(e),
247+
ast::ExprPath(_) | ast::ExprQPath(_) => self.lookup_constness(e),
248248

249249
ast::ExprRepeat(..) => general_const,
250250

@@ -356,6 +356,13 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<ast::Pat> {
356356
}
357357
}
358358

359+
ast::ExprQPath(_) => {
360+
match lookup_const(tcx, expr) {
361+
Some(actual) => return const_expr_to_pat(tcx, actual),
362+
_ => unreachable!()
363+
}
364+
}
365+
359366
_ => ast::PatLit(P(expr.clone()))
360367
};
361368
P(ast::Pat { id: expr.id, node: pat, span: expr.span })
@@ -542,7 +549,7 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result<const_val, St
542549
ty::ty_float(ast::TyF64) => (f64, const_float, f64)
543550
}))
544551
}
545-
ast::ExprPath(_) => {
552+
ast::ExprPath(_) | ast::ExprQPath(_) => {
546553
match lookup_const(tcx, e) {
547554
Some(actual_e) => eval_const_expr_partial(tcx, &*actual_e),
548555
None => Err("non-constant path in constant expr".to_string())

src/librustc/middle/effect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
175175
ast::ExprInlineAsm(..) => {
176176
self.require_unsafe(expr.span, "use of inline assembly");
177177
}
178-
ast::ExprPath(..) => {
178+
ast::ExprPath(_) | ast::ExprQPath(_) => {
179179
if let def::DefStatic(_, true) = ty::resolve_expr(self.tcx, expr) {
180180
self.require_unsafe(expr.span, "use of mutable static");
181181
}

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
424424
self.walk_expr(&**subexpr)
425425
}
426426

427-
ast::ExprPath(..) => { }
427+
ast::ExprPath(_) | ast::ExprQPath(_) => { }
428428

429429
ast::ExprUnary(ast::UnDeref, ref base) => { // *base
430430
if !self.walk_overloaded_operator(expr, &**base, Vec::new(), PassArgs::ByRef) {

src/librustc/middle/liveness.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ fn visit_arm(ir: &mut IrMaps, arm: &ast::Arm) {
447447
fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
448448
match expr.node {
449449
// live nodes required for uses or definitions of variables:
450-
ast::ExprPath(_) => {
450+
ast::ExprPath(_) | ast::ExprQPath(_) => {
451451
let def = ir.tcx.def_map.borrow()[expr.id].clone();
452452
debug!("expr {}: path that leads to {:?}", expr.id, def);
453453
if let DefLocal(..) = def {
@@ -960,7 +960,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
960960
match expr.node {
961961
// Interesting cases with control flow or which gen/kill
962962

963-
ast::ExprPath(_) => {
963+
ast::ExprPath(_) | ast::ExprQPath(_) => {
964964
self.access_path(expr, succ, ACC_READ | ACC_USE)
965965
}
966966

@@ -1289,7 +1289,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
12891289
// just ignore such cases and treat them as reads.
12901290

12911291
match expr.node {
1292-
ast::ExprPath(_) => succ,
1292+
ast::ExprPath(_) | ast::ExprQPath(_) => succ,
12931293
ast::ExprField(ref e, _) => self.propagate_through_expr(&**e, succ),
12941294
ast::ExprTupField(ref e, _) => self.propagate_through_expr(&**e, succ),
12951295
_ => self.propagate_through_expr(expr, succ)
@@ -1300,7 +1300,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
13001300
fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
13011301
-> LiveNode {
13021302
match expr.node {
1303-
ast::ExprPath(_) => self.access_path(expr, succ, acc),
1303+
ast::ExprPath(_) | ast::ExprQPath(_) => {
1304+
self.access_path(expr, succ, acc)
1305+
}
13041306

13051307
// We do not track other lvalues, so just propagate through
13061308
// to their subcomponents. Also, it may happen that
@@ -1492,7 +1494,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14921494
ast::ExprBlock(..) | ast::ExprMac(..) | ast::ExprAddrOf(..) |
14931495
ast::ExprStruct(..) | ast::ExprRepeat(..) | ast::ExprParen(..) |
14941496
ast::ExprClosure(..) | ast::ExprPath(..) | ast::ExprBox(..) |
1495-
ast::ExprRange(..) => {
1497+
ast::ExprRange(..) | ast::ExprQPath(..) => {
14961498
visit::walk_expr(this, expr);
14971499
}
14981500
ast::ExprIfLet(..) => {
@@ -1583,7 +1585,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
15831585

15841586
fn check_lvalue(&mut self, expr: &Expr) {
15851587
match expr.node {
1586-
ast::ExprPath(_) => {
1588+
ast::ExprPath(_) | ast::ExprQPath(_) => {
15871589
if let DefLocal(nid) = self.ir.tcx.def_map.borrow()[expr.id].clone() {
15881590
// Assignment to an immutable variable or argument: only legal
15891591
// if there is no later assignment. If this local is actually

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
520520
}
521521
}
522522

523-
ast::ExprPath(_) => {
523+
ast::ExprPath(_) | ast::ExprQPath(_) => {
524524
let def = (*self.tcx().def_map.borrow())[expr.id];
525525
self.cat_def(expr.id, expr.span, expr_ty, def)
526526
}

0 commit comments

Comments
 (0)