about summary refs log tree commit diff
path: root/compiler/rustc_feature/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-06-09Remove rustc_feature::Stabilitymejrs-11/+2
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-01-08rustc_feature: Avoid unsafe `std::env::set_var()` in `UnstableFeatures` testsMartin Nordholts-1/+11
Avoid unsafe `std::env::set_var()` by allowing tests to inject `std::env::var("RUSTC_BOOTSTRAP")` with a `env_var_rustc_bootstrap` parameter.
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+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-11-17Add `RUSTC_BOOTSTRAP=-1` to make rustc pretend as stable compilerJieyou Xu-7/+12
2024-10-25Introduce `Enabled{Lang,Lib}Feature`许杰友 Jieyou Xu (Joe)-1/+3
Instead of passing around random n-tuples of e.g. `(gate_name, attr_sp, since)`.
2024-10-23rename lang feature lists to include LANGRalf Jung-6/+6
2024-10-23remove no longer needd UnstableFeature typeRalf Jung-2/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-4/+4
2024-09-06Correctly handle stability of `#[diagnostic]` attributesGeorg Semmler-2/+3
This commit changes the way we treat the stability of attributes in the `#[diagnostic]` namespace. Instead of relaying on ad-hoc checks to ensure at call side that a certain attribute is really usable at that location it centralises the logic to one place. For diagnostic attributes comming from other crates it just skips serializing attributes that are not stable and that do not have the corresponding feature enabled. For attributes from the current crate we can just use the feature information provided by `TyCtx`.
2024-08-27Add `warn(unreachable_pub)` to `rustc_feature`.Nicholas Nethercote-0/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+4
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-14clarify the meaning of the version number for accepted/removed featuresRalf Jung-0/+4
2024-06-23Add hard error and migration lint for unsafe attrscarbotaniuman-1/+1
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-1/+3
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-06-06Error on unsafe on non-unsafe attributecarbotaniuman-2/+2
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-1/+0
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-03-19Change only_local to enum type and change the macros to always require a ↵surechen-1/+1
variant of that enum.
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-1/+1
2024-02-15Use generic `NonZero` internally.Markus Reiter-8/+9
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.
2023-12-10Remove edition umbrella features.Eric Huss-2/+1
2023-11-15Bump cfg(bootstrap)sMark Rousskov-3/+3
2023-10-16docs: add Rust logo to more compiler cratesMichael Howell-0/+3
c6e6ecb1afea9695a42d0f148ce153536b279eb5 added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.
2023-10-16Rename `ACTIVE_FEATURES` as `UNSTABLE_FEATURES`.Nicholas Nethercote-5/+5
It's a better name, and lets "active features" refer to the features that are active in a particular program, due to being declared or enabled by the edition. The commit also renames `Features::enabled` as `Features::active` to match this; I changed my mind and have decided that "active" is a little better thatn "enabled" for this, particularly because a number of pre-existing comments use "active" in this way. Finally, the commit renames `Status::Stable` as `Status::Accepted`, to match `ACCEPTED_FEATURES`.
2023-10-16Remove `rustc_feature::State`.Nicholas Nethercote-29/+9
`State` is used to distinguish active vs accepted vs removed features. However, these can also be distinguished by their location, in `ACTIVE_FEATURES`, `ACCEPTED_FEATURES`, and `REMOVED_FEATURES`. So this commit removes `State` and moves the internals of its variants next to the `Feature` in each element of `*_FEATURES`, introducing new types `ActiveFeature` and `RemovedFeature`. (There is no need for `AcceptedFeature` because `State::Accepted` had no fields.) This is a tighter type representation, avoids the need for some runtime checks, and makes the code a bit shorter.
2023-10-05Merge `STABLE_REMOVED_FEATURES` list into `REMOVED_FEATURES`.Nicholas Nethercote-4/+1
There is a single features (`no_stack_check`) in `STABLE_REMOVED_FEATURES`. But the treatment of `STABLE_REMOVED_FEATURES` and `REMOVED_FEATURES` is actually identical. So this commit just merges them, and uses a comment to record `no_stack_check`'s unique "stable removed" status. This also lets `State::Stabilized` (which was a terrible name) be removed.
2023-10-05Streamline `find_lang_feature_issue`.Nicholas Nethercote-15/+14
It currently processes `ACTIVE_FEATURES` separately from `ACCEPTED_FEATURES`, `REMOVED_FEATURES`, and `STABLE_REMOVED_FEATURES`, for no good reason. This commit treats them uniformly.
2023-10-05Remove unused `Span` from the `set` function in `State::Active`.Nicholas Nethercote-2/+2
2023-08-06Issue numbers are enforced on active features; remove FIXMEMartin Nordholts-2/+0
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-1/+1
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-5/+4
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-1/+1
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-01-12Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0Collin Baker-1/+2
Two locations check whether this build-time environment variable is defined. Allowing it to be explicitly disabled with a "0" value is useful, especially for integrating with external build systems.
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-1/+1
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-09-06get_attr should check that no duplicates are allowedyukang-2/+2
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-05-27Finish bumping stage0Mark Rousskov-1/+0
It looks like the last time had left some remaining cfg's -- which made me think that the stage0 bump was actually successful. This brings us to a released 1.62 beta though.
2022-05-10don't encode only locally used attrslcnr-2/+3
2022-04-07Stabilize `derive_default_enum`Jacob Pratt-1/+1
2021-11-18Check for duplicate attributes.Eric Huss-0/+2
2021-09-09Ignore automatically derived impls of `Clone` and `Debug` in dead code analysisFabian Wolff-1/+0
2021-06-28Make incomplete features part of delcarationSmitty-1/+1
This prevents mistakes where the feature is in the list of incomplete features but not actually a feature by making the incompleteness a part of the declaration.
2021-04-08Fix outdated crate names in compiler docspierwill-1/+1
Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged. Also fix incorrect file paths.
2020-12-12tidy: Re-enable check for inline unit testsVadim Petrochenkov-27/+3
2020-11-07Allow making `RUSTC_BOOTSTRAP` conditional on the crate nameJoshua Nelson-3/+39
The main change is that `UnstableOptions::from_environment` now requires an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how. Other major changes: - Added `Session::is_nightly_build()`, which uses the `crate_name` of the session - Added `nightly_options::match_is_nightly_build`, a convenience method for looking up `--crate-name` from CLI arguments. `Session::is_nightly_build()`should be preferred where possible, since it will take into account `#![crate_name]` (I think). - Added `unstable_features` to `rustdoc::RenderOptions` There is a user-facing change here: things like `RUSTC_BOOTSTRAP=0` no longer active nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway. - Add tests Check against `Cheat`, not whether nightly features are allowed. Nightly features are always allowed on the nightly channel. - Only call `is_nightly_build()` once within a function - Use booleans consistently for rustc_incremental Sessions can't be passed through threads, so `read_file` couldn't take a session. To be consistent, also take a boolean in `write_file_header`.
2020-10-01Add note about possible future improvementMara Bos-0/+2
Co-authored-by: David Tolnay <dtolnay@gmail.com>