diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-09-26 15:15:35 +0200 |
|---|---|---|
| committer | oli <github35764891676564198441@oli-obk.de> | 2020-11-04 09:58:59 +0000 |
| commit | 362123dd7577daa4cf737bc8f50146beedd3d944 (patch) | |
| tree | d0fa1d0538039e2f7cb227eb6323f07fcc6ba74f /src/librustdoc | |
| parent | 56293097f7f877f1350a6cd00f79d03132f16515 (diff) | |
| download | rust-362123dd7577daa4cf737bc8f50146beedd3d944.tar.gz rust-362123dd7577daa4cf737bc8f50146beedd3d944.zip | |
Split the "raw integer bytes" part out of `Scalar`
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/utils.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index b0ed233f5ec..167b06428e5 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -14,7 +14,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; -use rustc_middle::mir::interpret::{sign_extend, ConstValue, Scalar}; +use rustc_middle::mir::interpret::{sign_extend, ConstValue}; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::{self, DefIdTree, Ty}; use rustc_span::symbol::{kw, sym, Symbol}; @@ -499,12 +499,13 @@ fn print_const_with_custom_print_scalar(cx: &DocContext<'_>, ct: &'tcx ty::Const // Use a slightly different format for integer types which always shows the actual value. // For all other types, fallback to the original `pretty_print_const`. match (ct.val, ct.ty.kind()) { - (ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data, .. })), ty::Uint(ui)) => { - format!("{}{}", format_integer_with_underscore_sep(&data.to_string()), ui.name_str()) + (ty::ConstKind::Value(ConstValue::Scalar(int)), ty::Uint(ui)) => { + format!("{}{}", format_integer_with_underscore_sep(&int.to_string()), ui.name_str()) } - (ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data, .. })), ty::Int(i)) => { + (ty::ConstKind::Value(ConstValue::Scalar(int)), ty::Int(i)) => { let ty = cx.tcx.lift(ct.ty).unwrap(); let size = cx.tcx.layout_of(ty::ParamEnv::empty().and(ty)).unwrap().size; + let data = int.assert_bits(size); let sign_extended_data = sign_extend(data, size) as i128; format!( |
