Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Change to use exprPrecedence instead of exprKind.
  • Loading branch information
sam09 committed Oct 1, 2019
commit 9e4eb46790435c38a613d7f9d5d3e0eb5f77fca1
9 changes: 5 additions & 4 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/conversion-methods.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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]`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/infinite/infinite-autoderef.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/occurs-check-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/occurs-check.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/span/coerce-suggestions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down