Avoid calling report_forbidden_specialization for RPITITs
This commit is contained in:
parent
fd68a6ded9
commit
24326ee508
@ -722,7 +722,14 @@ pub(super) fn check_specialization_validity<'tcx>(
|
|||||||
let result = opt_result.unwrap_or(Ok(()));
|
let result = opt_result.unwrap_or(Ok(()));
|
||||||
|
|
||||||
if let Err(parent_impl) = result {
|
if let Err(parent_impl) = result {
|
||||||
|
if !tcx.is_impl_trait_in_trait(impl_item) {
|
||||||
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
||||||
|
} else {
|
||||||
|
tcx.sess.delay_span_bug(
|
||||||
|
DUMMY_SP,
|
||||||
|
format!("parent item: {:?} not marked as default", parent_impl),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1485,7 +1492,9 @@ fn opaque_type_cycle_error(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for closure_def_id in visitor.closures {
|
for closure_def_id in visitor.closures {
|
||||||
let Some(closure_local_did) = closure_def_id.as_local() else { continue; };
|
let Some(closure_local_did) = closure_def_id.as_local() else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let typeck_results = tcx.typeck(closure_local_did);
|
let typeck_results = tcx.typeck(closure_local_did);
|
||||||
|
|
||||||
let mut label_match = |ty: Ty<'_>, span| {
|
let mut label_match = |ty: Ty<'_>, span| {
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
error[E0046]: not all trait items implemented, missing: `foo`
|
||||||
|
--> $DIR/missing-feature-flag.rs:14:1
|
||||||
|
|
|
||||||
|
LL | async fn foo(_: T) -> &'static str;
|
||||||
|
| ----------------------------------- `foo` from trait
|
||||||
|
...
|
||||||
|
LL | impl<T> MyTrait<T> for MyStruct {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
|
||||||
|
|
||||||
|
error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
|
||||||
|
--> $DIR/missing-feature-flag.rs:18:5
|
||||||
|
|
|
||||||
|
LL | impl<T> MyTrait<T> for MyStruct {}
|
||||||
|
| ------------------------------- parent `impl` is here
|
||||||
|
...
|
||||||
|
LL | async fn foo(_: i32) -> &'static str {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo`
|
||||||
|
|
|
||||||
|
= note: to specialize, `foo` in the parent `impl` must be marked `default`
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/missing-feature-flag.rs:18:42
|
||||||
|
|
|
||||||
|
LL | async fn foo(_: i32) -> &'static str {}
|
||||||
|
| ^^ expected `&str`, found `()`
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0046, E0308, E0520.
|
||||||
|
For more information about an error, try `rustc --explain E0046`.
|
@ -0,0 +1,30 @@
|
|||||||
|
error[E0046]: not all trait items implemented, missing: `foo`
|
||||||
|
--> $DIR/missing-feature-flag.rs:14:1
|
||||||
|
|
|
||||||
|
LL | async fn foo(_: T) -> &'static str;
|
||||||
|
| ----------------------------------- `foo` from trait
|
||||||
|
...
|
||||||
|
LL | impl<T> MyTrait<T> for MyStruct {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
|
||||||
|
|
||||||
|
error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
|
||||||
|
--> $DIR/missing-feature-flag.rs:18:5
|
||||||
|
|
|
||||||
|
LL | impl<T> MyTrait<T> for MyStruct {}
|
||||||
|
| ------------------------------- parent `impl` is here
|
||||||
|
...
|
||||||
|
LL | async fn foo(_: i32) -> &'static str {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo`
|
||||||
|
|
|
||||||
|
= note: to specialize, `foo` in the parent `impl` must be marked `default`
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/missing-feature-flag.rs:18:42
|
||||||
|
|
|
||||||
|
LL | async fn foo(_: i32) -> &'static str {}
|
||||||
|
| ^^ expected `&str`, found `()`
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0046, E0308, E0520.
|
||||||
|
For more information about an error, try `rustc --explain E0046`.
|
23
tests/ui/async-await/in-trait/missing-feature-flag.rs
Normal file
23
tests/ui/async-await/in-trait/missing-feature-flag.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// edition:2018
|
||||||
|
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||||
|
// revisions: current next
|
||||||
|
|
||||||
|
#![feature(async_fn_in_trait)]
|
||||||
|
#![feature(min_specialization)]
|
||||||
|
|
||||||
|
struct MyStruct;
|
||||||
|
|
||||||
|
trait MyTrait<T> {
|
||||||
|
async fn foo(_: T) -> &'static str;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> MyTrait<T> for MyStruct {}
|
||||||
|
//~^ ERROR: not all trait items implemented, missing: `foo` [E0046]
|
||||||
|
|
||||||
|
impl MyTrait<i32> for MyStruct {
|
||||||
|
async fn foo(_: i32) -> &'static str {}
|
||||||
|
//~^ ERROR: `foo` specializes an item from a parent `impl`, but that item is not marked `default` [E0520]
|
||||||
|
//~| ERROR: mismatched types [E0308]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user