Skip to content

Commit a74ec9c

Browse files
Don't fire refinement lint if there are errors
1 parent c78e5dc commit a74ec9c

File tree

5 files changed

+6
-38
lines changed

5 files changed

+6
-38
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
6464
return;
6565
};
6666

67+
if hidden_tys.items().any(|(_, &ty)| ty.skip_binder().references_error()) {
68+
return;
69+
}
70+
6771
let mut collector = ImplTraitInTraitCollector { tcx, types: FxIndexSet::default() };
6872
trait_m_sig.visit_with(&mut collector);
6973

tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub trait Foo {
1111
impl Foo for () {
1212
fn bar<'im: 'im>(&'im mut self) -> impl Sized + use<'im> {}
1313
//~^ ERROR return type captures more lifetimes than trait definition
14-
//~| WARN impl trait in impl method signature does not match trait method signature
1514
}
1615

1716
fn main() {}

tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.stderr

+1-18
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,5 @@ LL | fn bar<'tr: 'tr>(&'tr mut self) -> impl Sized + use<Self>;
1313
| ^^^^^^^^^^^^^^^^^^^^^^
1414
= note: hidden type inferred to be `impl Sized`
1515

16-
warning: impl trait in impl method signature does not match trait method signature
17-
--> $DIR/rpitit-captures-more-method-lifetimes.rs:12:40
18-
|
19-
LL | fn bar<'tr: 'tr>(&'tr mut self) -> impl Sized + use<Self>;
20-
| ---------------------- return type from trait method defined here
21-
...
22-
LL | fn bar<'im: 'im>(&'im mut self) -> impl Sized + use<'im> {}
23-
| ^^^^^^^^^^^^^^^^^^^^^
24-
|
25-
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
26-
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
27-
= note: `#[warn(refining_impl_trait_reachable)]` on by default
28-
help: replace the return type so that it matches the trait
29-
|
30-
LL | fn bar<'im: 'im>(&'im mut self) -> impl Sized {}
31-
| ~~~~~~~~~~
32-
33-
error: aborting due to 1 previous error; 1 warning emitted
16+
error: aborting due to 1 previous error
3417

tests/ui/impl-trait/precise-capturing/rpitit-impl-captures-too-much.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ trait Trait {
99
impl Trait for () {
1010
fn hello(self_: Invariant<'_>) -> impl Sized + use<'_> {}
1111
//~^ ERROR return type captures more lifetimes than trait definition
12-
//~| WARNING impl trait in impl method signature does not match trait method signature
1312
}
1413

1514
fn main() {}

tests/ui/impl-trait/precise-capturing/rpitit-impl-captures-too-much.stderr

+1-18
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,5 @@ LL | fn hello(self_: Invariant<'_>) -> impl Sized + use<Self>;
1313
| ^^^^^^^^^^^^^^^^^^^^^^
1414
= note: hidden type inferred to be `impl Sized`
1515

16-
warning: impl trait in impl method signature does not match trait method signature
17-
--> $DIR/rpitit-impl-captures-too-much.rs:10:39
18-
|
19-
LL | fn hello(self_: Invariant<'_>) -> impl Sized + use<Self>;
20-
| ---------------------- return type from trait method defined here
21-
...
22-
LL | fn hello(self_: Invariant<'_>) -> impl Sized + use<'_> {}
23-
| ^^^^^^^^^^^^^^^^^^^^
24-
|
25-
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
26-
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
27-
= note: `#[warn(refining_impl_trait_internal)]` on by default
28-
help: replace the return type so that it matches the trait
29-
|
30-
LL | fn hello(self_: Invariant<'_>) -> impl Sized {}
31-
| ~~~~~~~~~~
32-
33-
error: aborting due to 1 previous error; 1 warning emitted
16+
error: aborting due to 1 previous error
3417

0 commit comments

Comments
 (0)