Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
369555c
Implement `FusedIterator` for `std::net::[Into]Incoming`
ChayimFriedman2 May 23, 2022
b884797
Clarify MIR semantics of checked binary operations
tmiasko Jun 30, 2022
b8213bb
Enable raw-dylib for binaries
dpaoliello Jul 1, 2022
a368830
Improve spans for specialization error
compiler-errors Jul 1, 2022
76c0429
Bump std::net::Incoming FusedIterator impl to Rust 1.64
dtolnay Jul 2, 2022
583d61f
adjust dangling-int-ptr error message
RalfJung Jul 3, 2022
7fc7780
fix interpreter validity check on Box
RalfJung Jul 3, 2022
d7edf66
move Box mess handling into general visitor
RalfJung Jul 4, 2022
658b7f3
more `rustc_pass_by_value`
lcnr Jul 4, 2022
eef5630
Fix wrap parenthesis suggestion for async closure
compiler-errors Jul 4, 2022
2acf859
Rollup merge of #97300 - ChayimFriedman2:patch-1, r=dtolnay
JohnTitor Jul 4, 2022
cf0557c
Rollup merge of #98738 - tmiasko:checked-binop, r=oli-obk
JohnTitor Jul 4, 2022
6aace7f
Rollup merge of #98778 - dpaoliello:rawdylibbin, r=michaelwoerister
JohnTitor Jul 4, 2022
0fe8ac3
Rollup merge of #98782 - compiler-errors:specialization-error-span, r…
JohnTitor Jul 4, 2022
392fbde
Rollup merge of #98847 - RalfJung:box-is-special, r=oli-obk
JohnTitor Jul 4, 2022
cf4ff4e
Rollup merge of #98860 - RalfJung:dangling-int-ptr, r=davidtwco
JohnTitor Jul 4, 2022
c9857bf
Rollup merge of #98878 - lcnr:more-rustc_pass_by_value, r=oli-obk
JohnTitor Jul 4, 2022
fc9b5de
Rollup merge of #98879 - compiler-errors:async-closure-wrap-parens, r…
JohnTitor Jul 4, 2022
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
27 changes: 24 additions & 3 deletions compiler/rustc_typeck/src/check/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,36 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
callee_node: &hir::ExprKind<'_>,
callee_span: Span,
) {
let hir_id = self.tcx.hir().get_parent_node(hir_id);
let parent_node = self.tcx.hir().get(hir_id);
let hir = self.tcx.hir();
let parent_hir_id = hir.get_parent_node(hir_id);
let parent_node = hir.get(parent_hir_id);
if let (
hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure { fn_decl_span, .. }, ..
kind: hir::ExprKind::Closure { fn_decl_span, body, .. },
..
}),
hir::ExprKind::Block(..),
) = (parent_node, callee_node)
{
let fn_decl_span = if hir.body(*body).generator_kind
== Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure))
{
// Actually need to unwrap a few more layers of HIR to get to
// the _real_ closure...
let async_closure = hir.get_parent_node(hir.get_parent_node(parent_hir_id));
if let hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure { fn_decl_span, .. },
..
}) = hir.get(async_closure)
{
*fn_decl_span
} else {
return;
}
} else {
*fn_decl_span
};

let start = fn_decl_span.shrink_to_lo();
let end = callee_span.shrink_to_hi();
err.multipart_suggestion(
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/suggestions/suggest-on-bare-closure-call.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// edition:2021

#![feature(async_closure)]

fn main() {
let _ = ||{}();
//~^ ERROR expected function, found `()`

let _ = async ||{}();
//~^ ERROR expected function, found `()`
}
17 changes: 15 additions & 2 deletions src/test/ui/suggestions/suggest-on-bare-closure-call.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0618]: expected function, found `()`
--> $DIR/suggest-on-bare-closure-call.rs:2:15
--> $DIR/suggest-on-bare-closure-call.rs:6:15
|
LL | let _ = ||{}();
| ^^--
Expand All @@ -11,6 +11,19 @@ help: if you meant to create this closure and immediately call it, surround the
LL | let _ = (||{})();
| + +

error: aborting due to previous error
error[E0618]: expected function, found `()`
--> $DIR/suggest-on-bare-closure-call.rs:9:21
|
LL | let _ = async ||{}();
| ^^--
| |
| call expression requires function
|
help: if you meant to create this closure and immediately call it, surround the closure with parentheses
|
LL | let _ = (async ||{})();
| + +

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0618`.