Skip to content

Commit fde5939

Browse files
committed
parse: tweak diagnostic wordings
1 parent e66a39b commit fde5939

23 files changed

+103
-103
lines changed

src/librustc_parse/parser/item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'a> Parser<'a> {
112112
}
113113
let vs = pprust::vis_to_string(&vis);
114114
let vs = vs.trim_end();
115-
self.struct_span_err(vis.span, &format!("visibility `{}` not followed by an item", vs))
115+
self.struct_span_err(vis.span, &format!("visibility `{}` is not followed by an item", vs))
116116
.span_label(vis.span, "the visibility")
117117
.help(&format!("you likely meant to define an item, e.g., `{} fn foo() {{}}`", vs))
118118
.emit();
@@ -121,7 +121,7 @@ impl<'a> Parser<'a> {
121121
/// Error in-case a `default` was parsed but no item followed.
122122
fn error_on_unmatched_defaultness(&self, def: Defaultness) {
123123
if let Defaultness::Default(sp) = def {
124-
self.struct_span_err(sp, "`default` not followed by an item")
124+
self.struct_span_err(sp, "`default` is not followed by an item")
125125
.span_label(sp, "the `default` qualifier")
126126
.note("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")
127127
.emit();
@@ -657,7 +657,7 @@ impl<'a> Parser<'a> {
657657
self.struct_span_err(span, "associated `static` items are not allowed").emit();
658658
AssocItemKind::Const(Defaultness::Final, a, b)
659659
}
660-
_ => return self.error_bad_item_kind(span, &kind, "`trait` or `impl`"),
660+
_ => return self.error_bad_item_kind(span, &kind, "`trait`s or `impl`s"),
661661
};
662662
Some(P(Item { attrs, id, span, vis, ident, kind, tokens }))
663663
}))
@@ -846,15 +846,15 @@ impl<'a> Parser<'a> {
846846
self.error_on_foreign_const(span, ident);
847847
ForeignItemKind::Static(a, Mutability::Not, b)
848848
}
849-
_ => return self.error_bad_item_kind(span, &kind, "`extern` block"),
849+
_ => return self.error_bad_item_kind(span, &kind, "`extern` blocks"),
850850
};
851851
Some(P(Item { attrs, id, span, vis, ident, kind, tokens }))
852852
}))
853853
}
854854

855855
fn error_bad_item_kind<T>(&self, span: Span, kind: &ItemKind, ctx: &str) -> Option<T> {
856856
let span = self.sess.source_map().def_span(span);
857-
let msg = format!("{} not supported in {}", kind.descr(), ctx);
857+
let msg = format!("{} is not supported in {}", kind.descr(), ctx);
858858
self.struct_span_err(span, &msg).emit();
859859
return None;
860860
}

src/test/ui/parser/default-on-wrong-item-kind.rs

