]> git.lizzy.rs Git - rust.git/commit
Emit a better diagnostic when function actually has a 'self' parameter
authorAaron Hill <aa1ronham@gmail.com>
Sun, 17 May 2020 22:28:12 +0000 (18:28 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Sun, 17 May 2020 23:04:13 +0000 (19:04 -0400)
commitb6844489f9dc3ca7aa23c3111a4576099919d65f
tree7a59d3dc84ac41af5b759a0b0da68078104d307c
parentd79f1bd31a1401b5d08096fcdf9a9eb23ddf95df
Emit a better diagnostic when function actually has a 'self' parameter

Fixes #66898

When we are unable to resolve a reference to `self`, we current assume
that the containing function doesn't have a `self` parameter, and
emit an error message accordingly.

However, if the reference to `self` was created by a macro invocation,
then resolution will correctly fail, due to hygiene. In this case, we
don't want to tell the user that the containing fuction doesn't have a
'self' paramter if it actually has one.

This PR checks for the precense of a 'self' parameter, and adjusts the
error message we emit accordingly.

TODO: The exact error message we emit could probably be improved. Should
we explicitly mention hygiene?
src/librustc_resolve/late.rs
src/librustc_resolve/late/diagnostics.rs
src/test/ui/hygiene/missing-self-diag.rs [new file with mode: 0644]
src/test/ui/hygiene/missing-self-diag.stderr [new file with mode: 0644]