about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/middle/privacy.rs
AgeCommit message (Collapse)AuthorLines
2023-10-13Format all the let chains in compilerMichael Goulet-1/+3
2023-07-28privacy: no nominal visibility for assoc fnsDavid Wood-2/+7
When `staged_api` is enabled, effective visibilities are computed earlier and this can trigger an ICE in some cases. In particular, if a impl of a trait method has a visibility then an error will be reported for that, but when privacy invariants are being checked, the effective visibility will still be greater than the nominal visbility and that will trigger a `span_bug!`. However, this invariant - that effective visibilites are limited to nominal visibility - doesn't make sense for associated functions. Signed-off-by: David Wood <david@davidtw.co>
2023-06-15privacy: Rename some variables for clarityVadim Petrochenkov-3/+3
2023-06-15privacy: Do not mark items reachable farther than their nominal visibilityVadim Petrochenkov-13/+16
This commit reverts a change made in #111425. It was believed that this change was necessary for implementing type privacy lints, but #111801 showed that it was not necessary. Quite opposite, the revert fixes some issues.
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-2/+1
2023-05-11Populate effective visibilities in rustc_privacyBryanskiy-26/+19
2023-05-08Revert "Populate effective visibilities in `rustc_privacy`"Michael Goulet-19/+26
This reverts commit cff85f22f5030fbe7266d272da74a9e76160523c.
2023-05-05Populate effective visibilities in `rustc_privacy`Bryanskiy-26/+19
2023-03-28effvis: Stop considering crate root its own parentVadim Petrochenkov-1/+5
It helped to reuse `update_def` for the crate root, but it created confusion and caused some mistakes when I implemented #109500
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-6/+6
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-20Remove IntoDefIdTreeOli Scherer-17/+8
2022-12-19clippy::complexity fixesMatthias Krüger-6/+1
filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool
2022-11-24effective visibility: Always add table entries for nodes used as parentsVadim Petrochenkov-33/+37
Previously if the parent was not in the table, and there was nothing to inherit from, the child's private visibility was used, but that's not correct - the parent may have a larger visibility so we should set it to at least the parent's private visibility. That parent's private visibility is also inserted into the table for caching, so it's not recalculated later if used again.
2022-11-24effective visibility: Remove questionable optimizationsVadim Petrochenkov-7/+0
First, they require eagerly calculating private visibility (current normal module), which is somewhat expensive. Private visibilities are also lost once calculated, instead of being cached in the table. Second, I cannot prove that the optimizations are correct. Maybe they can be partially reinstated in the future in cases when it's cheap and provably correct to do them. They will also probably be merged into `fn update` in that case. Partially fixes https://github.com/rust-lang/rust/issues/104249 Fixes https://github.com/rust-lang/rust/issues/104539
2022-11-24effective visibility: Satisfy borrow checker to use resolver lazily from a ↵Vadim Petrochenkov-10/+20
closure
2022-11-05resolve: Fill effective visibilities for import def ids in a separate passVadim Petrochenkov-2/+28
This should result in less update calls than doing it repeatedly during the fix point iteration.
2022-11-05privacy: Check effective visibility invariantsVadim Petrochenkov-1/+50
2022-11-05resolve: More detailed effective visibility tracking for importsVadim Petrochenkov-18/+25
Also drop `extern` blocks from the effective visibility table, they are nominally private and it doesn't make sense to keep them there.
2022-10-29rustc_middle: Remove unnecessary type parameter from `AccessLevels`Vadim Petrochenkov-32/+16
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-80/+79
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-25Perf improvements for effective visibility calculatingBryanskiy-33/+35
2022-10-16Populate effective visibilities in 'rustc_resolve'Bryanskiy-32/+104
2022-09-14change AccessLevels representationBryanskiy-6/+87
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-5/+3
2022-01-09Compute most of Public/Exported access level in rustc_resolveLamb-1/+1
Mak DefId to AccessLevel map in resolve for export hir_id to accesslevel in resolve and applied in privacy using local def id removing tracing probes making function not recursive and adding comments Move most of Exported/Public res to rustc_resolve moving public/export res to resolve fix missing stability attributes in core, std and alloc move code to access_levels.rs return for some kinds instead of going through them Export correctness, macro changes, comments add comment for import binding add comment for import binding renmae to access level visitor, remove comments, move fn as closure, remove new_key fmt fix rebase fix rebase fmt fmt fix: move macro def to rustc_resolve fix: reachable AccessLevel for enum variants fmt fix: missing stability attributes for other architectures allow unreachable pub in rustfmt fix: missing impl access level + renaming export to reexport Missing impl access level was found thanks to a test in clippy
2021-10-03Move ICH to rustc_query_system.Camille GILLOT-0/+11
2021-07-31rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tablesVadim Petrochenkov-11/+4
and passes using them - primarily privacy checking, stability checking and dead code checking. WIP
2020-12-21docs: Edit rustc_middle::middle::privacypierwill-4/+6
Add descriptions of `AccessLevel` and `AccessLevels`. Add missing punctuation.
2020-10-14Remove unused code from rustc_middleest31-5/+0
2020-08-30mv compiler to compiler/mark-0/+65