summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
AgeCommit message (Collapse)AuthorLines
2022-10-26Rollup merge of #103430 - cjgillot:receiver-attrs, r=petrochenkovDylan DPC-1/+8
Workaround unstable stmt_expr_attributes for method receiver expressions Fixes https://github.com/rust-lang/rust/issues/103244 cc ``@Mark-Simulacrum`` ``@ehuss``
2022-10-24Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726Yuki Okushi-17/+35
Sort tests at compile time, not at startup Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately. (except for doctests, because there is no compile-time harness)
2022-10-23Workaround unstable stmt_expr_attributes for method receiver expressions.Camille GILLOT-1/+8
2022-10-23Migrate all diagnosticsNilstrieb-2/+2
2022-10-15Mark derived StructuralEq as automatically derived.Camille GILLOT-5/+11
2022-10-10Rename AssocItemKind::TyAlias to AssocItemKind::TypeMichael Goulet-1/+1
2022-10-06Auto merge of #99324 - reez12g:issue-99144, r=jyn514bors-1/+7
Enable doctests in compiler/ crates Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-03Rollup merge of #101040 - ↵Matthias Krüger-1/+35
danielhenrymantilla:no-bounds-for-default-annotated-derive, r=joshtriplett Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds That is, given something like: ```rs // #[default] on a generic enum does not add `Default` bounds to the type params. #[derive(Default)] enum MyOption<T> { #[default] None, Some(T), } ``` then `MyOption<T> : Default`_as currently implemented_ only holds when `T : Default`, as reported by ```@5225225``` [over Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.23.5Bderive.28Default.29.5D.20for.20enums.20with.20fields). This is contrary to [what the accepted RFC proposes](https://rust-lang.github.io/rfcs/3107-derive-default-enum.html#generated-bounds) (_i.e._, that `T` be allowed not to be itself `Default`), and indeed seems to be a rather unnecessary limitation.
2022-10-02Fix duplicate usage of `a` article.Petr Portnov-1/+1
This fixes a typo first appearing in #94624 in which test-macro diagnostic uses "a" article twice. Since I searched sources for " a a " sequences, I also fixed the same issue in a few source files where I found it. Signed-off-by: Petr Portnov <gh@progrm-jarvis.ru>
2022-10-02Auto merge of #98354 - camsteffen:is-some-and-by-value, r=m-ou-sebors-1/+1
Change `is_some_and` to take by value Consistent with other function-accepting `Option` methods. Tracking issue: #93050 r? `@m-ou-se`
2022-10-01Change feature name to is_some_andCameron Steffen-1/+1
2022-09-30Fix format_args capture for macro expanded format stringsAlex Macleod-3/+3
2022-09-29Fix docs in compiler/rustc_builtin_macros/src/deriving/generic/mod.rsreez12g-0/+5
2022-09-29Fix docs in compiler/rustc_builtin_macros/src/assert/context.rsreez12g-1/+1
2022-09-29Add feature flag to docs in compiler/rustc_builtin_macros/src/assert/context.rsreez12g-0/+1
2022-09-27Remove confusing drop.Mara Bos-1/+0
2022-09-27Update doc comments.Mara Bos-2/+2
2022-09-27Turn format arguments Vec into its own struct.Mara Bos-84/+146
With efficient lookup through a hash map.
2022-09-27Add clarifying comments.Mara Bos-0/+3
2022-09-27Flatten if-let and match into one.Mara Bos-19/+14
2022-09-27Move enum definition closer to its usage.Mara Bos-5/+5
2022-09-27Use if let chain.Mara Bos-4/+2
2022-09-27Tweak comments.Mara Bos-2/+2
2022-09-27Prefer new_v1_formatted instead of new_v1 with duplicates.Mara Bos-36/+33
2022-09-27Fix typo.Mara Bos-1/+1
2022-09-27Move FormatArgs structure to its own module.Mara Bos-163/+172
2022-09-27Rewrite and refactor format_args!() builtin macro.Mara Bos-1287/+1145
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-09-21UPDATE - rename DiagnosticHandler macro to DiagnosticJhonny Bill Mena-3/+3
2022-09-21UPDATE - rename DiagnosticHandler trait to IntoDiagnosticJhonny Bill Mena-3/+3
2022-09-20Rollup merge of #100250 - cjgillot:recover-token-stream, r=Aaron1011Michael Howell-28/+36
Manually cleanup token stream when macro expansion aborts. In case of syntax error in macro expansion, the expansion code can decide to stop processing anything. In that case, the token stream is malformed. This makes downstream users, like derive macros, ICE. In this case, this PR manually cleans up the token stream by closing all currently open delimiters. Fixes https://github.com/rust-lang/rust/issues/96818. Fixes https://github.com/rust-lang/rust/issues/80447. Fixes https://github.com/rust-lang/rust/issues/81920. Fixes https://github.com/rust-lang/rust/issues/91023.
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-14make `mk_attr_id` part of `ParseSess`SparrowLii-3/+13
2022-09-13Emit an error instead of reconstructing token stream.Camille GILLOT-28/+36
2022-09-09Rename `AttrAnnotatedToken{Stream,Tree}`.Nicholas Nethercote-3/+3
These two type names are long and have long matching prefixes. I find them hard to read, especially in combinations like `AttrAnnotatedTokenStream::new(vec![AttrAnnotatedTokenTree::Token(..)])`. This commit renames them as `AttrToken{Stream,Tree}`.
2022-09-05Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary ↵Daniel Henry-Mantilla-1/+35
`Default` bounds
2022-09-02Refactor and re-use BindingAnnotationCameron Steffen-12/+16
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-2/+4
by module
2022-09-01Sort tests at compile time, not at startupBen Kimock-17/+35
Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately.
2022-09-01Auto merge of #100869 - nnethercote:replace-ThinVec, r=spastorinobors-31/+31
Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec` `rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations. r? `@spastorino`
2022-08-30Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrumbors-0/+1
Revert let_chains stabilization This is the revert against master, the beta revert was already done in #100538. Bumps the stage0 compiler which already has it reverted.
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-29Rollup merge of #101000 - m-ou-se:count-is-star, r=nagisaDylan DPC-6/+6
Separate CountIsStar from CountIsParam in rustc_parse_format. `rustc_parse_format`'s parser would result in the exact same output for `{:.*}` and `{:.0$}`, making it hard for diagnostics to handle these cases properly. This splits those cases by adding a new `CountIsStar` enum variant. This fixes #100995 Prerequisite for https://github.com/rust-lang/rust/pull/100996
2022-08-29Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.Nicholas Nethercote-31/+31
`rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations.
2022-08-28Auto merge of #100497 - kadiwa4:remove_clone_into_iter, r=cjgillotbors-2/+1
Avoid cloning a collection only to iterate over it `@rustbot` label: +C-cleanup
2022-08-25Separate CountIsStar from CountIsParam in rustc_parse_format.Mara Bos-6/+6
2022-08-23Rollup merge of #100909 - nnethercote:minor-ast-LitKind-improvement, ↵Dylan DPC-2/+2
r=petrochenkov Minor `ast::LitKind` improvements r? `@petrochenkov`
2022-08-23Rollup merge of #100851 - Alexendoo:rpf-width-prec-spans, r=fee1-deadDylan DPC-11/+16
Fix rustc_parse_format precision & width spans When a `precision`/`width` was `CountIsName - {:name$}` or `CountIs - {:10}` the `precision_span`/`width_span` was set to `None` For `width` the name span in `CountIsName(_, name_span)` had its `.start` off by one r? ``@fee1-dead`` / cc ``@PrestonFrom`` since this is similar to #99987
2022-08-23Remove the symbol from `ast::LitKind::Err`.Nicholas Nethercote-2/+2
Because it's never used meaningfully.
2022-08-22Rollup merge of #100694 - finalchild:ast-passes-diag, r=TaKO8KiDylan DPC-1/+1
Migrate rustc_ast_passes diagnostics to `SessionDiagnostic` and translatable messages (first part) Doing a full migration of the `rustc_ast_passes` crate. Making a draft here since there's not yet a tracking issue for the migrations going on. `@rustbot` label +A-translation