about summary refs log tree commit diff
path: root/compiler/rustc_attr
AgeCommit message (Collapse)AuthorLines
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-13/+14
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-4/+4
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-1/+1
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-3/+3
2023-12-02Use `Session::diagnostic` in more places.Nicholas Nethercote-1/+1
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-2/+2
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-27Detect and reject malformed repr(Rust) hintsLeón Orell Valerian Liehr-3/+3
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-3/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+0
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-15Bump cfg(bootstrap)sMark Rousskov-3/+3
2023-10-31Auto merge of #117377 - dtolnay:deprecatedsince, r=cjgillotbors-22/+62
Store #[deprecated] attribute's `since` value in parsed form This PR implements the first followup bullet listed in https://github.com/rust-lang/rust/pull/117148#issue-1960240108. We centralize error handling to the attribute parsing code in `compiler/rustc_attr/src/builtin.rs`, and thereby remove some awkward error codepaths from later phases of compilation that had to make sense of these #\[deprecated\] attributes, namely `compiler/rustc_passes/src/stability.rs` and `compiler/rustc_middle/src/middle/stability.rs`.
2023-10-30Add method for checking if deprecation is a rustc versionDavid Tolnay-0/+4
2023-10-30Descriptive variant name deprecation versions outside the standard libraryDavid Tolnay-3/+3
2023-10-30Represent absence of 'since' attribute as a variant of DeprecatedSinceDavid Tolnay-15/+17
2023-10-30Preserve deprecation attribute even if 'since' version is missingDavid Tolnay-3/+3
2023-10-30Add a DeprecatedSince::Err variant for versions that fail to parseDavid Tolnay-19/+8
2023-10-30Move deprecation_in_effect to inherent method on DeprecationDavid Tolnay-0/+16
2023-10-29Store version of `deprecated` attribute in structured formDavid Tolnay-16/+45
2023-10-29Rename Since -> StableSince in preparation for a DeprecatedSinceDavid Tolnay-6/+6
2023-10-30Clean up `rustc_*/Cargo.toml`.Nicholas Nethercote-2/+2
- Sort dependencies and features sections. - Add `tidy` markers to the sorted sections so they stay sorted. - Remove empty `[lib`] sections. - Remove "See more keys..." comments. Excluded files: - rustc_codegen_{cranelift,gcc}, because they're external. - rustc_lexer, because it has external use. - stable_mir, because it has external use.
2023-10-26Parse rustc version at compile timeDavid Tolnay-29/+14
2023-10-26Pre-intern a symbol for env!("CFG_RELEASE")David Tolnay-4/+0
2023-10-24Expose a non-Symbol way to access current rustc version stringDavid Tolnay-2/+4
2023-10-24CFG_RELEASE is mandatory, no need for option_envDavid Tolnay-2/+1
The same file already contains another env!("CFG_RELEASE") on line 632, so it's impossible for this crate to compile without CFG_RELEASE set.
2023-10-24Handle structured stable attribute 'since' version in rustdocDavid Tolnay-0/+7
2023-10-24Keep track of #[stable] attribute even if version cannot be parsedDavid Tolnay-7/+11
2023-10-24Store 'since' attribute as parsed VersionDavid Tolnay-9/+19
2023-10-23Validate `since` value in stable attributeDavid Tolnay-8/+21
2023-10-23Validate #[stable(feature = "…")] identifierDavid Tolnay-23/+28
2023-10-22Eliminate redundant .parse_sess in rustc_attr::builtin errorsDavid Tolnay-34/+23
2023-10-22Eliminate rustc_attr::builtin::handle_errorsDavid Tolnay-128/+84
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-15Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstriebbors-4/+9
Format all the let-chains in compiler crates Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped). This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else. I will also add this commit to the ignore list after it has landed. The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree. ``` ~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates ~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif ``` cc `@rust-lang/rustfmt` r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :> cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in https://github.com/rust-lang/rust/pull/95262#issue-1178993801. I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2023-10-13Format all the let chains in compilerMichael Goulet-4/+9
2023-10-12check-cfg: mention the unexpected name and value in the primary messageUrgau-2/+6
2023-10-06Factor out `insert_or_error`.Nicholas Nethercote-62/+23
It appears identically as a closure in two functions. Also change its return type from `bool` to `Option<()>` so it can be used with `?`.
2023-10-05Rollup merge of #116223 - catandcoder:master, r=cjgillotJubilee-1/+1
Fix misuses of a vs an Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/
2023-10-04Remove E0551.Nicholas Nethercote-10/+1
Because it's the same as E0539. Fixes #51489.
2023-10-04Sort `compiler/rustc_attr/Cargo.toml` dependencies.Nicholas Nethercote-5/+5
It's easier to read in sorted order.
2023-10-04Fix misuses of a vs ancui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-08-25Auto merge of #114201 - Centri3:explicit-repr-rust, r=WaffleLapkinbors-0/+2
Allow explicit `#[repr(Rust)]` This is identical to no `repr()` at all. For `Rust, packed` and `Rust, align(x)`, it should be the same as no `Rust` at all (as, afaik, `#[repr(align(16))]` uses the Rust ABI.) The main use case for this is being able to explicitly say "I want to use the Rust ABI" in very very rare circumstances where the first obvious choice would be the C ABI yet is undesirable, which is already possible with functions as `extern "Rust"`. This would be useful for silencing https://github.com/rust-lang/rust-clippy/pull/11253. It's also more consistent with `extern`. The lack of this also tripped me up a bit when I was new to Rust, as I expected this to be possible.
2023-08-11rustc: Move `features` from `Session` to `GlobalCtxt`Vadim Petrochenkov-12/+9
Removes two pieces of mutable state. Follow up to #114622.
2023-08-01[rustc_attr][nit] Replace `filter` + `is_some` with `map_or`.Taras Tsugrii-1/+1
It's slightly shorter and better communicates the intent.
2023-07-29Allow explicit `#[repr(Rust)]`Catherine Flores-0/+2
2023-07-16Add infrastructure `#[rustc_confusables]` attribute to allow targeted许杰友 Jieyou Xu (Joe)-0/+17
"no method" errors on standard library types The standard library developer can annotate methods on e.g. `BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if there are no other candidates to suggest.
2023-05-25Ensure Fluent messages are in alphabetical orderclubby789-64/+64
2023-05-17Only depend on CFG_VERSION in rustc_interfacejyn-2/+1
this avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
2023-05-05Improve check-cfg diagnostics (part 2)Urgau-2/+5
2023-05-05Improve check-cfg diagnostics (part 1)Urgau-1/+1