Skip to content

Commit

Permalink
Don't fire refinement lint if there are errors
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Sep 29, 2024
1 parent 2304da0 commit c1a7713
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
return;
};

if hidden_tys.items().any(|(_, &ty)| ty.skip_binder().references_error()) {
return;
}

let mut collector = ImplTraitInTraitCollector { tcx, types: FxIndexSet::default() };
trait_m_sig.visit_with(&mut collector);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub trait Foo {
impl Foo for () {
fn bar<'im: 'im>(&'im mut self) -> impl Sized + use<'im> {}
//~^ ERROR return type captures more lifetimes than trait definition
//~| WARN impl trait in impl method signature does not match trait method signature
}

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,5 @@ LL | fn bar<'tr: 'tr>(&'tr mut self) -> impl Sized + use<Self>;
| ^^^^^^^^^^^^^^^^^^^^^^
= note: hidden type inferred to be `impl Sized`

warning: impl trait in impl method signature does not match trait method signature
--> $DIR/rpitit-captures-more-method-lifetimes.rs:12:40
|
LL | fn bar<'tr: 'tr>(&'tr mut self) -> impl Sized + use<Self>;
| ---------------------- return type from trait method defined here
...
LL | fn bar<'im: 'im>(&'im mut self) -> impl Sized + use<'im> {}
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
= note: `#[warn(refining_impl_trait_reachable)]` on by default
help: replace the return type so that it matches the trait
|
LL | fn bar<'im: 'im>(&'im mut self) -> impl Sized {}
| ~~~~~~~~~~

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

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

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,5 @@ LL | fn hello(self_: Invariant<'_>) -> impl Sized + use<Self>;
| ^^^^^^^^^^^^^^^^^^^^^^
= note: hidden type inferred to be `impl Sized`

warning: impl trait in impl method signature does not match trait method signature
--> $DIR/rpitit-impl-captures-too-much.rs:10:39
|
LL | fn hello(self_: Invariant<'_>) -> impl Sized + use<Self>;
| ---------------------- return type from trait method defined here
...
LL | fn hello(self_: Invariant<'_>) -> impl Sized + use<'_> {}
| ^^^^^^^^^^^^^^^^^^^^
|
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
= note: `#[warn(refining_impl_trait_internal)]` on by default
help: replace the return type so that it matches the trait
|
LL | fn hello(self_: Invariant<'_>) -> impl Sized {}
| ~~~~~~~~~~

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

0 comments on commit c1a7713

Please sign in to comment.