Skip to content

Commit cca0ea7

Browse files
committed
Replace illegal with invalid in most diagnostics
1 parent ffcdf08 commit cca0ea7

19 files changed

+61
-62
lines changed

src/librustc/middle/resolve_lifetime.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ impl<'a> LifetimeContext<'a> {
674674
for lifetime in lifetimes {
675675
if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) {
676676
span_err!(self.sess, lifetime.lifetime.span, E0262,
677-
"illegal lifetime parameter name: `{}`",
678-
lifetime.lifetime.name);
677+
"invalid lifetime parameter name: `{}`", lifetime.lifetime.name);
679678
}
680679
}
681680

src/librustc_trans/trans/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
23252325
_ => {
23262326
bcx.tcx().sess.span_bug(
23272327
expr.span,
2328-
&format!("deref invoked on expr of illegal type {:?}",
2328+
&format!("deref invoked on expr of invalid type {:?}",
23292329
datum.ty));
23302330
}
23312331
};

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3468,7 +3468,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
34683468
let tcx = fcx.tcx();
34693469
if !tcx.expr_is_lval(&**lhs) {
34703470
span_err!(tcx.sess, expr.span, E0070,
3471-
"illegal left-hand side expression");
3471+
"invalid left-hand side expression");
34723472
}
34733473

34743474
let lhs_ty = fcx.expr_ty(&**lhs);

src/librustc_typeck/check/op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
5757

5858
let tcx = fcx.tcx();
5959
if !tcx.expr_is_lval(lhs_expr) {
60-
span_err!(tcx.sess, lhs_expr.span, E0067, "illegal left-hand side expression");
60+
span_err!(tcx.sess, lhs_expr.span, E0067, "invalid left-hand side expression");
6161
}
6262

6363
fcx.require_expr_have_sized_type(lhs_expr, traits::AssignmentLhsSized);

src/libsyntax/parse/lexer/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ impl<'a> StringReader<'a> {
694694
accum_int *= 16;
695695
accum_int += c.to_digit(16).unwrap_or_else(|| {
696696
self.err_span_char(self.last_pos, self.pos,
697-
"illegal character in numeric character escape", c);
697+
"invalid character in numeric character escape", c);
698698

699699
valid = false;
700700
0
@@ -714,7 +714,7 @@ impl<'a> StringReader<'a> {
714714
Some(_) => valid,
715715
None => {
716716
let last_bpos = self.last_pos;
717-
self.err_span_(start_bpos, last_bpos, "illegal numeric character escape");
717+
self.err_span_(start_bpos, last_bpos, "invalid numeric character escape");
718718
false
719719
}
720720
}
@@ -846,7 +846,7 @@ impl<'a> StringReader<'a> {
846846
"unterminated unicode escape (needed a `}`)");
847847
} else {
848848
self.err_span_char(self.last_pos, self.pos,
849-
"illegal character in unicode escape", c);
849+
"invalid character in unicode escape", c);
850850
}
851851
valid = false;
852852
0
@@ -862,7 +862,7 @@ impl<'a> StringReader<'a> {
862862
}
863863

864864
if valid && (char::from_u32(accum_int).is_none() || count == 0) {
865-
self.err_span_(start_bpos, self.last_pos, "illegal unicode character escape");
865+
self.err_span_(start_bpos, self.last_pos, "invalid unicode character escape");
866866
valid = false;
867867
}
868868

@@ -1138,8 +1138,8 @@ impl<'a> StringReader<'a> {
11381138
let last_bpos = self.last_pos;
11391139
let curr_char = self.curr.unwrap();
11401140
self.fatal_span_char(start_bpos, last_bpos,
1141-
"only `#` is allowed in raw string delimitation; \
1142-
found illegal character",
1141+
"found invalid character; \
1142+
only `#` is allowed in raw string delimitation",
11431143
curr_char);
11441144
}
11451145
self.bump();
@@ -1323,8 +1323,8 @@ impl<'a> StringReader<'a> {
13231323
let last_pos = self.last_pos;
13241324
let ch = self.curr.unwrap();
13251325
self.fatal_span_char(start_bpos, last_pos,
1326-
"only `#` is allowed in raw string delimitation; \
1327-
found illegal character",
1326+
"found invalid character; \
1327+
only `#` is allowed in raw string delimitation",
13281328
ch);
13291329
}
13301330
self.bump();

