Skip to content

Commit

Permalink
Tests, suppress refine lint when errors
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jun 28, 2024
1 parent 9b53b64 commit 7b0e962
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use rustc_lint_defs::builtin::{REFINING_IMPL_TRAIT_INTERNAL, REFINING_IMPL_TRAIT
use rustc_middle::span_bug;
use rustc_middle::traits::{ObligationCause, Reveal};
use rustc_middle::ty::{
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable, TypeVisitor,
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable,
TypeVisitableExt, TypeVisitor,
};
use rustc_span::Span;
use rustc_trait_selection::regions::InferCtxtRegionExt;
Expand Down Expand Up @@ -63,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
@@ -0,0 +1,14 @@
#![feature(precise_capturing)]

struct Invariant<'a>(&'a mut &'a mut ());

trait Trait {
fn hello(self_: Invariant<'_>) -> impl Sized + use<Self>;
}

impl Trait for () {
fn hello(self_: Invariant<'_>) -> impl Sized + use<'_> {}
//~^ return type captures more lifetimes than trait definition
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error: return type captures more lifetimes than trait definition
--> $DIR/rpitit-impl-captures-too-much.rs:10:39
|
LL | fn hello(self_: Invariant<'_>) -> impl Sized + use<'_> {}
| -- ^^^^^^^^^^^^^^^^^^^^
| |
| this lifetime was captured
|
note: hidden type must only reference lifetimes captured by this impl trait
--> $DIR/rpitit-impl-captures-too-much.rs:6:39
|
LL | fn hello(self_: Invariant<'_>) -> impl Sized + use<Self>;
| ^^^^^^^^^^^^^^^^^^^^^^
= note: hidden type inferred to be `impl Sized`

error: aborting due to 1 previous error

0 comments on commit 7b0e962

Please sign in to comment.