diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-12-31 17:24:42 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2015-01-02 23:05:22 +1300 |
| commit | 74d11d26f4042ce04c56edfd6caafa003383147d (patch) | |
| tree | 5ebb81f029eeed8ea0ff4d9c492cc718dc43316f /src | |
| parent | ee3c5957eaaf577bff895ce819447f7e40558a28 (diff) | |
| download | rust-74d11d26f4042ce04c56edfd6caafa003383147d.tar.gz rust-74d11d26f4042ce04c56edfd6caafa003383147d.zip | |
Accept `self` in place of `mod` in use items
[breaking-change] `mod` is still accepted, but gives a deprecated warning
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_resolve/build_reduced_graph.rs | 11 | ||||
| -rw-r--r-- | src/librustc_resolve/lib.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 7dbcc810b57..efb9b636247 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -681,9 +681,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> { ViewPathSimple(binding, ref full_path, id) => { let source_name = full_path.segments.last().unwrap().identifier.name; - if token::get_name(source_name).get() == "mod" { + if token::get_name(source_name).get() == "mod" || + token::get_name(source_name).get() == "self" { self.resolve_error(view_path.span, - "`mod` imports are only allowed within a { } list"); + "`self` imports are only allowed within a { } list"); } let subclass = SingleImport(binding.name, @@ -704,10 +705,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> { }).collect::<Vec<Span>>(); if mod_spans.len() > 1 { self.resolve_error(mod_spans[0], - "`mod` import can only appear once in the list"); + "`self` import can only appear once in the list"); for other_span in mod_spans.iter().skip(1) { self.session.span_note(*other_span, - "another `mod` import appears here"); + "another `self` import appears here"); } } @@ -720,7 +721,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> { Some(name) => *name, None => { self.resolve_error(source_item.span, - "`mod` import can only appear in an import list \ + "`self` import can only appear in an import list \ with a non-empty prefix"); continue; } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 10756f21551..11328bedcc4 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -971,6 +971,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } + // Import resolution // // This is a fixed-point algorithm. We resolve imports until our efforts diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 457085f5cc8..f84ddcf360e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -546,6 +546,10 @@ impl<'a> Parser<'a> { pub fn parse_path_list_item(&mut self) -> ast::PathListItem { let lo = self.span.lo; let node = if self.eat_keyword(keywords::Mod) { + let span = self.last_span; + self.span_warn(span, "deprecated syntax; use the `self` keyword now"); + ast::PathListMod { id: ast::DUMMY_NODE_ID } + } else if self.eat_keyword(keywords::Self) { ast::PathListMod { id: ast::DUMMY_NODE_ID } } else { let ident = self.parse_ident(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 02a03285d3b..877b2c7b7d3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2540,7 +2540,7 @@ impl<'a> State<'a> { s.print_ident(name) }, ast::PathListMod { .. } => { - word(&mut s.s, "mod") + word(&mut s.s, "self") } } })); |
