Closed
Description
We should extend rustc_on_unimplemented
to be able to point at the enclosing scope. With that capability, we could turn the following:
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> src/lib.rs:28:31
|
28 | let end = parse_range_u32(end)?;
| ^^^^^^^^^^^^^^^^^^^^^ cannot use the `?` operator in a function that returns `std::ops::RangeInclusive<u32>`
|
= help: the trait `std::ops::Try` is not implemented for `std::ops::RangeInclusive<u32>`
= note: required by `std::ops::Try::from_error`
into something along the lines of
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> src/lib.rs:28:31
|
24 | .map(|range_spec| {
| -
| ______________|
... |
28 || let end = parse_range_u32(end)?;
|| ^^^^^^^^^^^^^^^^^^^^^ cannot use the `?` operator in a function that returns `std::ops::RangeInclusive<u32>`
... |
48 || })
|| - this function should return `Result` or `Option` to accept `?`
||_________|
|
= help: the trait `std::ops::Try` is not implemented for `std::ops::RangeInclusive<u32>`
= note: required by `std::ops::Try::from_error`
Activity
sam09 commentedon Oct 2, 2019
@estebank Can I pick this up? I don't have much of an idea about this, but would like to get involved
estebank commentedon Oct 2, 2019
@sam09 of course! I can take a look at #54946 and #47613 for some changes made to this code, the currently up to date documentation for the feature. You will probably have to take a look at
fn report_selection_error
and find a way to get the enclosing scope to the current item. This part will likely be hard given that this function only deals with obligations, doesn't have access to the originating item. The most likely successful course of action would be to extend the obligation itself to keep some information (most likely just a span) of the enclosing scope. The you could extendrustc_on_unimplemented
to be something likebasil-cow commentedon Nov 20, 2019
@sam09 would you mind me picking this up?
sam09 commentedon Nov 21, 2019
@Areredify @estebank
Apologies for not following up. I have been super busy with some things at work.
@Areredify Please go ahead. I haven't found any time to work on this 😄
basil-cow commentedon Nov 22, 2019
@estebank I implemented it, but I don't know how to compile it, since I changed both libstd(added an annotation to the Try trait) and the compiler.
enclosing scope
parameter torustc_on_unimplemented
#66651Rollup merge of rust-lang#66651 - Areredify:on-unimplemented-scope, r…
Rollup merge of rust-lang#66651 - Areredify:on-unimplemented-scope, r…