summaryrefslogtreecommitdiff
path: root/compiler/rustc_builtin_macros/src
Commit message (Collapse)AuthorAgeFilesLines
* Rollup merge of #111649 - Nilstrieb:derive-const-param-ty, r=BoxyUwUDylan DPC2023-05-172-0/+24
|\ | | | | | | | | | | | | | | Add derive for `core::marker::ConstParamTy` This makes it easier to implement it for a type, just like `Copy`. `@BoxyUwU` half asked me to add it
| * Add derive for `core::marker::ConstParamTy`Nilstrieb2023-05-162-0/+24
| | | | | | | | This makes it easier to implement it for a type, just like `Copy`.
* | Rollup merge of #111463 - clubby789:env-escaped-var, r=cjgillotMatthias Krüger2023-05-141-3/+9
|\ \ | | | | | | | | | | | | | | | Better diagnostics for `env!` where variable contains escape Fixes #110559
| * | Better diagnostics for `env!` where variable contains escapeclubby7892023-05-111-3/+9
| |/
* | Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors2023-05-121-3/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Uplift `clippy::{drop,forget}_{ref,copy}` lints This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints. Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted. ## `drop_ref` and `forget_ref` The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value. ### Example ```rust let mut lock_guard = mutex.lock(); std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex // still locked operation_that_requires_mutex_to_be_unlocked(); ``` ### Explanation Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended. ## `drop_copy` and `forget_copy` The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait. ### Example ```rust let x: i32 = 42; // i32 implements Copy std::mem::forget(x) // A copy of x is passed to the function, leaving the // original unaffected ``` ### Explanation Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation. ----- Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
| * | Remove useless drop of copy typeUrgau2023-05-101-3/+1
| |/
* | refactor: use by-ref TokenTree iterator to avoid a few clonesCaleb Cartwright2023-05-112-2/+2
|/
* Rollup merge of #110694 - est31:builtin, r=petrochenkovDylan DPC2023-05-092-101/+0
|\ | | | | | | | | | | | | | | | | | | | | Implement builtin # syntax and use it for offset_of!(...) Add `builtin #` syntax to the parser, as well as a generic infrastructure to support both item and expression position builtin syntaxes. The PR also uses this infrastructure for the implementation of the `offset_of!` macro, added by #106934. cc `@petrochenkov` `@DrMeepster` cc #110680 `builtin #` tracking issue cc #106655 `offset_of!` tracking issue
| * Migrate offset_of from a macro to builtin # syntaxest312023-05-052-101/+0
| |
* | Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, ↵bors2023-05-081-1/+1
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | r=Mark-Simulacrum enable `rust_2018_idioms` lint group for doctests With this change, `rust_2018_idioms` lint group will be enabled for compiler/libstd doctests. Resolves #106086 Resolves #99144 Signed-off-by: ozkanonur <work@onurozkan.dev>
| * enable `rust_2018_idioms` for doctestsozkanonur2023-05-071-1/+1
| | | | | | | | Signed-off-by: ozkanonur <work@onurozkan.dev>
* | Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errorsDylan DPC2023-05-052-0/+9
|\ \ | | | | | | | | | | | | | | | | | | Implement RFC 3348, `c"foo"` literals RFC: https://github.com/rust-lang/rfcs/pull/3348 Tracking issue: #105723
| * | fix TODO commentsDeadbeef2023-05-021-2/+3
| | |
| * | initial step towards implementing C string literalsDeadbeef2023-05-022-0/+8
| | |
* | | Rollup merge of #111027 - clubby789:query-instability-builtin-macros, ↵Matthias Krüger2023-05-042-11/+11
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=petrochenkov Remove `allow(rustc::potential_query_instability)` for `builtin_macros` cc #84447
| * | | Use `GrowableBitSet` to store positional indexes in `asm!`clubby7892023-05-021-7/+8
| | | |
| * | | Remove `allow(rustc::potential_query_instability)` for `builtin_macros`clubby7892023-05-022-6/+5
| | | |
* | | | Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote2023-05-034-12/+12
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
* | | Auto merge of #109128 - chenyukang:yukang/remove-type-ascription, r=estebankbors2023-05-024-6/+1
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | Remove type ascription from parser and diagnostics Mostly based on https://github.com/rust-lang/rust/pull/106826 Part of #101728 r? `@estebank`
| * | soften the wording for removing type ascriptionyukang2023-05-011-2/+1
| | |
| * | Rip it outNilstrieb2023-05-014-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | My type ascription Oh rip it out Ah If you think we live too much then You can sacrifice diagnostics Don't mix your garbage Into my syntax So many weird hacks keep diagnostics alive Yet I don't even step outside So many bad diagnostics keep tyasc alive Yet tyasc doesn't even bother to survive!
* | | Rollup merge of #111042 - Zalathar:no-coverage, r=wesleywiserMatthias Krüger2023-05-011-2/+4
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | Add `#[no_coverage]` to the test harness's `fn main` There are two main motivations for adding `#[no_coverage]` to the test harness's entry point: - The entry point is trivial compiler-generated code that doesn't correspond to user source, and it always runs, so there's no value in instrumenting it for coverage. - Because it has dummy spans, it causes the instrumentor implementation to emit invalid coverage mappings that confuse `llvm-cov` and result in strange coverage reports. Fixes #110749.
| * | Add `#[no_coverage]` to the test harness's `fn main`Zalathar2023-05-011-2/+4
| |/
* | Rollup merge of #111032 - clubby789:migrate-asm-diagnostics, r=compiler-errorsMatthias Krüger2023-05-012-72/+144
|\ \ | | | | | | | | | | | | | | | | | | | | | Migrate `builtin_macros::asm` diagnostics to translatable diagnostics cc #100717 Planning on working through the remaining diagnostics in this crate
| * | Migrate `builtin_macros::asm` diagnostics to translatable diagnosticsclubby7892023-04-302-72/+144
| |/
* | Tweak await spanMichael Goulet2023-04-271-1/+1
|/
* Fix static string lintsclubby7892023-04-254-34/+84
|
* Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger2023-04-253-0/+106
| | | | This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
* Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors2023-04-223-106/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Report allocation errors as panics OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`. This should be review one commit at a time: - The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics. - The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API. ACP: https://github.com/rust-lang/libs-team/issues/192 Closes #51540 Closes #51245
| * Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras2023-04-163-106/+0
| |
* | use P<[Ident]> instead of Vec<Ident>DrMeepster2023-04-211-2/+2
| |
* | offset_ofDrMeepster2023-04-213-0/+102
| |
* | Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb2023-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
* | fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger2023-04-161-7/+1
|/
* Auto merge of #110252 - matthiaskrgr:rollup-ovaixra, r=matthiaskrgrbors2023-04-121-22/+40
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rollup of 8 pull requests Successful merges: - #109810 (Replace rustdoc-ui/{c,z}-help tests with a stable run-make test ) - #110035 (fix: ensure bad `#[test]` invocs retain correct AST) - #110089 (sync::mpsc: synchronize receiver disconnect with initialization) - #110103 (Report overflows gracefully with new solver) - #110122 (Fix x check --stage 1 when download-ci-llvm=false) - #110133 (Do not use ImplDerivedObligationCause for inherent impl method error reporting) - #110135 (Revert "Don't recover lifetimes/labels containing emojis as character literals") - #110235 (Fix `--extend-css` option) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| * Rollup merge of #110035 - Ezrashaw:improve-test-attr-expansion-code, r=davidtwcoMatthias Krüger2023-04-121-22/+40
| |\ | | | | | | | | | | | | | | | | | | | | | fix: ensure bad `#[test]` invocs retain correct AST Fixes #109816 Ensures that a `StmtKind::Item` doesn't get converted into a plain `Item` (causing the ICE from the linked issue) Also unifies the error path a bit.
| | * refactor: extract `not_testable_error` into functionEzra Shaw2023-04-111-32/+32
| | |
| | * fix: ensure bad `#[test]` invocs retain correct ASTEzra Shaw2023-04-071-22/+40
| | |
* | | Rollup merge of #110153 - DaniPopes:compiler-typos, r=NilstriebMatthias Krüger2023-04-121-1/+1
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | Fix typos in compiler I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory. Refs #110150
| * | Fix typos in compilerDaniPopes2023-04-101-1/+1
| | |
* | | Auto merge of #110092 - clubby789:builtin-macros-translatable, r=compiler-errorsbors2023-04-1115-329/+771
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | Migrate most of `rustc_builtin_macros` to diagnostic impls cc #100717 This is a couple of days work, but I decided to stop for now before the PR becomes too big. There's around 50 unresolved failures when `rustc::untranslatable_diagnostic` is denied, which I'll finish addressing once this PR goes thtough A couple of outputs have changed, but in all instances I think the changes are an improvement/are more consistent with other diagnostics (although I'm happy to revert any which seem worse)
| * | Migrate most of `rustc_builtin_macros` to diagnostic implsclubby7892023-04-1015-329/+771
| | | | | | | | | | | | | | | Co-authored-by: Joe ST <joe@fbstj.net> Co-authored-by: Michael Goulet <michael@errs.io>
* | | Migrate `sess.opts.tests` uses to `sess.is_test_crate()`blyxyas2023-04-091-1/+1
|/ /
* | Stabilize is_some_andJonas Platte2023-04-061-1/+0
|/
* Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`Oli Scherer2023-04-041-2/+2
|
* box a bunch of large typesOli Scherer2023-04-042-24/+28
|
* Split out ast::ItemKind::Const into its own structOli Scherer2023-04-041-5/+5
|
* rust-analyzer guided tuple field to named fieldOli Scherer2023-04-041-2/+2
|
* rust-analyzer guided enum variant structificationOli Scherer2023-04-041-2/+2
|
* Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errorsGuillaume Gomez2023-03-271-1/+1
|\ | | | | | | | | | | | | | | | | Remove the `NodeId` of `ast::ExprKind::Async` This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416. In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`. It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.