recover const Tr
bounds (no ~
)
This commit is contained in:
parent
798016c2df
commit
5d5e451618
@ -809,6 +809,20 @@ impl<'a> Parser<'a> {
|
|||||||
self.expect_keyword(kw::Const)?;
|
self.expect_keyword(kw::Const)?;
|
||||||
let span = tilde.to(self.prev_token.span);
|
let span = tilde.to(self.prev_token.span);
|
||||||
self.sess.gated_spans.gate(sym::const_trait_impl, span);
|
self.sess.gated_spans.gate(sym::const_trait_impl, span);
|
||||||
|
Some(span)
|
||||||
|
} else if self.eat_keyword(kw::Const) {
|
||||||
|
let span = self.prev_token.span;
|
||||||
|
self.sess.gated_spans.gate(sym::const_trait_impl, span);
|
||||||
|
|
||||||
|
self.struct_span_err(span, "const bounds must start with `~`")
|
||||||
|
.span_suggestion(
|
||||||
|
span.shrink_to_lo(),
|
||||||
|
"add `~`",
|
||||||
|
"~",
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
|
||||||
Some(span)
|
Some(span)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -3,5 +3,4 @@
|
|||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
|
|
||||||
struct S<T: const Tr>;
|
struct S<T: const Tr>;
|
||||||
//~^ ERROR expected identifier, found keyword `const`
|
//~^ ERROR const bounds must start with `~`
|
||||||
//~| ERROR expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`, found `Tr`
|
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
error: expected identifier, found keyword `const`
|
error: const bounds must start with `~`
|
||||||
--> $DIR/without-tilde.rs:5:13
|
--> $DIR/without-tilde.rs:5:13
|
||||||
|
|
|
|
||||||
LL | struct S<T: const Tr>;
|
LL | struct S<T: const Tr>;
|
||||||
| ^^^^^ expected identifier, found keyword
|
| -^^^^
|
||||||
|
| |
|
||||||
|
| help: add `~`: `~`
|
||||||
|
|
||||||
error: expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`, found `Tr`
|
error: aborting due to previous error
|
||||||
--> $DIR/without-tilde.rs:5:19
|
|
||||||
|
|
|
||||||
LL | struct S<T: const Tr>;
|
|
||||||
| ^^ expected one of 7 possible tokens
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user