mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-21 19:33:16 +00:00
Fix rebase and clippy tests
This commit is contained in:
parent
8888d0d61e
commit
b825b0fe63
@ -130,7 +130,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
hir::AsyncGeneratorKind::Block,
|
||||
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
|
||||
),
|
||||
ExprKind::Await(ref expr) => self.lower_expr_await(e.span, expr),
|
||||
ExprKind::Await(ref expr) => {
|
||||
let span = if expr.span.hi() < e.span.hi() {
|
||||
expr.span.shrink_to_hi().with_hi(e.span.hi())
|
||||
} else {
|
||||
// this is a recovered `await expr`
|
||||
e.span
|
||||
};
|
||||
self.lower_expr_await(span, expr)
|
||||
}
|
||||
ExprKind::Closure(
|
||||
capture_clause,
|
||||
asyncness,
|
||||
@ -639,6 +647,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
self.allow_gen_future.clone(),
|
||||
);
|
||||
let expr = self.lower_expr_mut(expr);
|
||||
let expr_hir_id = expr.hir_id;
|
||||
|
||||
let pinned_ident = Ident::with_dummy_span(sym::pinned);
|
||||
let (pinned_pat, pinned_pat_hid) =
|
||||
@ -665,19 +674,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span,
|
||||
hir::LangItem::PinNewUnchecked,
|
||||
arena_vec![self; ref_mut_pinned],
|
||||
Some(expr.hir_id),
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let get_context = self.expr_call_lang_item_fn_mut(
|
||||
gen_future_span,
|
||||
hir::LangItem::GetContext,
|
||||
arena_vec![self; task_context],
|
||||
Some(expr.hir_id),
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let call = self.expr_call_lang_item_fn(
|
||||
span,
|
||||
hir::LangItem::FuturePoll,
|
||||
arena_vec![self; new_unchecked, get_context],
|
||||
Some(expr.hir_id),
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
self.arena.alloc(self.expr_unsafe(call))
|
||||
};
|
||||
@ -694,7 +703,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span,
|
||||
hir::LangItem::PollReady,
|
||||
ready_field,
|
||||
Some(expr.hir_id),
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let break_x = self.with_loop_scope(loop_node_id, move |this| {
|
||||
let expr_break =
|
||||
@ -710,7 +719,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span,
|
||||
hir::LangItem::PollPending,
|
||||
&[],
|
||||
Some(expr.hir_id),
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let empty_block = self.expr_block_empty(span);
|
||||
self.arm(pending_pat, empty_block)
|
||||
@ -731,7 +740,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let unit = self.expr_unit(span);
|
||||
let yield_expr = self.expr(
|
||||
span,
|
||||
hir::ExprKind::Yield(unit, hir::YieldSource::Await { expr: Some(expr.hir_id) }),
|
||||
hir::ExprKind::Yield(unit, hir::YieldSource::Await { expr: Some(expr_hir_id) }),
|
||||
ThinVec::new(),
|
||||
);
|
||||
let yield_expr = self.arena.alloc(yield_expr);
|
||||
@ -778,6 +787,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
into_future_span,
|
||||
hir::LangItem::IntoFutureIntoFuture,
|
||||
arena_vec![self; expr],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
|
||||
// match <into_future_expr> {
|
||||
|
@ -1153,7 +1153,7 @@ impl<'a> Parser<'a> {
|
||||
/// Assuming we have just parsed `.`, continue parsing into an expression.
|
||||
fn parse_dot_suffix(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
|
||||
if self.token.uninterpolated_span().rust_2018() && self.eat_keyword(kw::Await) {
|
||||
return Ok(self.mk_await_expr(self_arg));
|
||||
return Ok(self.mk_await_expr(self_arg, lo));
|
||||
}
|
||||
|
||||
let fn_span_lo = self.token.span;
|
||||
@ -2838,8 +2838,8 @@ impl<'a> Parser<'a> {
|
||||
ExprKind::Call(f, args)
|
||||
}
|
||||
|
||||
fn mk_await_expr(&mut self, self_arg: P<Expr>) -> P<Expr> {
|
||||
let span = self.prev_token.span;
|
||||
fn mk_await_expr(&mut self, self_arg: P<Expr>, lo: Span) -> P<Expr> {
|
||||
let span = lo.to(self.prev_token.span);
|
||||
let await_expr = self.mk_expr(span, ExprKind::Await(self_arg), AttrVec::new());
|
||||
self.recover_from_await_method_call();
|
||||
await_expr
|
||||
|
@ -421,11 +421,14 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
|
||||
// Mark this expr's scope and all parent scopes as containing `yield`.
|
||||
let mut scope = Scope { id: expr.hir_id.local_id, data: ScopeData::Node };
|
||||
loop {
|
||||
let data = YieldData {
|
||||
span: expr.span,
|
||||
expr_and_pat_count: visitor.expr_and_pat_count,
|
||||
source: *source,
|
||||
let span = match expr.kind {
|
||||
hir::ExprKind::Yield(expr, hir::YieldSource::Await { .. }) => {
|
||||
expr.span.shrink_to_hi().to(expr.span)
|
||||
}
|
||||
_ => expr.span,
|
||||
};
|
||||
let data =
|
||||
YieldData { span, expr_and_pat_count: visitor.expr_and_pat_count, source: *source };
|
||||
visitor.scope_tree.yield_in_scope.insert(scope, data);
|
||||
if visitor.pessimistic_yield {
|
||||
debug!("resolve_expr in pessimistic_yield - marking scope {:?} for fixup", scope);
|
||||
|
@ -886,46 +886,48 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
) {
|
||||
let span = obligation.cause.span;
|
||||
|
||||
if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code {
|
||||
// FIXME: use `obligation.predicate.kind()...trait_ref.self_ty()` to see if we have `()`
|
||||
// and if not maybe suggest doing something else? If we kept the expression around we
|
||||
// could also check if it is an fn call (very likely) and suggest changing *that*, if
|
||||
// it is from the local crate.
|
||||
err.span_suggestion_verbose(
|
||||
span,
|
||||
"do not `.await` the expression",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
// FIXME: account for associated `async fn`s.
|
||||
if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code.peel_derives() {
|
||||
let hir = self.tcx.hir();
|
||||
if let Some(node) = hir_id.and_then(|hir_id| hir.find(hir_id)) {
|
||||
if let hir::Node::Expr(hir::Expr {
|
||||
span, kind: hir::ExprKind::Call(base, _), ..
|
||||
}) = node
|
||||
{
|
||||
if let ty::PredicateKind::Trait(pred) =
|
||||
obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
err.span_label(*span, &format!("this call returns `{}`", pred.self_ty()));
|
||||
}
|
||||
if let Some(typeck_results) =
|
||||
self.in_progress_typeck_results.map(|t| t.borrow())
|
||||
{
|
||||
let ty = typeck_results.expr_ty_adjusted(base);
|
||||
if let ty::FnDef(def_id, _substs) = ty.kind() {
|
||||
if let Some(hir::Node::Item(hir::Item { span, ident, .. })) =
|
||||
hir.get_if_local(*def_id)
|
||||
{
|
||||
err.span_suggestion_verbose(
|
||||
span.shrink_to_lo(),
|
||||
&format!(
|
||||
"alternatively, consider making `fn {}` asynchronous",
|
||||
ident
|
||||
),
|
||||
"async ".to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
if let hir::Node::Expr(expr) = node {
|
||||
// FIXME: use `obligation.predicate.kind()...trait_ref.self_ty()` to see if we have `()`
|
||||
// and if not maybe suggest doing something else? If we kept the expression around we
|
||||
// could also check if it is an fn call (very likely) and suggest changing *that*, if
|
||||
// it is from the local crate.
|
||||
err.span_suggestion_verbose(
|
||||
expr.span.shrink_to_hi().with_hi(span.hi()),
|
||||
"do not `.await` the expression",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
// FIXME: account for associated `async fn`s.
|
||||
if let hir::Expr { span, kind: hir::ExprKind::Call(base, _), .. } = expr {
|
||||
if let ty::PredicateKind::Trait(pred) =
|
||||
obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
err.span_label(
|
||||
*span,
|
||||
&format!("this call returns `{}`", pred.self_ty()),
|
||||
);
|
||||
}
|
||||
if let Some(typeck_results) =
|
||||
self.in_progress_typeck_results.map(|t| t.borrow())
|
||||
{
|
||||
let ty = typeck_results.expr_ty_adjusted(base);
|
||||
if let ty::FnDef(def_id, _substs) = ty.kind() {
|
||||
if let Some(hir::Node::Item(hir::Item { span, ident, .. })) =
|
||||
hir.get_if_local(*def_id)
|
||||
{
|
||||
err.span_suggestion_verbose(
|
||||
span.shrink_to_lo(),
|
||||
&format!(
|
||||
"alternatively, consider making `fn {}` asynchronous",
|
||||
ident
|
||||
),
|
||||
"async ".to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -810,7 +810,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
def_id,
|
||||
&substs,
|
||||
match lang_item {
|
||||
hir::LangItem::FuturePoll => ObligationCauseCode::AwaitableExpr(expr_hir_id),
|
||||
hir::LangItem::IntoFutureIntoFuture => {
|
||||
ObligationCauseCode::AwaitableExpr(expr_hir_id)
|
||||
}
|
||||
hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => {
|
||||
ObligationCauseCode::ForLoopIterator
|
||||
}
|
||||
|
@ -162,68 +162,68 @@ LL | let _ = (await bar())?;
|
||||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:71:19
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:71:18
|
||||
|
|
||||
LL | fn foo13() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
LL | let _ = bar().await();
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:76:19
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:76:18
|
||||
|
|
||||
LL | fn foo14() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
LL | let _ = bar().await()?;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:81:19
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:81:18
|
||||
|
|
||||
LL | fn foo15() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
LL | let _ = bar().await;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:85:19
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:85:18
|
||||
|
|
||||
LL | fn foo16() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
LL | let _ = bar().await?;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:90:23
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:90:22
|
||||
|
|
||||
LL | fn foo() -> Result<(), ()> {
|
||||
| --- this is not `async`
|
||||
LL | let _ = bar().await?;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:97:23
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:97:22
|
||||
|
|
||||
LL | let foo = || {
|
||||
| -- this is not `async`
|
||||
LL | let _ = bar().await?;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:113:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:113:29
|
||||
|
|
||||
LL | fn foo() -> Result<(), ()> {
|
||||
| --- this is not `async`
|
||||
LL | let _ = await!(bar())?;
|
||||
| ^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:121:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:121:29
|
||||
|
|
||||
LL | let foo = || {
|
||||
| -- this is not `async`
|
||||
LL | let _ = await!(bar())?;
|
||||
| ^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^ only allowed inside `async` functions and blocks
|
||||
|
||||
error: aborting due to 33 previous errors
|
||||
|
||||
|
@ -6,7 +6,6 @@ async fn fun() {
|
||||
//~| error: `.await` is not allowed in a `const`
|
||||
//~| error: `.await` is not allowed in a `const`
|
||||
//~| error: `()` is not a future
|
||||
//~| error: `()` is not a future
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,16 +1,16 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-70594.rs:4:12
|
||||
--> $DIR/issue-70594.rs:4:11
|
||||
|
|
||||
LL | async fn fun() {
|
||||
| --- this is not `async`
|
||||
LL | [1; ().await];
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0744]: `.await` is not allowed in a `const`
|
||||
--> $DIR/issue-70594.rs:4:12
|
||||
--> $DIR/issue-70594.rs:4:9
|
||||
|
|
||||
LL | [1; ().await];
|
||||
| ^^^^^
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0744]: `.await` is not allowed in a `const`
|
||||
--> $DIR/issue-70594.rs:4:11
|
||||
@ -18,16 +18,6 @@ error[E0744]: `.await` is not allowed in a `const`
|
||||
LL | [1; ().await];
|
||||
| ^^^^^^
|
||||
|
||||
error[E0277]: `()` is not a future
|
||||
--> $DIR/issue-70594.rs:4:12
|
||||
|
|
||||
LL | [1; ().await];
|
||||
| ^^^^^ `()` is not a future
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `()`
|
||||
= note: () must be a future or must implement `IntoFuture` to be awaited
|
||||
= note: required because of the requirements on the impl of `IntoFuture` for `()`
|
||||
|
||||
error[E0277]: `()` is not a future
|
||||
--> $DIR/issue-70594.rs:4:11
|
||||
|
|
||||
@ -36,13 +26,14 @@ LL | [1; ().await];
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `()`
|
||||
= note: () must be a future or must implement `IntoFuture` to be awaited
|
||||
= note: required because of the requirements on the impl of `IntoFuture` for `()`
|
||||
help: do not `.await` the expression
|
||||
|
|
||||
LL - [1; ().await];
|
||||
LL + [1; ()];
|
||||
|
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0728, E0744.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-51719.rs:8:25
|
||||
--> $DIR/issue-51719.rs:8:24
|
||||
|
|
||||
LL | let _gen = || foo().await;
|
||||
| -- ^^^^^ only allowed inside `async` functions and blocks
|
||||
| -- ^^^^^^ only allowed inside `async` functions and blocks
|
||||
| |
|
||||
| this is not `async`
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-51751.rs:9:27
|
||||
--> $DIR/issue-51751.rs:9:26
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
LL | let result = inc(10000);
|
||||
LL | let finished = result.await;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -12,5 +12,4 @@ fn main() {
|
||||
(|_| 2333).await;
|
||||
//~^ ERROR `await` is only allowed inside `async` functions and blocks
|
||||
//~| ERROR is not a future
|
||||
//~| ERROR is not a future
|
||||
}
|
||||
|
@ -1,38 +1,28 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-62009-1.rs:6:23
|
||||
--> $DIR/issue-62009-1.rs:6:22
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
LL | async { let (); }.await;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-62009-1.rs:10:7
|
||||
--> $DIR/issue-62009-1.rs:10:6
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
...
|
||||
LL | }.await;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-62009-1.rs:12:16
|
||||
--> $DIR/issue-62009-1.rs:12:15
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
...
|
||||
LL | (|_| 2333).await;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
|
||||
--> $DIR/issue-62009-1.rs:12:16
|
||||
|
|
||||
LL | (|_| 2333).await;
|
||||
| ^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
|
||||
= note: [closure@$DIR/issue-62009-1.rs:12:5: 12:15] must be a future or must implement `IntoFuture` to be awaited
|
||||
= note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
|
||||
--> $DIR/issue-62009-1.rs:12:15
|
||||
@ -42,13 +32,14 @@ LL | (|_| 2333).await;
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
|
||||
= note: [closure@$DIR/issue-62009-1.rs:12:5: 12:15] must be a future or must implement `IntoFuture` to be awaited
|
||||
= note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
|
||||
help: do not `.await` the expression
|
||||
|
|
||||
LL - (|_| 2333).await;
|
||||
LL + (|_| 2333);
|
||||
|
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0728.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-62009-2.rs:8:23
|
||||
--> $DIR/issue-62009-2.rs:8:22
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
LL | (async || 2333)().await;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/non-async-enclosing-span.rs:9:28
|
||||
--> $DIR/non-async-enclosing-span.rs:9:27
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
LL | let x = move || {};
|
||||
LL | let y = do_the_thing().await;
|
||||
| ^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -39,7 +39,7 @@ LL | dummy();
|
||||
| +
|
||||
|
||||
error[E0308]: `if` and `else` have incompatible types
|
||||
--> $DIR/suggest-missing-await.rs:35:17
|
||||
--> $DIR/suggest-missing-await.rs:35:9
|
||||
|
|
||||
LL | let _x = if true {
|
||||
| ______________-
|
||||
@ -48,7 +48,7 @@ LL | | dummy()
|
||||
LL | |
|
||||
LL | | } else {
|
||||
LL | | dummy().await
|
||||
| | ^^^^^ expected opaque type, found `()`
|
||||
| | ^^^^^^^^^^^^^ expected opaque type, found `()`
|
||||
LL | |
|
||||
LL | | };
|
||||
| |_____- `if` and `else` have incompatible types
|
||||
@ -61,7 +61,7 @@ LL | dummy().await
|
||||
| ++++++
|
||||
|
||||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/suggest-missing-await.rs:45:22
|
||||
--> $DIR/suggest-missing-await.rs:45:14
|
||||
|
|
||||
LL | let _x = match 0usize {
|
||||
| ______________-
|
||||
@ -70,7 +70,7 @@ LL | | 0 => dummy(),
|
||||
LL | | 1 => dummy(),
|
||||
| | ------- this is found to be of type `impl Future<Output = ()>`
|
||||
LL | | 2 => dummy().await,
|
||||
| | ^^^^^ expected opaque type, found `()`
|
||||
| | ^^^^^^^^^^^^^ expected opaque type, found `()`
|
||||
LL | |
|
||||
LL | | };
|
||||
| |_____- `match` arms have incompatible types
|
||||
|
@ -7,6 +7,8 @@ LL | boo().await;
|
||||
| this call returns `()`
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `()`
|
||||
= note: () must be a future or must implement `IntoFuture` to be awaited
|
||||
= note: required because of the requirements on the impl of `IntoFuture` for `()`
|
||||
help: do not `.await` the expression
|
||||
|
|
||||
LL - boo().await;
|
||||
|
@ -23,20 +23,6 @@ LL | for _ in HashMap::new().iter().cloned() {}
|
||||
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
= note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
|
||||
<<<<<<< HEAD
|
||||
error: aborting due to 2 previous errors
|
||||
=======
|
||||
error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_`
|
||||
--> $DIR/issue-33941.rs:4:14
|
||||
|
|
||||
LL | for _ in HashMap::new().iter().cloned() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
|
||||
|
|
||||
= note: expected tuple `(&_, &_)`
|
||||
found reference `&_`
|
||||
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
>>>>>>> 330b90f5fc1 (Remove yet more output from `for`-loop and `?` errors)
|
||||
|
||||
For more information about this error, try `rustc --explain E0271`.
|
||||
|
@ -73,7 +73,7 @@ fn contains_assign_expr<'tcx>(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'tcx>) ->
|
||||
seen
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
struct LocalAssign {
|
||||
lhs_id: HirId,
|
||||
lhs_span: Span,
|
||||
@ -154,9 +154,14 @@ fn assignment_suggestions<'tcx>(
|
||||
assignments.push(assign);
|
||||
}
|
||||
|
||||
let suggestions = assignments
|
||||
let suggestions = assignments.clone()
|
||||
.into_iter()
|
||||
.map(|assignment| Some((assignment.span, snippet_opt(cx, assignment.rhs_span)?)))
|
||||
.map(|assignment| Some((assignment.span.until(assignment.rhs_span), String::new())))
|
||||
.chain(
|
||||
assignments
|
||||
.into_iter()
|
||||
.map(|assignment| Some((assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()), String::new())))
|
||||
)
|
||||
.collect::<Option<Vec<(Span, String)>>>()?;
|
||||
|
||||
let applicability = if suggestions.len() > 1 {
|
||||
|
@ -1,38 +0,0 @@
|
||||
// run-rustfix
|
||||
|
||||
#![allow(unused, clippy::assign_op_pattern)]
|
||||
|
||||
fn main() {
|
||||
|
||||
let a = "zero";
|
||||
|
||||
|
||||
|
||||
let b = 1;
|
||||
let c = 2;
|
||||
|
||||
|
||||
let d: usize = 1;
|
||||
|
||||
|
||||
let mut e = 1;
|
||||
e = 2;
|
||||
|
||||
|
||||
let f = match 1 {
|
||||
1 => "three",
|
||||
_ => return,
|
||||
}; // has semi
|
||||
|
||||
|
||||
let g: usize = if true {
|
||||
5
|
||||
} else {
|
||||
panic!();
|
||||
};
|
||||
|
||||
|
||||
let h = format!("{}", e);
|
||||
|
||||
println!("{}", a);
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
// run-rustfix
|
||||
|
||||
#![allow(unused, clippy::assign_op_pattern)]
|
||||
|
||||
fn main() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:6:5
|
||||
--> $DIR/needless_late_init_fixable.rs:4:5
|
||||
|
|
||||
LL | let a;
|
||||
| ^^^^^^
|
||||
@ -11,7 +11,7 @@ LL | let a = "zero";
|
||||
| ~~~~~
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:9:5
|
||||
--> $DIR/needless_late_init_fixable.rs:7:5
|
||||
|
|
||||
LL | let b;
|
||||
| ^^^^^^
|
||||
@ -22,7 +22,7 @@ LL | let b = 1;
|
||||
| ~~~~~
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:10:5
|
||||
--> $DIR/needless_late_init_fixable.rs:8:5
|
||||
|
|
||||
LL | let c;
|
||||
| ^^^^^^
|
||||
@ -33,7 +33,7 @@ LL | let c = 2;
|
||||
| ~~~~~
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:14:5
|
||||
--> $DIR/needless_late_init_fixable.rs:12:5
|
||||
|
|
||||
LL | let d: usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
@ -44,7 +44,7 @@ LL | let d: usize = 1;
|
||||
| ~~~~~~~~~~~~
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:17:5
|
||||
--> $DIR/needless_late_init_fixable.rs:15:5
|
||||
|
|
||||
LL | let mut e;
|
||||
| ^^^^^^^^^^
|
||||
@ -55,7 +55,7 @@ LL | let mut e = 1;
|
||||
| ~~~~~~~~~
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:21:5
|
||||
--> $DIR/needless_late_init_fixable.rs:19:5
|
||||
|
|
||||
LL | let f;
|
||||
| ^^^^^^
|
||||
@ -66,11 +66,12 @@ LL | let f = match 1 {
|
||||
| +++++++
|
||||
help: remove the assignments from the `match` arms
|
||||
|
|
||||
LL | 1 => "three",
|
||||
| ~~~~~~~
|
||||
LL - 1 => f = "three",
|
||||
LL + 1 => "three",
|
||||
|
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:27:5
|
||||
--> $DIR/needless_late_init_fixable.rs:25:5
|
||||
|
|
||||
LL | let g: usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
@ -81,15 +82,16 @@ LL | let g: usize = if true {
|
||||
| ++++++++++++++
|
||||
help: remove the assignments from the branches
|
||||
|
|
||||
LL | 5
|
||||
|
|
||||
LL - g = 5;
|
||||
LL + 5
|
||||
|
|
||||
help: add a semicolon after the `if` expression
|
||||
|
|
||||
LL | };
|
||||
| +
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:34:5
|
||||
--> $DIR/needless_late_init_fixable.rs:32:5
|
||||
|
|
||||
LL | let h;
|
||||
| ^^^^^^
|
||||
|
Loading…
Reference in New Issue
Block a user