Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,15 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
fn visit_fn(&mut self, fn_kind: FnKind<'a>, _: &AttrVec, span: Span, _: NodeId) {
match fn_kind {
FnKind::Fn(
_ctxt,
ctxt,
_vis,
Fn {
sig: FnSig { header, decl, span: _ }, ident, generics, contract, body, ..
},
) if let Some(coroutine_kind) = header.coroutine_kind => {
) if let Some(coroutine_kind) = header.coroutine_kind
// Foreign ones are denied, so don't create them here.
&& ctxt != visit::FnCtxt::Foreign =>
{
self.visit_ident(ident);
self.visit_fn_header(header);
self.visit_generics(generics);
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/extern/bad-external-async-fn-issue-146754.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ edition:2024
#![crate_type = "lib"]

unsafe extern "C" {
async fn function() -> [(); || {}];
//~^ ERROR functions in `extern` blocks cannot have `async` qualifier
//~^^ ERROR mismatched types
}
21 changes: 21 additions & 0 deletions tests/ui/extern/bad-external-async-fn-issue-146754.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error: functions in `extern` blocks cannot have `async` qualifier
--> $DIR/bad-external-async-fn-issue-146754.rs:5:5
|
LL | unsafe extern "C" {
| ----------------- in this `extern` block
LL | async fn function() -> [(); || {}];
| ^^^^^ help: remove the `async` qualifier

error[E0308]: mismatched types
--> $DIR/bad-external-async-fn-issue-146754.rs:5:33
|
LL | async fn function() -> [(); || {}];
| ^^^^^ expected `usize`, found closure
|
= note: expected type `usize`
found closure `{closure@$DIR/bad-external-async-fn-issue-146754.rs:5:33: 5:35}`
= note: array length can only be `usize`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
Loading