diff options
| author | bors <bors@rust-lang.org> | 2022-06-05 04:16:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-05 04:16:03 +0000 |
| commit | 656eec8785e25a7fba568dba83190df2b0981daa (patch) | |
| tree | 8d66b368d4c247998bbe98c9dcb2887d331efb31 /compiler/rustc_resolve | |
| parent | 6dadfc06fe628d7a381a52b07714a7a849a6223d (diff) | |
| parent | b76d1125d4f1596e4c4481064fa6342990f1a985 (diff) | |
| download | rust-656eec8785e25a7fba568dba83190df2b0981daa.tar.gz rust-656eec8785e25a7fba568dba83190df2b0981daa.zip | |
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`
Diffstat (limited to 'compiler/rustc_resolve')
| -rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 7e6375968ae..2e2d3674560 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -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) } |
