Commit Graph

468 Commits

Author SHA1 Message Date
Bryanskiy 5d394148be Privacy: enqueue type alias 2026-05-22 12:36:19 +03:00
Bryanskiy d143a60611 Privacy: try use queue instead of fixed-point iteration 2026-05-19 11:32:54 +03:00
Bryanskiy 3d0ee528cb Privacy: move macros handling to early stage 2026-05-13 20:04:42 +03:00
Vadim Petrochenkov cc630bc470 resolve: Evaluate private visibilities eagerly in eff vis computation 2026-05-10 08:06:03 +03:00
Vadim Petrochenkov 714df2bf00 privacy: Assert that compared visibilities are (usually) ordered
Also use `greater_than` instead of `is_at_least` for comparing visibilities, which we can do because visibilities are asserted to be ordered now.
2026-04-23 18:22:48 +03:00
Adwin White 6279106e72 fix all errors 2026-04-20 00:18:28 +08:00
Waffle Lapkin 0f767084b8 ty::Alias refactor: fixup all the compiler code 2026-04-07 10:08:12 +02:00
Jonathan Brouwer b20e49f5e6 Rollup merge of #152543 - petrochenkov:rprivtit2, r=fmease
privacy: Fix type privacy holes in RPITITs

A subset of https://github.com/rust-lang/rust/pull/146470.

