Skip to content

Commit 3fba7b4

Browse files
Rollup merge of #105965 - compiler-errors:issue-105896, r=cjgillot
Provide local extern function arg names Fixes #105896
2 parents 996fb66 + e5c159c commit 3fba7b4

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

compiler/rustc_middle/src/hir/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,13 @@ pub fn provide(providers: &mut Providers) {
160160
} else if let Node::TraitItem(&TraitItem {
161161
kind: TraitItemKind::Fn(_, TraitFn::Required(idents)),
162162
..
163+
})
164+
| Node::ForeignItem(&ForeignItem {
165+
kind: ForeignItemKind::Fn(_, idents, _),
166+
..
163167
}) = hir.get(hir_id)
164168
{
165-
tcx.arena.alloc_slice(idents)
169+
idents
166170
} else {
167171
span_bug!(hir.span(hir_id), "fn_arg_names: unexpected item {:?}", id);
168172
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extern "Rust" {
2+
fn dstfn(src: i32, dst: err);
3+
//~^ ERROR cannot find type `err` in this scope
4+
}
5+
6+
fn main() {
7+
dstfn(1);
8+
//~^ ERROR this function takes 2 arguments but 1 argument was supplied
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0412]: cannot find type `err` in this scope
2+
--> $DIR/extern-fn-arg-names.rs:2:29
3+
|
4+
LL | fn dstfn(src: i32, dst: err);
5+
| ^^^ not found in this scope
6+
7+
error[E0061]: this function takes 2 arguments but 1 argument was supplied
8+
--> $DIR/extern-fn-arg-names.rs:7:5
9+
|
10+
LL | dstfn(1);
11+
| ^^^^^--- an argument is missing
12+
|
13+
note: function defined here
14+
--> $DIR/extern-fn-arg-names.rs:2:8
15+
|
16+
LL | fn dstfn(src: i32, dst: err);
17+
| ^^^^^
18+
help: provide the argument
19+
|
20+
LL | dstfn(1, /* dst */);
21+
| ~~~~~~~~~~~~~~
22+
23+
error: aborting due to 2 previous errors
24+
25+
Some errors have detailed explanations: E0061, E0412.
26+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)