about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros
AgeCommit message (Collapse)AuthorLines
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-20Add the `#[derive_const]` attributeDeadbeef-20/+56
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-37/+38
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-37/+38
`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
2022-08-22Use `AttrVec` in more places.Nicholas Nethercote-32/+34
In some places we use `Vec<Attribute>` and some places we use `ThinVec<Attribute>` (a.k.a. `AttrVec`). This results in various points where we have to convert between `Vec` and `ThinVec`. This commit changes the places that use `Vec<Attribute>` to use `AttrVec`. A lot of this is mechanical and boring, but there are some interesting parts: - It adds a few new methods to `ThinVec`. - It implements `MapInPlace` for `ThinVec`, and introduces a macro to avoid the repetition of this trait for `Vec`, `SmallVec`, and `ThinVec`. Overall, it makes the code a little nicer, and has little effect on performance. But it is a precursor to removing `rustc_data_structures::thin_vec::ThinVec` and replacing it with `thin_vec::ThinVec`, which is implemented more efficiently.
2022-08-21Fix rustc_parse_format precision & width spansAlex Macleod-11/+16
2022-08-22Remove redundant clonefinalchild-1/+1
2022-08-22Use DiagnosticMessage for BufferedEarlyLint.msgfinalchild-1/+1
2022-08-21Replace #[lint/warning/error] with #[diag]Xiretza-2/+2
2022-08-20Auto merge of #100564 - nnethercote:box-ast-MacCall, r=spastorinobors-6/+6
Box the `MacCall` in various types. r? `@spastorino`
2022-08-18Auto merge of #98655 - nnethercote:dont-derive-PartialEq-ne, r=dtolnaybors-57/+25
Don't derive `PartialEq::ne`. Currently we skip deriving `PartialEq::ne` for C-like (fieldless) enums and empty structs, thus reyling on the default `ne`. This behaviour is unnecessarily conservative, because the `PartialEq` docs say this: > Implementations must ensure that eq and ne are consistent with each other: > > `a != b` if and only if `!(a == b)` (ensured by the default > implementation). This means that the default implementation (`!(a == b)`) is always good enough. So this commit changes things such that `ne` is never derived. The motivation for this change is that not deriving `ne` reduces compile times and binary sizes. Observable behaviour may change if a user has defined a type `A` with an inconsistent `PartialEq` and then defines a type `B` that contains an `A` and also derives `PartialEq`. Such code is already buggy and preserving bug-for-bug compatibility isn't necessary. Two side-effects of the change: - There is only one error message produced for types where `PartialEq` cannot be derived, instead of two. - For coverage reports, some warnings about generated `ne` methods not being executed have disappeared. Both side-effects seem fine, and possibly preferable.
2022-08-18Rollup merge of #100669 - nnethercote:attribute-cleanups, r=spastorinoMatthias Krüger-21/+5
Attribute cleanups r? `@ghost`
2022-08-17Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkovMatthias Krüger-16/+9
Clean up `LitKind` r? ``@petrochenkov``
2022-08-17Remove `attrs` arg from `typaram` and `mk_ty_param`.Nicholas Nethercote-4/+3
Because it's always empty.
2022-08-17Remove `TraitDef::attributes`.Nicholas Nethercote-17/+2
Because it's always empty.
2022-08-17Box the `MacCall` in various types.Nicholas Nethercote-6/+6
2022-08-16Rename some things related to literals.Nicholas Nethercote-3/+3
- Rename `ast::Lit::token` as `ast::Lit::token_lit`, because its type is `token::Lit`, which is not a token. (This has been confusing me for a long time.) reasonable because we have an `ast::token::Lit` inside an `ast::Lit`. - Rename `LitKind::{from,to}_lit_token` as `LitKind::{from,to}_token_lit`, to match the above change and `token::Lit`.
2022-08-16Remove `{ast,hir}::WhereEqPredicate::id`.Nicholas Nethercote-5/+1
These fields are unused.
2022-08-16Make `ExtCtxt::expr_lit` non-`pub`.Nicholas Nethercote-13/+6
By using `expr_str` more and adding `expr_{char,byte_str}`.
2022-08-15Rollup merge of #100277 - m-ou-se:format-args-1, r=compiler-errorsMatthias Krüger-90/+64
Simplify format_args builtin macro implementation. Instead of a FxHashMap<Symbol, (usize, Span)> for the named arguments, this now includes the name and span in the elements of the Vec<FormatArg> directly. The FxHashMap still exists to look up the index, but no longer contains the span. Looking up the name or span of an argument is now trivial and does not need the map anymore.
2022-08-13avoid cloning and then iteratingKaDiWa-2/+1
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-08-11Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillotMatthias Krüger-6/+2
Simplify visitors By removing some unused arguments. r? `@cjgillot`
2022-08-11Simplify `rustc_ast::visit::Visitor::visit_poly_trait_ref`.Nicholas Nethercote-6/+2
It is passed an argument that is never used.
2022-08-10Do not consider method call receiver as an argument in AST.Camille GILLOT-11/+10
2022-08-08Get rid of named_pos in format_args impl.Mara Bos-5/+1
2022-08-08Simplify format_args builtin macro implementation.Mara Bos-86/+64
Instead of a FxHashMap<Symbol, (usize, Span)> for the named arguments, this now includes the name and span in the elements of the Vec<FormatArg> directly. The FxHashMap still exists to look up the index, but no longer contains the span. Looking up the name or span of an argument is now trivial and does not need the map anymore.
2022-08-04Rollup merge of #100058 - ↵Matthias Krüger-8/+32
TaKO8Ki:suggest-positional-formatting-argument-instead-of-format-args-capture, r=estebank Suggest a positional formatting argument instead of a captured argument This patch fixes a part of #96999. fixes #98241 fixes #97311 r? `@estebank`
2022-08-04return when captured argument is not a struct fieldTakayuki Maeda-7/+8