about summary refs log tree commit diff
path: root/compiler/rustc_feature/src
AgeCommit message (Collapse)AuthorLines
2024-06-12Auto merge of #126273 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrumbors-7/+7
Bump stage0 to 1.80.0 r? `@Mark-Simulacrum`
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-1/+3
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-11replace version placeholderPietro Albini-7/+7
2024-06-08offset_of: allow (unstably) taking the offset of slice tail fieldsRalf Jung-0/+2
2024-06-06Fix orderingcarbotaniuman-2/+2
2024-06-06Remove extraneous attributecarbotaniuman-1/+0
2024-06-06Add unsafe to `ffi_pure` and `ffi_const`carbotaniuman-2/+2
2024-06-06Fix doc commentcarbotaniuman-1/+2
2024-06-06Error on unsafe on non-unsafe attributecarbotaniuman-2/+6
2024-06-06Reorder `unsafe` macro casescarbotaniuman-12/+12
2024-06-06Parse unsafe attributescarbotaniuman-3/+54
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-0/+2
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-06Rollup merge of #125168 - ↵Matthias Krüger-4/+3
Jules-Bertholet:match-ergonomics-2024-align-with-rfc, r=Nadrieril Match ergonomics 2024: align implementation with RFC - Remove eat-two-layers (`ref_pat_everywhere`) - Consolidate `mut_preserve_binding_mode_2024` into `ref_pat_eat_one_layer_2024` - `&mut` no longer peels off `&` - Apply "no `ref mut` behind `&`" rule on all editions with `ref_pat_eat_one_layer_2024` - Require `mut_ref` feature gate for all mutable by-reference bindings r? ``@Nadrieril`` cc https://github.com/rust-lang/rust/issues/123076 ``@rustbot`` label A-edition-2024 A-patterns
2024-06-05Add unsafe_extern_blocks feature flagSantiago Pastorino-0/+2
2024-06-04Rollup merge of #124486 - beetrees:vectorcall-tracking-issue, r=ehuss许杰友 Jieyou Xu (Joe)-2/+2
Add tracking issue and unstable book page for `"vectorcall"` ABI Originally added in 2015 by #30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now. Tracking issue: #124485
2024-06-01Auto merge of #124577 - ↵bors-2/+2
GuillaumeGomez:stabilize-custom_code_classes_in_docs, r=rustdoc Stabilize `custom_code_classes_in_docs` feature Fixes #79483. This feature has been around for quite some time now, I think it's fine to stabilize it now. ## Summary ## What is the feature about? In short, this PR changes two things, both related to codeblocks in doc comments in Rust documentation: * Allow to disable generation of `language-*` CSS classes with the `custom` attribute. * Add your own CSS classes to a code block so that you can use other tools to highlight them. #### The `custom` attribute Let's start with the new `custom` attribute: it will disable the generation of the `language-*` CSS class on the generated HTML code block. For example: ```rust /// ```custom,c /// int main(void) { /// return 0; /// } /// ``` ``` The generated HTML code block will not have `class="language-c"` because the `custom` attribute has been set. The `custom` attribute becomes especially useful with the other thing added by this feature: adding your own CSS classes. #### Adding your own CSS classes The second part of this feature is to allow users to add CSS classes themselves so that they can then add a JS library which will do it (like `highlight.js` or `prism.js`), allowing to support highlighting for other languages than Rust without increasing burden on rustdoc. To disable the automatic `language-*` CSS class generation, you need to use the `custom` attribute as well. This allow users to write the following: ```rust /// Some code block with `{class=language-c}` as the language string. /// /// ```custom,{class=language-c} /// int main(void) { /// return 0; /// } /// ``` fn main() {} ``` This will notably produce the following HTML: ```html <pre class="language-c"> int main(void) { return 0; }</pre> ``` Instead of: ```html <pre class="rust rust-example-rendered"> <span class="ident">int</span> <span class="ident">main</span>(<span class="ident">void</span>) { <span class="kw">return</span> <span class="number">0</span>; } </pre> ``` To be noted, we could have written `{.language-c}` to achieve the same result. `.` and `class=` have the same effect. One last syntax point: content between parens (`(like this)`) is now considered as comment and is not taken into account at all. In addition to this, I added an `unknown` field into `LangString` (the parsed code block "attribute") because of cases like this: ```rust /// ```custom,class:language-c /// main; /// ``` pub fn foo() {} ``` Without this `unknown` field, it would generate in the DOM: `<pre class="language-class:language-c language-c">`, which is quite bad. So instead, it now stores all unknown tags into the `unknown` field and use the first one as "language". So in this case, since there is no unknown tag, it'll simply generate `<pre class="language-c">`. I added tests to cover this. EDIT(camelid): This description is out-of-date. Using `custom,class:language-c` will generate the output `<pre class="language-class:language-c">` as would be expected; it treats `class:language-c` as just the name of a language (similar to the langstring `c` or `js` or what have you) since it does not use the designed class syntax. Finally, I added a parser for the codeblock attributes to make it much easier to maintain. It'll be pretty easy to extend. As to why this syntax for adding attributes was picked: it's [Pandoc's syntax](https://pandoc.org/MANUAL.html#extension-fenced_code_attributes). Even if it seems clunkier in some cases, it's extensible, and most third-party Markdown renderers are smart enough to ignore Pandoc's brace-delimited attributes (from [this comment](https://github.com/rust-lang/rust/pull/110800#issuecomment-1522044456)). r? `@notriddle`
2024-05-29Make `std::env::{set_var, remove_var}` unsafe in edition 2024Tobias Bucher-0/+6
Allow calling these functions without `unsafe` blocks in editions up until 2021, but don't trigger the `unused_unsafe` lint for `unsafe` blocks containing these functions. Fixes #27970. Fixes #90308. CC #124866.
2024-05-15Gate implicit mutable by-reference bindings behind `mut ref`Jules Bertholet-2/+2
2024-05-15Remove `ref_pat_everywhere`Jules Bertholet-2/+1
2024-05-06Auto merge of #124747 - MasterAwesome:master, r=davidtwcobors-0/+3
Support Result<T, E> across FFI when niche optimization can be used (v2) This PR is identical to #122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe. Implementation of https://github.com/rust-lang/rfcs/pull/3391 Tracking issue: https://github.com/rust-lang/rust/issues/110503 Additional ABI and codegen tests were added in https://github.com/rust-lang/rust/pull/115372
2024-05-05Rollup merge of #124749 - RossSmyth:stable_range, r=davidtwcoGuillaume Gomez-2/+2
Stabilize exclusive_range_pattern (v2) This PR is identical to #124459, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F). r? ghost Original PR description: --- Stabilization report: https://github.com/rust-lang/rust/issues/37854#issuecomment-1842398130 FCP: https://github.com/rust-lang/rust/issues/37854#issuecomment-1872520294 Stabilization was blocked by a lint that was merged here: #118879 Documentation PR is here: rust-lang/reference#1484 `@rustbot` label +F-exclusive_range_pattern +T-lang
2024-05-04Implement do_not_recommend in the new solverMichael Goulet-1/+1
2024-05-03Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxuMichael Goulet-6/+0
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](https://github.com/rust-lang/rust/pull/120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](https://github.com/rust-lang/rust/pull/120832#issuecomment-2007394609) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-05-02Stabilize exclusive_rangeRoss Smyth-2/+2
2024-05-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-6/+0
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern was raised related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was also raised, namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.
2024-05-01Replace version placeholders for 1.79Mark Rousskov-14/+14
2024-05-01Stabilize `custom_code_classes_in_docs` featureGuillaume Gomez-2/+2
2024-04-28Add tracking issue and unstable book page for `"vectorcall"` ABIbeetrees-2/+2
2024-04-25debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and ↵Vadim Petrochenkov-8/+5
`#[collapse_debuginfo]` `-Z debug-macros` is "stabilized" by enabling it by default and removing. `-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`. It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no. Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local). `#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
2024-04-24Stabilise `inline_const`Gary Guo-2/+2
2024-04-24Add explicit syntax for coroutines instead of relying on closures having ↵Oli Scherer-0/+6
`yield` expressions
2024-04-23Put the RFC behind a feature gate `result_ffi_guarantees`Arvind Mukund-0/+3
2024-04-23Rollup merge of #124067 - RalfJung:weak-lang-items, r=davidtwcoMatthias Krüger-1/+1
weak lang items are not allowed to be #[track_caller] For instance the panic handler will be called via this import ```rust extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; } ``` A `#[track_caller]` would add an extra argument and thus make this the wrong signature. The 2nd commit is a consistency rename; based on the docs [here](https://doc.rust-lang.org/unstable-book/language-features/lang-items.html) and [here](https://rustc-dev-guide.rust-lang.org/lang-items.html) I figured "lang item" is more widely used. (In the compiler output, "lang item" and "language item" seem to be pretty even.)
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-17consistency rename: language item -> lang itemRalf Jung-1/+1
2024-04-16Rollup merge of #123512 - Jules-Bertholet:ref-pat-eat-one-layer-2024, ↵Guillaume Gomez-0/+2
r=Nadrieril Match ergonomics 2024: Implement eat-one-layer r? `@Nadrieril` cc #123076 `@rustbot` label A-edition-2024 A-patterns
2024-04-16Rollup merge of #123535 - Jules-Bertholet:mut_dont_reset_binding_mode_2024, ↵Matthias Krüger-0/+2
r=Nadrieril Match ergonomics 2024: `mut` doesn't reset binding mode r? ``@Nadrieril`` cc https://github.com/rust-lang/rust/issues/123076 ``@rustbot`` label A-edition-2024 A-patterns
2024-04-15Match ergonomics 2024: Implement eat-one-layerJules Bertholet-0/+2
2024-04-15Mark gate as incompleteJules Bertholet-1/+1
2024-04-15Rename feature gateJules Bertholet-1/+1
2024-04-15Match ergonomics 2024: `mut` doesn't reset binding modeJules Bertholet-0/+2
2024-04-15Validation and other thingsMichael Goulet-2/+2
2024-04-15Parsing , pre-lowering support for precise capturesMichael Goulet-0/+2
2024-04-11remove some things that do not need to beMatthias Krüger-1/+1
2024-04-08Set the correct tracking issue for pattern typesOli Scherer-1/+1
2024-04-08Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errorsbors-0/+2
Implement minimal, internal-only pattern types in the type system rebase of https://github.com/rust-lang/rust/pull/107606 You can create pattern types with `std::pat::pattern_type!(ty is pat)`. The feature is incomplete and will panic on you if you use any pattern other than integral range patterns. The only way to create or deconstruct a pattern type is via `transmute`. This PR's implementation differs from the MCP's text. Specifically > This means you could implement different traits for different pattern types with the same base type. Thus, we just forbid implementing any traits for pattern types. is violated in this PR. The reason is that we do need impls after all in order to make them usable as fields. constants of type `std::time::Nanoseconds` struct are used in patterns, so the type must be structural-eq, which it only can be if you derive several traits on it. It doesn't need to be structural-eq recursively, so we can just manually implement the relevant traits on the pattern type and use the pattern type as a private field. Waiting on: * [x] move all unrelated commits into their own PRs. * [x] fix niche computation (see 2db07f94f44f078daffe5823680d07d4fded883f) * [x] add lots more tests * [x] T-types MCP https://github.com/rust-lang/types-team/issues/126 to finish * [x] some commit cleanup * [x] full self-review * [x] remove 61bd325da19a918cc3e02bbbdce97281a389c648, it's not necessary anymore I think. * [ ] ~~make sure we never accidentally leak pattern types to user code (add stability checks or feature gate checks and appopriate tests)~~ we don't even do this for the new float primitives * [x] get approval that [the scope expansion to trait impls](https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/Pattern.20types.20types-team.23126/near/427670099) is ok r? `@BoxyUwU`
2024-04-08Rollup merge of #120144 - petrochenkov:unty, r=davidtwcoMatthias Krüger-2/+2
privacy: Stabilize lint `unnameable_types` This is the last piece of ["RFC #2145: Type privacy and private-in-public lints"](https://github.com/rust-lang/rust/issues/48054). Having unstable lints is not very useful because you cannot even dogfood them in the compiler/stdlib in this case (https://github.com/rust-lang/rust/pull/113284). The worst thing that may happen when a lint is removed are some `removed_lints` warnings, but I haven't heard anyone suggesting removing this specific lint. This lint is allow-by-default and is supposed to be enabled explicitly. Some false positives are expected, because sometimes unnameable types are a legitimate pattern. This lint also have some unnecessary false positives, that can be fixed - see https://github.com/rust-lang/rust/issues/120146 and https://github.com/rust-lang/rust/issues/120149. Closes https://github.com/rust-lang/rust/issues/48054.
2024-04-08Add pattern types to parserOli Scherer-0/+2
2024-04-06Put checks that detect UB under their own flag below debug_assertionsBen Kimock-0/+3
2024-04-02Address review commentsJules Bertholet-2/+2