Print an error if we try to refer to a module in an expr_path.
This commit is contained in:
parent
9e2324ad1e
commit
1b82060c5e
3 changed files with 22 additions and 1 deletions
|
|
@ -504,6 +504,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
|
|||
arg-count-mismatch.rs \
|
||||
arg-type-mismatch.rs \
|
||||
bad-expr-path.rs \
|
||||
bad-expr-path2.rs \
|
||||
import.rs \
|
||||
import2.rs \
|
||||
import3.rs \
|
||||
|
|
|
|||
|
|
@ -444,7 +444,17 @@ fn fold_expr_path(&env e, &span sp, &ast.path p, &option.t[def] d,
|
|||
// the expr_field(expr_field(...(expr_path(...)))) we should return.
|
||||
|
||||
auto index = new_def_hash[def_wrap]();
|
||||
find_final_def(e, index, sp, p.node.idents, none[ast.def_id]);
|
||||
auto d = find_final_def(e, index, sp, p.node.idents, none[ast.def_id]);
|
||||
alt (d) {
|
||||
case (def_wrap_expr_field(_)) {
|
||||
}
|
||||
case (def_wrap_other(_)) {
|
||||
}
|
||||
case (def_wrap_mod(?m)) {
|
||||
e.sess.span_err(sp,
|
||||
"can't refer to a module as a first-class value");
|
||||
}
|
||||
}
|
||||
|
||||
auto p_ = rec(node=rec(idents = vec(id0) with p.node) with p);
|
||||
auto ex = @fold.respan[ast.expr_](sp, ast.expr_path(p_, d_, a));
|
||||
|
|
|
|||
10
src/test/compile-fail/bad-expr-path2.rs
Normal file
10
src/test/compile-fail/bad-expr-path2.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// error-pattern: can't refer to a module as a first-class value
|
||||
|
||||
mod m1 {
|
||||
mod a {
|
||||
}
|
||||
}
|
||||
|
||||
fn main(vec[str] args) {
|
||||
log m1.a;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue