Skip to content

Commit 70ed4f9

Browse files
committed
Point at def span on incorrect panic or alloc error handler
1 parent e6b35b0 commit 70ed4f9

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
11781178
}
11791179
}
11801180
} else {
1181+
let span = fcx.tcx.sess.source_map().def_span(span);
11811182
fcx.tcx.sess.span_err(span, "function should have one argument");
11821183
}
11831184
} else {
@@ -1226,6 +1227,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
12261227
}
12271228
}
12281229
} else {
1230+
let span = fcx.tcx.sess.source_map().def_span(span);
12291231
fcx.tcx.sess.span_err(span, "function should have one argument");
12301232
}
12311233
} else {
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error: function should have one argument
22
--> $DIR/alloc-error-handler-bad-signature-3.rs:20:1
33
|
4-
LL | / fn oom() -> ! { //~ ERROR function should have one argument
5-
LL | | loop {}
6-
LL | | }
7-
| |_^
4+
LL | fn oom() -> ! { //~ ERROR function should have one argument
5+
| ^^^^^^^^^^^^^
86

97
error: aborting due to previous error
108

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error: function should have one argument
22
--> $DIR/panic-handler-bad-signature-3.rs:20:1
33
|
4-
LL | / fn panic() -> ! { //~ ERROR function should have one argument
5-
LL | | loop {}
6-
LL | | }
7-
| |_^
4+
LL | fn panic() -> ! { //~ ERROR function should have one argument
5+
| ^^^^^^^^^^^^^^^
86

97
error: aborting due to previous error
108

0 commit comments

Comments
 (0)