about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/middle/stability.rs
AgeCommit message (Collapse)AuthorLines
2025-08-22Refactor lint buffering to avoid requiring a giant enumJosh Triplett-2/+2
Lint buffering currently relies on a giant enum `BuiltinLintDiag` containing all the lints that might potentially get buffered. In addition to being an unwieldy enum in a central crate, this also makes `rustc_lint_defs` a build bottleneck: it depends on various types from various crates (with a steady pressure to add more), and many crates depend on it. Having all of these variants in a separate crate also prevents detecting when a variant becomes unused, which we can do with a dedicated type defined and used in the same crate. Refactor this to use a dyn trait, to allow using `LintDiagnostic` types directly. This requires boxing, but all of this is already on the slow path (emitting an error). Because the existing `BuiltinLintDiag` requires some additional types in order to decorate some variants, which are only available later in `rustc_lint`, use an enum `DecorateDiagCompat` to handle both the `dyn LintDiagnostic` case and the `BuiltinLintDiag` case.
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-7/+5
2025-07-17Retire stability_index query.Camille GILLOT-19/+0
2025-07-17Querify lookup_const_stability.Camille GILLOT-10/+1
2025-07-17Querify lookup_stability.Camille GILLOT-5/+0
2025-07-17Querify lookup_default_body_stability.Camille GILLOT-5/+0
2025-07-17Querify lookup_deprecation_entry.Camille GILLOT-5/+0
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-1/+1
2025-06-12Tracking the old name of renamed unstable library attributexizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-4/+4
2025-04-03Make LevelAndSource a structOli Scherer-1/+1
2025-03-07depend more on attr_data_structures and move find_attr! thereJana Dönszelmann-1/+1
2025-02-21Move methods from Map to TyCtxt, part 3.Nicholas Nethercote-1/+1
Continuing the work from #137162. Every method gains a `hir_` prefix.
2025-02-11Simplify intra-crate qualifiers.Nicholas Nethercote-1/+1
The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers.
2025-01-15Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable, ↵Guillaume Gomez-9/+12
r=davidtwco deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead The `rustc_allowed_through_unstable_modules` attribute lets users call `std::mem::transmute` as `std::intrinsics::transmute`. The former is a reexport of the latter, and for a long time we didn't properly check stability for reexports, so making this a hard error now would be a breaking change for little gain. But at the same time, `std::intrinsics::transmute` is not the intended path for this function, so I think it is a good idea to show a deprecation warning when that path is used. This PR implements that, for all the functions in `std::intrinsics` that carry the attribute. I assume this will need ``@rust-lang/libs-api`` FCP.
2025-01-15late_report_deprecation: move fast-path closer to the core logicRalf Jung-9/+12
2025-01-14Enforce syntactical stability of const traits in HIRMichael Goulet-2/+87
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-16split attributesJonathan Dönszelmann-2/+2
2024-11-18stability: remove skip_stability_check_due_to_privacyRalf Jung-28/+1
2024-11-03use backticks instead of single quotes when reporting "use of unstable ↵dianne-2/+2
library feature" This is consistent with all other diagnostics I could find containing features and enables the use of `DiagSymbolList` for generalizing diagnostics for unstable library features to multiple features.
2024-10-22terminology: #[feature] *enables* a feature (instead of "declaring" or ↵Ralf Jung-4/+4
"activating" it)
2024-09-29cleanup: don't clone types that are CopyMatthias Krüger-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-11Simplify some nested if statementsMichael Goulet-4/+5
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+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-19Avoid ref when using format! in compilerYuri Astrakhan-1/+1
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-1/+1
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-11/+10
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_middle`.Nicholas Nethercote-0/+1
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-11/+10
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-21Rename buffer_lint_with_diagnostic to buffer_lintXiretza-1/+1
2024-05-21Make early lints translatableXiretza-14/+7
2024-05-21Port DeprecatedMacro to diag structsXiretza-85/+103
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-2/+2
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
2024-04-29Remove `extern crate rustc_macros` from `rustc_middle`.Nicholas Nethercote-0/+1
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-2/+2
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-1/+1
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-2/+2
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-19Prefer `DiagnosticBuilder` over `Diagnostic` in diagnostic modifiers.Nicholas Nethercote-2/+2
There are lots of functions that modify a diagnostic. This can be via a `&mut Diagnostic` or a `&mut DiagnosticBuilder`, because the latter type wraps the former and impls `DerefMut`. This commit converts all the `&mut Diagnostic` occurrences to `&mut DiagnosticBuilder`. This is a step towards greatly simplifying `Diagnostic`. Some of the relevant function are made generic, because they deal with both errors and warnings. No function bodies are changed, because all the modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`.
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-1/+1
2024-02-15Use generic `NonZero` internally.Markus Reiter-4/+4
2024-01-23Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.Nicholas Nethercote-2/+2
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-2/+1
2024-01-04Make iteration order of stability_index query stableMichael Woerister-6/+5
2024-01-04Replace a number of FxHashMaps/Sets with stable-iteration-order alternatives.Michael Woerister-1/+2
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-2/+1
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-1/+1
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`