Expr,
/// In other contexts, notably in types, no ambiguity exists and paths can be written
/// without the disambiguator, e.g. `x<y>` - unambiguously a path.
- /// Paths with disambiguators are rejected for now, but may be allowed in the future.
+ /// Paths with disambiguators are still accepted, `x::<Y>` - unambiguously a path too.
Type,
/// A path with generic arguments disallowed, e.g. `foo::bar::Baz`, used in imports,
/// visibilities or attributes.
&& self.look_ahead(1, |t| is_args_start(t)) {
// Generic arguments are found - `<`, `(`, `::<` or `::(`.
let lo = self.span;
- if self.eat(&token::ModSep) {
- // These errors are not strictly necessary and may be removed in the future.
- if style == PathStyle::Type {
- let mut err = self.diagnostic().struct_span_err(self.prev_span,
- "unnecessary path disambiguator");
- err.span_label(self.prev_span, "try removing `::`");
- err.emit();
- } else if self.token == token::OpenDelim(token::Paren) {
- self.diagnostic().span_err(self.prev_span,
- "`::` is not supported before parenthesized generic arguments")
- }
- }
+ self.eat(&token::ModSep);
let parameters = if self.eat_lt() {
// `<'a, T, A = U>`
//~^ ERROR parenthesized parameters may only be used with a trait
//~| WARN previously accepted
- macro_rules! pathexpr {
- ($p:path) => { $p }
- }
-
- let p = pathexpr!(::std::str()::from_utf8)(b"foo").unwrap();
+ let p = ::std::str::()::from_utf8(b"foo").unwrap();
//~^ ERROR parenthesized parameters may only be used with a trait
//~| WARN previously accepted
- let p = pathexpr!(::std::str::from_utf8())(b"foo").unwrap();
+ let p = ::std::str::from_utf8::()(b"foo").unwrap();
//~^ ERROR parenthesized parameters may only be used with a trait
//~| WARN previously accepted
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// Unnecessary path disambiguator is ok
+
+#![feature(rustc_attrs)]
+#![allow(unused)]
+
struct Foo<T> {
_a: T,
}
-fn main() {
+fn f() {
let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
- //~^ ERROR unnecessary path disambiguator
- //~| NOTE try removing `::`
-
let g: Foo::<i32> = Foo { _a: 42 };
- //~^ ERROR unnecessary path disambiguator
- //~| NOTE try removing `::`
}
+
+#[rustc_error]
+fn main() {} //~ ERROR compilation successful
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that parentheses form parses in expression paths.
+
+struct Bar<A,R> {
+ f: A, r: R
+}
+
+impl<A,B> Bar<A,B> {
+ fn new() -> Bar<A,B> { panic!() }
+}
+
+fn bar() {
+ let b = Bar::<isize, usize>::new(); // OK
+
+ let b = Bar::(isize, usize)::new(); // OK too (for the parser)
+ //~^ ERROR parenthesized parameters may only be used with a trait
+}
+
+fn main() {}
//~^ ERROR field expressions may not have generic arguments
f.x::<>;
//~^ ERROR field expressions may not have generic arguments
+ f.x::();
+ //~^ ERROR field expressions may not have generic arguments
}
+++ /dev/null
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags: -Z parse-only
-
-// Test that parentheses form doesn't work in expression paths.
-
-struct Bar<A,R> {
- f: A, r: R
-}
-
-impl<A,B> Bar<A,B> {
- fn new() -> Bar<A,B> { panic!() }
-}
-
-fn bar() {
- let b = Box::Bar::<isize,usize>::new(); // OK
-
- let b = Box::Bar::()::new();
- //~^ ERROR `::` is not supported before parenthesized generic arguments
-}
-
-fn main() { }