Rollup merge of #105506 - estebank:rustc_must_implement_one_of, r=compiler-errors

Tweak `rustc_must_implement_one_of` diagnostic output
This commit is contained in:
Matthias Krüger 2022-12-09 22:31:59 +01:00 committed by GitHub
commit 376b0bce36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 39 deletions

View File

@ -955,7 +955,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
.struct_span_err(
attr.span,
"the `#[rustc_must_implement_one_of]` attribute must be \
used with at least 2 args",
used with at least 2 args",
)
.emit();
@ -987,7 +987,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
tcx.sess
.struct_span_err(
item.span,
"This function doesn't have a default implementation",
"function doesn't have a default implementation",
)
.span_note(attr_span, "required by this annotation")
.emit();
@ -999,17 +999,17 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
}
Some(item) => {
tcx.sess
.struct_span_err(item.span, "Not a function")
.struct_span_err(item.span, "not a function")
.span_note(attr_span, "required by this annotation")
.note(
"All `#[rustc_must_implement_one_of]` arguments \
must be associated function names",
"all `#[rustc_must_implement_one_of]` arguments must be associated \
function names",
)
.emit();
}
None => {
tcx.sess
.struct_span_err(ident.span, "Function not found in this trait")
.struct_span_err(ident.span, "function not found in this trait")
.emit();
}
}
@ -1027,11 +1027,8 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
for ident in &*list {
if let Some(dup) = set.insert(ident.name, ident.span) {
tcx.sess
.struct_span_err(vec![dup, ident.span], "Functions names are duplicated")
.note(
"All `#[rustc_must_implement_one_of]` arguments \
must be unique",
)
.struct_span_err(vec![dup, ident.span], "functions names are duplicated")
.note("all `#[rustc_must_implement_one_of]` arguments must be unique")
.emit();
no_dups = false;

View File

@ -1,15 +1,15 @@
#![feature(rustc_attrs)]
#[rustc_must_implement_one_of(a, a)]
//~^ Functions names are duplicated
//~^ functions names are duplicated
trait Trait {
fn a() {}
}
#[rustc_must_implement_one_of(b, a, a, c, b, c)]
//~^ Functions names are duplicated
//~| Functions names are duplicated
//~| Functions names are duplicated
//~^ functions names are duplicated
//~| functions names are duplicated
//~| functions names are duplicated
trait Trait1 {
fn a() {}
fn b() {}

View File

@ -1,34 +1,34 @@
error: Functions names are duplicated
error: functions names are duplicated
--> $DIR/rustc_must_implement_one_of_duplicates.rs:3:31
|
LL | #[rustc_must_implement_one_of(a, a)]
| ^ ^
|
= note: All `#[rustc_must_implement_one_of]` arguments must be unique
= note: all `#[rustc_must_implement_one_of]` arguments must be unique
error: Functions names are duplicated
error: functions names are duplicated
--> $DIR/rustc_must_implement_one_of_duplicates.rs:9:34
|
LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)]
| ^ ^
|
= note: All `#[rustc_must_implement_one_of]` arguments must be unique
= note: all `#[rustc_must_implement_one_of]` arguments must be unique
error: Functions names are duplicated
error: functions names are duplicated
--> $DIR/rustc_must_implement_one_of_duplicates.rs:9:31
|
LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)]
| ^ ^
|
= note: All `#[rustc_must_implement_one_of]` arguments must be unique
= note: all `#[rustc_must_implement_one_of]` arguments must be unique
error: Functions names are duplicated
error: functions names are duplicated
--> $DIR/rustc_must_implement_one_of_duplicates.rs:9:40
|
LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)]
| ^ ^
|
= note: All `#[rustc_must_implement_one_of]` arguments must be unique
= note: all `#[rustc_must_implement_one_of]` arguments must be unique
error: aborting due to 4 previous errors

View File

@ -1,12 +1,12 @@
#![feature(rustc_attrs)]
#[rustc_must_implement_one_of(a, b)]
//~^ Function not found in this trait
//~| Function not found in this trait
//~^ function not found in this trait
//~| function not found in this trait
trait Tr0 {}
#[rustc_must_implement_one_of(a, b)]
//~^ Function not found in this trait
//~^ function not found in this trait
trait Tr1 {
fn a() {}
}
@ -23,16 +23,16 @@ trait Tr3 {}
#[rustc_must_implement_one_of(A, B)]
trait Tr4 {
const A: u8 = 1; //~ Not a function
const A: u8 = 1; //~ not a function
type B; //~ Not a function
type B; //~ not a function
}
#[rustc_must_implement_one_of(a, b)]
trait Tr5 {
fn a(); //~ This function doesn't have a default implementation
fn a(); //~ function doesn't have a default implementation
fn b(); //~ This function doesn't have a default implementation
fn b(); //~ function doesn't have a default implementation
}
#[rustc_must_implement_one_of(abc, xyz)]

View File

@ -22,19 +22,19 @@ LL |
LL | struct Struct {}
| ---------------- not a trait
error: Function not found in this trait
error: function not found in this trait
--> $DIR/rustc_must_implement_one_of_misuse.rs:3:31
|
LL | #[rustc_must_implement_one_of(a, b)]
| ^
error: Function not found in this trait
error: function not found in this trait
--> $DIR/rustc_must_implement_one_of_misuse.rs:3:34
|
LL | #[rustc_must_implement_one_of(a, b)]
| ^
error: Function not found in this trait
error: function not found in this trait
--> $DIR/rustc_must_implement_one_of_misuse.rs:8:34
|
LL | #[rustc_must_implement_one_of(a, b)]
@ -46,7 +46,7 @@ error: the `#[rustc_must_implement_one_of]` attribute must be used with at least
LL | #[rustc_must_implement_one_of(a)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: Not a function
error: not a function
--> $DIR/rustc_must_implement_one_of_misuse.rs:26:5
|
LL | const A: u8 = 1;
@ -57,9 +57,9 @@ note: required by this annotation
|
LL | #[rustc_must_implement_one_of(A, B)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: All `#[rustc_must_implement_one_of]` arguments must be associated function names
= note: all `#[rustc_must_implement_one_of]` arguments must be associated function names
error: Not a function
error: not a function
--> $DIR/rustc_must_implement_one_of_misuse.rs:28:5
|
LL | type B;
@ -70,9 +70,9 @@ note: required by this annotation
|
LL | #[rustc_must_implement_one_of(A, B)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: All `#[rustc_must_implement_one_of]` arguments must be associated function names
= note: all `#[rustc_must_implement_one_of]` arguments must be associated function names
error: This function doesn't have a default implementation
error: function doesn't have a default implementation
--> $DIR/rustc_must_implement_one_of_misuse.rs:33:5
|
LL | fn a();
@ -84,7 +84,7 @@ note: required by this annotation
LL | #[rustc_must_implement_one_of(a, b)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: This function doesn't have a default implementation
error: function doesn't have a default implementation
--> $DIR/rustc_must_implement_one_of_misuse.rs:35:5
|
LL | fn b();