Skip to content

Commit 7714db8

Browse files
Add note
1 parent 4d05da4 commit 7714db8

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

compiler/rustc_hir_analysis/messages.ftl

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ hir_analysis_rpitit_refined = impl trait in impl method signature does not match
226226
.suggestion = replace the return type so that it matches the trait
227227
.label = return type from trait method defined here
228228
.unmatched_bound_label = this bound is stronger than that defined on the trait
229+
.note = add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
229230
230231
hir_analysis_self_in_impl_self =
231232
`Self` is not valid in the self type of an impl block

compiler/rustc_hir_analysis/src/errors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ pub struct UnusedAssociatedTypeBounds {
921921

922922
#[derive(LintDiagnostic)]
923923
#[diag(hir_analysis_rpitit_refined)]
924+
#[note]
924925
pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
925926
#[suggestion(applicability = "maybe-incorrect", code = "{pre}{return_ty}{post}")]
926927
pub impl_return_span: Span,

tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ LL | fn iter(&self) -> impl '_ + Iterator<Item = Self::Item<'_>>;
2121
LL | fn iter(&self) -> impl 'a + Iterator<Item = I::Item<'a>> {
2222
| ^^ this bound is stronger than that defined on the trait
2323
|
24+
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
2425
= note: `#[warn(refining_impl_trait)]` on by default
2526
help: replace the return type so that it matches the trait
2627
|

tests/ui/impl-trait/in-trait/refine.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | fn bar() -> impl Sized;
77
LL | fn bar() -> impl Copy {}
88
| ^^^^ this bound is stronger than that defined on the trait
99
|
10+
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
1011
note: the lint level is defined here
1112
--> $DIR/refine.rs:2:9
1213
|
@@ -26,6 +27,7 @@ LL | fn bar() -> impl Sized;
2627
LL | fn bar() {}
2728
| ^^^^^^^^
2829
|
30+
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
2931
help: replace the return type so that it matches the trait
3032
|
3133
LL | fn bar() -> impl Sized {}
@@ -40,6 +42,7 @@ LL | fn bar() -> impl Sized;
4042
LL | fn bar() -> () {}
4143
| ^^
4244
|
45+
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
4346
help: replace the return type so that it matches the trait
4447
|
4548
LL | fn bar() -> impl Sized {}
@@ -54,6 +57,7 @@ LL | fn bar<'a>(&'a self) -> impl Sized + 'a;
5457
LL | fn bar(&self) -> impl Copy + '_ {}
5558
| ^^^^ this bound is stronger than that defined on the trait
5659
|
60+
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
5761
help: replace the return type so that it matches the trait
5862
|
5963
LL | fn bar(&self) -> impl Sized + '_ {}

0 commit comments

Comments
 (0)