Skip to content

Commit c146e8c

Browse files
committed
revert workaround #73027
1 parent 71ca239 commit c146e8c

File tree

4 files changed

+10
-28
lines changed

4 files changed

+10
-28
lines changed

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,6 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> {
9191
if let (None, Some(ty)) =
9292
(self.found_local_pattern, self.node_ty_contains_target(local.hir_id))
9393
{
94-
// FIXME: There's a trade-off here - we can either check that our target span
95-
// is contained in `local.span` or not. If we choose to check containment
96-
// we can avoid some spurious suggestions (see #72690), but we lose
97-
// the ability to report on things like:
98-
//
99-
// ```
100-
// let x = vec![];
101-
// ```
102-
//
103-
// because the target span will be in the macro expansion of `vec![]`.
104-
// At present we choose not to check containment.
10594
self.found_local_pattern = Some(&*local.pat);
10695
self.found_node_ty = Some(ty);
10796
}
@@ -113,10 +102,8 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> {
113102
if let (None, Some(ty)) =
114103
(self.found_arg_pattern, self.node_ty_contains_target(param.hir_id))
115104
{
116-
if self.target_span.contains(param.pat.span) {
117-
self.found_arg_pattern = Some(&*param.pat);
118-
self.found_node_ty = Some(ty);
119-
}
105+
self.found_arg_pattern = Some(&*param.pat);
106+
self.found_node_ty = Some(ty);
120107
}
121108
}
122109
intravisit::walk_body(self, body);

src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0282]: type annotations needed
2-
--> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:8:5
2+
--> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:8:27
33
|
44
LL | with_closure(|x: u32, y| {});
5-
| ^^^^^^^^^^^^ cannot infer type for type parameter `B` declared on the function `with_closure`
5+
| ^ consider giving this closure parameter a type
66

77
error: aborting due to previous error
88

src/test/ui/issues/issue-23046.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn let_<'var, VAR, F: for<'v> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>>
1414
}
1515

1616
fn main() {
17-
let ex = |x| {
18-
let_(add(x,x), |y| { //~ ERROR type annotations needed
17+
let ex = |x| { //~ ERROR type annotations needed
18+
let_(add(x,x), |y| {
1919
let_(add(x, x), |x|x)})};
2020
}

src/test/ui/issues/issue-23046.stderr

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
error[E0282]: type annotations needed for the closure `fn(Expr<'_, _>) -> Expr<'_, _>`
2-
--> $DIR/issue-23046.rs:18:9
1+
error[E0282]: type annotations needed for `Expr<'_, VAR>`
2+
--> $DIR/issue-23046.rs:17:15
33
|
4-
LL | let_(add(x,x), |y| {
5-
| ^^^^ cannot infer type for type parameter `VAR` declared on the function `let_`
6-
|
7-
help: give this closure an explicit return type without `_` placeholders
8-
|
9-
LL | let_(add(x, x), |x|-> Expr<'_, _> { x })})};
10-
| ^^^^^^^^^^^^^^^^ ^
4+
LL | let ex = |x| {
5+
| ^ consider giving this closure parameter the explicit type `Expr<'_, VAR>`, where the type parameter `VAR` is specified
116

127
error: aborting due to previous error
138

0 commit comments

Comments
 (0)