about summary refs log tree commit diff
path: root/tests/ui/privacy
AgeCommit message (Collapse)AuthorLines
2023-12-20resolve: Stop feeding visibilities for import list stemsVadim Petrochenkov-0/+14
2023-12-19resolve: Feed visibilities for unresolved trait impl itemsVadim Petrochenkov-0/+37
2023-12-08privacy: visit trait def id of projectionsDavid Wood-13/+82
A refactoring in #117076 changed the `DefIdVisitorSkeleton` to avoid calling `visit_projection_ty` for `ty::Projection` aliases, and instead just iterate over the args - this makes sense, as `visit_projection_ty` will indirectly visit all of the same args, but in doing so, will also create a `TraitRef` containing the trait's `DefId`, which also gets visited. The trait's `DefId` isn't visited when we only visit the arguments without separating them into `TraitRef` and own args first. Signed-off-by: David Wood <david@davidtw.co>
2023-12-04Structured `use` suggestion on privacy errorEsteban Küber-1/+1
When encoutering a privacy error on an item through a re-export that is accessible in an alternative path, provide a structured suggestion with that path. ``` error[E0603]: module import `mem` is private --> $DIR/private-std-reexport-suggest-public.rs:4:14 | LL | use foo::mem; | ^^^ private module import | note: the module import `mem` is defined here... --> $DIR/private-std-reexport-suggest-public.rs:8:9 | LL | use std::mem; | ^^^^^^^^ note: ...and refers to the module `mem` which is defined here --> $SRC_DIR/std/src/lib.rs:LL:COL | = note: you could import this help: import `mem` through the re-export | LL | use std::mem; | ~~~~~~~~ ``` Fix #42909.
2023-12-01vis note for no pub reexports glob importbohan-4/+30
2023-11-29Tweak message on ADT with private fields buildingEsteban Küber-3/+3
When trying to create an inaccessible ADT due to private fields, handle the case when no fields were passed. ``` error: cannot construct `Foo` with struct literal syntax due to private fields --> $DIR/issue-76077.rs:8:5 | LL | foo::Foo {}; | ^^^^^^^^ | = note: private field `you_cant_use_this_field` that was not provided ```
2023-11-24Show number in error message even for one errorNilstrieb-26/+26
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-19Account for number of arguments in suggestionEsteban Küber-15/+15
2023-11-19Suggest Default::default() for struct literals with private fieldsEsteban Küber-0/+8
2023-11-19Suggest builder functions on struct literal with private fieldsEsteban Küber-1/+41
2023-11-19Suggest using builder on curly brace struct called as fnEsteban Küber-7/+33
2023-11-19On private tuple struct, suggest `Default::default` when possibleEsteban Küber-0/+4
2023-11-19When encountering struct fn call literal with private fields, suggest all ↵Esteban Küber-18/+9
builders When encountering code like `Box(42)`, suggest `Box::new(42)` and *all* other associated functions that return `-> Box<T>`.
2023-10-27When encountering sealed traits, point types that implement itEsteban Küber-7/+77
``` error[E0277]: the trait bound `S: d::Hidden` is not satisfied --> $DIR/sealed-trait-local.rs:53:20 | LL | impl c::Sealed for S {} | ^ the trait `d::Hidden` is not implemented for `S` | note: required by a bound in `c::Sealed` --> $DIR/sealed-trait-local.rs:17:23 | LL | pub trait Sealed: self::d::Hidden { | ^^^^^^^^^^^^^^^ required by this bound in `Sealed` = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `c::d::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it = help: the following types implement the trait: - c::X - c::Y ``` The last `help` is new.
2023-10-27Auto merge of #116858 - estebank:issue-22488, r=petrochenkovbors-0/+50
Suggest assoc fn `new` when trying to build tuple struct with private fields Fix #22488.
2023-10-26Suggest assoc fn `new` when trying to build tuple struct with private fieldsEsteban Küber-0/+50
Fix #22488.
2023-10-25Auto merge of #117076 - oli-obk:privacy_visitor_types, r=petrochenkovbors-17/+17
Refactor type visitor walking r? `@petrochenkov` pulling out the uncontroversial parts of https://github.com/rust-lang/rust/pull/113671
2023-10-23Merge associated types with the other alias typesOli Scherer-17/+17
2023-10-22use visibility to check unused imports and delete some stmtsbohan-9/+45
2023-10-09Extend impl's def_span to include where clausesMichael Goulet-6/+12
2023-10-05Add a note to duplicate diagnosticsAlex Macleod-0/+7
2023-09-07Lint node for PRIVATE_BOUNDS is the item which has the boundsMichael Goulet-0/+7
2023-09-06Rollup merge of #115578 - ouz-a:rustc_clarify, r=oli-obkMatthias Krüger-4/+4
Clarify cryptic comments Clarifies some unclear comments that lurked in the compiler. r? ``@oli-obk``
2023-09-06make comments less crypticouz-a-4/+4
2023-09-01Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkovbors-782/+686
Replace old private-in-public diagnostic with type privacy lints Next part of RFC https://github.com/rust-lang/rust/issues/48054. r? `@petrochenkov`
2023-08-05Fix a typo in the error reporting for sealed traits.kernelmethod-1/+1
2023-08-02Replace old private-in-public diagnostic with type privacy lintsBryanskiy-782/+686
2023-07-30Weaken unnameable_types lintBryanskiy-15/+3
2023-07-28privacy: no nominal visibility for assoc fnsDavid Wood-0/+195
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-07-11typeck in parallelSparrowLii-5/+9
2023-06-29Fix type privacy lints error messageBryanskiy-57/+65
2023-06-29Rollup merge of #112670 - petrochenkov:typriv, r=eholkMatthias Krüger-6/+6
privacy: Type privacy lints fixes and cleanups See individual commits. Follow up to https://github.com/rust-lang/rust/pull/111801.
2023-06-22Tweak privacy errors to account for reachable itemsEsteban Küber-9/+127
Suggest publicly accessible paths for items in private mod: When encountering a path in non-import situations that are not reachable due to privacy constraints, search for any public re-exports that the user could use instead. Track whether an import suggestion is offering a re-export. When encountering a path with private segments, mention if the item at the final path segment is not publicly accessible at all. Add item visibility metadata to privacy errors from imports: On unreachable imports, record the item that was being imported in order to suggest publicly available re-exports or to be explicit that the item is not available publicly from any path. In order to allow this, we add a mode to `resolve_path` that will not add new privacy errors, nor return early if it encounters one. This way we can get the `Res` corresponding to the final item in the import, which is used in the privacy error machinery.
2023-06-22Account for sealed traits in trait bound errorsEsteban Küber-0/+35
When implementing a public trait with a private super-trait, we now emit a note that the missing bound is not going to be able to be satisfied, and we explain the concept of a sealed trait.
2023-06-15privacy: Do not mark items reachable farther than their nominal visibilityVadim Petrochenkov-2/+2
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-06-15privacy: Feature gate new type privacy lintsVadim Petrochenkov-4/+4
2023-06-12Private-in-public lints implementationBryanskiy-20/+317
2023-06-08increase the accuracy of effective visibilities calculationBryanskiy-0/+47
2023-05-26fix for `Self` not respecting tuple Ctor privacyDeadbeef-0/+109
This fixes #111220 by checking the privacy of tuple constructors using `Self`, so the following code now errors ```rust mod my { pub struct Foo(&'static str); } impl AsRef<str> for my::Foo { fn as_ref(&self) -> &str { let Self(s) = self; // previously compiled, now errors correctly s } } ```
2023-04-21Leave it to the query system to invoke the typeck query instead of invoking ↵Oli Scherer-14/+2
it eagerly. Later queries that are run on all body owners will invoke typeck as they need information from its result to perform their own logic
2023-04-12Special-case item attributes in the suggestion outputEsteban Küber-6/+0
2023-04-12Tweak output for 'add line' suggestionEsteban Küber-6/+12
2023-04-12Split out a separate feature gate for impl trait in associated typesOli Scherer-2/+2
2023-04-11Rollup merge of #109923 - ElectrifyPro:visibility, r=wesleywiserYuki Okushi-78/+114
Update `error [E0449]: unnecessary visibility qualifier` to be more clear This updates the error message `error[E0449]: unnecessary visibility qualifier` by clearly indicating that visibility qualifiers already inherit their visibility from a parent item. The error message previously implied that the qualifiers were permitted, which is not the case anymore. Resolves #109822.
2023-04-05Auto merge of #109437 - petrochenkov:effvisopt, r=davidtwcobors-6/+6
resolve: Restore some effective visibility optimizations Something similar was previously removed as a part of https://github.com/rust-lang/rust/pull/104602. So we can see [bitmaps-3.1.0](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/bitmaps-3.1.0), [match-stress](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/match-stress) and [unused-warnings](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/unused-warnings) in regressions there, and in improvements in this PR. After this PR all table changes should also be "locally correct" after every update.
2023-04-03Update ui tests involving invalid visibility qualifiersTam Pham-78/+114
2023-04-02Move some UI tests into subdirectoriesjyn-0/+105
to avoid going over the existing limit now that the ui-fulldeps tests have been moved to ui.
2023-03-31resolve: Restore some effective visibility optimizationsVadim Petrochenkov-6/+6
Something similar was previously removed as a part of #104602, but after this PR all table changes should also be "locally correct" after every update.
2023-03-28privacy: Support `#![rustc_effective_visibility]` on the crate rootVadim Petrochenkov-24/+37
2023-02-22diagnostics: update test cases to refer to assoc fn with `self` as methodMichael Howell-29/+29