diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2021-06-30 23:56:43 +0800 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2021-06-30 23:56:43 +0800 |
| commit | 3b9453bfe23a861ac1622f3562df7f1f980a4b34 (patch) | |
| tree | 11733fe12e565d4d0207c107cc6c851e18ab3ebc | |
| parent | 7ede6e2a2359c1bb9032baffa4fdafe5633749e3 (diff) | |
| download | rust-3b9453bfe23a861ac1622f3562df7f1f980a4b34.tar.gz rust-3b9453bfe23a861ac1622f3562df7f1f980a4b34.zip | |
use is_const_fn_raw when encoding constness
this properly encodes cross-crate constness data.
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 76007398000..4231db620b0 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1223,7 +1223,12 @@ impl EncodeContext<'a, 'tcx> { let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind { FnData { asyncness: sig.header.asyncness, - constness: sig.header.constness, + // Can be inside `impl const Trait`, so using sig.header.constness is not reliable + constness: if self.tcx.is_const_fn_raw(def_id) { + hir::Constness::Const + } else { + hir::Constness::NotConst + }, param_names: self.encode_fn_param_names_for_body(body), } } else { |
