forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#74073 - Manishearth:rollup-faqo9lx, r=Manishe…
…arth Rollup of 12 pull requests Successful merges: - rust-lang#72688 (added .collect() into String from Box<str>) - rust-lang#73787 (Add unstable docs for rustc_attrs) - rust-lang#73834 (Some refactoring around intrinsic type checking) - rust-lang#73871 (Fix try_print_visible_def_path for Rust 2018) - rust-lang#73937 (Explain exhaustive matching on {usize,isize} maximum values) - rust-lang#73973 (Use `Span`s to identify unreachable subpatterns in or-patterns) - rust-lang#74000 (add `lazy_normalization_consts` feature gate) - rust-lang#74025 (Remove unnecessary release from Arc::try_unwrap) - rust-lang#74027 (Convert more `DefId`s to `LocalDefId`s) - rust-lang#74055 (Fix spacing in Iterator fold doc) - rust-lang#74057 (expected_found `&T` -> `T`) - rust-lang#74064 (variant_count: avoid incorrect dummy implementation) Failed merges: r? @ghost
- Loading branch information
Showing
56 changed files
with
796 additions
and
332 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/doc/unstable-book/src/language-features/rustc-attrs.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# `rustc_attrs` | ||
|
||
This feature has no tracking issue, and is therefore internal to | ||
the compiler, not being intended for general use. | ||
|
||
Note: `rustc_attrs` enables many rustc-internal attributes and this page | ||
only discuss a few of them. | ||
|
||
------------------------ | ||
|
||
The `rustc_attrs` feature allows debugging rustc type layouts by using | ||
`#[rustc_layout(...)]` to debug layout at compile time (it even works | ||
with `cargo check`) as an alternative to `rustc -Z print-type-sizes` | ||
that is way more verbose. | ||
|
||
Options provided by `#[rustc_layout(...)]` are `debug`, `size`, `abi`. | ||
Note that it only work best with sized type without generics. | ||
|
||
## Examples | ||
|
||
```rust,ignore | ||
#![feature(rustc_attrs)] | ||
#[rustc_layout(abi, size)] | ||
pub enum X { | ||
Y(u8, u8, u8), | ||
Z(isize), | ||
} | ||
``` | ||
|
||
When that is compiled, the compiler will error with something like | ||
|
||
```text | ||
error: abi: Aggregate { sized: true } | ||
--> src/lib.rs:4:1 | ||
| | ||
4 | / pub enum T { | ||
5 | | Y(u8, u8, u8), | ||
6 | | Z(isize), | ||
7 | | } | ||
| |_^ | ||
error: size: Size { raw: 16 } | ||
--> src/lib.rs:4:1 | ||
| | ||
4 | / pub enum T { | ||
5 | | Y(u8, u8, u8), | ||
6 | | Z(isize), | ||
7 | | } | ||
| |_^ | ||
error: aborting due to 2 previous errors | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.