File tree Expand file tree Collapse file tree 3 files changed +23
-8
lines changed
compiler/rustc_hir_analysis/src/check/compare_impl_item Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,12 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
2323 if !tcx. impl_method_has_trait_impl_trait_tys ( impl_m. def_id ) {
2424 return ;
2525 }
26- // crate-private traits don't have any library guarantees, there's no need to do this check.
27- if !tcx. visibility ( trait_m. container_id ( tcx) ) . is_public ( ) {
26+ // unreachable traits don't have any library guarantees, there's no need to do this check.
27+ if trait_m
28+ . container_id ( tcx)
29+ . as_local ( )
30+ . is_some_and ( |trait_def_id| !tcx. effective_visibilities ( ( ) ) . is_reachable ( trait_def_id) )
31+ {
2832 return ;
2933 }
3034
Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ LL | async fn foo(_: T) -> &'static str;
77LL | impl<T> MyTrait<T> for MyStruct {}
88 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
99
10+ error[E0308]: mismatched types
11+ --> $DIR/missing-feature-flag.rs:16:42
12+ |
13+ LL | async fn foo(_: i32) -> &'static str {}
14+ | ^^ expected `&str`, found `()`
15+
1016error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
1117 --> $DIR/missing-feature-flag.rs:16:5
1218 |
@@ -18,12 +24,6 @@ LL | async fn foo(_: i32) -> &'static str {}
1824 |
1925 = note: to specialize, `foo` in the parent `impl` must be marked `default`
2026
21- error[E0308]: mismatched types
22- --> $DIR/missing-feature-flag.rs:16:42
23- |
24- LL | async fn foo(_: i32) -> &'static str {}
25- | ^^ expected `&str`, found `()`
26-
2727error: aborting due to 3 previous errors
2828
2929Some errors have detailed explanations: E0046, E0308, E0520.
Original file line number Diff line number Diff line change @@ -45,4 +45,15 @@ impl Late for D {
4545 //~^ ERROR impl method signature does not match trait method signature
4646}
4747
48+ mod unreachable {
49+ pub trait UnreachablePub {
50+ fn bar ( ) -> impl Sized ;
51+ }
52+
53+ struct E ;
54+ impl UnreachablePub for E {
55+ fn bar ( ) { }
56+ }
57+ }
58+
4859fn main ( ) { }
You can’t perform that action at this time.
0 commit comments