1
Fork 0

vis note for no pub reexports glob import

This commit is contained in:
bohan 2023-12-01 10:25:40 +08:00
parent c263ccf185
commit d0941f92d7
12 changed files with 118 additions and 32 deletions

View file

@ -8,7 +8,7 @@ use crate::errors::{
ItemsInTraitsAreNotImportable,
};
use crate::Determinacy::{self, *};
use crate::{fluent_generated as fluent, Namespace::*};
use crate::Namespace::*;
use crate::{module_to_string, names_to_string, ImportSuggestion};
use crate::{AmbiguityKind, BindingKey, ModuleKind, ResolutionError, Resolver, Segment};
use crate::{Finalize, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet};
@ -987,13 +987,23 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
if !is_prelude
&& let Some(max_vis) = max_vis.get()
&& !max_vis.is_at_least(import.expect_vis(), self.tcx)
&& let import_vis = import.expect_vis()
&& !max_vis.is_at_least(import_vis, self.tcx)
{
self.lint_buffer.buffer_lint(
let def_id = self.local_def_id(id);
let msg = format!(
"glob import doesn't reexport anything with visibility `{}` because no imported item is public enough",
import_vis.to_string(def_id, self.tcx)
);
self.lint_buffer.buffer_lint_with_diagnostic(
UNUSED_IMPORTS,
id,
import.span,
fluent::resolve_glob_import_doesnt_reexport,
msg.to_string(),
BuiltinLintDiagnostics::RedundantImportVisibility {
max_vis: max_vis.to_string(def_id, self.tcx),
span: import.span,
},
);
}
return None;