-
Notifications
You must be signed in to change notification settings - Fork 13.4k
"consider borrowing here" suggestion is missing parentheses #104961
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
@rustbot claim |
@compiler-errors
Seems we can only get more context from The current An completed solution should make sure we get something like 2 | x.starts_with(&("hi".to_string() + " you"))
| ++ |
I guess we have more similar issues for other suggestions come from |
This is an similar case, but we handle it well: fn bar(val: &str) {
todo!()
}
fn main() {
bar("hello".to_string() + "world");
} Output is: error[E0308]: mismatched types
--> ./p/n.rs:7:9
|
7 | bar("hello".to_string() + "world");
| --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | expected `&str`, found struct `String`
| | help: consider borrowing here: `&("hello".to_string() + "world")`
| arguments to this function are incorrect
|
note: function defined here
--> ./p/n.rs:2:4
|
2 | fn bar(val: &str) {
| ^^^ ---------
error: aborting due to previous error The codepath is different, we take care parenthesis here, with rust/compiler/rustc_hir_typeck/src/demand.rs Line 830 in df04d28
|
…w, r=cjgillot Add parentheses properly for borrowing suggestion Fixes rust-lang#104961
Uh oh!
There was an error while loading. Please reload this page.
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c03c22d0ff9f0d88bb0cacb6edb95501
The current output is:
Ideally the output should look like:
The text was updated successfully, but these errors were encountered: