about summary refs log tree commit diff
path: root/src/doc/unstable-book
AgeCommit message (Collapse)AuthorLines
2021-10-09Fix ABNF of inline asm optionsGary Guo-1/+1
2021-10-08Fix asm docs typoasquared31415-2/+2
2021-10-06Enable AutoFDO.Michael Benfield-0/+45
This largely involves implementing the options debug-info-for-profiling and profile-sample-use and forwarding them on to LLVM. AutoFDO can be used on x86-64 Linux like this: rustc -O -Cdebug-info-for-profiling main.rs -o main perf record -b ./main create_llvm_prof --binary=main --out=code.prof rustc -O -Cprofile-sample-use=code.prof main.rs -o main2 Now `main2` will have feedback directed optimization applied to it. The create_llvm_prof tool can be obtained from this github repository: https://github.com/google/autofdo Fixes #64892.
2021-09-22Support `#[track_caller]` on closures and generatorsAaron Hill-0/+12
This PR allows applying a `#[track_caller]` attribute to a closure/generator expression. The attribute as interpreted as applying to the compiler-generated implementation of the corresponding trait method (`FnOnce::call_once`, `FnMut::call_mut`, `Fn::call`, or `Generator::resume`). This feature does not have its own feature gate - however, it requires `#![feature(stmt_expr_attributes)]` in order to actually apply an attribute to a closure or generator. This is implemented in the same way as for functions - an extra location argument is appended to the end of the ABI. For closures, this argument is *not* part of the 'tupled' argument storing the parameters - the final closure argument for `#[track_caller]` closures is no longer a tuple. For direct (monomorphized) calls, the necessary support was already implemented - we just needeed to adjust some assertions around checking the ABI and argument count to take closures into account. For calls through a trait object, more work was needed. When creating a `ReifyShim`, we need to create a shim for the trait method (e.g. `FnOnce::call_mut`) - unlike normal functions, closures are never invoked directly, and always go through a trait method. Additional handling was needed for `InstanceDef::ClosureOnceShim`. In order to pass location information throgh a direct (monomorphized) call to `FnOnce::call_once` on an `FnMut` closure, we need to make `ClosureOnceShim` aware of `#[tracked_caller]`. A new field `track_caller` is added to `ClosureOnceShim` - this is used by `InstanceDef::requires_caller` location, allowing codegen to pass through the extra location argument. Since `ClosureOnceShim.track_caller` is only used by codegen, we end up generating two identical MIR shims - one for `track_caller == true`, and one for `track_caller == false`. However, these two shims are used by the entire crate (i.e. it's two shims total, not two shims per unique closure), so this shouldn't a big deal.
2021-09-16Rollup merge of #88985 - Commeownist:patch-1, r=AmanieuManish Goregaokar-3/+3
Update clobber_abi list to include k[1-7] regs
2021-09-15Rollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoeristerManish Goregaokar-0/+24
Introduce -Z remap-cwd-prefix switch This switch remaps any absolute paths rooted under the current working directory to a new value. This includes remapping the debug info in `DW_AT_comp_dir` and `DW_AT_decl_file`. Importantly, this flag does not require passing the current working directory to the compiler, such that the command line can be run on any machine (with the same input files) and produce the same results. This is critical property for debugging compiler issues that crop up on remote machines. This is based on adetaylor's https://github.com/rust-lang/rust/commit/dbc4ae7cba0ba8d650b91ddd459b86a02a2d05c5 Major Change Proposal: https://github.com/rust-lang/compiler-team/issues/450 Discussed on #38322. Would resolve issue #87325.
2021-09-15Update clobber_abi list to include k[1-7] regsCommeownist-3/+3
2021-09-10Fix typo `option` -> `options`.Gerd Zellweger-1/+1
2021-09-07Move documentation to the unstable bookdanakj-0/+24
2021-09-01Rollup merge of #88350 - programmerjake:add-ppc-cr-xer-clobbers, r=AmanieuMara Bos-0/+4
add support for clobbering xer, cr, and cr[0-7] for asm! on OpenPower/PowerPC Fixes #88315
2021-08-30Auto merge of #88281 - asquared31415:asm-docs, r=Amanieubors-19/+20
Update unstable docs for `asm!` macro This adds documentation that SPIR-V is supported, expands on the restrictions for labels, and has some minor cleanups or clarifications. r? `@joshtriplett`
2021-08-25add support for clobbering xer, cr, and cr[0-7] for asm! on OpenPower/PowerPCJacob Lifshay-0/+4
Fixes #88315
2021-08-25remove mention of ICEs/segfaultsasquared31415-2/+2
2021-08-24Document `force-warn`inquisitivecrystal-21/+0
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2021-08-22Update asm docsasquared31415-19/+20
2021-08-18Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichautbors-37/+0
Stabilize `arbitrary_enum_discriminant` Closes #60553. ---- ## Stabilization Report _copied from https://github.com/rust-lang/rust/issues/60553#issuecomment-865922311_ ### Summary Enables a user to specify *explicit* discriminants on arbitrary enums. Previously, this was hard to achieve: ```rust #[repr(u8)] enum Foo { A(u8) = 0, B(i8) = 1, C(bool) = 42, } ``` Someone would need to add 41 hidden variants in between as a workaround with implicit discriminants. In conjunction with [RFC 2195](https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md), this feature would provide more flexibility for FFI and unsafe code involving enums. ### Test cases Most tests are in [`src/test/ui/enum-discriminant`](https://github.com/rust-lang/rust/tree/master/src/test/ui/enum-discriminant), there are two [historical](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/tag-variant-disr-non-nullary.rs) [tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/issue-17383.rs) that are now covered by the feature (removed by this pr due to them being obsolete). ### Edge cases The feature is well defined and does not have many edge cases. One [edge case](https://github.com/rust-lang/rust/issues/70509) was related to another unstable feature named `repr128` and is resolved. ### Previous PRs The [implementation PR](https://github.com/rust-lang/rust/pull/60732) added documentation to the Unstable Book, https://github.com/rust-lang/reference/pull/1055 was opened as a continuation of https://github.com/rust-lang/reference/pull/639. ### Resolution of unresolved questions The questions are resolved in https://github.com/rust-lang/rust/issues/60553#issuecomment-511235271. ---- (someone please add `needs-fcp`)
2021-08-14Auto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisabors-21/+50
Add support for clobber_abi to asm! This PR adds the `clobber_abi` feature that was proposed in #81092. Fixes #81092 cc `@rust-lang/wg-inline-asm` r? `@nagisa`
2021-08-12Add support for clobber_abi to asm!Amanieu d'Antras-21/+49
2021-08-12Mark RISC-V vector state as clobbered in inline assemblyAmanieu d'Antras-0/+1
2021-08-10Replace #[plugin_registrar] with exporting __rustc_plugin_registrarbjorn3-19/+3
2021-08-03Auto merge of #87515 - crlf0710:trait_upcasting_part2, r=bjorn3bors-0/+27
Trait upcasting coercion (part2) This is the second part of trait upcasting coercion implementation. Currently this is blocked on #86264 . The third part might be implemented using unsafety checking r? `@bjorn3`
2021-08-02Another onenoproto-1/+1
2021-08-02Correct typonoproto-1/+1
2021-08-03Various adjustments to historic tests and documents.Charles Lew-6/+7
2021-08-03Added page to Unstable Book.Alexander Regueiro-0/+26
2021-08-02Implement a `explicit_generic_args_with_impl_trait` feature gateGary Guo-0/+53
When this gate is enabled, explicit generic arguments can be specified even if `impl Trait` is used in argument position. Generic arguments can only be specified for explicit generic parameters but not for the synthetic type parameters from `impl Trait`
2021-07-28Stabilize `arbitrary_enum_discriminant`Deadbeef-37/+0
2021-07-28Rollup merge of #87315 - ricobbe:raw-dylib-unstable-book, r=wesleywiserYuki Okushi-0/+34
Add docs for raw-dylib to unstable book
2021-07-27Rollup merge of #86450 - tmiasko:move-size-limit, r=pnkfelixYuki Okushi-0/+10
Add flag to configure `large_assignments` lint The `large_assignments` lints detects moves over specified limit. The limit is configured through `move_size_limit = "N"` attribute placed at the root of a crate. When attribute is absent, the lint is disabled. Make it possible to enable the lint without making any changes to the source code, through a new flag `-Zmove-size-limit=N`. For example, to detect moves exceeding 1023 bytes in a cargo crate, including all dependencies one could use: ``` $ env RUSTFLAGS=-Zmove-size-limit=1024 cargo build -vv ``` Lint tracking issue #83518.
2021-07-21Rename force-warns to force-warnRyan Levick-3/+3
2021-07-20Fix ignore annotationRichard Cobbe-2/+1
2021-07-20Ignore example in automationRichard Cobbe-1/+2
2021-07-19Add docs for raw-dylib to unstable bookRichard Cobbe-0/+34
2021-07-18Remove impl_trait_in_bindings feature flagSantiago Pastorino-28/+0
2021-07-11Auto merge of #83918 - workingjubilee:stable-rangefrom-pat, r=joshtriplettbors-0/+53
Stabilize "RangeFrom" patterns in 1.55 Implements a partial stabilization of #67264 and #37854. Reference PR: https://github.com/rust-lang/reference/pull/900 # Stabilization Report This stabilizes the `X..` pattern, shown as such, offering an exhaustive match for unsigned integers: ```rust match x as u32 { 0 => println!("zero!"), 1.. => println!("positive number!"), } ``` Currently if a Rust author wants to write such a match on an integer, they must use `1..={integer}::MAX` . By allowing a "RangeFrom" style pattern, this simplifies the match to not require the MAX path and thus not require specifically repeating the type inside the match, allowing for easier refactoring. This is particularly useful for instances like the above case, where different behavior on "0" vs. "1 or any positive number" is desired, and the actual MAX is unimportant. Notably, this excepts slice patterns which include half-open ranges from stabilization, as the wisdom of those is still subject to some debate. ## Practical Applications Instances of this specific usage have appeared in the compiler: https://github.com/rust-lang/rust/blob/16143d10679537d3fde4247e15334e78ad9d55b9/compiler/rustc_middle/src/ty/inhabitedness/mod.rs#L219 https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/compiler/rustc_ty_utils/src/ty.rs#L524 And I have noticed there are also a handful of "in the wild" users who have deployed it to similar effect, especially in the case of rejecting any value of a certain number or greater. It simply makes it much more ergonomic to write an irrefutable match, as done in Katholieke Universiteit Leuven's [SCALE and MAMBA project](https://github.com/KULeuven-COSIC/SCALE-MAMBA/blob/05e5db00d553573534258585651c525d0da5f83f/WebAssembly/scale_std/src/fixed_point.rs#L685-L695). ## Tests There were already many tests in [src/test/ui/half-open-range/patterns](https://github.com/rust-lang/rust/tree/90a2e5e3fe59a254d4d707aa291517b3791ea5a6/src/test/ui/half-open-range-patterns), as well as [generic pattern tests that test the `exclusive_range_pattern` feature](https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/src/test/ui/pattern/usefulness/integer-ranges/reachability.rs), many dating back to the feature's introduction and remaining standing to this day. However, this stabilization comes with some additional tests to explore the... sometimes interesting behavior of interactions with other patterns. e.g. There is, at least, a mild diagnostic improvement in some edge cases, because before now, the pattern `0..=(5+1)` encounters the `half_open_range_patterns` feature gate and can thus emit the request to enable the feature flag, while also emitting the "inclusive range with no end" diagnostic. There is no intent to allow an `X..=` pattern that I am aware of, so removing the flag request is a strict improvement. The arrival of the `J | K` "or" pattern also enables some odd formations. Some of the behavior tested for here is derived from experiments in this [Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=58777b3c715c85165ac4a70d93efeefc) example, linked at https://github.com/rust-lang/rust/issues/67264#issuecomment-812770692, which may be useful to reference to observe the current behavior more closely. In addition tests constituting an explanation of the "slicing range patterns" syntax issue are included in this PR. ## Desiderata The exclusive range patterns and half-open range patterns are fairly strongly requested by many authors, as they make some patterns much more natural to write, but there is disagreement regarding the "closed" exclusive range pattern or the "RangeTo" pattern, especially where it creates "off by one" gaps in the presence of a "catch-all" wildcard case. Also, there are obviously no range analyses in place that will force diagnostics for e.g. highly overlapping matches. I believe these should be warned on, ideally, and I think it would be reasonable to consider such a blocker to stabilizing this feature, but there is no technical issue with the feature as-is from the purely syntactic perspective as such overlapping or missed matches can already be generated today with such a catch-all case. And part of the "point" of the feature, at least from my view, is to make it easier to omit wildcard matches: a pattern with such an "open" match produces an irrefutable match and does not need the wild card case, making it easier to benefit from exhaustiveness checking. ## History - Implemented: - Partially via exclusive ranges: https://github.com/rust-lang/rust/pull/35712 - Fully with half-open ranges: https://github.com/rust-lang/rust/pull/67258 - Unresolved Questions: - The precedence concerns of https://github.com/rust-lang/rust/pull/48501 were considered as likely requiring adjustment but probably wanting a uniform consistent change across all pattern styles, given https://github.com/rust-lang/rust/issues/67264#issuecomment-720711656, but it is still unknown what changes might be desired - How we want to handle slice patterns in ranges seems to be an open question still, as witnessed in the discussion of this PR! I checked but I couldn't actually find an RFC for this, and given "approved provisionally by lang team without an RFC", I believe this might require an RFC before it can land? Unsure of procedure here, on account of this being stabilizing a subset of a feature of syntax. r? `@scottmcm`
2021-07-11Auto merge of #86416 - Amanieu:asm_clobber_only, r=nagisabors-0/+10
Add clobber-only register classes for asm! These are needed to properly express a function call ABI using a clobber list, even though we don't support passing actual values into/out of these registers.
2021-07-10Add clobber-only register classes for asm!Amanieu d'Antras-0/+10
These are needed to properly express a function call ABI using a clobber list, even though we don't support passing actual values into/out of these registers.
2021-07-06Add flag to configure `large_assignments` lintTomasz Miąsko-0/+10
The `large_assignments` lints detects moves over specified limit. The limit is configured through `move_size_limit = "N"` attribute placed at the root of a crate. When attribute is absent, the lint is disabled. Make it possible to enable the lint without making any changes to the source code, through a new flag `-Zmove-size-limit=N`. For example, to detect moves exceeding 1023 bytes in a cargo crate, including all dependencies one could use: ``` $ env RUSTFLAGS=-Zmove-size-limit=1024 cargo build -vv ```
2021-06-28Update to new bootstrap compilerMark Rousskov-50/+0
2021-06-25Auto merge of #86599 - Amanieu:asm_raw, r=nagisabors-1/+2
Add a "raw" option for asm! which ignores format string specifiers This is useful when including raw assembly snippets using `include_str!`.
2021-06-24Add a "raw" option for asm! which ignores format string specifiersAmanieu d'Antras-1/+2
2021-06-10Add support for using qualified paths with structs in expression and patternRyan Levick-0/+29
position.
2021-06-06Auto merge of #79608 - alessandrod:bpf, r=nagisabors-0/+6
BPF target support This adds `bpfel-unknown-none` and `bpfeb-unknown-none`, two new no_std targets that generate little and big endian BPF. The approach taken is very similar to the cuda target, where `TargetOptions::obj_is_bitcode` is enabled and code generation is done by the linker. I added the targets to `dist-various-2`. There are [some tests](https://github.com/alessandrod/bpf-linker/tree/main/tests/assembly) in bpf-linker and I'm planning to add more. Those are currently not ran as part of rust CI.
2021-06-05Auto merge of #85457 - jyn514:remove-doc-include, r=GuillaumeGomezbors-40/+0
Remove `doc(include)` This nightly feature is redundant now that `extended_key_value_attributes` is stable (https://github.com/rust-lang/rust/pull/83366). `@rust-lang/rustdoc` not sure if you think this needs FCP; there was already an FCP in #82539, but technically it was for deprecating, not removing the feature altogether. This should not be merged before #83366. cc `@petrochenkov`
2021-06-04Remove `doc(include)`Joshua Nelson-40/+0
2021-06-03Satisfy unstable book lintJubilee Young-2/+5
2021-06-03Add run-make test testing flag stabilityRyan Levick-1/+1
2021-06-02Add a page on force-warns in unstable bookRyan Levick-0/+21
2021-05-29BPF: misc minor review fixesAlessandro Decina-3/+3
2021-05-26stabilize member constraintsNiko Matsakis-29/+0