You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #112043 - jieyouxu:suggestion_macro_expansion_source_callsites, r=cjgillot
Fix suggestion spans for expr from macro expansions
### Issue #112007: rustc shows expanded `writeln!` macro in code suggestion
#### Before This PR
```
help: consider using a semicolon here
|
6 | };
| +
help: you might have meant to return this value
--> C:\Users\hayle\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\macros\mod.rs:557:9
|
55| return $dst.write_fmt($crate::format_args_nl!($($arg)*));
| ++++++ +
```
#### After This PR
```
help: consider using a semicolon here
|
LL | };
| +
help: you might have meant to return this value
|
LL | return writeln!(w, "but not here");
| ++++++ +
```
### Issue #110017: `format!` `.into()` suggestion deletes the `format` macro
#### Before This PR
```
help: call `Into::into` on this expression to convert `String` into `Box<dyn std::error::Error>`
--> /Users/eric/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/macros.rs:121:12
|
12| res.into()
| +++++++
```
#### After This PR
```
help: call `Into::into` on this expression to convert `String` into `Box<dyn std::error::Error>`
|
LL | Err(format!("error: {x}").into())
| +++++++
```
---
Fixes#112007.
Fixes#110017.
= note: this error originates in the macro `format` which comes from the expansion of the macro `outer` (in Nightly builds, run with -Z macro-backtrace for more info)
24
+
help: call `Into::into` on this expression to convert `String` into `Box<dyn std::error::Error>`
= note: this error originates in the macro `format` which comes from the expansion of the macro `entire_fn_outer` (in Nightly builds, run with -Z macro-backtrace for more info)
38
+
help: call `Into::into` on this expression to convert `String` into `Box<dyn std::error::Error>`
= note: this error originates in the macro `format` which comes from the expansion of the macro `nontrivial` (in Nightly builds, run with -Z macro-backtrace for more info)
52
+
help: call `Into::into` on this expression to convert `String` into `Box<dyn std::error::Error>`
53
+
|
54
+
LL | Err(format!("error: {}", $x).into())
55
+
| +++++++
56
+
57
+
error: aborting due to 4 previous errors
58
+
59
+
For more information about this error, try `rustc --explain E0308`.
| | ^^^^^^^ expected `()`, found `Result<(), Error>`
33
+
LL | | }
34
+
| |_____- expected this to be `()`
35
+
|
36
+
= note: expected unit type `()`
37
+
found enum `Result<(), std::fmt::Error>`
38
+
= note: this error originates in the macro `writeln` which comes from the expansion of the macro `baz` (in Nightly builds, run with -Z macro-backtrace for more info)
39
+
help: consider using a semicolon here
40
+
|
41
+
LL | };
42
+
| +
43
+
help: you might have meant to return this value
44
+
|
45
+
LL | return baz!(w);
46
+
| ++++++ +
47
+
48
+
error: aborting due to 2 previous errors
49
+
50
+
For more information about this error, try `rustc --explain E0308`.
0 commit comments