about summary refs log tree commit diff
path: root/compiler/rustc_privacy/src
AgeCommit message (Collapse)AuthorLines
2025-01-04turn hir::ItemKind::Fn into a named-field variantRalf Jung-1/+1
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-0/+1
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-1/+1
2024-12-09Introduce `default_field_values` featureEsteban Küber-18/+41
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. Support default fields in enum struct variant Allow default values in an enum struct variant definition: ```rust pub enum Bar { Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Allow using `..` without a base on an enum struct variant ```rust Bar::Foo { .. } ``` `#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants. Support `#[derive(Default)]` on enum struct variants with all defaulted fields ```rust pub enum Bar { #[default] Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Check for missing fields in typeck instead of mir_build. Expand test with `const` param case (needs `generic_const_exprs` enabled). Properly instantiate MIR const The following works: ```rust struct S<A> { a: Vec<A> = Vec::new(), } S::<i32> { .. } ``` Add lint for default fields that will always fail const-eval We *allow* this to happen for API writers that might want to rely on users' getting a compile error when using the default field, different to the error that they would get when the field isn't default. We could change this to *always* error instead of being a lint, if we wanted. This will *not* catch errors for partially evaluated consts, like when the expression relies on a const parameter. Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`: - Suggest adding a base expression if there are missing fields. - Suggest enabling the feature if all the missing fields have optional values. - Suggest removing `..` if there are no missing fields.
2024-11-11Simplify some places that deal with generic parameter defaultsLeón Orell Valerian Liehr-15/+5
2024-10-30Merge HostPolarity and BoundConstnessMichael Goulet-1/+1
2024-10-24Implement const effect predicate in new solverMichael Goulet-0/+4
2024-10-22Rollup merge of #131049 - compiler-errors:more-validation, r=spastorinoMatthias Krüger-4/+4
Validate args are correct for `UnevaluatedConst`, `ExistentialTraitRef`/`ExistentialProjection` For the `Existential*` ones, we have to do some adjustment to the args list to deal with the missing `Self` type, so we introduce a `debug_assert_existential_args_compatible` function to the interner as well.
2024-10-04Visit opaques for visibilities.Camille GILLOT-51/+47
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-9/+9
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-10-02Visit in embargo visitor if trait method has bodyMichael Goulet-10/+38
2024-10-02Move in_trait into OpaqueTyOriginMichael Goulet-2/+1
2024-09-30Validate ExistentialPredicate argsMichael Goulet-4/+4
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-5/+5
2024-09-13Rename and reorder lots of lifetimes.Nicholas Nethercote-5/+5
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and 'me with vanilla 'a. These are cases where the original name isn't really any more informative than 'a. - Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime applies to multiple fields and so the original lifetime name isn't really accurate. - Put 'tcx last in lifetime lists, and 'a before 'b.
2024-08-29Add `warn(unreachable_pub)` to `rustc_privacy`.Nicholas Nethercote-10/+11
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-1/+2
closures
2024-07-29Reformat `use` declarations.Nicholas Nethercote-16/+16
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-17Do not ICE in privacy when type inference fails.Camille GILLOT-2/+6
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-3/+5
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-1/+1
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-13split out AliasTy -> AliasTermMichael Goulet-4/+7
2024-05-10Lift `TraitRef` into `rustc_type_ir`Michael Goulet-0/+1
2024-05-09Rename Generics::params to Generics::own_paramsMichael Goulet-2/+2
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-3/+1
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+1
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-1/+1
2024-03-21rename items -> free_itemsRalf Jung-1/+1
2024-03-14Test and implement reachability for trait objects and generic parameters of ↵Oli Scherer-2/+2
functions
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-4/+4
2024-03-05Convert `SpannedTypeVisitor` to use `VisitorResult`Jason Newcomb-2/+2
2024-03-05Convert `TypeVisitor` and `DefIdVisitor` to use `VisitorResult`Jason Newcomb-65/+56
2024-02-29Mark some once-again-unreachable paths as unreachable.Nicholas Nethercote-4/+1
This undoes the changes from #121482 and #121586, now that stashed errors will trigger more early aborts.
2024-02-28Rename `DiagnosticArgFromDisplay` as `DiagArgFromDisplay`.Nicholas Nethercote-7/+7
2024-02-23Allow for a missing `adt_def` in `NamePrivacyVisitor`.Nicholas Nethercote-1/+4
This was caused by 72b172bdf6 in #121206. That commit removed an early return from `analysis` when there are stashed errors. As a result, it's possible to reach privacy analysis when there are stashed errors, which means more code paths can be reached. One such code path was handled in that commit, where a `span_bug` was changed to a `span_delayed_bug`. This commit handles another such code path uncovered by fuzzing, in much the same way. Fixes #121455.
2024-02-12Dejargnonize substShoyu Vanilla-3/+3
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-2/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-07Remove dead codeOli Scherer-3/+0
2024-02-07Remove now-useless method overrideOli Scherer-7/+0
2024-02-07Stop using `hir_ty_to_ty` in rustc_privacyOli Scherer-52/+51
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-0/+1
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-3/+3
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-26Rollup merge of #120339 - petrochenkov:nameprivisit, r=michaelwoeristerMatthias Krüger-43/+16
privacy: Refactor top-level visiting in `NamePrivacyVisitor` Full hierarchical visiting (`nested_filter::All`) is not necessary, visiting all item-likes in isolation is enough. Tracking current item is not necessary, passing any `HirId` with the same parent module to `adjust_ident_and_get_scope` is enough. Follow up to https://github.com/rust-lang/rust/pull/120284.
2024-01-25Remove unused featuresclubby789-2/+0
2024-01-25privacy: Refactor top-level visiting in `NamePrivacyVisitor`Vadim Petrochenkov-43/+16
2024-01-24privacy: Refactor top-level visiting in `TypePrivacyVisitor`Vadim Petrochenkov-63/+27
2024-01-23Rename `TyCtxt::emit_spanned_lint` as `TyCtxt::emit_node_span_lint`.Nicholas Nethercote-3/+3
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-7/+7
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.