mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
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)?;
|
||||
let span = tilde.to(self.prev_token.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)
|
||||
} else {
|
||||
None
|
||||
|
@ -3,5 +3,4 @@
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
struct S<T: const Tr>;
|
||||
//~^ ERROR expected identifier, found keyword `const`
|
||||
//~| ERROR expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`, found `Tr`
|
||||
//~^ ERROR const bounds must start with `~`
|
||||
|
@ -1,14 +1,10 @@
|
||||
error: expected identifier, found keyword `const`
|
||||
error: const bounds must start with `~`
|
||||
--> $DIR/without-tilde.rs:5:13
|
||||
|
|
||||
LL | struct S<T: const Tr>;
|
||||
| ^^^^^ expected identifier, found keyword
|
||||
| -^^^^
|
||||
| |
|
||||
| help: add `~`: `~`
|
||||
|
||||
error: expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`, found `Tr`
|
||||
--> $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
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user