Skip to content

Commit b95945c

Browse files
authored
Rollup merge of rust-lang#69539 - Centril:fix-69401, r=petrochenkov
late resolve, visit_fn: bail early if there's no body. Fixes rust-lang#69401 which was injected by rust-lang@b2c6eeb in rust-lang#68788. r? @petrochenkov
2 parents e4cedc9 + 85b585d commit b95945c

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/librustc_resolve/late.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,9 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
456456
}
457457
fn visit_fn(&mut self, fn_kind: FnKind<'ast>, sp: Span, _: NodeId) {
458458
let rib_kind = match fn_kind {
459-
FnKind::Fn(FnCtxt::Foreign, ..) => return visit::walk_fn(self, fn_kind, sp),
460-
FnKind::Fn(FnCtxt::Free, ..) => FnItemRibKind,
459+
// Bail if there's no body.
460+
FnKind::Fn(.., None) => return visit::walk_fn(self, fn_kind, sp),
461+
FnKind::Fn(FnCtxt::Free, ..) | FnKind::Fn(FnCtxt::Foreign, ..) => FnItemRibKind,
461462
FnKind::Fn(FnCtxt::Assoc(_), ..) | FnKind::Closure(..) => NormalRibKind,
462463
};
463464
let previous_value = replace(&mut self.diagnostic_metadata.current_function, Some(sp));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {}
2+
3+
trait Foo {
4+
fn fn_with_type_named_same_as_local_in_param(b: b);
5+
//~^ ERROR cannot find type `b` in this scope
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `b` in this scope
2+
--> $DIR/issue-69401-trait-fn-no-body-ty-local.rs:4:53
3+
|
4+
LL | fn fn_with_type_named_same_as_local_in_param(b: b);
5+
| ^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)