Fix order-dependent visibility diagnostics#155948
Fix order-dependent visibility diagnostics#155948SynapLink wants to merge 1 commit intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
bfb4b8a to
21b1458
Compare
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| match self.try_resolve_visibility(vis, true) { | ||
| Ok(vis) => vis, | ||
| Err(err) => { | ||
| if !self.delay_vis_resolution(vis) { |
There was a problem hiding this comment.
I think it would be simpler to delay unconditionally.
DelayedVisResolutionError can contain the actual VisResolutionError, if late resolve_path fails then we report the new error, if it succeeds then we report the stashed error.
|
|
||
| fn delay_vis_resolution(&mut self, vis: &ast::Visibility) -> bool { | ||
| let ast::VisibilityKind::Restricted { ref path, id, .. } = vis.kind else { | ||
| return false; |
There was a problem hiding this comment.
This case is unreachable, non-Restricted visibilities cannot produce errors.
| let ast::VisibilityKind::Restricted { ref path, id, .. } = vis.kind else { | ||
| return false; | ||
| }; | ||
| let Ok(segments) = self.visibility_path_segments(path) else { |
There was a problem hiding this comment.
We can probably just save Box<Path> in the delayed error, without converting it into segments.
There was a problem hiding this comment.
Or perhaps we can clone the whole ast::Visibility to store it in the delayed error, and then call try_resolve_visibility from report_delayed_vis_resolution_errors instead of reusing just parts of it.
| ), | ||
| }) | ||
| } | ||
| ast::VisibilityKind::Restricted { ref path, id, .. } => { |
There was a problem hiding this comment.
Could you extract the logic below and share it between report_delayed_vis_resolution_errors and this function?
Fixes #40066.
Fixes #109657.
Delay visibility path diagnostics until module collection has finished, so paths to later non-ancestor modules report E0742 instead of an unresolved path error.