-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Avoid calling report_forbidden_specialization for RPITITs #113456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -722,7 +722,14 @@ pub(super) fn check_specialization_validity<'tcx>( | |
let result = opt_result.unwrap_or(Ok(())); | ||
|
||
if let Err(parent_impl) = result { | ||
report_forbidden_specialization(tcx, impl_item, parent_impl); | ||
if !tcx.is_impl_trait_in_trait(impl_item) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added this to avoid calling @compiler-errors would you prefer a code comment about this instead? |
||
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 { | ||
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 mut label_match = |ty: Ty<'_>, span| { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// edition:2018 | ||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty | ||
spastorino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// 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() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please delay a bug here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have delayed a bug, but please would rather if you check what I did what you meant and if the english wording is fine :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a bug so it's fine.