File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -291,10 +291,15 @@ or perhaps if we want to be more strictly correct:
291
291
292
292
We could also go further and analyze the type to which ` ? ` is applied
293
293
and figure out the set of legal return types for the function to
294
- have. So if the code is invoking ` foo.write()? ` (i.e., applying ` ? ` to an
295
- ` io::Result ` ), then we could offer a suggestion like "consider changing
296
- the return type to ` Result<(), io::Error> ` " or perhaps just "consider
297
- changing the return type to a ` Result" ` .
294
+ have. So if the code is invoking ` foo.write()? ` (i.e., applying ` ? ` to
295
+ an ` io::Result ` ), then we could offer a suggestion like "consider
296
+ changing the return type to ` Result<(), io::Error> ` " or perhaps just
297
+ "consider changing the return type to a ` Result" ` . Note however that
298
+ if ` ? ` is used within an impl of a trait method, or within ` main() ` ,
299
+ or in some other context where the user is not free to change the type
300
+ signature, then we should make this suggestion. In the case of an impl
301
+ of a trait defined in the current crate, we could consider suggesting
302
+ that the user change the definition of the trait.
298
303
299
304
On an implementation note, it would probably be helpful for improving
300
305
the error message if ` ? ` were not desugared when lowering from AST to
You can’t perform that action at this time.
0 commit comments