Small tweaks to parser errors
This commit is contained in:
parent
de3c4be099
commit
7feb802d89
5 changed files with 39 additions and 24 deletions
|
@ -1012,7 +1012,10 @@ impl<'a> Parser<'a> {
|
||||||
if text.is_empty() {
|
if text.is_empty() {
|
||||||
self.span_bug(sp, "found empty literal suffix in Some")
|
self.span_bug(sp, "found empty literal suffix in Some")
|
||||||
}
|
}
|
||||||
self.span_err(sp, &format!("{} with a suffix is invalid", kind));
|
let msg = format!("{} with a suffix is invalid", kind);
|
||||||
|
self.struct_span_err(sp, &msg)
|
||||||
|
.span_label(sp, msg)
|
||||||
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1768,9 +1771,11 @@ impl<'a> Parser<'a> {
|
||||||
Mutability::Immutable
|
Mutability::Immutable
|
||||||
} else {
|
} else {
|
||||||
let span = self.prev_span;
|
let span = self.prev_span;
|
||||||
self.span_err(span,
|
let msg = "expected mut or const in raw pointer type";
|
||||||
"expected mut or const in raw pointer type (use \
|
self.struct_span_err(span, msg)
|
||||||
`*mut T` or `*const T` as appropriate)");
|
.span_label(span, msg)
|
||||||
|
.help("use `*mut T` or `*const T` as appropriate")
|
||||||
|
.emit();
|
||||||
Mutability::Immutable
|
Mutability::Immutable
|
||||||
};
|
};
|
||||||
let t = self.parse_ty_no_plus()?;
|
let t = self.parse_ty_no_plus()?;
|
||||||
|
@ -5612,15 +5617,20 @@ impl<'a> Parser<'a> {
|
||||||
// *mut self
|
// *mut self
|
||||||
// *not_self
|
// *not_self
|
||||||
// Emit special error for `self` cases.
|
// Emit special error for `self` cases.
|
||||||
|
let msg = "cannot pass `self` by raw pointer";
|
||||||
(if isolated_self(self, 1) {
|
(if isolated_self(self, 1) {
|
||||||
self.bump();
|
self.bump();
|
||||||
self.span_err(self.span, "cannot pass `self` by raw pointer");
|
self.struct_span_err(self.span, msg)
|
||||||
|
.span_label(self.span, msg)
|
||||||
|
.emit();
|
||||||
SelfKind::Value(Mutability::Immutable)
|
SelfKind::Value(Mutability::Immutable)
|
||||||
} else if self.look_ahead(1, |t| t.is_mutability()) &&
|
} else if self.look_ahead(1, |t| t.is_mutability()) &&
|
||||||
isolated_self(self, 2) {
|
isolated_self(self, 2) {
|
||||||
self.bump();
|
self.bump();
|
||||||
self.bump();
|
self.bump();
|
||||||
self.span_err(self.span, "cannot pass `self` by raw pointer");
|
self.struct_span_err(self.span, msg)
|
||||||
|
.span_label(self.span, msg)
|
||||||
|
.emit();
|
||||||
SelfKind::Value(Mutability::Immutable)
|
SelfKind::Value(Mutability::Immutable)
|
||||||
} else {
|
} else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
|
@ -5957,7 +5967,10 @@ impl<'a> Parser<'a> {
|
||||||
tps.where_clause = self.parse_where_clause()?;
|
tps.where_clause = self.parse_where_clause()?;
|
||||||
self.expect(&token::Semi)?;
|
self.expect(&token::Semi)?;
|
||||||
if unsafety != Unsafety::Normal {
|
if unsafety != Unsafety::Normal {
|
||||||
self.span_err(self.prev_span, "trait aliases cannot be unsafe");
|
let msg = "trait aliases cannot be unsafe";
|
||||||
|
self.struct_span_err(self.prev_span, msg)
|
||||||
|
.span_label(self.prev_span, msg)
|
||||||
|
.emit();
|
||||||
}
|
}
|
||||||
Ok((ident, ItemKind::TraitAlias(tps, bounds), None))
|
Ok((ident, ItemKind::TraitAlias(tps, bounds), None))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,49 +2,49 @@ error: ABI spec with a suffix is invalid
|
||||||
--> $DIR/bad-lit-suffixes.rs:5:5
|
--> $DIR/bad-lit-suffixes.rs:5:5
|
||||||
|
|
|
|
||||||
LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid
|
LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ ABI spec with a suffix is invalid
|
||||||
|
|
||||||
error: ABI spec with a suffix is invalid
|
error: ABI spec with a suffix is invalid
|
||||||
--> $DIR/bad-lit-suffixes.rs:9:5
|
--> $DIR/bad-lit-suffixes.rs:9:5
|
||||||
|
|
|
|
||||||
LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid
|
LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ ABI spec with a suffix is invalid
|
||||||
|
|
||||||
error: string literal with a suffix is invalid
|
error: string literal with a suffix is invalid
|
||||||
--> $DIR/bad-lit-suffixes.rs:13:5
|
--> $DIR/bad-lit-suffixes.rs:13:5
|
||||||
|
|
|
|
||||||
LL | ""suffix; //~ ERROR string literal with a suffix is invalid
|
LL | ""suffix; //~ ERROR string literal with a suffix is invalid
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^ string literal with a suffix is invalid
|
||||||
|
|
||||||
error: byte string literal with a suffix is invalid
|
error: byte string literal with a suffix is invalid
|
||||||
--> $DIR/bad-lit-suffixes.rs:14:5
|
--> $DIR/bad-lit-suffixes.rs:14:5
|
||||||
|
|
|
|
||||||
LL | b""suffix; //~ ERROR byte string literal with a suffix is invalid
|
LL | b""suffix; //~ ERROR byte string literal with a suffix is invalid
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ byte string literal with a suffix is invalid
|
||||||
|
|
||||||
error: string literal with a suffix is invalid
|
error: string literal with a suffix is invalid
|
||||||
--> $DIR/bad-lit-suffixes.rs:15:5
|
--> $DIR/bad-lit-suffixes.rs:15:5
|
||||||
|
|
|
|
||||||
LL | r#""#suffix; //~ ERROR string literal with a suffix is invalid
|
LL | r#""#suffix; //~ ERROR string literal with a suffix is invalid
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^ string literal with a suffix is invalid
|
||||||
|
|
||||||
error: byte string literal with a suffix is invalid
|
error: byte string literal with a suffix is invalid
|
||||||
--> $DIR/bad-lit-suffixes.rs:16:5
|
--> $DIR/bad-lit-suffixes.rs:16:5
|
||||||
|
|
|
|
||||||
LL | br#""#suffix; //~ ERROR byte string literal with a suffix is invalid
|
LL | br#""#suffix; //~ ERROR byte string literal with a suffix is invalid
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^ byte string literal with a suffix is invalid
|
||||||
|
|
||||||
error: char literal with a suffix is invalid
|
error: char literal with a suffix is invalid
|
||||||
--> $DIR/bad-lit-suffixes.rs:17:5
|
--> $DIR/bad-lit-suffixes.rs:17:5
|
||||||
|
|
|
|
||||||
LL | 'a'suffix; //~ ERROR char literal with a suffix is invalid
|
LL | 'a'suffix; //~ ERROR char literal with a suffix is invalid
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ char literal with a suffix is invalid
|
||||||
|
|
||||||
error: byte literal with a suffix is invalid
|
error: byte literal with a suffix is invalid
|
||||||
--> $DIR/bad-lit-suffixes.rs:18:5
|
--> $DIR/bad-lit-suffixes.rs:18:5
|
||||||
|
|
|
|
||||||
LL | b'a'suffix; //~ ERROR byte literal with a suffix is invalid
|
LL | b'a'suffix; //~ ERROR byte literal with a suffix is invalid
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^ byte literal with a suffix is invalid
|
||||||
|
|
||||||
error: invalid width `1024` for integer literal
|
error: invalid width `1024` for integer literal
|
||||||
--> $DIR/bad-lit-suffixes.rs:20:5
|
--> $DIR/bad-lit-suffixes.rs:20:5
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fn foo(_: *()) {
|
fn foo(_: *()) {
|
||||||
//~^ expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
|
//~^ ERROR expected mut or const in raw pointer type
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
error: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
|
error: expected mut or const in raw pointer type
|
||||||
--> $DIR/bad-pointer-type.rs:1:11
|
--> $DIR/bad-pointer-type.rs:1:11
|
||||||
|
|
|
|
||||||
LL | fn foo(_: *()) {
|
LL | fn foo(_: *()) {
|
||||||
| ^
|
| ^ expected mut or const in raw pointer type
|
||||||
|
|
|
||||||
|
= help: use `*mut T` or `*const T` as appropriate
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,37 +2,37 @@ error: cannot pass `self` by raw pointer
|
||||||
--> $DIR/no-unsafe-self.rs:4:17
|
--> $DIR/no-unsafe-self.rs:4:17
|
||||||
|
|
|
|
||||||
LL | fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer
|
LL | fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer
|
||||||
| ^^^^
|
| ^^^^ cannot pass `self` by raw pointer
|
||||||
|
|
||||||
error: cannot pass `self` by raw pointer
|
error: cannot pass `self` by raw pointer
|
||||||
--> $DIR/no-unsafe-self.rs:5:19
|
--> $DIR/no-unsafe-self.rs:5:19
|
||||||
|
|
|
|
||||||
LL | fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer
|
LL | fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer
|
||||||
| ^^^^
|
| ^^^^ cannot pass `self` by raw pointer
|
||||||
|
|
||||||
error: cannot pass `self` by raw pointer
|
error: cannot pass `self` by raw pointer
|
||||||
--> $DIR/no-unsafe-self.rs:6:13
|
--> $DIR/no-unsafe-self.rs:6:13
|
||||||
|
|
|
|
||||||
LL | fn bar(*self); //~ ERROR cannot pass `self` by raw pointer
|
LL | fn bar(*self); //~ ERROR cannot pass `self` by raw pointer
|
||||||
| ^^^^
|
| ^^^^ cannot pass `self` by raw pointer
|
||||||
|
|
||||||
error: cannot pass `self` by raw pointer
|
error: cannot pass `self` by raw pointer
|
||||||
--> $DIR/no-unsafe-self.rs:11:17
|
--> $DIR/no-unsafe-self.rs:11:17
|
||||||
|
|
|
|
||||||
LL | fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer
|
LL | fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer
|
||||||
| ^^^^
|
| ^^^^ cannot pass `self` by raw pointer
|
||||||
|
|
||||||
error: cannot pass `self` by raw pointer
|
error: cannot pass `self` by raw pointer
|
||||||
--> $DIR/no-unsafe-self.rs:12:19
|
--> $DIR/no-unsafe-self.rs:12:19
|
||||||
|
|
|
|
||||||
LL | fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer
|
LL | fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer
|
||||||
| ^^^^
|
| ^^^^ cannot pass `self` by raw pointer
|
||||||
|
|
||||||
error: cannot pass `self` by raw pointer
|
error: cannot pass `self` by raw pointer
|
||||||
--> $DIR/no-unsafe-self.rs:13:13
|
--> $DIR/no-unsafe-self.rs:13:13
|
||||||
|
|
|
|
||||||
LL | fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer
|
LL | fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer
|
||||||
| ^^^^
|
| ^^^^ cannot pass `self` by raw pointer
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue