Change to use exprPrecedence instead of exprKind.
This commit is contained in:
parent
c9baaa70be
commit
9e4eb46790
@ -128,6 +128,7 @@ use syntax::attr;
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
use syntax::source_map::{DUMMY_SP, original_sp};
|
||||
use syntax::symbol::{kw, sym};
|
||||
use syntax::util::parser::ExprPrecedence;
|
||||
|
||||
use std::cell::{Cell, RefCell, Ref, RefMut};
|
||||
use std::collections::hash_map::Entry;
|
||||
@ -4344,10 +4345,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let max_len = receiver.rfind(".").unwrap();
|
||||
format!("{}{}", &receiver[..max_len], method_call)
|
||||
} else {
|
||||
match &expr.kind {
|
||||
ExprKind::Binary(_,_,_) => format!("({}){}", receiver, method_call),
|
||||
ExprKind::Unary(_,_) => format!("({}){}", receiver, method_call),
|
||||
_ => format!("{}{}", receiver, method_call),
|
||||
if expr.precedence().order() < ExprPrecedence::MethodCall.order() {
|
||||
format!("({}){}", receiver, method_call)
|
||||
} else {
|
||||
format!("{}{}", receiver, method_call)
|
||||
}
|
||||
};
|
||||
Some(if is_struct_pat_shorthand_field {
|
||||
|
@ -41,7 +41,7 @@ LL | let _prove_piercing_earnest: Vec<usize> = &[1, 2, 3];
|
||||
| ^^^^^^^^^^
|
||||
| |
|
||||
| expected struct `std::vec::Vec`, found reference
|
||||
| help: try using a conversion method: `&[1, 2, 3].to_vec()`
|
||||
| help: try using a conversion method: `(&[1, 2, 3]).to_vec()`
|
||||
|
|
||||
= note: expected type `std::vec::Vec<usize>`
|
||||
found type `&[{integer}; 3]`
|
||||
|
@ -5,7 +5,7 @@ LL | x = box x;
|
||||
| ^^^^^
|
||||
| |
|
||||
| cyclic type of infinite size
|
||||
| help: try using a conversion method: `box x.to_string()`
|
||||
| help: try using a conversion method: `(box x).to_string()`
|
||||
|
||||
error[E0055]: reached the recursion limit while auto-dereferencing `Foo`
|
||||
--> $DIR/infinite-autoderef.rs:25:5
|
||||
|
@ -5,7 +5,7 @@ LL | f = box g;
|
||||
| ^^^^^
|
||||
| |
|
||||
| cyclic type of infinite size
|
||||
| help: try using a conversion method: `box g.to_string()`
|
||||
| help: try using a conversion method: `(box g).to_string()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | f = box f;
|
||||
| ^^^^^
|
||||
| |
|
||||
| cyclic type of infinite size
|
||||
| help: try using a conversion method: `box f.to_string()`
|
||||
| help: try using a conversion method: `(box f).to_string()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -44,7 +44,7 @@ LL | f = box f;
|
||||
| ^^^^^
|
||||
| |
|
||||
| cyclic type of infinite size
|
||||
| help: try using a conversion method: `box f.to_string()`
|
||||
| help: try using a conversion method: `(box f).to_string()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-suggestions.rs:21:9
|
||||
|
Loading…
x
Reference in New Issue
Block a user