Auto merge of #97391 - Urgau:cfg_accessible, r=petrochenkov
Handle more cases in cfg_accessible This PR tries to handle more cases in the cfg_accessible implementation by only emitting a "not sure" error only if we have partially resolved a path. This PR also adds many tests for the "not sure" cases and for private items. r? `@petrochenkov`
This commit is contained in:
commit
656eec8785
9 changed files with 445 additions and 49 deletions
|
@ -443,11 +443,22 @@ impl<'a> ResolverExpand for Resolver<'a> {
|
|||
PathResult::NonModule(partial_res) if partial_res.unresolved_segments() == 0 => {
|
||||
return Ok(true);
|
||||
}
|
||||
PathResult::NonModule(..) |
|
||||
// HACK(Urgau): This shouldn't be necessary
|
||||
PathResult::Failed { is_error_from_last_segment: false, .. } => {
|
||||
self.session
|
||||
.struct_span_err(span, "not sure whether the path is accessible or not")
|
||||
.note("the type may have associated items, but we are currently not checking them")
|
||||
.emit();
|
||||
|
||||
// If we get a partially resolved NonModule in one namespace, we should get the
|
||||
// same result in any other namespaces, so we can return early.
|
||||
return Ok(false);
|
||||
}
|
||||
PathResult::Indeterminate => indeterminate = true,
|
||||
// FIXME: `resolve_path` is not ready to report partially resolved paths
|
||||
// correctly, so we just report an error if the path was reported as unresolved.
|
||||
// This needs to be fixed for `cfg_accessible` to be useful.
|
||||
PathResult::NonModule(..) | PathResult::Failed { .. } => {}
|
||||
// We can only be sure that a path doesn't exist after having tested all the
|
||||
// posibilities, only at that time we can return false.
|
||||
PathResult::Failed { .. } => {}
|
||||
PathResult::Module(_) => panic!("unexpected path resolution"),
|
||||
}
|
||||
}
|
||||
|
@ -456,10 +467,6 @@ impl<'a> ResolverExpand for Resolver<'a> {
|
|||
return Err(Indeterminate);
|
||||
}
|
||||
|
||||
self.session
|
||||
.struct_span_err(span, "not sure whether the path is accessible or not")
|
||||
.span_note(span, "`cfg_accessible` is not fully implemented")
|
||||
.emit();
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue