Closed
Description
Currently, the manual states that only "Path, field and index expressions are lvalues." However, this seems inaccurate; for example, *x
should be considered an lvalue.
expr_kind
in src/librustc/middle/ty.rs seems to have the definitive say on what is an lvalue:
match expr.node {
ast::ExprPath(..) | ast::ExprSelf => {
match resolve_expr(tcx, expr) {
ast::DefVariant(..) | ast::DefStruct(..) => RvalueDpsExpr,
// Fn pointers are just scalar values.
ast::DefFn(..) | ast::DefStaticMethod(..) => RvalueDatumExpr,
// Note: there is actually a good case to be made that
// def_args, particularly those of immediate type, ought to
// considered rvalues.
ast::DefStatic(..) |
ast::DefBinding(..) |
ast::DefUpvar(..) |
ast::DefArg(..) |
ast::DefLocal(..) |
ast::DefSelf(..) => LvalueExpr,
def => {
tcx.sess.span_bug(expr.span, format!(
"Uncategorized def for expr {:?}: {:?}",
expr.id, def));
}
}
}
ast::ExprUnary(_, ast::UnDeref, _) |
ast::ExprField(..) |
ast::ExprIndex(..) => {
LvalueExpr
}
[snip]
So, I suggest changing this line to something like, "Paths to memory locations, fields, index expressions and dereferences are lvalues." I can submit a pull request if people agree.
Metadata
Metadata
Assignees
Labels
No labels