diff --git a/macro/src/expand.rs b/macro/src/expand.rs index bc3f000d6..59b5928ef 100644 --- a/macro/src/expand.rs +++ b/macro/src/expand.rs @@ -1127,9 +1127,11 @@ fn expand_rust_function_shim_super( Some(ret) => quote!(#ret), None => quote!(()), }; - let impl_trait = quote_spanned!(result.span=> impl); - let display = quote_spanned!(rangle.span=> ::std::fmt::Display); - quote!(-> ::std::result::Result<#ok, #impl_trait #display>) + // Set spans that result in the `Result<...>` written by the user being + // highlighted as the cause if their error type has no Display impl. + let result_begin = quote_spanned!(result.span=> ::std::result::Result<#ok, impl); + let result_end = quote_spanned!(rangle.span=> ::std::fmt::Display>); + quote!(-> #result_begin #result_end) } else { expand_return_type(&sig.ret) }; diff --git a/tests/ui/array_len_suffix.stderr b/tests/ui/array_len_suffix.stderr index b72fc0227..ea5fac740 100644 --- a/tests/ui/array_len_suffix.stderr +++ b/tests/ui/array_len_suffix.stderr @@ -7,4 +7,4 @@ error[E0308]: mismatched types help: change the type of the numeric literal from `u16` to `usize` | 4 | fn array() -> [String; 12usize]; - | ^^^^^^^ + | ~~~~~~~ diff --git a/tests/ui/expected_named.stderr b/tests/ui/expected_named.stderr index 46764014d..dab3b5a36 100644 --- a/tests/ui/expected_named.stderr +++ b/tests/ui/expected_named.stderr @@ -8,4 +8,4 @@ error[E0106]: missing lifetime specifier help: consider using the `'static` lifetime | 5 | fn borrowed() -> UniquePtr>; - | ^^^^^^^^^^^^^^^^^ + | ~~~~~~~~~~~~~~~~~ diff --git a/tests/ui/unsupported_elided.stderr b/tests/ui/unsupported_elided.stderr index cd4642c9f..c9c401aa9 100644 --- a/tests/ui/unsupported_elided.stderr +++ b/tests/ui/unsupported_elided.stderr @@ -16,4 +16,4 @@ error[E0106]: missing lifetime specifier help: consider introducing a named lifetime parameter | 8 | fn f<'a>(t: &'a T) -> &'a str; - | ^^^^ ^^^^^ ^^^ + | ++++ ~~~~~ ~~~