+36-36
Original file line numberDiff line numberDiff line change
@@ -31,110 +31,110 @@ mod free_items {
3131
#[cfg(FALSE)]
3232
extern "C" {
3333
default extern crate foo; //~ ERROR an extern crate cannot be `default`
34-
//~^ ERROR extern crate not supported in `extern` block
34+
//~^ ERROR extern crate is not supported in `extern` blocks
3535
default use foo; //~ ERROR a `use` import cannot be `default`
36-
//~^ ERROR `use` import not supported in `extern` block
36+
//~^ ERROR `use` import is not supported in `extern` blocks
3737
default static foo: u8; //~ ERROR a static item cannot be `default`
3838
default const foo: u8;
3939
//~^ ERROR extern items cannot be `const`
4040
default fn foo();
4141
default mod foo {} //~ ERROR a module cannot be `default`
42-
//~^ ERROR module not supported in `extern` block
42+
//~^ ERROR module is not supported in `extern` blocks
4343
default extern "C" {} //~ ERROR an extern block cannot be `default`
44-
//~^ ERROR extern block not supported in `extern` block
44+
//~^ ERROR extern block is not supported in `extern` blocks
4545
default type foo = u8;
4646
default enum foo {} //~ ERROR an enum cannot be `default`
47-
//~^ ERROR enum not supported in `extern` block
47+
//~^ ERROR enum is not supported in `extern` blocks
4848
default struct foo {} //~ ERROR a struct cannot be `default`
49-
//~^ ERROR struct not supported in `extern` block
49+
//~^ ERROR struct is not supported in `extern` blocks
5050
default union foo {} //~ ERROR a union cannot be `default`
51-
//~^ ERROR union not supported in `extern` block
51+
//~^ ERROR union is not supported in `extern` blocks
5252
default trait foo {} //~ ERROR a trait cannot be `default`
53-
//~^ ERROR trait not supported in `extern` block
53+
//~^ ERROR trait is not supported in `extern` blocks
5454
default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
55-
//~^ ERROR trait alias not supported in `extern` block
55+
//~^ ERROR trait alias is not supported in `extern` blocks
5656
default impl foo {}
57-
//~^ ERROR implementation not supported in `extern` block
57+
//~^ ERROR implementation is not supported in `extern` blocks
5858
default!();
5959
default::foo::bar!();
6060
default default!(); //~ ERROR an item macro invocation cannot be `default`
6161
default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
6262
default macro foo {} //~ ERROR a macro definition cannot be `default`
63-
//~^ ERROR macro definition not supported in `extern` block
63+
//~^ ERROR macro definition is not supported in `extern` blocks
6464
default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
65-
//~^ ERROR macro definition not supported in `extern` block
65+
//~^ ERROR macro definition is not supported in `extern` blocks
6666
}
6767

6868
#[cfg(FALSE)]
6969
impl S {
7070
default extern crate foo; //~ ERROR an extern crate cannot be `default`
71-
//~^ ERROR extern crate not supported in `trait` or `impl`
71+
//~^ ERROR extern crate is not supported in `trait`s or `impl`s
7272
default use foo; //~ ERROR a `use` import cannot be `default`
73-
//~^ ERROR `use` import not supported in `trait` or `impl`
73+
//~^ ERROR `use` import is not supported in `trait`s or `impl`s
7474
default static foo: u8; //~ ERROR a static item cannot be `default`
7575
//~^ ERROR associated `static` items are not allowed
7676
default const foo: u8;
7777
default fn foo();
7878
default mod foo {}//~ ERROR a module cannot be `default`
79-
//~^ ERROR module not supported in `trait` or `impl`
79+
//~^ ERROR module is not supported in `trait`s or `impl`s
8080
default extern "C" {} //~ ERROR an extern block cannot be `default`
81-
//~^ ERROR extern block not supported in `trait` or `impl`
81+
//~^ ERROR extern block is not supported in `trait`s or `impl`s
8282
default type foo = u8;
8383
default enum foo {} //~ ERROR an enum cannot be `default`
84-
//~^ ERROR enum not supported in `trait` or `impl`
84+
//~^ ERROR enum is not supported in `trait`s or `impl`s
8585
default struct foo {} //~ ERROR a struct cannot be `default`
86-
//~^ ERROR struct not supported in `trait` or `impl`
86+
//~^ ERROR struct is not supported in `trait`s or `impl`s
8787
default union foo {} //~ ERROR a union cannot be `default`
88-
//~^ ERROR union not supported in `trait` or `impl`
88+
//~^ ERROR union is not supported in `trait`s or `impl`s
8989
default trait foo {} //~ ERROR a trait cannot be `default`
90-
//~^ ERROR trait not supported in `trait` or `impl`
90+
//~^ ERROR trait is not supported in `trait`s or `impl`s
9191
default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
92-
//~^ ERROR trait alias not supported in `trait` or `impl`
92+
//~^ ERROR trait alias is not supported in `trait`s or `impl`s
9393
default impl foo {}
94-
//~^ ERROR implementation not supported in `trait` or `impl`
94+
//~^ ERROR implementation is not supported in `trait`s or `impl`s
9595
default!();
9696
default::foo::bar!();
9797
default default!(); //~ ERROR an item macro invocation cannot be `default`
9898
default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
9999
default macro foo {} //~ ERROR a macro definition cannot be `default`
100-
//~^ ERROR macro definition not supported in `trait` or `impl`
100+
//~^ ERROR macro definition is not supported in `trait`s or `impl`s
101101
default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
102-
//~^ ERROR macro definition not supported in `trait` or `impl`
102+
//~^ ERROR macro definition is not supported in `trait`s or `impl`s
103103
}
104104

105105
#[cfg(FALSE)]
106106
trait T {
107107
default extern crate foo; //~ ERROR an extern crate cannot be `default`
108-
//~^ ERROR extern crate not supported in `trait` or `impl`
108+
//~^ ERROR extern crate is not supported in `trait`s or `impl`s
109109
default use foo; //~ ERROR a `use` import cannot be `default`
110-
//~^ ERROR `use` import not supported in `trait` or `impl`
110+
//~^ ERROR `use` import is not supported in `trait`s or `impl`s
111111
default static foo: u8; //~ ERROR a static item cannot be `default`
112112
//~^ ERROR associated `static` items are not allowed
113113
default const foo: u8;
114114
default fn foo();
115115
default mod foo {}//~ ERROR a module cannot be `default`
116-
//~^ ERROR module not supported in `trait` or `impl`
116+
//~^ ERROR module is not supported in `trait`s or `impl`s
117117
default extern "C" {} //~ ERROR an extern block cannot be `default`
118-
//~^ ERROR extern block not supported in `trait` or `impl`
118+
//~^ ERROR extern block is not supported in `trait`s or `impl`s
119119
default type foo = u8;
120120
default enum foo {} //~ ERROR an enum cannot be `default`
121-
//~^ ERROR enum not supported in `trait` or `impl`
121+
//~^ ERROR enum is not supported in `trait`s or `impl`s
122122
default struct foo {} //~ ERROR a struct cannot be `default`
123-
//~^ ERROR struct not supported in `trait` or `impl`
123+
//~^ ERROR struct is not supported in `trait`s or `impl`s
124124
default union foo {} //~ ERROR a union cannot be `default`
125-
//~^ ERROR union not supported in `trait` or `impl`
125+
//~^ ERROR union is not supported in `trait`s or `impl`s
126126
default trait foo {} //~ ERROR a trait cannot be `default`
127-
//~^ ERROR trait not supported in `trait` or `impl`
127+
//~^ ERROR trait is not supported in `trait`s or `impl`s
128128
default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
129-
//~^ ERROR trait alias not supported in `trait` or `impl`
129+
//~^ ERROR trait alias is not supported in `trait`s or `impl`s
130130
default impl foo {}
131-
//~^ ERROR implementation not supported in `trait` or `impl`
131+
//~^ ERROR implementation is not supported in `trait`s or `impl`s
132132
default!();
133133
default::foo::bar!();
134134
default default!(); //~ ERROR an item macro invocation cannot be `default`
135135
default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
136136
default macro foo {} //~ ERROR a macro definition cannot be `default`
137-
//~^ ERROR macro definition not supported in `trait` or `impl`
137+
//~^ ERROR macro definition is not supported in `trait`s or `impl`s
138138
default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
139-
//~^ ERROR macro definition not supported in `trait` or `impl`
139+
//~^ ERROR macro definition is not supported in `trait`s or `impl`s
140140
}

0 commit comments

Comments
 (0)