Skip to content

Commit 376b0bc

Browse files
authoredDec 9, 2022
Rollup merge of #105506 - estebank:rustc_must_implement_one_of, r=compiler-errors
Tweak `rustc_must_implement_one_of` diagnostic output
2 parents d0563c6 + b3b17bd commit 376b0bc

File tree

5 files changed

+36
-39
lines changed

5 files changed

+36
-39
lines changed
 

‎compiler/rustc_hir_analysis/src/collect.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
955955
.struct_span_err(
956956
attr.span,
957957
"the `#[rustc_must_implement_one_of]` attribute must be \
958-
used with at least 2 args",
958+
used with at least 2 args",
959959
)
960960
.emit();
961961

@@ -987,7 +987,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
987987
tcx.sess
988988
.struct_span_err(
989989
item.span,
990-
"This function doesn't have a default implementation",
990+
"function doesn't have a default implementation",
991991
)
992992
.span_note(attr_span, "required by this annotation")
993993
.emit();
@@ -999,17 +999,17 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
999999
}
10001000
Some(item) => {
10011001
tcx.sess
1002-
.struct_span_err(item.span, "Not a function")
1002+
.struct_span_err(item.span, "not a function")
10031003
.span_note(attr_span, "required by this annotation")
10041004
.note(
1005-
"All `#[rustc_must_implement_one_of]` arguments \
1006-
must be associated function names",
1005+
"all `#[rustc_must_implement_one_of]` arguments must be associated \
1006+
function names",
10071007
)
10081008
.emit();
10091009
}
10101010
None => {
10111011
tcx.sess
1012-
.struct_span_err(ident.span, "Function not found in this trait")
1012+
.struct_span_err(ident.span, "function not found in this trait")
10131013
.emit();
10141014
}
10151015
}
@@ -1027,11 +1027,8 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
10271027
for ident in &*list {
10281028
if let Some(dup) = set.insert(ident.name, ident.span) {
10291029
tcx.sess
1030-
.struct_span_err(vec![dup, ident.span], "Functions names are duplicated")
1031-
.note(
1032-
"All `#[rustc_must_implement_one_of]` arguments \
1033-
must be unique",
1034-
)
1030+
.struct_span_err(vec![dup, ident.span], "functions names are duplicated")
1031+
.note("all `#[rustc_must_implement_one_of]` arguments must be unique")
10351032
.emit();
10361033

10371034
no_dups = false;

‎src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#![feature(rustc_attrs)]
22

33
#[rustc_must_implement_one_of(a, a)]
4-
//~^ Functions names are duplicated
4+
//~^ functions names are duplicated
55
trait Trait {
66
fn a() {}
77
}
88

99
#[rustc_must_implement_one_of(b, a, a, c, b, c)]
10-
//~^ Functions names are duplicated
11-
//~| Functions names are duplicated
12-
//~| Functions names are duplicated
10+
//~^ functions names are duplicated
11+
//~| functions names are duplicated
12+
//~| functions names are duplicated
1313
trait Trait1 {
1414
fn a() {}
1515
fn b() {}
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
error: Functions names are duplicated
1+
error: functions names are duplicated
22
--> $DIR/rustc_must_implement_one_of_duplicates.rs:3:31
33
|
44
LL | #[rustc_must_implement_one_of(a, a)]
55
| ^ ^
66
|
7-
= note: All `#[rustc_must_implement_one_of]` arguments must be unique
7+
= note: all `#[rustc_must_implement_one_of]` arguments must be unique
88

9-
error: Functions names are duplicated
9+
error: functions names are duplicated
1010
--> $DIR/rustc_must_implement_one_of_duplicates.rs:9:34
1111
|
1212
LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)]
1313
| ^ ^
1414
|
15-
= note: All `#[rustc_must_implement_one_of]` arguments must be unique
15+
= note: all `#[rustc_must_implement_one_of]` arguments must be unique
1616

17-
error: Functions names are duplicated
17+
error: functions names are duplicated
1818
--> $DIR/rustc_must_implement_one_of_duplicates.rs:9:31
1919
|
2020
LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)]
2121
| ^ ^
2222
|
23-
= note: All `#[rustc_must_implement_one_of]` arguments must be unique
23+
= note: all `#[rustc_must_implement_one_of]` arguments must be unique
2424

