Skip to content

Commit 069fdd2

Browse files
Rollup merge of rust-lang#156633 - eval-exec:issue-41261-regression-test, r=mu001999
Add regression test for issue rust-lang#41261 Adds a regression test for rust-lang#41261.
2 parents 94a1b09 + 87821d9 commit 069fdd2

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ edition: 2021
2+
3+
// Regression test for issue #41261.
4+
// The diagnostic should point at the ambiguous cast, not at the later method call.
5+
6+
struct S {
7+
v: Vec<(u32, Vec<u32>)>,
8+
}
9+
10+
impl S {
11+
pub fn remove(&mut self, i: u32) -> Option<std::vec::Drain<'_, u32>> {
12+
self.v.get_mut(i as _).map(|&mut (_, ref mut v2)| {
13+
//~^ ERROR type annotations needed
14+
v2.drain(..)
15+
})
16+
}
17+
}
18+
19+
fn main() {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0282]: type annotations needed for `&mut (_, _)`
2+
--> $DIR/ambiguous-cast-suggestion-issue-41261.rs:12:37
3+
|
4+
LL | self.v.get_mut(i as _).map(|&mut (_, ref mut v2)| {
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
LL |
7+
LL | v2.drain(..)
8+
| -- type must be known at this point
9+
|
10+
help: consider giving this closure parameter an explicit type, where the placeholders `_` are specified
11+
|
12+
LL | self.v.get_mut(i as _).map(|&mut (_, ref mut v2): &mut (_, _)| {
13+
| +++++++++++++
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)