Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,16 @@ pub(crate) fn apply_computed_concrete_opaque_types<'tcx>(
let mut errors = Vec::new();
for &(key, hidden_type) in opaque_types {
let Some(expected) = get_concrete_opaque_type(concrete_opaque_types, key.def_id) else {
assert!(tcx.use_typing_mode_borrowck(), "non-defining use in defining scope");
if !tcx.use_typing_mode_borrowck() {
if let ty::Alias(ty::Opaque, alias_ty) = hidden_type.ty.kind()
&& alias_ty.def_id == key.def_id.to_def_id()
&& alias_ty.args == key.args
{
continue;
} else {
unreachable!("non-defining use in defining scope");
}
}
errors.push(DeferredOpaqueTypeError::NonDefiningUseInDefiningScope {
span: hidden_type.span,
opaque_type_key: key,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0277]: the trait bound `(): ReturnsSend` is not satisfied
--> $DIR/ice-issue-146191.rs:6:52
|
LL | fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
| ^^^^^^^^^^^^^^^^ the trait `ReturnsSend` is not implemented for `()`
|
help: this trait has no implementations, consider adding one
--> $DIR/ice-issue-146191.rs:14:1
|
LL | trait ReturnsSend {}
| ^^^^^^^^^^^^^^^^^
note: required by a bound in an opaque type
--> $DIR/ice-issue-146191.rs:6:57
|
LL | fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
| ^^^^^^^^^^^

error[E0733]: recursion in an async block requires boxing
--> $DIR/ice-issue-146191.rs:8:5
|
LL | async { create_complex_future().await }
| ^^^^^ ----------------------------- recursive call here
|
= note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0733.
For more information about an error, try `rustc --explain E0277`.
17 changes: 17 additions & 0 deletions tests/ui/impl-trait/non-defining-uses/ice-issue-146191.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0282]: type annotations needed
--> $DIR/ice-issue-146191.rs:8:5
|
LL | async { create_complex_future().await }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type

error[E0282]: type annotations needed
--> $DIR/ice-issue-146191.rs:8:5
|
LL | async { create_complex_future().await }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0282`.
15 changes: 15 additions & 0 deletions tests/ui/impl-trait/non-defining-uses/ice-issue-146191.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ edition: 2024
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)

fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
//[current]~^ ERROR the trait bound `(): ReturnsSend` is not satisfied
async { create_complex_future().await }
//[current]~^ ERROR recursion in an async block requires
//[next]~^^ ERROR type annotations needed
//[next]~| ERROR type annotations needed
}

trait ReturnsSend {}
fn main() {}
Loading