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 5076e84

Browse files
committedMar 14, 2025
Pass struct field HirId when check_expr_struct_fields
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
1 parent a2aba05 commit 5076e84

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed
 

‎compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2060,7 +2060,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20602060
// struct-like enums (yet...), but it's definitely not
20612061
// a bug to have constructed one.
20622062
if adt_kind != AdtKind::Enum {
2063-
tcx.check_stability(v_field.did, Some(expr.hir_id), field.span, None);
2063+
tcx.check_stability(v_field.did, Some(field.hir_id), field.span, None);
20642064
}
20652065

20662066
self.field_ty(field.span, v_field, args)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//@ check-pass
2+
fn _foo() {
3+
_Bar { //~ WARNING use of deprecated struct `_Bar`: reason
4+
#[expect(deprecated)]
5+
foo: 0,
6+
};
7+
}
8+
9+
#[deprecated = "reason"]
10+
struct _Bar {
11+
foo: u32,
12+
}
13+
14+
fn _foo2() {
15+
#[expect(deprecated)]
16+
_Bar2 {
17+
foo2: 0,
18+
};
19+
}
20+
21+
#[deprecated = "reason"]
22+
struct _Bar2 {
23+
foo2: u32,
24+
}
25+
26+
fn _foo3() {
27+
_Bar3 {
28+
#[expect(deprecated)]
29+
foo3: 0,
30+
};
31+
}
32+
33+
struct _Bar3 {
34+
#[deprecated = "reason"]
35+
foo3: u32,
36+
}
37+
38+
39+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: use of deprecated struct `_Bar`: reason
2+
--> $DIR/check-stability-issue-138319.rs:3:5
3+
|
4+
LL | _Bar {
5+
| ^^^^
6+
|
7+
= note: `#[warn(deprecated)]` on by default
8+
9+
warning: 1 warning emitted
10+

0 commit comments

Comments
 (0)
Failed to load comments.