Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl<'a> AstValidator<'a> {
if let Defaultness::Default(def_span) = defaultness {
let span = self.session.source_map().guess_head_span(span);
self.err_handler()
.struct_span_err(span, "`default` is only allowed on items in `impl` definitions")
.struct_span_err(span, "`default` is only allowed on items in trait impls")
.span_label(def_span, "`default` because of this")
.emit();
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/parser/trait-item-with-defaultness-fail-semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
fn main() {}

trait X {
default const A: u8; //~ ERROR `default` is only allowed on items in `impl` definitions
default const B: u8 = 0; //~ ERROR `default` is only allowed on items in `impl` definitions
default type D; //~ ERROR `default` is only allowed on items in `impl` definitions
default type C: Ord; //~ ERROR `default` is only allowed on items in `impl` definitions
default fn f1(); //~ ERROR `default` is only allowed on items in `impl` definitions
default fn f2() {} //~ ERROR `default` is only allowed on items in `impl` definitions
default const A: u8; //~ ERROR `default` is only allowed on items in trait impls
default const B: u8 = 0; //~ ERROR `default` is only allowed on items in trait impls
default type D; //~ ERROR `default` is only allowed on items in trait impls
default type C: Ord; //~ ERROR `default` is only allowed on items in trait impls
default fn f1(); //~ ERROR `default` is only allowed on items in trait impls
default fn f2() {} //~ ERROR `default` is only allowed on items in trait impls
}
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
error: `default` is only allowed on items in `impl` definitions
error: `default` is only allowed on items in trait impls
--> $DIR/trait-item-with-defaultness-fail-semantic.rs:6:5
|
LL | default const A: u8;
| -------^^^^^^^^^^^^^
| |
| `default` because of this

error: `default` is only allowed on items in `impl` definitions
error: `default` is only allowed on items in trait impls
--> $DIR/trait-item-with-defaultness-fail-semantic.rs:7:5
|
LL | default const B: u8 = 0;
| -------^^^^^^^^^^^^^^^^^
| |
| `default` because of this

error: `default` is only allowed on items in `impl` definitions
error: `default` is only allowed on items in trait impls
--> $DIR/trait-item-with-defaultness-fail-semantic.rs:8:5
|
LL | default type D;
| -------^^^^^^^^
| |
| `default` because of this

error: `default` is only allowed on items in `impl` definitions
error: `default` is only allowed on items in trait impls
--> $DIR/trait-item-with-defaultness-fail-semantic.rs:9:5
|
LL | default type C: Ord;
| -------^^^^^^^^^^^^^
| |
| `default` because of this

error: `default` is only allowed on items in `impl` definitions
error: `default` is only allowed on items in trait impls
--> $DIR/trait-item-with-defaultness-fail-semantic.rs:10:5
|
LL | default fn f1();
| -------^^^^^^^^^
| |
| `default` because of this

error: `default` is only allowed on items in `impl` definitions
error: `default` is only allowed on items in trait impls
--> $DIR/trait-item-with-defaultness-fail-semantic.rs:11:5
|
LL | default fn f2() {}
Expand Down