@@ -156,12 +156,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
156
156
/// Note that inspecting a type's structure *directly* may expose the fact
157
157
/// that there are actually multiple representations for `Error`, so avoid
158
158
/// that when err needs to be handled differently.
159
+ #[ instrument( skip( self ) , level="debug" ) ]
159
160
pub ( super ) fn check_expr_with_expectation (
160
161
& self ,
161
162
expr : & ' tcx hir:: Expr < ' tcx > ,
162
163
expected : Expectation < ' tcx > ,
163
164
) -> Ty < ' tcx > {
164
- debug ! ( ">> type-checking: expected={:?}, expr={:?} " , expected, expr) ;
165
+ if self . tcx ( ) . sess . verbose ( ) {
166
+ // make this code only run with -Zverbose because it is probably slow
167
+ if let Ok ( lint_str) = self . tcx . sess . source_map ( ) . span_to_snippet ( expr. span ) {
168
+ if !lint_str. contains ( "\n " ) {
169
+ debug ! ( "expr text: {}" , lint_str) ;
170
+ } else {
171
+ let mut lines = lint_str. lines ( ) ;
172
+ if let Some ( line0) = lines. next ( ) {
173
+ let remaining_lines = lines. count ( ) ;
174
+ debug ! ( "expr text: {}" , line0) ;
175
+ debug ! ( "expr text: ...(and {} more lines)" , remaining_lines) ;
176
+ }
177
+ }
178
+ }
179
+ }
165
180
166
181
// True if `expr` is a `Try::from_ok(())` that is a result of desugaring a try block
167
182
// without the final expr (e.g. `try { return; }`). We don't want to generate an
@@ -1049,6 +1064,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1049
1064
let mut deferred_cast_checks = self . deferred_cast_checks . borrow_mut ( ) ;
1050
1065
match cast:: CastCheck :: new ( self , e, t_expr, t_cast, t. span , expr. span ) {
1051
1066
Ok ( cast_check) => {
1067
+ debug ! (
1068
+ "check_expr_cast: deferring cast from {:?} to {:?}: {:?}" ,
1069
+ t_cast,
1070
+ t_expr,
1071
+ cast_check,
1072
+ ) ;
1052
1073
deferred_cast_checks. push ( cast_check) ;
1053
1074
t_cast
1054
1075
}
0 commit comments