about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
AgeCommit message (Collapse)AuthorLines
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-09Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxuMatthias Krüger-1/+0
Use workspace lints for crates in `compiler/` This is nicer and hopefully less error prone than specifying lints via bootstrap. r? ``@jieyouxu``
2025-03-07Rollup merge of #138187 - matthiaskrgr:rmclone, r=cjgillotJacob Pratt-19/+10
remove clones
2025-03-07Rollup merge of #137606 - davidtwco:next-edition, r=traviscross,ehussJacob Pratt-0/+1
add a "future" edition This idea has been discussed previously [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Continuous.20edition-like.20changes.3F/near/432559262) (though what I've implemented isn't exactly the "next"/"future" editions proposed in that message, just the "future" edition). I've found myself prototyping changes that involve edition migrations and wanting to target an upcoming edition for those migrations, but none exists. This should be permanently unstable and not removed.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-07remove clonesMatthias Krüger-19/+10
2025-03-07Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakisMatthias Krüger-0/+1
Ergonomic ref counting This is an experimental first version of ergonomic ref counting. This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations. RFC: https://github.com/rust-lang/rfcs/pull/3680 Tracking issue: https://github.com/rust-lang/rust/issues/132290 Project goal: https://github.com/rust-lang/rust-project-goals/issues/107 r? ```@nikomatsakis```
2025-03-06Simplify printf and shell format suggestionsThalia Archibald-9/+11
2025-03-06Implement .use keyword as an alias of cloneSantiago Pastorino-0/+1
2025-03-04mgca: Lower all const paths as `ConstArgKind::Path`Noah Lev-1/+2
When `#![feature(min_generic_const_args)]` is enabled, we now lower all const paths in generic arg position to `hir::ConstArgKind::Path`. We then lower assoc const paths to `ty::ConstKind::Unevaluated` since we can no longer use the anon const expression lowering machinery. In the process of implementing this, I factored out `hir_ty_lowering` code that is now shared between lowering assoc types and assoc consts. This PR also introduces a `#[type_const]` attribute for trait assoc consts that are allowed as const args. However, we still need to implement code to check that assoc const definitions satisfy `#[type_const]` if present (basically is it a const path or a monomorphic anon const).
2025-03-01Implment `#[cfg]` and `#[cfg_attr]` in `where` clausesFrank King-10/+20
2025-02-27switch #[cfg(not(llvm_enzyme))] to cfg!(llvm_enzyme)Vayun Biyani-26/+4
2025-02-25Fix enzyme build errorsVayun Biyani-4/+4
2025-02-24span: add a "future" editionDavid Wood-0/+1
It's hard to implement edition migrations without having a perma-unstable "future" edition to target.
2025-02-24Introduce new-style attribute parsers for several attributesJana Dönszelmann-9/+6
note: compiler compiles but librustdoc and clippy don't
2025-02-23Rollup merge of #135501 - tgross35:stdlib-dependencies-private, r=bjorn3Matthias Krüger-36/+13
Inject `compiler_builtins` during postprocessing and ensure it is made private Follow up of https://github.com/rust-lang/rust/pull/135278 Do the following: * Inject `compiler_builtins` during postprocessing, rather than injecting `extern crate compiler_builtins as _` into the AST * Do not make dependencies of `std` private by default (this was added in #135278) * Make sure sysroot crates correctly mark their dependencies private/public * Ensure that marking a dependency private makes its dependents private by default as well, unless otherwise specified * Do the `compiler_builtins` update that has been blocked on this There is more detail in the commit messages. This includes the changes I was working on in https://github.com/rust-lang/rust/pull/136226. try-job: test-various try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: i686-mingw-1 try-job: i686-mingw-2
2025-02-21fix build regressionsManuel Drehwald-0/+1
2025-02-21Inject `compiler_builtins` during postprocessing rather than via ASTTrevor Gross-36/+13
`compiler_builtins` is currently injected as `extern crate compiler_builtins as _`. This has made gating via diagnostics difficult because it appears in the crate graph as a non-private dependency, and there isn't an easy way to differentiate between the injected AST and user-specified `extern crate compiler_builtins`. Resolve this by injecting `compiler_builtins` during postprocessing rather than early in the AST. Most of the time this isn't even needed because it shows up in `std` or `core`'s crate graph, but injection is still needed to ensure `#![no_core]` works correctly. A similar change was attempted at [1] but this encountered errors building `proc_macro` and `rustc-std-workspace-std`. Similar failures showed up while working on this patch, which were traced back to `compiler_builtins` showing up in the graph twice (once via dependency and once via injection). This is resolved by not injecting if a `#![compiler_builtins]` crate already exists. [1]: https://github.com/rust-lang/rust/pull/113634
2025-02-12Rollup merge of #136646 - oli-obk:pattern-types-ast, r=BoxyUwUMatthias Krüger-3/+15
Add a TyPat in the AST to reuse the generic arg lowering logic This simplifies ast lowering significantly with little cost to the pattern types parser. Also fixes any problems we've had with generic args (well, pushes any problems onto the `generic_const_exprs` feature gate) follow-up to https://github.com/rust-lang/rust/pull/136284#discussion_r1939292367 r? ``@BoxyUwU``
2025-02-11Auto merge of #136851 - jhpratt:rollup-ftijn95, r=jhprattbors-14/+9
Rollup of 11 pull requests Successful merges: - #136606 (Fix long lines which rustfmt fails to format) - #136663 (Stabilize `NonZero::count_ones`) - #136672 (library: doc: core::alloc::Allocator: trivial typo fix) - #136704 (Improve examples for file locking) - #136721 (cg_llvm: Reduce visibility of some items outside the `llvm` module) - #136813 (rustc_target: Add the fp16 target feature for AArch32) - #136830 (fix i686-unknown-hurd-gnu x87 footnote) - #136832 (Fix platform support table for i686-unknown-uefi) - #136835 (Stop using span hack for contracts feature gating) - #136837 (Overhaul how contracts are lowered on fn-like bodies) - #136839 (fix ensure_monomorphic_enough) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-11Add a TyPat in the AST to reuse the generic arg lowering logicOli Scherer-3/+15
2025-02-11Rollup merge of #136107 - dingxiangfei2009:coerce-pointee-wellformed, ↵Matthias Krüger-19/+55
r=compiler-errors Introduce CoercePointeeWellformed for coherence checks at typeck stage Fix #135206 This is the first PR to introduce the "wellformedness" check for `derive(CoercePointee)`. This patch introduces a new error code to cover all the prerequisites of the said macro. The checks that is enforced with this patch is whether the data is indeed `struct` and whether the layout is set to `repr(transparent)`. A following series of patch will arrive later to address the following concern. 1. #135217 so that we would only admit one single coercion on one type parameter, and leave the rest for future consideration in tandem of development of other coercion rules. 1. Enforcement of data field requirements. **An open question** is whether there is a good schema to encode the `#[pointee]` as well, so that we could also check if the `#[pointee]` type parameter is indeed `?Sized`. ``@rustbot`` label F-derive_coerce_pointee
2025-02-10Fix imports, remove attrs for unused_*Michael Goulet-4/+2
2025-02-10Stop using span hack for contracts feature gatingMichael Goulet-12/+9
2025-02-09move repr(transparent) checks to coherenceDing Xiang Fei-10/+0
2025-02-09rename the trait to validity and place a feature gate afrontDing Xiang Fei-2/+2
2025-02-09introduce CoercePointeeWellformed for coherence checks at typeck stageDing Xiang Fei-9/+55
2025-02-08Rustfmtbjorn3-148/+199
2025-02-06Auto merge of #136471 - safinaskar:parallel, r=SparrowLiibors-2/+2
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` This is continuation of https://github.com/rust-lang/rust/pull/132282 . I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement. There are other possibilities, through. We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase. So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge. cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 ) r? SparrowLii `@rustbot` label WG-compiler-parallel
2025-02-03Rename rustc_contract to contractCelina G. Val-3/+3
This has now been approved as a language feature and no longer needs a `rustc_` prefix. Also change the `contracts` feature to be marked as incomplete and `contracts_internals` as internal.
2025-02-03Refactor contract builtin macro + error handlingCelina G. Val-71/+71
Instead of parsing the different components of a function signature, eagerly look for either the `where` keyword or the function body. - Also address feedback to use `From` instead of `TryFrom` in cranelift contract and ubcheck codegen.
2025-02-03Separate contract feature gates for the internal machineryFelix S. Klock II-8/+12
The extended syntax for function signature that includes contract clauses should never be user exposed versus the interface we want to ship externally eventually.
2025-02-03Desugars contract into the internal AST extensionsFelix S. Klock II-0/+177
Check ensures on early return due to Try / Yeet Expand these two expressions to include a call to contract checking
2025-02-03Express contracts as part of function header and lower it to the contract ↵Celina G. Val-0/+4
lang items includes post-developed commit: do not suggest internal-only keywords as corrections to parse failures. includes post-developed commit: removed tabs that creeped in into rustfmt tool source code. includes post-developed commit, placating rustfmt self dogfooding. includes post-developed commit: add backquotes to prevent markdown checking from trying to treat an attr as a markdown hyperlink/ includes post-developed commit: fix lowering to keep contracts from being erroneously inherited by nested bodies (like closures). Rebase Conflicts: - compiler/rustc_parse/src/parser/diagnostics.rs - compiler/rustc_parse/src/parser/item.rs - compiler/rustc_span/src/hygiene.rs Remove contracts keywords from diagnostic messages
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-2/+2
2025-02-02Rollup merge of #134272 - RalfJung:destabilize-rustc_encodable_decodable, ↵Matthias Krüger-525/+10
r=oli-obk Remove rustc_encodable_decodable feature This has been shown in future-compat reports since Rust 1.79 (https://github.com/rust-lang/rust/pull/116016), released June 2024. Let's see if crater still finds any issues. Part of https://github.com/rust-lang/rust/issues/134301. Cc ``@rust-lang/libs-api``
2025-01-31Make comma separated lists of anything easier to make for errorsEsteban Küber-10/+8
Provide a new function `listify`, meant to be used in cases similar to `pluralize!`. When you have a slice of arbitrary elements that need to be presented to the user, `listify` allows you to turn that into a list of comma separated strings. This reduces a lot of redundant logic that happens often in diagnostics.
2025-01-30Rollup merge of #135882 - hkBst:master, r=estebankMatthias Krüger-8/+7
simplify `similar_tokens` from `Option<Vec<_>>` to `&[_]` All uses immediately invoke contains, so maybe a further simplification is possible.
2025-01-28parse_format optimize import useMarijn Schouten-2/+2
2025-01-27Remove redundant to_ident_string callsMichael Goulet-2/+2
2025-01-23simplify similar_tokens from Option<Vec<_>> to Vec<_>Marijn Schouten-8/+7
2025-01-22Rollup merge of #135557 - estebank:wtf8, r=fee1-deadMatthias Krüger-5/+7
Point at invalid utf-8 span on user's source code ``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: byte `193` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-22Point at invalid utf-8 span on user's source codeEsteban Küber-5/+7
``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `[193]` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-21remove support for the #[start] attributeRalf Jung-4/+3
2025-01-14remove Rustc{En,De}codable from library and compilerRalf Jung-525/+10
2025-01-01Rollup merge of #134877 - DavisRayM:129966-format-string-help-message, ↵Stuart Cook-0/+18
r=estebank add suggestion for wrongly ordered format parameters Add suggestion for wrongly ordered format parameters like `?#`. Supersedes #131004 Fix #129966
2024-12-31Account for format_args in HiddenUnicodeCodepoints lintMichael Goulet-2/+18
2024-12-31Make parsed string literal fields namedMichael Goulet-9/+23
2024-12-30add suggestion for wrongly ordered format parametersDavis Muro-0/+18