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:
|
21b1458 to
4f56ffe
Compare
|
@rustbot ready |
4f56ffe to
843b87b
Compare
|
|
||
| fn report_delayed_vis_resolution_errors(&mut self) { | ||
| for DelayedVisResolutionError { vis, parent_scope, error } in | ||
| std::mem::take(&mut self.delayed_vis_resolution_errors) |
There was a problem hiding this comment.
| std::mem::take(&mut self.delayed_vis_resolution_errors) | |
| mem::take(&mut self.delayed_vis_resolution_errors) |
Nit: proper importing.
| std::mem::take(&mut self.delayed_vis_resolution_errors) | ||
| { | ||
| match self.try_resolve_visibility(parent_scope, &vis, VisResolutionMode::Finalize) { | ||
| Ok(_) => { |
There was a problem hiding this comment.
| Ok(_) => { | |
| Ok(_) => self.report_vis_error(error), |
Nit: shorter formatting.
| Res::Def(self.r.tcx.def_kind(def_id), def_id) | ||
| } | ||
| impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | ||
| fn visibility_path_segments( |
There was a problem hiding this comment.
This method is no longer necessary, could you inline it back to its place?
| } | ||
|
|
||
| fn try_resolve_visibility<'ast>( | ||
| pub(crate) fn try_resolve_visibility( |
There was a problem hiding this comment.
There's an existing impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ... } block above, you could put this function there.
| finalize: bool, | ||
| ) -> Result<Visibility, VisResolutionError<'ast>> { | ||
| let parent_scope = &self.parent_scope; | ||
| parent_scope: ParentScope<'ra>, |
There was a problem hiding this comment.
| parent_scope: ParentScope<'ra>, | |
| parent_scope: &ParentScope<'ra>, |
| if finalize { | ||
| self.r.record_partial_res(id, PartialRes::new(res)); | ||
| if matches!(mode, VisResolutionMode::FinalizeAndRecord) { | ||
| self.record_partial_res(id, PartialRes::new(res)); |
There was a problem hiding this comment.
Was VisResolutionMode introduced to avoid calling record_partial_res twice?
I don't think we need it, it would be better to call record_partial_res only if we are returning Ok instead.
843b87b to
f7c62f5
Compare
|
@rustbot ready |
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.