Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b523301

Browse files
committedMar 21, 2025
Add test to ensure no index out of bounds panic (#135474)
1 parent f7b4354 commit b523301

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
 
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn retry() -> impl Sized {}
2+
3+
struct Core<T>(T);
4+
5+
impl Core<XXX> { //~ ERROR cannot find type `XXX` in this scope
6+
pub fn spawn(self) {}
7+
}
8+
9+
fn main() {
10+
let core = Core(1);
11+
core.spawn(retry()); //~ ERROR this method takes 0 arguments but 1 argument was supplied
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0412]: cannot find type `XXX` in this scope
2+
--> $DIR/trait-fn-generic-mismatch.rs:5:11
3+
|
4+
LL | impl Core<XXX> {
5+
| ^^^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | impl<XXX> Core<XXX> {
10+
| +++++
11+
12+
error[E0061]: this method takes 0 arguments but 1 argument was supplied
13+
--> $DIR/trait-fn-generic-mismatch.rs:11:10
14+
|
15+
LL | core.spawn(retry());
16+
| ^^^^^ ------- unexpected argument of type `impl Sized`
17+
|
18+
note: method defined here
19+
--> $DIR/trait-fn-generic-mismatch.rs:6:12
20+
|
21+
LL | pub fn spawn(self) {}
22+
| ^^^^^
23+
help: remove the extra argument
24+
|
25+
LL - core.spawn(retry());
26+
LL + core.spawn();
27+
|
28+
29+
error: aborting due to 2 previous errors
30+
31+
Some errors have detailed explanations: E0061, E0412.
32+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)
Failed to load comments.