Auto merge of #76499 - guswynn:priv_des, r=petrochenkov
Give better diagnostic when using a private tuple struct constructor Fixes #75907 Some notes: 1. This required some deep changes, including removing a Copy impl for PatKind. If some tests fail, I would still appreciate review on the overall approach 2. this only works with basic patterns (no wildcards for example), and fails if there is any problems getting the visibility of the fields (i am not sure what the failure that can happen in resolve_visibility_speculative, but we check the length of our fields in both cases against each other, so if anything goes wrong, we fall back to the worse error. This could be extended to more patterns 3. this does not yet deal with #75906, but I believe it will be similar 4. let me know if you want more tests 5. doesn't yet at the suggestion that `@yoshuawuyts` suggested at the end of their issue, but that could be added relatively easily (i believe)
This commit is contained in:
commit
bc57bd8c7e
9 changed files with 152 additions and 29 deletions
|
@ -1005,7 +1005,8 @@ pub struct Resolver<'a> {
|
|||
|
||||
/// Table for mapping struct IDs into struct constructor IDs,
|
||||
/// it's not used during normal resolution, only for better error reporting.
|
||||
struct_constructors: DefIdMap<(Res, ty::Visibility)>,
|
||||
/// Also includes of list of each fields visibility
|
||||
struct_constructors: DefIdMap<(Res, ty::Visibility, Vec<ty::Visibility>)>,
|
||||
|
||||
/// Features enabled for this crate.
|
||||
active_features: FxHashSet<Symbol>,
|
||||
|
@ -1042,6 +1043,7 @@ pub struct ResolverArenas<'a> {
|
|||
name_resolutions: TypedArena<RefCell<NameResolution<'a>>>,
|
||||
macro_rules_bindings: TypedArena<MacroRulesBinding<'a>>,
|
||||
ast_paths: TypedArena<ast::Path>,
|
||||
pattern_spans: TypedArena<Span>,
|
||||
}
|
||||
|
||||
impl<'a> ResolverArenas<'a> {
|
||||
|
@ -1073,6 +1075,9 @@ impl<'a> ResolverArenas<'a> {
|
|||
fn alloc_ast_paths(&'a self, paths: &[ast::Path]) -> &'a [ast::Path] {
|
||||
self.ast_paths.alloc_from_iter(paths.iter().cloned())
|
||||
}
|
||||
fn alloc_pattern_spans(&'a self, spans: impl Iterator<Item = Span>) -> &'a [Span] {
|
||||
self.pattern_spans.alloc_from_iter(spans)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsMut<Resolver<'a>> for Resolver<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue