) {
let source_map = self.tcx.sess.source_map();
- let is_async_fn = self
- .tcx
- .parent(inner_generator)
- .map(|parent_did| self.tcx.asyncness(parent_did))
- .map(|parent_asyncness| parent_asyncness == hir::IsAsync::Async)
- .unwrap_or(false);
- let is_async_move = self
+ let is_async = self
.tcx
.hir()
.as_local_hir_id(inner_generator)
_ => false,
})
.unwrap_or(false);
- let await_or_yield = if is_async_fn || is_async_move { "await" } else { "yield" };
+ let await_or_yield = if is_async { "await" } else { "yield" };
+ let future_or_generator = if is_async { "future" } else { "generator" };
// Special case the primary error message when send or sync is the trait that was
// not implemented.
err.clear_code();
err.set_primary_message(format!(
- "future cannot be {} between threads safely",
+ "{} cannot be {} between threads safely",
+ future_or_generator,
trait_verb
));
format!("future created by async closure is not {}", trait_name),
}
))
- .unwrap_or_else(|| format!("future is not {}", trait_name));
+ .unwrap_or_else(|| format!("{} is not {}", future_or_generator, trait_name));
span.push_span_label(original_span, message);
err.set_span(span);
- format!("is not {}", trait_name)
+ format!("{} is not {}", future_or_generator, trait_name)
} else {
- format!("does not implement `{}`", trait_ref.print_only_trait_path())
+ format!(
+ "{} does not implement `{}`",
+ future_or_generator,
+ trait_ref.print_only_trait_path()
+ )
};
// Look at the last interior type to get a span for the `.await`.
err.span_note(
span,
- &format!(
- "future {} as this value is used across an {}",
- trait_explanation, await_or_yield,
- ),
+ &format!("{} as this value is used across an {}", trait_explanation, await_or_yield),
);
if let Some(expr_id) = expr {
-error: future cannot be sent between threads safely
+error: generator cannot be sent between threads safely
--> $DIR/issue-68112.rs:33:5
|
LL | fn require_send(_: impl Send) {}
| ^^^^^^^^^^^^ generator is not `Send`
|
= help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell<i32>`
-note: future is not `Send` as this value is used across an yield
+note: generator is not `Send` as this value is used across an yield
--> $DIR/issue-68112.rs:31:9
|
LL | let _non_send_gen = make_non_send_generator();
= note: required because of the requirements on the impl of `std::marker::Send` for `&std::cell::Cell<i32>`
= note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:16:17: 20:6 a:&std::cell::Cell<i32> _]`
-error: future cannot be shared between threads safely
+error: generator cannot be shared between threads safely
--> $DIR/not-send-sync.rs:9:5
|
LL | fn assert_sync<T: Sync>(_: T) {}
| ^^^^^^^^^^^ generator is not `Sync`
|
= help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6 {std::cell::Cell<i32>, ()}]`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell<i32>`
-note: future is not `Sync` as this value is used across an yield
+note: generator is not `Sync` as this value is used across an yield
--> $DIR/not-send-sync.rs:12:9
|
LL | let a = Cell::new(2);