Skip to content

Cleanup (pretty) printing of ty::Const #59276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
May 25, 2019
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
86d65d8
Remove unnecessary secondary recursion
oli-obk Mar 18, 2019
d85e866
Ignore .vscode even if it is a symlink
oli-obk Mar 26, 2019
8d4f4cd
Reuse the pretty printing architecture for printing of constants
oli-obk Mar 29, 2019
a92d97e
There's a tcx in scope, don't use the tls one
oli-obk Apr 2, 2019
5713677
Merge the string printing paths of ty::Const
oli-obk Apr 2, 2019
9d82107
Print const chars escaped with surrounding quotes
oli-obk Apr 2, 2019
e694b63
Don't use `ty::Const` without immediately interning
oli-obk Apr 3, 2019
264c149
Add test showing how byte slices are printed in MIR
oli-obk Apr 11, 2019
af6ac1f
Refactor string constant printing to prep for byte string printing
oli-obk Apr 11, 2019
fa17654
Make `ConstValue::Slice` solely take `[u8]` and `str`
oli-obk Apr 11, 2019
9b5896a
Render const byte slices in MIR
oli-obk Apr 11, 2019
669bc77
`u8` is printed as a number, not a character
oli-obk Apr 15, 2019
db652fc
Render unresolved anon consts like closures
oli-obk Apr 17, 2019
0528954
Group common printing code during constant pretty printing
oli-obk Apr 17, 2019
fec79d3
Print generic args in function calls in MIR
oli-obk Apr 17, 2019
90bb861
Fix tidy
oli-obk Apr 24, 2019
ecee75d
Use `write_char` to skip the formatting infrastructure
oli-obk Apr 24, 2019
b816ec1
Print unevaluted constants as `_` or as their source representation
oli-obk Apr 24, 2019
28198bb
Update ui tests
oli-obk Apr 24, 2019
89b2fb6
rustc: integrate ty::Const into ty::print as print_const.
eddyb Mar 18, 2019
52fa900
Break cycle during array length printing
oli-obk May 3, 2019
fa459a0
Fix rebase fallout
oli-obk May 7, 2019
825cfdb
Print types for unevaluated constants
oli-obk May 11, 2019
dd32795
Update ui tests
oli-obk May 11, 2019
a0275e3
Only print integers in symbol path's constants
oli-obk May 11, 2019
e694807
Fix missing tcx
varkor May 24, 2019
0b732aa
Update nll ui tests
oli-obk May 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only print integers in symbol path's constants
  • Loading branch information
oli-obk committed May 25, 2019
commit a0275e3bf3aa72b40f8f9cb1b3b64c620569377c
12 changes: 10 additions & 2 deletions src/librustc_codegen_utils/symbol_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ use rustc::ty::print::{PrettyPrinter, Printer, Print};
use rustc::ty::query::Providers;
use rustc::ty::subst::{Kind, SubstsRef, UnpackedKind};
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::mir::interpret::{ConstValue, Scalar};
use rustc::util::common::record_time;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_mir::monomorphize::item::{InstantiationMode, MonoItem, MonoItemExt};
Expand Down Expand Up @@ -438,10 +439,17 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'_, 'tcx> {
}

fn print_const(
self,
mut self,
ct: &'tcx ty::Const<'tcx>,
) -> Result<Self::Const, Self::Error> {
self.pretty_print_const(ct)
// only print integers
if let ConstValue::Scalar(Scalar::Bits { .. }) = ct.val {
if ct.ty.is_integral() {
return self.pretty_print_const(ct);
}
}
self.write_str("_")?;
Ok(self)
}

fn path_crate(
Expand Down