mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Parser: recover from :::
to ::
in delegations
This commit is contained in:
parent
e90e2593ea
commit
82482dc357
@ -707,7 +707,7 @@ impl<'a> Parser<'a> {
|
||||
})
|
||||
};
|
||||
|
||||
let (ident, item_kind) = if self.eat(&token::PathSep) {
|
||||
let (ident, item_kind) = if self.eat_path_sep() {
|
||||
let suffixes = if self.eat(&token::BinOp(token::Star)) {
|
||||
None
|
||||
} else {
|
||||
|
44
tests/ui/parser/triple-colon-delegation.fixed
Normal file
44
tests/ui/parser/triple-colon-delegation.fixed
Normal file
@ -0,0 +1,44 @@
|
||||
//@ run-rustfix
|
||||
|
||||
#![feature(fn_delegation)]
|
||||
#![allow(incomplete_features, unused)]
|
||||
|
||||
trait Trait {
|
||||
fn foo(&self) {}
|
||||
}
|
||||
|
||||
struct F;
|
||||
impl Trait for F {}
|
||||
|
||||
pub mod to_reuse {
|
||||
pub fn bar() {}
|
||||
}
|
||||
|
||||
mod fn_to_other {
|
||||
use super::*;
|
||||
|
||||
reuse Trait::foo; //~ ERROR path separator must be a double colon
|
||||
reuse to_reuse::bar; //~ ERROR path separator must be a double colon
|
||||
}
|
||||
|
||||
impl Trait for u8 {}
|
||||
|
||||
struct S(u8);
|
||||
|
||||
mod to_import {
|
||||
pub fn check(arg: &u8) -> &u8 { arg }
|
||||
}
|
||||
|
||||
impl Trait for S {
|
||||
reuse Trait::* { //~ ERROR path separator must be a double colon
|
||||
use to_import::check;
|
||||
|
||||
let _arr = Some(self.0).map(|x| [x * 2; 3]);
|
||||
check(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = S(0);
|
||||
s.foo();
|
||||
}
|
44
tests/ui/parser/triple-colon-delegation.rs
Normal file
44
tests/ui/parser/triple-colon-delegation.rs
Normal file
@ -0,0 +1,44 @@
|
||||
//@ run-rustfix
|
||||
|
||||
#![feature(fn_delegation)]
|
||||
#![allow(incomplete_features, unused)]
|
||||
|
||||
trait Trait {
|
||||
fn foo(&self) {}
|
||||
}
|
||||
|
||||
struct F;
|
||||
impl Trait for F {}
|
||||
|
||||
pub mod to_reuse {
|
||||
pub fn bar() {}
|
||||
}
|
||||
|
||||
mod fn_to_other {
|
||||
use super::*;
|
||||
|
||||
reuse Trait:::foo; //~ ERROR path separator must be a double colon
|
||||
reuse to_reuse:::bar; //~ ERROR path separator must be a double colon
|
||||
}
|
||||
|
||||
impl Trait for u8 {}
|
||||
|
||||
struct S(u8);
|
||||
|
||||
mod to_import {
|
||||
pub fn check(arg: &u8) -> &u8 { arg }
|
||||
}
|
||||
|
||||
impl Trait for S {
|
||||
reuse Trait:::* { //~ ERROR path separator must be a double colon
|
||||
use to_import::check;
|
||||
|
||||
let _arr = Some(self.0).map(|x| [x * 2; 3]);
|
||||
check(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = S(0);
|
||||
s.foo();
|
||||
}
|
38
tests/ui/parser/triple-colon-delegation.stderr
Normal file
38
tests/ui/parser/triple-colon-delegation.stderr
Normal file
@ -0,0 +1,38 @@
|
||||
error: path separator must be a double colon
|
||||
--> $DIR/triple-colon-delegation.rs:20:18
|
||||
|
|
||||
LL | reuse Trait:::foo;
|
||||
| ^
|
||||
|
|
||||
help: use a double colon instead
|
||||
|
|
||||
LL - reuse Trait:::foo;
|
||||
LL + reuse Trait::foo;
|
||||
|
|
||||
|
||||
error: path separator must be a double colon
|
||||
--> $DIR/triple-colon-delegation.rs:21:21
|
||||
|
|
||||
LL | reuse to_reuse:::bar;
|
||||
| ^
|
||||
|
|
||||
help: use a double colon instead
|
||||
|
|
||||
LL - reuse to_reuse:::bar;
|
||||
LL + reuse to_reuse::bar;
|
||||
|
|
||||
|
||||
error: path separator must be a double colon
|
||||
--> $DIR/triple-colon-delegation.rs:33:18
|
||||
|
|
||||
LL | reuse Trait:::* {
|
||||
| ^
|
||||
|
|
||||
help: use a double colon instead
|
||||
|
|
||||
LL - reuse Trait:::* {
|
||||
LL + reuse Trait::* {
|
||||
|
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user