Skip to content

Commit 3b9453b

Browse files
committed
use is_const_fn_raw when encoding constness
this properly encodes cross-crate constness data.
1 parent 7ede6e2 commit 3b9453b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,12 @@ impl EncodeContext<'a, 'tcx> {
12231223
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
12241224
FnData {
12251225
asyncness: sig.header.asyncness,
1226-
constness: sig.header.constness,
1226+
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
1227+
constness: if self.tcx.is_const_fn_raw(def_id) {
1228+
hir::Constness::Const
1229+
} else {
1230+
hir::Constness::NotConst
1231+
},
12271232
param_names: self.encode_fn_param_names_for_body(body),
12281233
}
12291234
} else {

0 commit comments

Comments
 (0)