Skip to content

Commit

Permalink
Rollup merge of rust-lang#67835 - euclio:delimiter-wording, r=Centril
Browse files Browse the repository at this point in the history
tweak wording of mismatched delimiter errors

This PR improves the wording of the "incorrect delimiter" error messages. Here's a quick rationale:

- *"un-closed" -> "unclosed"*: "unclosed" is valid English, so there's no need to hyphenate the prefix. This should be pretty uncontroversial, I think.
- *"close delimiter" -> "closing delimiter"*: In my anecdotal experience, I've always heard "closing delimiter" or "closing parenthesis". In addition, the codebase already uses this terminology in comments and function names more than "close delimiter", which could indicate that it's more intuitive.
- "incorrect delimiter" -> "mismatched delimiter": "Incorrect delimiter" is vague; why is it incorrect? "mismatched" clearly indicates why the delimiter is causing the error.

r? @estebank
  • Loading branch information
Centril authored Jan 4, 2020
2 parents b32dc91 + 7fd014d commit 689e29f
Show file tree
Hide file tree
Showing 50 changed files with 135 additions and 135 deletions.
10 changes: 5 additions & 5 deletions src/librustc_parse/lexer/tokentrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ impl<'a> TokenTreesReader<'a> {
let sm = self.string_reader.sess.source_map();
match self.token.kind {
token::Eof => {
let msg = "this file contains an un-closed delimiter";
let msg = "this file contains an unclosed delimiter";
let mut err =
self.string_reader.sess.span_diagnostic.struct_span_err(self.token.span, msg);
for &(_, sp) in &self.open_braces {
err.span_label(sp, "un-closed delimiter");
err.span_label(sp, "unclosed delimiter");
self.unmatched_braces.push(UnmatchedBrace {
expected_delim: token::DelimToken::Brace,
found_delim: None,
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'a> TokenTreesReader<'a> {
close_brace_span,
));
}
// Parse the close delimiter.
// Parse the closing delimiter.
self.real_token();
}
// Incorrect delimiter.
Expand Down Expand Up @@ -218,7 +218,7 @@ impl<'a> TokenTreesReader<'a> {
// An unexpected closing delimiter (i.e., there is no
// matching opening delimiter).
let token_str = token_to_string(&self.token);
let msg = format!("unexpected close delimiter: `{}`", token_str);
let msg = format!("unexpected closing delimiter: `{}`", token_str);
let mut err =
self.string_reader.sess.span_diagnostic.struct_span_err(self.token.span, &msg);

Expand All @@ -228,7 +228,7 @@ impl<'a> TokenTreesReader<'a> {
"this block is empty, you might have not meant to close it",
);
}
err.span_label(self.token.span, "unexpected close delimiter");
err.span_label(self.token.span, "unexpected closing delimiter");
Err(err)
}
_ => {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,16 +1354,16 @@ crate fn make_unclosed_delims_error(
let mut err = sess.span_diagnostic.struct_span_err(
unmatched.found_span,
&format!(
"incorrect close delimiter: `{}`",
"mismatched closing delimiter: `{}`",
pprust::token_kind_to_string(&token::CloseDelim(found_delim)),
),
);
err.span_label(unmatched.found_span, "incorrect close delimiter");
err.span_label(unmatched.found_span, "mismatched closing delimiter");
if let Some(sp) = unmatched.candidate_span {
err.span_label(sp, "close delimiter possibly meant for this");
err.span_label(sp, "closing delimiter possibly meant for this");
}
if let Some(sp) = unmatched.unclosed_span {
err.span_label(sp, "un-closed delimiter");
err.span_label(sp, "unclosed delimiter");
}
Some(err)
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-62554.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ fn main() {}

fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
//~^ ERROR expected `{`, found `macro_rules`
//~ ERROR this file contains an un-closed delimiter
//~ ERROR this file contains an unclosed delimiter
14 changes: 7 additions & 7 deletions src/test/ui/issues/issue-62554.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
error: this file contains an un-closed delimiter
--> $DIR/issue-62554.rs:5:53
error: this file contains an unclosed delimiter
--> $DIR/issue-62554.rs:5:52
|
LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
| - - - - - un-closed delimiter
| - - - - - unclosed delimiter
| | | | |
| | | | un-closed delimiter
| | | un-closed delimiter
| un-closed delimiter un-closed delimiter
| | | | unclosed delimiter
| | | unclosed delimiter
| unclosed delimiter unclosed delimiter
LL |
LL |
| ^
| ^

error: expected `{`, found `macro_rules`
--> $DIR/issue-62554.rs:3:23
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser-recovery-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ fn main() {
let x = y.;
//~^ ERROR unexpected token
//~| ERROR cannot find value `y` in this scope
} //~ ERROR this file contains an un-closed delimiter
} //~ ERROR this file contains an unclosed delimiter
8 changes: 4 additions & 4 deletions src/test/ui/parser-recovery-1.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error: this file contains an un-closed delimiter
--> $DIR/parser-recovery-1.rs:15:55
error: this file contains an unclosed delimiter
--> $DIR/parser-recovery-1.rs:15:54
|
LL | trait Foo {
| - un-closed delimiter
| - unclosed delimiter
LL | fn bar() {
| - this delimiter might not be properly closed...
...
LL | }
| - ...as it matches this but it has different indentation
...
LL | }
| ^
| ^

error: unexpected token: `;`
--> $DIR/parser-recovery-1.rs:12:15
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser-recovery-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
trait Foo {
fn bar() {
let x = foo(); //~ ERROR cannot find function `foo` in this scope
) //~ ERROR incorrect close delimiter: `)`
) //~ ERROR mismatched closing delimiter: `)`
}

fn main() {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/parser-recovery-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ error: unexpected token: `;`
LL | let x = y.;
| ^

error: incorrect close delimiter: `)`
error: mismatched closing delimiter: `)`
--> $DIR/parser-recovery-2.rs:8:5
|
LL | fn bar() {
| - un-closed delimiter
| - unclosed delimiter
LL | let x = foo();
LL | )
| ^ incorrect close delimiter
| ^ mismatched closing delimiter

error[E0425]: cannot find function `foo` in this scope
--> $DIR/parser-recovery-2.rs:7:17
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/parser/issue-10636-1.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
struct Obj {
//~^ NOTE: un-closed delimiter
//~^ NOTE: unclosed delimiter
member: usize
)
//~^ ERROR incorrect close delimiter
//~| NOTE incorrect close delimiter
//~^ ERROR mismatched closing delimiter
//~| NOTE mismatched closing delimiter

fn main() {}
6 changes: 3 additions & 3 deletions src/test/ui/parser/issue-10636-1.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: incorrect close delimiter: `)`
error: mismatched closing delimiter: `)`
--> $DIR/issue-10636-1.rs:4:1
|
LL | struct Obj {
| - un-closed delimiter
| - unclosed delimiter
...
LL | )
| ^ incorrect close delimiter
| ^ mismatched closing delimiter

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/parser/issue-2354-1.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
static foo: isize = 2; } //~ ERROR unexpected close delimiter:
static foo: isize = 2; } //~ ERROR unexpected closing delimiter:
4 changes: 2 additions & 2 deletions src/test/ui/parser/issue-2354-1.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: unexpected close delimiter: `}`
error: unexpected closing delimiter: `}`
--> $DIR/issue-2354-1.rs:1:24
|
LL | static foo: isize = 2; }
| ^ unexpected close delimiter
| ^ unexpected closing delimiter

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/parser/issue-2354.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn foo() { //~ NOTE un-closed delimiter
fn foo() { //~ NOTE unclosed delimiter
match Some(10) {
//~^ NOTE this delimiter might not be properly closed...
Some(y) => { panic!(); }
Expand All @@ -12,4 +12,4 @@ fn bar() {
}

fn main() {}
//~ ERROR this file contains an un-closed delimiter
//~ ERROR this file contains an unclosed delimiter
8 changes: 4 additions & 4 deletions src/test/ui/parser/issue-2354.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error: this file contains an un-closed delimiter
--> $DIR/issue-2354.rs:15:53
error: this file contains an unclosed delimiter
--> $DIR/issue-2354.rs:15:52
|
LL | fn foo() {
| - un-closed delimiter
| - unclosed delimiter
LL | match Some(10) {
| - this delimiter might not be properly closed...
...
LL | }
| - ...as it matches this but it has different indentation
...
LL |
| ^
| ^

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: this file contains an un-closed delimiter
error: this file contains an unclosed delimiter
--> $DIR/issue-58094-missing-right-square-bracket.rs:4:4
|
LL | #[Ѕ
| - ^
| |
| un-closed delimiter
| unclosed delimiter

error: expected item after attributes
--> $DIR/issue-58094-missing-right-square-bracket.rs:4:4
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/parser/issue-62524.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: this file contains an un-closed delimiter
error: this file contains an unclosed delimiter
--> $DIR/issue-62524.rs:4:3
|
LL | y![
| - un-closed delimiter
| - unclosed delimiter
LL | Ϥ,
| ^

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/issue-62546.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub t(#
//~^ ERROR missing `fn` or `struct` for function or struct definition
//~ ERROR this file contains an un-closed delimiter
//~ ERROR this file contains an unclosed delimiter
8 changes: 4 additions & 4 deletions src/test/ui/parser/issue-62546.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: this file contains an un-closed delimiter
--> $DIR/issue-62546.rs:3:53
error: this file contains an unclosed delimiter
--> $DIR/issue-62546.rs:3:52
|
LL | pub t(#
| - un-closed delimiter
| - unclosed delimiter
LL |
LL |
| ^
| ^

error: missing `fn` or `struct` for function or struct definition
--> $DIR/issue-62546.rs:1:4
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/issue-62881.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ fn main() {}
fn f() -> isize { fn f() -> isize {} pub f<
//~^ ERROR missing `fn` or `struct` for function or struct definition
//~| ERROR mismatched types
//~ ERROR this file contains an un-closed delimiter
//~ ERROR this file contains an unclosed delimiter
8 changes: 4 additions & 4 deletions src/test/ui/parser/issue-62881.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: this file contains an un-closed delimiter
--> $DIR/issue-62881.rs:6:53
error: this file contains an unclosed delimiter
--> $DIR/issue-62881.rs:6:52
|
LL | fn f() -> isize { fn f() -> isize {} pub f<
| - un-closed delimiter
| - unclosed delimiter
...
LL |
| ^
| ^

error: missing `fn` or `struct` for function or struct definition
--> $DIR/issue-62881.rs:3:41
Expand Down
18 changes: 9 additions & 9 deletions src/test/ui/parser/issue-62973.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: this file contains an un-closed delimiter
error: this file contains an unclosed delimiter
--> $DIR/issue-62973.rs:8:2
|
LL | fn p() { match s { v, E { [) {) }
| - - un-closed delimiter
| - - unclosed delimiter
| |
| un-closed delimiter
| unclosed delimiter
LL |
LL |
| ^
Expand Down Expand Up @@ -44,21 +44,21 @@ LL |
LL |
| ^ expected one of `.`, `?`, `{`, or an operator

error: incorrect close delimiter: `)`
error: mismatched closing delimiter: `)`
--> $DIR/issue-62973.rs:6:28
|
LL | fn p() { match s { v, E { [) {) }
| -^ incorrect close delimiter
| -^ mismatched closing delimiter
| |
| un-closed delimiter
| unclosed delimiter

error: incorrect close delimiter: `)`
error: mismatched closing delimiter: `)`
--> $DIR/issue-62973.rs:6:31
|
LL | fn p() { match s { v, E { [) {) }
| -^ incorrect close delimiter
| -^ mismatched closing delimiter
| |
| un-closed delimiter
| unclosed delimiter

error: aborting due to 6 previous errors

4 changes: 2 additions & 2 deletions src/test/ui/parser/issue-63116.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: this file contains an un-closed delimiter
error: this file contains an unclosed delimiter
--> $DIR/issue-63116.rs:3:18
|
LL | impl W <s(f;Y(;]
| - ^
| |
| un-closed delimiter
| unclosed delimiter

error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `;`
--> $DIR/issue-63116.rs:3:12
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/parser/issue-63135.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: this file contains an un-closed delimiter
error: this file contains an unclosed delimiter
--> $DIR/issue-63135.rs:3:16
|
LL | fn i(n{...,f #
| - - ^
| | |
| | un-closed delimiter
| un-closed delimiter
| | unclosed delimiter
| unclosed delimiter

error: expected field pattern, found `...`
--> $DIR/issue-63135.rs:3:8
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/macro-mismatched-delim-brace-paren.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ macro_rules! foo { ($($tt:tt)*) => () }
fn main() {
foo! {
bar, "baz", 1, 2.0
) //~ ERROR incorrect close delimiter
) //~ ERROR mismatched closing delimiter
}
6 changes: 3 additions & 3 deletions src/test/ui/parser/macro-mismatched-delim-brace-paren.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: incorrect close delimiter: `)`
error: mismatched closing delimiter: `)`
--> $DIR/macro-mismatched-delim-brace-paren.rs:6:5
|
LL | foo! {
| - un-closed delimiter
| - unclosed delimiter
LL | bar, "baz", 1, 2.0
LL | )
| ^ incorrect close delimiter
| ^ mismatched closing delimiter

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/parser/macro-mismatched-delim-paren-brace.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
foo! (
bar, "baz", 1, 2.0
} //~ ERROR incorrect close delimiter
} //~ ERROR unexpected close delimiter: `}`
} //~ ERROR mismatched closing delimiter
} //~ ERROR unexpected closing delimiter: `}`
Loading

0 comments on commit 689e29f

Please sign in to comment.