Auto merge of #116273 - compiler-errors:refine2, r=tmandry · rust-lang/rust@5236c8e (original) (raw)

File tree

3 files changed

lines changed

3 files changed

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>(
23 23 if !tcx.impl_method_has_trait_impl_trait_tys(impl_m.def_id) {
24 24 return;
25 25 }
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
31 +{
28 32 return;
29 33 }
30 34
Original file line number Diff line number Diff line change
@@ -7,6 +7,12 @@ LL | async fn foo(_: T) -> &'static str;
7 7 LL | impl MyTrait for MyStruct {}
8 8 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
9 9
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 +
10 16 error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
11 17 --> $DIR/missing-feature-flag.rs:16:5
12 18 |
@@ -18,12 +24,6 @@ LL | async fn foo(_: i32) -> &'static str {}
18 24 |
19 25 = note: to specialize, `foo` in the parent `impl` must be marked `default`
20 26
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 -
27 27 error: aborting due to 3 previous errors
28 28
29 29 Some 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 {
45 45 //~^ ERROR impl method signature does not match trait method signature
46 46 }
47 47
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 +
48 59 fn main() {}