src/libsyntax/parse/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,11 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
446446
Some(suf) => {
447447
if suf.len() >= 2 && looks_like_width_suffix(&['f'], suf) {
448448
// if it looks like a width, lets try to be helpful.
449-
sd.span_err(sp, &*format!("illegal width `{}` for float literal, \
450-
valid widths are 32 and 64", &suf[1..]));
449+
sd.span_err(sp, &*format!("invalid width `{}` for float literal", &suf[1..]));
450+
sd.fileline_help(sp, "valid widths are 32 and 64");
451451
} else {
452-
sd.span_err(sp, &*format!("illegal suffix `{}` for float literal, \
453-
valid suffixes are `f32` and `f64`", suf));
452+
sd.span_err(sp, &*format!("invalid suffix `{}` for float literal", suf));
453+
sd.fileline_help(sp, "valid suffixes are `f32` and `f64`");
454454
}
455455

456456
ast::LitFloatUnsuffixed(data)
@@ -619,11 +619,11 @@ pub fn integer_lit(s: &str,
619619
// i<digits> and u<digits> look like widths, so lets
620620
// give an error message along those lines
621621
if looks_like_width_suffix(&['i', 'u'], suf) {
622-
sd.span_err(sp, &*format!("illegal width `{}` for integer literal; \
623-
valid widths are 8, 16, 32 and 64",
622+
sd.span_err(sp, &*format!("invalid width `{}` for integer literal",
624623
&suf[1..]));
624+
sd.fileline_help(sp, "valid widths are 8, 16, 32 and 64");
625625
} else {
626-
sd.span_err(sp, &*format!("illegal suffix `{}` for numeric literal", suf));
626+
sd.span_err(sp, &*format!("invalid suffix `{}` for numeric literal", suf));
627627
sd.fileline_help(sp, "the suffix must be one of the integral types \
628628
(`u32`, `isize`, etc)");
629629
}

src/libsyntax/parse/parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ impl<'a> Parser<'a> {
681681
if text.is_empty() {
682682
self.span_bug(sp, "found empty literal suffix in Some")
683683
}
684-
self.span_err(sp, &*format!("{} with a suffix is illegal", kind));
684+
self.span_err(sp, &*format!("{} with a suffix is invalid", kind));
685685
}
686686
}
687687
}
@@ -5286,7 +5286,7 @@ impl<'a> Parser<'a> {
52865286
let last_span = self.last_span;
52875287
self.span_err(
52885288
last_span,
5289-
&format!("illegal ABI: expected one of [{}], \
5289+
&format!("invalid ABI: expected one of [{}], \
52905290
found `{}`",
52915291
abi::all_names().join(", "),
52925292
s));

src/test/compile-fail/bad-expr-lhs.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
1 = 2; //~ ERROR illegal left-hand side expression
13-
1 += 2; //~ ERROR illegal left-hand side expression
14-
(1, 2) = (3, 4); //~ ERROR illegal left-hand side expression
12+
1 = 2; //~ ERROR invalid left-hand side expression
13+
1 += 2; //~ ERROR invalid left-hand side expression
14+
(1, 2) = (3, 4); //~ ERROR invalid left-hand side expression
1515

1616
let (a, b) = (1, 2);
17-
(a, b) = (3, 4); //~ ERROR illegal left-hand side expression
17+
(a, b) = (3, 4); //~ ERROR invalid left-hand side expression
1818

19-
None = Some(3); //~ ERROR illegal left-hand side expression
19+
None = Some(3); //~ ERROR invalid left-hand side expression
2020
}

src/test/compile-fail/issue-13407.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ mod A {
1414

1515
fn main() {
1616
A::C = 1;
17-
//~^ ERROR: illegal left-hand side expression
17+
//~^ ERROR: invalid left-hand side expression
1818
//~| ERROR: mismatched types
1919
}

src/test/compile-fail/old-suffixes-are-really-forbidden.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let a = 1_is; //~ ERROR illegal suffix
13-
let b = 2_us; //~ ERROR illegal suffix
12+
let a = 1_is; //~ ERROR invalid suffix
13+
let b = 2_us; //~ ERROR invalid suffix
1414
}

src/test/compile-fail/regions-name-static.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
struct Foo<'static> { //~ ERROR illegal lifetime parameter name: `'static`
11+
struct Foo<'static> { //~ ERROR invalid lifetime parameter name: `'static`
1212
x: &'static isize
1313
}
1414

src/test/parse-fail/bad-lit-suffixes.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@
1212

1313

1414
extern
15-
"C"suffix //~ ERROR ABI spec with a suffix is illegal
15+
"C"suffix //~ ERROR ABI spec with a suffix is invalid
1616
fn foo() {}
1717

1818
extern
19-
"C"suffix //~ ERROR ABI spec with a suffix is illegal
19+
"C"suffix //~ ERROR ABI spec with a suffix is invalid
2020
{}
2121

2222
fn main() {
23-
""suffix; //~ ERROR str literal with a suffix is illegal
24-
b""suffix; //~ ERROR binary str literal with a suffix is illegal
25-
r#""#suffix; //~ ERROR str literal with a suffix is illegal
26-
br#""#suffix; //~ ERROR binary str literal with a suffix is illegal
27-
'a'suffix; //~ ERROR char literal with a suffix is illegal
28-
b'a'suffix; //~ ERROR byte literal with a suffix is illegal
23+
""suffix; //~ ERROR str literal with a suffix is invalid
24+
b""suffix; //~ ERROR binary str literal with a suffix is invalid
25+
r#""#suffix; //~ ERROR str literal with a suffix is invalid
26+
br#""#suffix; //~ ERROR binary str literal with a suffix is invalid
27+
'a'suffix; //~ ERROR char literal with a suffix is invalid
28+
b'a'suffix; //~ ERROR byte literal with a suffix is invalid
2929

30-
1234u1024; //~ ERROR illegal width `1024` for integer literal
31-
1234i1024; //~ ERROR illegal width `1024` for integer literal
32-
1234f1024; //~ ERROR illegal width `1024` for float literal
33-
1234.5f1024; //~ ERROR illegal width `1024` for float literal
30+
1234u1024; //~ ERROR invalid width `1024` for integer literal
31+
1234i1024; //~ ERROR invalid width `1024` for integer literal
32+
1234f1024; //~ ERROR invalid width `1024` for float literal
33+
1234.5f1024; //~ ERROR invalid width `1024` for float literal
3434

35-
1234suffix; //~ ERROR illegal suffix `suffix` for numeric literal
36-
0b101suffix; //~ ERROR illegal suffix `suffix` for numeric literal
37-
1.0suffix; //~ ERROR illegal suffix `suffix` for float literal
38-
1.0e10suffix; //~ ERROR illegal suffix `suffix` for float literal
35+
1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal
36+
0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal
37+
1.0suffix; //~ ERROR invalid suffix `suffix` for float literal
38+
1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal
3939
}

src/test/parse-fail/byte-literals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static FOO: u8 = b'\f'; //~ ERROR unknown byte escape
1717

1818
pub fn main() {
1919
b'\f'; //~ ERROR unknown byte escape
20-
b'\x0Z'; //~ ERROR illegal character in numeric character escape: Z
20+
b'\x0Z'; //~ ERROR invalid character in numeric character escape: Z
2121
b' '; //~ ERROR byte constant must be escaped
2222
b'''; //~ ERROR byte constant must be escaped
2323
b'é'; //~ ERROR byte constant must be ASCII

src/test/parse-fail/byte-string-literals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape
1717

1818
pub fn main() {
1919
b"\f"; //~ ERROR unknown byte escape
20-
b"\x0Z"; //~ ERROR illegal character in numeric character escape: Z
20+
b"\x0Z"; //~ ERROR invalid character in numeric character escape: Z
2121
b"é"; //~ ERROR byte constant must be ASCII
2222
b"a //~ ERROR unterminated double quote byte string
2323
}

src/test/parse-fail/issue-23620-invalid-escapes.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@ fn main() {
2323
//~^ ERROR numeric character escape is too short
2424

2525
let _ = b'\xxy';
26-
//~^ ERROR illegal character in numeric character escape: x
27-
//~^^ ERROR illegal character in numeric character escape: y
26+
//~^ ERROR invalid character in numeric character escape: x
27+
//~^^ ERROR invalid character in numeric character escape: y
2828

2929
let _ = '\x5';
3030
//~^ ERROR numeric character escape is too short
3131

3232
let _ = '\xxy';
33-
//~^ ERROR illegal character in numeric character escape: x
34-
//~^^ ERROR illegal character in numeric character escape: y
33+
//~^ ERROR invalid character in numeric character escape: x
34+
//~^^ ERROR invalid character in numeric character escape: y
3535

3636
let _ = b"\u{a4a4} \xf \u";
3737
//~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
38-
//~^^ ERROR illegal character in numeric character escape:
38+
//~^^ ERROR invalid character in numeric character escape:
3939
//~^^^ ERROR incorrect unicode escape sequence
4040
//~^^^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string
4141

4242
let _ = "\u{ffffff} \xf \u";
43-
//~^ ERROR illegal unicode character escape
44-
//~^^ ERROR illegal character in numeric character escape:
43+
//~^ ERROR invalid unicode character escape
44+
//~^^ ERROR invalid character in numeric character escape:
4545
//~^^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f]
4646
//~^^^^ ERROR incorrect unicode escape sequence
4747
}

src/test/parse-fail/issue-8537.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// compile-flags: -Z parse-only
1212

1313
pub extern
14-
"invalid-ab_isize" //~ ERROR illegal ABI
14+
"invalid-ab_isize" //~ ERROR invalid ABI
1515
fn foo() {}
1616

1717
fn main() {}

src/test/parse-fail/new-unicode-escapes-3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
// compile-flags: -Z parse-only
1212

1313
pub fn main() {
14-
let s = "\u{d805}"; //~ ERROR illegal unicode character escape
14+
let s = "\u{d805}"; //~ ERROR invalid unicode character escape
1515
}

src/test/parse-fail/new-unicode-escapes-4.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
pub fn main() {
1414
let s = "\u{lol}";
15-
//~^ ERROR illegal character in unicode escape: l
16-
//~^^ ERROR illegal character in unicode escape: o
17-
//~^^^ ERROR illegal character in unicode escape: l
15+
//~^ ERROR invalid character in unicode escape: l
16+
//~^^ ERROR invalid character in unicode escape: o
17+
//~^^^ ERROR invalid character in unicode escape: l
1818
}

src/test/parse-fail/raw-str-delim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
// compile-flags: -Z parse-only
1212

1313
static s: &'static str =
14-
r#x"#"x# //~ ERROR only `#` is allowed in raw string delimitation; found illegal character
14+
r#x"#"x# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation
1515
;

0 commit comments

Comments
 (0)