Private types in RPITITs now report hard errors.
Private types in bounds of associated types still only report the `private_bounds` lint due to unacceptable amount of breakage (https://github.com/rust-lang/rust/pull/146470#issuecomment-3682850214).

Closes https://github.com/rust-lang/rust/issues/144139
2026-03-23 12:14:51 +01:00
Jonathan Brouwer 7174c100f4 Rollup merge of #153227 - kpreid:struct-missing-field, r=estebank
Don’t report missing fields in struct exprs with syntax errors.

@Noratrieb [told me](https://internals.rust-lang.org/t/custom-cargo-command-to-show-only-errors-avoid-setting-rustflags-every-time/24032/7?u=kpreid) that “it is a bug if this recovery causes follow-up errors that would not be there if the user fixed the first error.” So, here’s a contribution to hide a follow-up error that annoyed me recently.

Specifically, if the user writes a struct literal with a syntax error, such as

```rust
StructName { foo: 1 bar: 2 }
```

the compiler will no longer report that the field `bar` is missing in addition to the syntax error.

This is my first time attempting any change to the parser or AST; please let me know if there is a better way to do what I’ve done here. ~~The part I’m least happy with is the blast radius of adding another field to `hir::ExprKind::Struct`, but this seems to be in line with the style of the rest of the code. (If this were my own code, I would consider changing `hir::ExprKind::Struct` to a nested struct, the same way it is in `ast::ExprKind`.)~~ The additional information is now stored as an additional variant of `ast::StructRest` / `hir::StructTailExpr`.

**Note to reviewers:** I recommend reviewing each commit separately, and in the case of the first one with indentation changes ignored.
2026-03-03 07:14:12 +01:00
Kevin Reid d6eefce00d Remember whether a struct literal had syntax errors.
This adds a variant `NoneWithError` to AST and HIR representations of
the “rest” or “tail”, which is currently always treated identically to
the `None` variant.
2026-02-28 18:12:34 -08:00
bors 38c0de8dcb Auto merge of #153050 - JayanAXHF:refactor/change-is-type-const, r=BoxyUwU
refactor(mgca): Change `DefKind::Const` and `DefKind::AssocConst` to have a `is_type_const` flag



Addresses rust-lang/rust#152940 

- Changed `DefKind::Const` and `DefKind::AssocConst` to have a `is_type_const` flag.
- changed `is_type_const` query to check for this flag
- removed `is_rhs_type_const` query

r? @BoxyUwU
2026-02-28 18:27:06 +00:00
JayanAXHF efc150e5b3 refactor(mgca): Change DefKind::Const and DefKind::AssocConst to have a is_type_const flag
* refactor: add `is_type_const` flag to `DefKind::Const` and `AssocConst`
* refactor(cleanup) remove the `rhs_is_type_const` query
* style: fix formatting
* refactor: refactor stuff in librustdoc for new Const and AssocConst
* refactor: refactor clippy for the changes
* chore: formatting
* fix: fix test
* fix: fix suggestions
* Update context.rs

Co-authored-by: Boxy <rust@boxyuwu.dev>
* changed AssocKind::Const to store data about being a type const
2026-02-28 17:27:46 +00:00
Guillaume Gomez 2bb3b01af2 Replace TyCtxt::emit_node_span_lint with emit_diag_node_span_lint 2026-02-24 20:34:22 +01:00
Guillaume Gomez 327f778130 Migrate rustc_privacy to use TyCtxt::emit_diag_node_span_lint 2026-02-24 20:12:42 +01:00
Jana Dönszelmann decec173ec remove AttributeKind everywhere 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 63edc913fa change all uses 2026-02-20 09:50:16 +01:00
Vadim Petrochenkov ef8c95cde1 privacy: Fix type privacy holes when it doesn't cause too much breakage 2026-02-12 18:20:18 +03:00
Stuart Cook 68f4a99963 Rollup merge of #151887 - scottmcm:homogeneous-try-in-compiler, r=jackh726
Remove some unnecessary `try`-related type annotations

I left a few, like
```rust
let result: Result<_, ModError<'_>> = try {
```
where it felt like seeing it might still be useful for the reader.

Feel free to push back on any of these changes if you think they should be left alone.
2026-02-08 16:58:23 +11:00
Jana Dönszelmann 911203936b Port rustc_effective_visibility to the new attribute parser 2026-02-05 15:33:23 +01:00
Jonathan Brouwer ae21d43933 Convert to inline diagnostics in rustc_privacy 2026-02-04 08:11:40 +01:00
Scott McMurray f7931c8050 Remove some unnecessary try-related type annotations
I left a few, like
```rust
let result: Result<_, ModError<'_>> = try {
```
where it felt like seeing it might still be useful for the reader.

Feel free to push back on any of these changes if you think seeing the type would be better.
2026-01-30 18:21:19 -08:00
bors ef2657cbaf Auto merge of #151168 - petrochenkov:rprivtit, r=eholk
privacy: Fix privacy lints in RPITITs

Visit RPITITs and report `private_interfaces`, `private_bounds` and `exported_private_dependencies` in them (these are regular, non-deprecation lints).
New hard errors are not reported, https://github.com/rust-lang/rust/pull/146470 is for hard errors.
So this PR doesn't contain any breakage or language changes.
2026-01-30 01:45:52 +00:00
Jamie Hill-Daniel 02bd3e86c0 Use Rustc prefix for rustc attrs in AttributeKind 2026-01-29 14:52:09 +00:00
Vadim Petrochenkov 7b5a4d8653 privacy: Synchronize PrivateItemsInPublicInterfacesChecker and EmbargoVisitor 2026-01-29 16:34:17 +03:00
Vadim Petrochenkov 1ce89c0449 privacy: Close one more hole in associated type visiting 2026-01-29 16:34:16 +03:00
Vadim Petrochenkov 989568a79f privacy: Fix privacy lints in RPITITs 2026-01-29 16:34:16 +03:00
bjorn3 973c7527b4 Unify the configuration of the compiler docs
Previously it was rather inconsistent which crates got the rust logo and
which didn't and setting html_root_url was forgotten in many cases.
2025-11-05 11:25:27 +00:00
Cameron Steffen ead5e120a5 Remove QPath::LangItem 2025-10-27 21:19:38 -05:00
Vadim Petrochenkov f9464f827b privacy: Introduce some caching to type visiting in DefIdVisitorSkeleton 2025-10-22 17:31:12 +03:00
Vadim Petrochenkov 156499e561 privacy: Avoid some unnecessary mutability 2025-10-22 17:06:07 +03:00
Cameron Steffen e60e9f0826 Split impl_(opt_)trait_ref 2025-10-17 08:36:34 -05:00
Cameron Steffen ae8ff943c1 Remove some impl_opt_trait_header usages 2025-10-17 08:36:34 -05:00
Marijn Schouten fc703ec5c8 fix doc comments to be more standard 2025-09-26 09:25:56 +00:00
Nicholas Nethercote 301655eafe Revert introduction of [workspace.dependencies].
This was done in #145740 and #145947. It is causing problems for people
using r-a on anything that uses the rustc-dev rustup package, e.g. Miri,
clippy.

This repository has lots of submodules and subtrees and various
different projects are carved out of pieces of it. It seems like
`[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-02 19:12:54 +10:00
Nicholas Nethercote c50d2cc807 Add tracing to [workspace.dependencies]. 2025-08-27 14:21:19 +10:00
Cameron Steffen bf266dc834 Propagate TraitImplHeader to hir 2025-08-11 17:05:42 -05:00
bors 6d091b2baa Auto merge of #144554 - cjgillot:no-hir-eff-vis, r=petrochenkov
Use less HIR to compute effective visibility.

r? `@ghost`
2025-08-02 09:23:36 +00:00
Camille GILLOT 63e1327ce9 Use less HIR to compute effective visibility. 2025-08-02 02:08:52 +00:00
bors c23f07d8c5 Auto merge of #144479 - cjgillot:incr-privacy-mod, r=petrochenkov
Perform check_private_in_public by module.

Based on https://github.com/rust-lang/rust/pull/116316
2025-08-02 01:59:11 +00:00
Jana Dönszelmann e1d3ad89c7 remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
Kivooeo b8eb046e6e use let chains in mir, resolve, target 2025-07-28 06:10:36 +05:00
Camille GILLOT 1b01decc1c Do not fetch spans if not required. 2025-07-27 22:15:40 +00:00
Camille GILLOT c0fe285815 Parallelize check_private_in_public. 2025-07-27 22:15:30 +00:00
Camille GILLOT a1f5a6d781 Perform check_private_in_public by module. 2025-07-26 21:21:04 +00:00
León Orell Valerian Liehr ac4ffdce9a Rollup merge of #144276 - cjgillot:no-hir-privacy, r=petrochenkov
Use less HIR in check_private_in_public.

r? ````````@petrochenkov````````
2025-07-24 15:08:25 +02:00
Camille GILLOT 6e8762f769 Use less HIR in check_private_in_public. 2025-07-22 01:40:45 +00:00
Camille GILLOT c004a96603 Do not check privacy for RPITIT. 2025-07-17 23:59:41 +00:00
tiif 7356ff7517 Implement other logics 2025-07-15 13:48:30 +00:00
Camille GILLOT 21fd82adbc Retire hir::*ItemRef. 2025-07-13 13:50:01 +00:00
Camille GILLOT 5bd3841668 Retire hir::ForeignItemRef. 2025-07-13 13:50:00 +00:00