25-
error: Functions names are duplicated
25+
error: functions names are duplicated
2626
--> $DIR/rustc_must_implement_one_of_duplicates.rs:9:40
2727
|
2828
LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)]
2929
| ^ ^
3030
|
31-
= note: All `#[rustc_must_implement_one_of]` arguments must be unique
31+
= note: all `#[rustc_must_implement_one_of]` arguments must be unique
3232

3333
error: aborting due to 4 previous errors
3434

‎src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#![feature(rustc_attrs)]
22

33
#[rustc_must_implement_one_of(a, b)]
4-
//~^ Function not found in this trait
5-
//~| Function not found in this trait
4+
//~^ function not found in this trait
5+
//~| function not found in this trait
66
trait Tr0 {}
77

88
#[rustc_must_implement_one_of(a, b)]
9-
//~^ Function not found in this trait
9+
//~^ function not found in this trait
1010
trait Tr1 {
1111
fn a() {}
1212
}
@@ -23,16 +23,16 @@ trait Tr3 {}
2323

2424
#[rustc_must_implement_one_of(A, B)]
2525
trait Tr4 {
26-
const A: u8 = 1; //~ Not a function
26+
const A: u8 = 1; //~ not a function
2727

28-
type B; //~ Not a function
28+
type B; //~ not a function
2929
}
3030

3131
#[rustc_must_implement_one_of(a, b)]
3232
trait Tr5 {
33-
fn a(); //~ This function doesn't have a default implementation
33+
fn a(); //~ function doesn't have a default implementation
3434

35-
fn b(); //~ This function doesn't have a default implementation
35+
fn b(); //~ function doesn't have a default implementation
3636
}
3737

3838
#[rustc_must_implement_one_of(abc, xyz)]

‎src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ LL |
2222
LL | struct Struct {}
2323
| ---------------- not a trait
2424

25-
error: Function not found in this trait
25+
error: function not found in this trait
2626
--> $DIR/rustc_must_implement_one_of_misuse.rs:3:31
2727
|
2828
LL | #[rustc_must_implement_one_of(a, b)]
2929
| ^
3030

31-
error: Function not found in this trait
31+
error: function not found in this trait
3232
--> $DIR/rustc_must_implement_one_of_misuse.rs:3:34
3333
|
3434
LL | #[rustc_must_implement_one_of(a, b)]
3535
| ^
3636

37-
error: Function not found in this trait
37+
error: function not found in this trait
3838
--> $DIR/rustc_must_implement_one_of_misuse.rs:8:34
3939
|
4040
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
4646
LL | #[rustc_must_implement_one_of(a)]
4747
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4848

49-
error: Not a function
49+
error: not a function
5050
--> $DIR/rustc_must_implement_one_of_misuse.rs:26:5
5151
|
5252
LL | const A: u8 = 1;
@@ -57,9 +57,9 @@ note: required by this annotation
5757
|
5858
LL | #[rustc_must_implement_one_of(A, B)]
5959
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60-
= note: All `#[rustc_must_implement_one_of]` arguments must be associated function names
60+
= note: all `#[rustc_must_implement_one_of]` arguments must be associated function names
6161

62-
error: Not a function
62+
error: not a function
6363
--> $DIR/rustc_must_implement_one_of_misuse.rs:28:5
6464
|
6565
LL | type B;
@@ -70,9 +70,9 @@ note: required by this annotation
7070
|
7171
LL | #[rustc_must_implement_one_of(A, B)]
7272
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73-
= note: All `#[rustc_must_implement_one_of]` arguments must be associated function names
73+
= note: all `#[rustc_must_implement_one_of]` arguments must be associated function names
7474

75-
error: This function doesn't have a default implementation
75+
error: function doesn't have a default implementation
7676
--> $DIR/rustc_must_implement_one_of_misuse.rs:33:5
7777
|
7878
LL | fn a();
@@ -84,7 +84,7 @@ note: required by this annotation
8484
LL | #[rustc_must_implement_one_of(a, b)]
8585
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8686

87-
error: This function doesn't have a default implementation
87+
error: function doesn't have a default implementation
8888
--> $DIR/rustc_must_implement_one_of_misuse.rs:35:5
8989
|
9090
LL | fn b();

0 commit comments

Comments
 (0)
Please sign in to comment.