Commit Graph

5680 Commits

Author SHA1 Message Date
Eric Huss de725fe56f Remove note about missing ios/tvos targets in platform docs.
I misunderstood how this works, and I have fixed the linux builds
to support ios/tvos.
2020-09-25 12:09:06 -07:00
bors 78a089487b Auto merge of #74430 - Manishearth:stabilize-intra-doc, r=Manishearth
Stabilize intra-doc links

Fixes https://github.com/rust-lang/rust/issues/43466

Thanks to the great work of `@jyn514` in getting the [cross-crate reexport issue](https://github.com/rust-lang/rust/issues/65983) in intra-rustdoc links fixed, I think we're now in a position to stabilize this feature.

The tracking issue currently has two unresolved issues:

 - <s>behavior around doc(hidden): This is fixed in https://github.com/rust-lang/rust/pull/73365, which is just waiting for CI and should land tomorrow. It's also a pretty niche bug so while I expect it to land soon I don't think we need to block stabilization on it anyway.</s>
 - Non-identifier primitive types like slices: This was not a part of the original RFC anyway, and is a pretty niche use case

The feature itself, sans https://github.com/rust-lang/rust/issues/65983, has been shipped on nightly for three years now, with people using it on docs.rs. https://github.com/rust-lang/rust/issues/65983 itself is not an overwhelmingly central bit of functionality; the reason we elected to block stabilization on it was that back in 2017 it was not possible to fix the issue without some major refactorings of resolve, and we did not want to stabilize something that had such a potentially unfixable bug.

Given that we've fixed it, I see no reason to delay stabilization on this long awaited feature. It's possible that the latest patches have problems, however we _have_ done crater runs of some of the crucial parts. Furthermore, that's what the release trains are for, we will have a solid three months to let it ride the trains before it actually hits the stable compiler.

r? `@rust-lang/rustdoc`
2020-09-24 03:42:53 +00:00
dylni f055b0bb08 Rename method to `assert_len` 2020-09-18 13:55:03 -04:00
dylni 1ff7da6551 Move `slice::check_range` to `RangeBounds` 2020-09-18 12:17:51 -04:00
Manish Goregaokar 6928041c0a
Update src/doc/rustdoc/src/linking-to-items-by-name.md
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-17 20:21:09 -07:00
bors 285fc7d704 Auto merge of #76804 - tmandry:rollup-nwntt3q, r=tmandry
Rollup of 16 pull requests

Successful merges:

 - #75026 (Add array_windows fn)
 - #76642 (Do not lint ignored private doc tests)
 - #76719 (Change error message for ty param in const)
 - #76721 (Use intra-doc links in `core::mem`)
 - #76728 (Add a comment why `extern crate` is necessary for rustdoc)
 - #76735 (Remove unnecessary `clone()`s in bootstrap)
 - #76741 (Avoid printing dry run timings)
 - #76747 (Add missing code examples in libcore)
 - #76756 (fix a couple of stylistic clippy warnings)
 - #76758 ([fuchsia] Propagate the userspace UTC clock)
 - #76759 (Fix stabilization marker for future_readiness_fns)
 - #76760 (don't lazily evaluate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations))
 - #76764 (Update books)
 - #76775 (Strip a single leading tab when rendering dataflow diffs)
 - #76778 (Simplify iter fuse struct doc)
 - #76794 (Make graphviz font configurable)

Failed merges:

r? `@ghost`
2020-09-16 20:18:19 +00:00
Tyler Mandry 5d8bc90715
Rollup merge of #76764 - ehuss:update-books, r=ehuss
Update books

## nomicon

1 commits in 25854752549d44d76fbd7650e17cb4f167a0b8fb..6e57e64501f61873ab80cb78a07180a22751a5d6
2020-08-19 16:41:48 -0400 to 2020-09-14 11:40:23 -0400
- Fix API change to alloc::Global::grow. (rust-lang-nursery/nomicon#236)

## reference

3 commits in 25391dba46262f882fa846beefaff54a966a8fa5..56a13c082ee90736c08d6abdcd90462517b703d3
2020-09-02 07:22:55 -0700 to 2020-09-14 23:20:16 -0700
- Update the description of staticlib (rust-lang-nursery/reference#884)
- Rust 1.46 now allows more features in const fn (rust-lang-nursery/reference#883)
- Document the enum changes in RFC 2195 (rust-lang-nursery/reference#879)

## book

1 commits in e5ed97128302d5fa45dbac0e64426bc7649a558c..cb28dee95e5e50b793e6ba9291c5d1568d3ad72e
2020-08-31 12:53:40 -0500 to 2020-09-09 10:06:00 -0500
- Fixed the error message of invalid array element access in ch03.2 (rust-lang/book#2446)
2020-09-16 12:24:25 -07:00
bors ff806b8716 Auto merge of #76420 - Gelbpunkt:aarch64-linux-musl, r=pietroalbini
Add aarch64-unknown-linux-musl host builds

This adds aarch64-unknown-linux-musl to the hosts list and adds the build to the dist-arm-linux builder as `@Mark-Simulacrum` suggested to me in Zulip. `@jyn514` requested to be mentioned 😄

I had to update the config for crosstool-ng as it had a prompt about the glibc version.

I ran `src/ci/docker/run.sh dist-arm-linux` to test it.

```
Build completed successfully in 1:31:50
Compile requests              8180
Compile requests executed     8135
Cache hits                     287
Cache misses                  7848
Cache timeouts                   0
Cache read errors                0
Forced recaches                  0
Cache write errors               0
Compilation failures             0
Cache errors                     0
Non-cacheable compilations       0
Non-cacheable calls             36
Non-compilation calls            9
Unsupported compiler calls       0
Average cache write          0.000 s
Average cache read miss      6.389 s
Average cache read hit       0.000 s
Cache location             Local disk: "/sccache"
Cache size                     202 MiB
Max cache size                  10 GiB
== clock drift check ==
  local time: Sun Sep  6 19:30:17 UTC 2020
  network time: Sun, 06 Sep 2020 19:30:17 GMT
== end clock drift check ==
```

Only errors were in miri due to struct fields being private (already been reported [here](https://github.com/rust-lang/rust/issues/76337))

Edit: Maybe it is helpful if I add that it is a working compiler
```sh
/rust-nightly-aarch64-unknown-linux-musl # ash install.sh
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'cargo'
install: installing component 'rls-preview'
install: installing component 'rust-analyzer-preview'
install: installing component 'clippy-preview'
install: installing component 'rustfmt-preview'
install: installing component 'llvm-tools-preview'
install: installing component 'rust-analysis-aarch64-unknown-linux-musl'
install: installing component 'rust-std-aarch64-unknown-linux-musl'
install: WARNING: failed to run ldconfig. this may happen when not installing as root. run with --verbose to see the error

    Rust is ready to roll.

/ # cat test.rs
fn main() { println!("hello world"); }
/ # rustc test.rs
/ # ./test
hello world
 # file test
test: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped
```
2020-09-16 17:22:54 +00:00
Dylan DPC 6194d7e735
Rollup merge of #76675 - lzutao:asm_doc, r=Amanieu
Small improvements to asm documentation

Save people from searching and reading tons of comments in tracking issues.
2020-09-16 12:34:14 +02:00
Lzu Tao e82be710e4 document how to use memory addresses as operands
Co-authored-by: Amanieu <amanieu@gmail.com>
2020-09-16 03:09:07 +00:00
Eric Huss e0c1621a3f Update books 2020-09-15 14:55:50 -07:00
Alistair Francis e968f86f71 doc: platform-support.md: Move to tier 3
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-15 08:13:01 -07:00
Alistair Francis cbda1546b1 doc: platform-support.md: Document port
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-15 07:58:33 -07:00
Manish Goregaokar 792b2ea581
Update src/doc/rustdoc/src/lints.md
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-14 22:35:41 -07:00
Jens Reidel bfb56d82d4 Update based on @alex's PR 2020-09-14 13:15:01 +02:00
Guillaume Gomez d069c7e928 Stabilize doc_alias feature 2020-09-14 11:03:47 +02:00
Manish Goregaokar 6f1fa2b163 Fix lint name in docs 2020-09-13 18:16:54 -07:00
Manish Goregaokar 51c1351f7b Resolve some conflicts 2020-09-13 18:14:34 -07:00
Manish Goregaokar 175e30539d Update src/doc/rustdoc/src/linking-to-items-by-name.md
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-13 18:12:52 -07:00
Manish Goregaokar 4e0eb0b73b Update src/doc/rustdoc/src/linking-to-items-by-name.md
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-13 18:12:52 -07:00
Manish Goregaokar 2a98409634 Fill out docs on intra-doc resolution failure lint 2020-09-13 18:12:52 -07:00
Manish Goregaokar f072e4a732 Mention URL fragments 2020-09-13 18:12:52 -07:00
Manish Goregaokar bc06674774 Mention super/crate/self in docs 2020-09-13 18:12:51 -07:00
Manish Goregaokar 63d5beec43 Move intra-doc-links documentation out of unstable section 2020-09-13 18:12:49 -07:00
Eric Huss ce014be0b9 Link rustdoc lint docs to the rustdoc book. 2020-09-13 08:48:03 -07:00
Eric Huss 45c1e0ae07 Auto-generate lint documentation. 2020-09-13 08:48:03 -07:00
Lzu Tao 8d96cc238e make llvm_asm options more intense 2020-09-13 14:39:55 +00:00
Tyler Mandry f9df658aad
Rollup merge of #76555 - alilleybrinker:reword_trivial_casts_lint_doc, r=steveklabnik
Reword `trivial_casts` lint in rustc book to better explain what it does.

The current description of the trivial casts lint under the "allowed
by default" listing in the rustc book indicates the lint is for casts
which may be removed, which is less clear than saying it's for casts
which may be replaced by coercion (which is the wording used by the
error message included in the doc).

This commit changes the wording slightly to better describe what the
lint does.

This issue bit me in some recent code where I was attempting to
convert a `Vec<SomeType>` to a `Vec<SomeTraitObject>`, and
hit my project-wide `#![deny(trivial_casts)]` with
`map(|o| Box::new(o) as TraitObject)`. I'd read the book docs for
`trivial_casts` and was surprised by the error, as I took it to mean
the cast ought to be removed (rather than replaced by ascription
in this case). Removing the cast meant other code didn't compile,
and I then found issues like #23742 and realized my misunderstanding.
2020-09-10 12:20:06 -07:00
Tyler Mandry 91c3ef8bef
Rollup merge of #76289 - arijit79:master, r=jyn514
Add docs about crate level documentation support

Wrote information about how to write documentation on the crate level in rhe rustdoc book
2020-09-10 12:19:59 -07:00
arijit79 fd5859a673 Add docs about crate level documentation support 2020-09-10 10:29:24 -04:00
Andrew Lilley Brinker 01bf35010f Reword `trivial_casts` lint to better explain.
The current description of the trivial casts lint under the "allowed
by default" listing in the rustc book indicates the lint is for lints
which may be removed, which is less clear than saying it's for lints
which may be replaced by coercion (which is the wording used by the
error message included in the doc).

This commit changes the wording slightly to better describe what the
lint does.
2020-09-09 19:36:15 -07:00
Tyler Mandry df84ac74bd
Rollup merge of #76465 - jyn514:auto-versioning, r=elichai
Add a script to automatically update Rust/Clang versions in documentation

From https://github.com/rust-lang/rust/pull/76402#issuecomment-687974508.

r? @elichai
2020-09-09 15:05:53 -07:00
Tyler Mandry d0c2a2d37c
Rollup merge of #76430 - pickfire:patch-7, r=steveklabnik
Add align to rustc-attrs unstable book
2020-09-09 15:05:51 -07:00
Dylan DPC 1aef86c858
Rollup merge of #76402 - elichai:patch-2, r=wesleywiser
Update linker-plugin-lto.md to contain up to rust 1.46

Hi,
this is the same as https://github.com/rust-lang/rust/pull/72290, if anyone has suggestions on how to automate this please say :)
otherwise, you can check the versions I've added via:

```sh
$ rustup install 1.44.0
$ rustc +1.44.0 -Vv
rustc 1.44.0 (49cae5576 2020-06-01)
binary: rustc
commit-hash: 49cae55760da0a43428eba73abcb659bb70cf2e4
commit-date: 2020-06-01
host: x86_64-unknown-linux-gnu
release: 1.44.0
LLVM version: 9.0

$ rustup install 1.45.0
$ rustc +1.45.0 -Vv
rustc 1.45.0 (5c1f21c3b 2020-07-13)
binary: rustc
commit-hash: 5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2
commit-date: 2020-07-13
host: x86_64-unknown-linux-gnu
release: 1.45.0
LLVM version: 10.0

$ rustup install 1.46.0
$ rustc +stable -Vv
rustc 1.46.0 (04488afe3 2020-08-24)
binary: rustc
commit-hash: 04488afe34512aa4c33566eb16d8c912a3ae04f9
commit-date: 2020-08-24
host: x86_64-unknown-linux-gnu
release: 1.46.0
LLVM version: 10.0
```
2020-09-09 01:35:22 +02:00
Joshua Nelson 0c9bf13f5f Add a script to automatically update Rust/Clang versions 2020-09-07 22:06:23 -04:00
Ivan Tham 3a3a08585f
Unstable book rust-attrs does not work on generics
Co-authored-by: Peter Todd <pete@petertodd.org>
2020-09-08 09:08:25 +08:00
Ivan Tham 3740b0064d
Add align to rustc-attrs unstable book 2020-09-07 15:10:31 +08:00
Elichai Turkel 2e82589741
linker-plugin-lto.md: Convert the rust-clang MxN table to a 2xM table 2020-09-06 14:55:27 +03:00
Elichai Turkel 9e1403373d
Update linker-plugin-lto.md to contain up to rust 1.46 2020-09-06 11:20:53 +03:00
dylni cf529c767e Adjust documentation for slice_check_range 2020-09-05 19:53:35 -04:00
Dylan DPC c3a09fba84
Rollup merge of #75954 - ArekPiekarz:unstable_book_ffi_tracking_issues, r=steveklabnik
Unstable Book: add links to tracking issues for FFI features
2020-09-05 16:28:20 +02:00
Eric Huss c012487bde Update books 2020-09-02 11:10:36 -07:00
Tyler Mandry c22de44a80
Rollup merge of #76212 - JesHansen:fix-lint-doc, r=jyn514
Document lint missing_doc_code_examples is nightly-only

Closes #76194
2020-09-01 18:24:44 -07:00
Jes Bak Hansen 7eb4b1b4b9 Document lint missing_doc_code_examples is nightly-only 2020-09-01 20:45:21 +02:00
Mateusz Mikuła 23f0ccfe5d Stabilise link-self-contained option 2020-08-31 15:13:31 +02:00
bors 360eb349ae Auto merge of #75919 - rust-lang:jonas-schievink-patch-1, r=ehuss
Fix typo (`thumbv8m.main-none-eabihf` is Mainline)
2020-08-30 06:32:12 +00:00
Dylan DPC fe43918c38
Rollup merge of #75892 - ArekPiekarz:unstable_book_tls_model_typo, r=petrochenkov
Fix typo in TLS Model in Unstable Book
2020-08-30 01:43:46 +02:00
bors 3d0c847d33 Auto merge of #74941 - dylanmckay:replace-broken-avr-unknown-unknown-target, r=oli-obk
[AVR] Replace broken 'avr-unknown-unknown' target with 'avr-unknown-gnu-atmega328' target

The `avr-unknown-unknown` target has never worked correctly, always trying to invoke
the host linker and failing. It aimed to be a mirror of AVR-GCC's
default handling of the `avr-unknown-unknown' triple (assume bare
minimum chip features, silently skip linking runtime libraries, etc).
This behaviour is broken-by-default as it will cause a miscompiled executable
when flashed.

This patch improves the AVR builtin target specifications to instead
expose only a 'avr-unknown-gnu-atmega328' target. This target system is
`gnu`, as it uses the AVR-GCC frontend along with avr-binutils. The
target triple ABI is 'atmega328'.

In the future, it should be possible to replace the dependency on
AVR-GCC and binutils by using the in-progress AVR LLD and compiler-rt support.
Perhaps at that point it would make sense to add an
'avr-unknown-unknown-atmega328' target as a better default when
implemented.

There is no current intention to add in-tree AVR target specifications for other
AVR microcontrollers - this one can serve as a reference implementation
for other devices via `rustc --print target-spec-json
avr-unknown-gnu-atmega328p`.

There should be no users of the existing 'avr-unknown-unknown' Rust
target as a custom target specification JSON has always been
recommended, and the avr-unknown-unknown target could never pass the
linking step anyway.
2020-08-27 15:48:56 +00:00
Arkadiusz Piekarz aa40c028fc Unstable Book: add links to tracking issues for FFI features 2020-08-26 22:03:29 +02:00
Jonas Schievink d9b075a756
Fix typo (`thumbv8m.main-none-eabihf` is Mainline) 2020-08-25 22:55:04 +02:00
Arkadiusz Piekarz 1831f65288 Fix typo in TLS Model in Unstable Book 2020-08-24 23:02:44 +02:00
Dylan McKay c9ead8c895 [AVR] Replace 'avr-unknown-unknown' with 'avr-unknown-gnu-atmega328' in platform-support.md 2020-08-24 20:44:10 +12:00
Joshua Nelson 73de34319e Document prim@ and primitive@ 2020-08-23 22:40:20 -04:00
Dylan DPC cc1e5c0509
Rollup merge of #75753 - koutheir:patch-1, r=steveklabnik
Another motivation for CFG: return-oriented programming
2020-08-22 02:14:49 +02:00
Dr. Koutheir Attouchi 8ae3384bf7
Added link to Microsoft's documentation of CFG 2020-08-21 14:52:30 -04:00
Dr. Koutheir Attouchi ec9657aec6
Fixed a typo 2020-08-21 14:47:18 -04:00
Guillaume Gomez 10a880d20e Improve wording 2020-08-21 09:49:26 +02:00
Dr. Koutheir Attouchi 5673b0e492
Switched ROP link to Desktop layout instead of mobile layout 2020-08-21 03:34:25 -04:00
Dr. Koutheir Attouchi 6fca004ba9
Another motivation for CFG: return-oriented programming 2020-08-20 18:54:40 -04:00
Guillaume Gomez d108bd5386 Add documentation for --show-coverage option 2020-08-20 21:26:57 +02:00
Eric Huss 4890186957 Update books 2020-08-19 14:07:46 -07:00
Aleksey Kladov 5ba961018c Remove missing_fragment_specifier lint 2020-08-18 09:06:45 +02:00
Sasha bdbb995df3 Mark x86_64-linux-kernel as * 2020-08-17 12:57:42 +02:00
Eric Huss 9976a60077 Move CloudABI to tier 3. 2020-08-14 20:43:27 -07:00
bors d69b0997d7 Auto merge of #75431 - ehuss:platform-support, r=Mark-Simulacrum
Move platform support to the rustc book.

This moves the [Platform Support](https://forge.rust-lang.org/release/platform-support.html) page from the forge to the rustc book. There are several reasons for doing this:

* The forge is not really oriented towards end-users (it mostly contains infrastructure, governance and policy, internal team pages, etc.). This platform support page is useful to user to know which targets are supported.
* This page can now be updated in-sync with any PRs that add or remove a target, or change its status.
* This is now automatically checked on CI to verify the list does not get out of sync. Currently it only checks the presence/absence of an entry, but more sophisticated checks could be added in the future.

I'm not 100% certain this is the best location, but I think it fits. I'd like to see the rustc guide continue to grow, including things like linking information and more platform-specific details.
2020-08-13 06:17:25 +00:00
Eric Huss ce717476ff Add a script to verify the Platform Support page is up-to-date. 2020-08-12 08:40:22 -07:00
Eric Huss 392116e021 Platform Support page updates.
A few updates:
- Some minor wording and formatting changes.
- Remove the `cargo` column.
- Explain the columns up-front.
- Add no-wrap on the target-triple, which looks better to me.
- Minor mention on how to install support for a built-in target via rustup.
2020-08-11 16:05:43 -07:00
Eric Huss 1902983f45 Move forge platform-support to the rustc book. 2020-08-11 16:02:00 -07:00
Amanieu d'Antras b5cef24f5f Update asm! documentation in unstable book
- Update the list of supported architectures.
- Clarify issues with LLVM's use of reserved registers.
2020-08-06 23:22:07 +01:00
Eric Huss 583133308b Update books 2020-08-04 16:45:19 -07:00
Manish Goregaokar e65d6ed80f
Rollup merge of #74981 - giraffate:fix_sample_codes_in_unstable_book_plugin, r=GuilliameGomez
Some fixes for `plugin.md` in unstable-book

- sample codes not working
I referred to https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs and https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/lint-plugin.rs.

- broken link
https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs -> https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs
2020-08-01 09:30:13 -07:00
Takayuki Nakata 3e48848538 Some fixes for `plugin.md` in unstable-book
- sample codes not working
- broken link
2020-07-31 23:56:18 +09:00
bors ffa80f01d8 Auto merge of #74926 - Manishearth:rename-lint, r=jyn514
Rename intra_doc_link_resolution_failure

It should be plural to follow the conventions in https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints
2020-07-31 02:20:47 +00:00
Manish Goregaokar 8fe438e632 intra_doc_resolution_failures -> broken_intra_doc_links 2020-07-30 10:38:55 -07:00
Manish Goregaokar 4df76f0f90 Rename to intra_doc_resolution_failures 2020-07-30 08:14:27 -07:00
Manish Goregaokar 48de8ac041 Rename usage of intra_doc_link_resolution_failure 2020-07-29 15:23:14 -07:00
Takayuki Nakata ab166cfffa Fix broken link in unstable book `plugin` 2020-07-29 23:21:56 +09:00
mark 2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00
16yuki0702 04b2deb381 Fix rustc docs typo. 2020-07-25 10:14:14 +09:00
Manish Goregaokar 3de0de1ded
Rollup merge of #74589 - ehuss:update-books, r=ehuss
Update books

## reference

5 commits in 0ea7bc494f1289234d8800bb9185021e0ad946f0..b329ce37424874ad4db94f829a55807c6e21d2cb
2020-07-02 15:33:04 -0700 to 2020-07-20 08:54:08 -0700
- this '*' is unnecessary, and reduces readability (rust-lang-nursery/reference#853)
- Tiny typo fix (rust-lang-nursery/reference#849)
- Update const eval chapter to latest changes (rust-lang-nursery/reference#842)
- Document #[track_caller]. (rust-lang-nursery/reference#742)
- Document shebang restriction. (rust-lang-nursery/reference#823)

## book

2 commits in 84a31397b34f9d405df44f2899ff17a4828dba18..a914f2c7e5cdb771fa465de142381a51c53b580e
2020-07-04 10:50:18 -0500 to 2020-07-21 09:20:05 -0500
- Change misleading wording (rust-lang/book#2399)
- Improve wording to include Windows versions (rust-lang/book#2395)

## edition-guide

3 commits in 82bec5877c77cfad530ca11095db4456d757f668..bd6e4a9f59c5c1545f572266af77f5c7a5bad6d1
2020-06-03 08:56:02 -0500 to 2020-07-12 17:37:08 -0500
- update guide for 1.36 and 1.37 (rust-lang/edition-guide#217)
- Add contents for Rust 1.35 (rust-lang/edition-guide#216)
- update edition guide for Rust 1.34 (rust-lang/edition-guide#215)
2020-07-22 09:29:15 -07:00
Manish Goregaokar 8afb305e72
Rollup merge of #73893 - ajpaverd:cfguard-stabilize, r=nikomatsakis
Stabilize control-flow-guard codegen option

This is the stabilization PR discussed in #68793. It converts the `-Z control-flow-guard` debugging option into a codegen option (`-C control-flow-guard`), and changes the associated tests.
2020-07-22 09:29:03 -07:00
Eric Huss 3eed7da1f9 Update books 2020-07-21 07:58:59 -07:00
Tomasz Miąsko 58b862072c Document AddressSanitizer memory leak detection defaults 2020-07-19 17:12:44 +02:00
Tomasz Miąsko 251878ebc4 Remove CC & CFLAGS from MemorySanitizer example
They are now unnecessary for projects written in Rust, since
backtrace-rs used by the standard library has only Rust dependencies.
2020-07-19 17:11:33 +02:00
Manish Goregaokar 98450757e5 Revert "Remove "important traits" feature"
This reverts commit 1244ced958.
2020-07-16 09:58:17 -07:00
Andrew Paverd 31c7aae113 Stabilize control-flow-guard codegen option 2020-07-14 15:27:42 +01:00
Manish Goregaokar b43c26eb9d
Rollup merge of #74135 - ehuss:update-books, r=ehuss
Update books

## book

3 commits in 4e7c00bece1544d409312ec93467beb62b5bd0cb..84a31397b34f9d405df44f2899ff17a4828dba18
2020-06-19 09:39:12 -0400 to 2020-07-04 10:50:18 -0500
- Update Windows install instructions (rust-lang/book#2389)
- Update ch01-02-hello-world.md (rust-lang/book#2386)
- bump mdbook version in github action (rust-lang/book#2380)

## reference

2 commits in 04d5d5d7ba624b6f5016298451f3a63d557f3260..0ea7bc494f1289234d8800bb9185021e0ad946f0
2020-06-16 15:08:05 -0700 to 2020-07-02 15:33:04 -0700
- Fix mis-capitalization of type name. (rust-lang-nursery/reference#844)
- Fix name of trait for array indexing. (rust-lang-nursery/reference#840)

## embedded-book

1 commits in 616962ad0dd80f34d8b802da038d0aed9dd691bb..94d9ea8460bcbbbfef1877b47cb930260b5849a7
2020-06-23 16:03:45 +0000 to 2020-07-05 14:17:40 +0000
- Note on transformation of static variables by attribute exception  (rust-embedded/book#251)

## rust-by-example

1 commits in 6f94ccb48da6fa4ed0031290f21411cf789f7d5e..229c6945a26a53a751ffa4f9cb418388c00029d3
2020-06-20 17:51:30 -0300 to 2020-07-06 10:13:15 -0300
- Modify comments (rust-lang/rust-by-example#1359)
2020-07-10 23:26:51 -07:00
Manish Goregaokar 31d53decd0
Rollup merge of #74184 - Manishearth:doc-intra-doc, r=GuillaumeGomez
Add docs for intra-doc-links

Fixes https://github.com/rust-lang/rust/issues/66000

Hmm, for some reason my push closed the previous PR
2020-07-09 11:50:48 -07:00
Manish Goregaokar 36a229b28d Move to unstable section 2020-07-09 09:19:50 -07:00
Manish Goregaokar 271e2a988f Update src/doc/rustdoc/src/intra-doc-links.md 2020-07-09 08:34:42 -07:00
Manish Goregaokar 09f51d41cc Add docs for intra-doc-links 2020-07-09 08:34:38 -07:00
Yuki Okushi dd07774617
Fix broken link in rustdocdoc 2020-07-08 07:15:17 +09:00
Eric Huss b50c13cc28 Update books 2020-07-07 13:53:46 -07:00
Manish Goregaokar e2ae88d4a6
Rollup merge of #73787 - pickfire:rustc-attrs, r=RalfJung
Add unstable docs for rustc_attrs

r? @RalfJung
2020-07-05 16:07:21 -07:00
Manish Goregaokar 4a8d9ea80f
Rollup merge of #73670 - davidhewitt:format-args-capture, r=varkor
Add `format_args_capture` feature

This is the initial implementation PR for [RFC 2795](https://github.com/rust-lang/rfcs/pull/2795).

Note that, as dicussed in the tracking issue (#67984), the feature gate has been called `format_args_capture`.

Next up I guess I need to add documentation for this feature. I've not written any docs before for rustc / std so I would appreciate suggestions on where I should add docs.
2020-07-03 17:16:52 -07:00
Adam Perry f07d10db7c Stabilize `#[track_caller]`.
Does not yet make its constness stable, though. Use of
`Location::caller` in const contexts is still gated by
`#![feature(const_caller_location)]`.
2020-06-30 22:22:32 -07:00
Ivan Tham 49b4804d29 Ignore example compile in rustc-attrs doc 2020-06-29 21:58:00 +08:00
Dylan MacKenzie 69a5cb1592 Remove `const_if_match` from unstable book 2020-06-28 10:08:10 -07:00
Ivan Tham 0e6f1093be Add preamable on rustc-attrs doc discussion 2020-06-28 21:48:50 +08:00
David Hewitt a1217cb29d Add `format_args_capture` to the unstable book 2020-06-27 22:02:01 +01:00
Ivan Tham 725918f17e
Update src/doc/unstable-book/src/language-features/rustc-attrs.md
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-06-28 00:23:37 +08:00
Takuto Ikuta 9308860a7b
fix typo in self-profile.md 2020-06-27 21:38:51 +09:00
Ivan Tham f772587aba Add unstable docs for rustc_attrs 2020-06-27 15:01:57 +08:00
Manish Goregaokar 81d2d3cf35
Rollup merge of #73588 - Amanieu:thumb-fp, r=nagisa
Fix handling of reserved registers for ARM inline asm

`r6` is now disallowed as an operand since LLVM sometimes uses it as a base pointer.

The check against using the frame pointer as an operand now takes the platform into account and will block either `r7` or `r11` as appropriate.

Fixes #73450

cc @cbiffle
2020-06-26 00:39:06 -07:00
Eric Huss e02dafcaaa Update books 2020-06-23 17:56:33 -07:00
Amanieu d'Antras a98868dc9f Update asm! documentation 2020-06-22 00:22:23 +01:00
Adrian Taylor a63eb3c678 Clarify --extern documentation.
Fixes #64731, #73531.

See also #64402#issuecomment-530852886
2020-06-20 17:02:18 -07:00
Ralf Jung 91bd3337e3
Rollup merge of #73404 - ajpaverd:cfguard_syntax, r=Mark-Simulacrum
Update CFGuard syntax

Update the naming and syntax of the control-flow-guard option, as discussed in #68793.

r? @Mark-Simulacrum
2020-06-20 16:39:53 +02:00
Manish Goregaokar 17b80d947d
Rollup merge of #73347 - tmiasko:incompatible-sanitizers, r=nikic
Diagnose use of incompatible sanitizers

Emit an error when incompatible sanitizer are configured through command
line options. Previously the last one configured prevailed and others
were silently ignored.

Additionally use a set to represent configured sanitizers, making it
possible to enable multiple sanitizers at once. At least in principle,
since currently all of them are considered to be incompatible with
others.
2020-06-19 19:42:55 -07:00
Manish Goregaokar 687f929c9b
Rollup merge of #73364 - joshtriplett:inline-asm, r=Amanieu
asm: Allow multiple template string arguments; interpret them as newline-separated

Allow the `asm!` macro to accept a series of template arguments, and interpret them as if they were concatenated with a '\n' between them. This allows writing an `asm!` where each line of assembly appears in a separate template string argument.

This syntax makes it possible for rustfmt to reliably format and indent each line of assembly, without risking changes to the inside of a template string. It also avoids the complexity of having the user carefully format and indent a multi-line string (including where to put the surrounding quotes), and avoids the extra indentation and lines of a call to `concat!`.

For example, rewriting the second example from the [blog post on the new inline assembly syntax](https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html) using multiple template strings:

```rust

fn main() {
    let mut bits = [0u8; 64];
    for value in 0..=1024u64 {
        let popcnt;
        unsafe {
            asm!(
                "    popcnt {popcnt}, {v}",
                "2:",
                "    blsi rax, {v}",
                "    jz 1f",
                "    xor {v}, rax",
                "    tzcnt rax, rax",
                "    stosb",
                "    jmp 2b",
                "1:",
                v = inout(reg) value => _,
                popcnt = out(reg) popcnt,
                out("rax") _, // scratch
                inout("rdi") bits.as_mut_ptr() => _,
            );
        }
        println!("bits of {}: {:?}", value, &bits[0..popcnt]);
    }
}
```

Note that all the template strings must appear before all other arguments; you cannot, for instance, provide a series of template strings intermixed with the corresponding operands.
2020-06-19 09:15:14 -07:00
Manish Goregaokar bc773fe568
Rollup merge of #73214 - androm3da:hex_inline_asm_00, r=Amanieu
Add asm!() support for hexagon
2020-06-19 09:15:00 -07:00
Andrew Paverd 83e6c0e986 Update CFGuard syntax 2020-06-16 17:44:03 +01:00
Brian Cain 7a9f29d305 Add initial asm!() support for hexagon
GPRs only
2020-06-16 08:58:13 -05:00
Josh Triplett fd9ed30e4b asm: Update chapter in unstable book for multiple template string arguments
Update all examples to use the new formatting, and update explanations
to document it.
2020-06-15 13:30:13 -07:00
Tomasz Miąsko 0a65f280c8 Diagnose use of incompatible sanitizers
Emit an error when incompatible sanitizer are configured through command
line options. Previously the last one configured prevailed and others
were silently ignored.

Additionally use a set to represent configured sanitizers, making it
possible to enable multiple sanitizers at once. At least in principle,
since currently all of them are considered to be incompatible with
others.
2020-06-14 18:14:10 +02:00
Dylan DPC 8650df5dea
Rollup merge of #73230 - Amanieu:asm-unused2, r=petrochenkov
Suggest including unused asm arguments in a comment to avoid error

We require all arguments to an `asm!` to be used in the template string, just like format strings. However in some cases (e.g. `black_box`) it may be desirable to have `asm!` arguments that are not used in the template string.

Currently this is a hard error rather than a lint since `#[allow]` does not work on macros (#63221), so this PR suggests using the unused arguments in an asm comment as a workaround.

r? @petrochenkov
2020-06-11 19:04:20 +02:00
Dylan DPC 12e5a69fee
Rollup merge of #73080 - ertos-rs:sean.wilson/devel/external_doc-ref-fix, r=ollie27
doc/rustdoc: Fix incorrect external_doc feature flag
2020-06-11 13:15:58 +02:00
Amanieu d'Antras 34bb6d0448 Cleanup docs 2020-06-11 01:27:39 +01:00
Dylan DPC 8a0e6e9335
Rollup merge of #73149 - cuviper:awailable, r=steveklabnik
typo: awailable -> available
2020-06-10 01:06:34 +02:00
Josh Stone fd483c86db typo: awailable -> available 2020-06-08 13:37:58 -07:00
Dylan DPC 9890107a81
Rollup merge of #73143 - ehuss:update-books, r=ehuss
Update books

## nomicon

3 commits in d1517d4e3f29264c5c67bce2658516bb5202c800..bfe1ab96d717d1dda50e499b360f2e2f57e1750a
2020-05-12 13:47:00 -0400 to 2020-06-05 13:19:42 -0400
- Clarify that str data must still be initialized
- Remove language-level UB for non-UTF-8 str
- fix Nomicon transmute UB

## reference

5 commits in becdca9477c9eafa96a4eea5156fe7a2730d9dd2..5d40ba5c2515caffa7790cda621239dc21ef5a72
2020-05-21 21:08:02 +0100 to 2020-06-06 20:25:36 -0700
- Add some links to Disambiguating Function Calls. (rust-lang-nursery/reference#829)
- change bash to sh as shell code blocks language indentifier (rust-lang-nursery/reference#827)
- Fix sentence mistake in array-expr.md (rust-lang-nursery/reference#826)
- removed the word "Second" form the beginning of the 2nd list item and  labelled it as `2` (rust-lang-nursery/reference#822)
- Update fn-like proc-macro invocation restrictions. (rust-lang-nursery/reference#816)

## book

14 commits in e8a4714a9d8a6136a59b8e63544e149683876e36..30cd9dfe71c446de63826bb4472627af45acc9db
2020-05-25 10:29:27 -0500 to 2020-06-07 23:07:19 -0500
- Unnecessarily long type name in Ch 13 (rust-lang/book#2362)
- Tweak example in chapter 10 (rust-lang/book#2363)
- Mention that to_lowercase isn't perfect (rust-lang/book#2364)
- fix typo in CONTRIBUTING.md (rust-lang/book#2360)
- Link German translation in appendix F (rust-lang/book#2347)
- Updates wording on Box example (rust-lang/book#2332)
- fix: match 15-24 with 15-18 (rust-lang/book#2324)
- Reword ch01-03 recap paragraph (rust-lang/book#2305)
- Remove some confusing wording. (rust-lang/book#2358)
- Clarify some wording a bit (rust-lang/book#2357)
- Update ch12-05 PowerShell note (rust-lang/book#2348)
- text -&gt; console (rust-lang/book#2352)
- Improve wording around drop (rust-lang/book#2350)
- Make some statements about crates more correct (rust-lang/book#2349)

## edition-guide

1 commits in 0a8ab5046829733eb03df0738c4fafaa9b36b348..82bec5877c77cfad530ca11095db4456d757f668
2020-05-18 08:34:23 -0500 to 2020-06-03 08:56:02 -0500
- Add stuff for Rust 1.33 (rust-lang/edition-guide#214)
2020-06-08 22:15:21 +02:00
Eric Huss ef4c4a570f Update books 2020-06-08 12:01:01 -07:00
Ralf Jung 244465dbb8
Rollup merge of #73001 - ilya-bobyr:master, r=dtolnay
Free `default()` forwarding to `Default::default()`

It feels a bit redundant to have to say `Default::default()` every time I need a new value of a type that has a `Default` instance.
Especially so, compared to Haskell, where the same functionality is called `def`.
Providing a free `default()` function that forwards to `Default::default()` seems to improve the situation.
The trait is still there, so if someone wants to be explicit and to say `Default::default()` - it still works, but if imported as `std::default::default;`, then the free function reduces typing and visual noise.
2020-06-08 09:55:31 +02:00
Ralf Jung e8bb4c7001
Rollup merge of #72615 - jschwe:fix-Zprofile-documentation, r=steveklabnik
Fix documentation example for gcov profiling

closes #72546
Improves the documentation for the unstable Rustflag `-Zprofile` by:
- stating that Incremental compilation must be turned off.
- Adding the other `RUSTFLAGS` that should/need to be turned on (taken from [grcov documentation](https://github.com/mozilla/grcov#example-how-to-generate-gcda-files-for-a-rust-project))
- Mentioning `RUSTC_WRAPPER` to prevent everything getting instrumented.

r? @steveklabnik
2020-06-08 09:55:22 +02:00
Ilya Bobyr ebb8722ea7 unstable book: default_free_fn 2020-06-07 01:27:06 -07:00
Sean Wilson 2650c5fc6c doc/rustdoc: Fix incorrect external_doc feature flag 2020-06-06 17:20:06 -07:00
Andrew Paverd d282fb000b Updated documentation for Control Flow Guard 2020-06-03 14:31:08 +01:00
Jonathan Schwender 7bf026eed6
Doc: unstable book - profile.md: improve wording
- mention `--target` flag excludes RUSTFLAGS passing to build scripts and proc macros
2020-06-03 11:05:56 +02:00
Ralf Jung 37894559ab
Rollup merge of #72439 - westernmagic:master, r=Amanieu
NVPTX support for new asm!

This PR implements the new `asm!` syntax for the `nvptx64-nvidia-cuda` target.

r? @Amanieu
2020-05-29 21:58:34 +02:00
Eric Huss 4329261095 Remove rustc-ux-guidelines 2020-05-28 08:23:23 -07:00
Jonathan Schwender 2b26b8b32b
Fix documentation example for gcov profiling
Incremental compilation needs to be turned off. Also added the other RUSTFLAGS that should/need to be turned on.
2020-05-26 15:43:19 +02:00
Eric Huss 0fdbfd3f05 Update books 2020-05-25 17:17:27 -07:00
Michal Sudwoj 83a5cdf0ae Update src/doc/unstable-book/src/library-features/asm.md
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2020-05-24 08:20:40 +02:00
Michal Sudwoj 70cd375c57 Corrected statement about zero-extension in docs. 2020-05-24 08:20:40 +02:00
Michal Sudwoj ed559b3770 Updated documentation 2020-05-24 08:20:40 +02:00
bors 148c125b1b Auto merge of #71718 - NeoRaider:ffi_const_pure, r=Amanieu
Experimentally add `ffi_const` and `ffi_pure` extern fn attributes

Add FFI function attributes corresponding to clang/gcc/... `const` and `pure`.

Rebased version of #58327 by @gnzlbg with the following changes:

- Switched back from the `c_ffi_const` and `c_ffi_pure` naming to `ffi_const` and `ffi_pure`, as I agree with https://github.com/rust-lang/rust/pull/58327#issuecomment-462718772 and this nicely aligns with `ffi_returns_twice`
- (Hopefully) took care of all of @hanna-kruppe's change requests in the original PR

r? @hanna-kruppe
2020-05-21 15:02:08 +00:00
Ralf Jung e5a4550869
Rollup merge of #72397 - petrochenkov:tiny, r=Amanieu
llvm: Expose tiny code model to users

This model is relevant to embedded AArch64 targets and was added to LLVM relatively recently (https://reviews.llvm.org/D49673, mid 2018), so rustc frontend didn't provide access to it with `-C code-model`. The gcc analogue is [`-mcmodel=tiny`](https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html).
(This is one of the options that are passed directly to LLVM without being interpreted by rustc.)

Follow up to https://github.com/rust-lang/rust/pull/72248.
2020-05-21 13:12:24 +02:00
Ralf Jung e2c05d1e9c
Rollup merge of #72111 - petrochenkov:docstrip, r=ehuss
rustc-book: Document `-Z strip=val` option

cc https://github.com/rust-lang/rust/issues/72110
2020-05-21 13:12:15 +02:00
bors 963bf52829 Auto merge of #70705 - lcnr:generic_discriminant, r=nikomatsakis
Use `T`'s discriminant type in `mem::Discriminant<T>` instead of `u64`.

fixes #70509

Adds the lang-item `discriminant_kind`.
Updates the function signature of `intrinsics::discriminant_value`.
Adds the *probably permanently unstable* trait `DiscriminantKind`.
`mem::Discriminant` should now be smaller in some cases.

r? @ghost
2020-05-21 03:48:47 +00:00
Vadim Petrochenkov c7813ff7d2 llvm: Expose tiny code model to users 2020-05-20 23:10:48 +03:00
Matthias Schiffer a114a23723 Document `#[ffi_const]` and `#[ffi_pure]` function attributes in unstable book
Based on the work of gnzlbg <gonzalobg88@gmail.com>.
2020-05-20 01:16:11 +02:00
bors 3a7dfda40a Auto merge of #69171 - Amanieu:new-asm, r=nagisa,nikomatsakis
Implement new asm! syntax from RFC 2850

This PR implements the new `asm!` syntax proposed in https://github.com/rust-lang/rfcs/pull/2850.

# Design

A large part of this PR revolves around taking an `asm!` macro invocation and plumbing it through all of the compiler layers down to LLVM codegen. Throughout the various stages, an `InlineAsm` generally consists of 3 components:

- The template string, which is stored as an array of `InlineAsmTemplatePiece`. Each piece represents either a literal or a placeholder for an operand (just like format strings).
```rust
pub enum InlineAsmTemplatePiece {
    String(String),
    Placeholder { operand_idx: usize, modifier: Option<char>, span: Span },
}
```

- The list of operands to the `asm!` (`in`, `[late]out`, `in[late]out`, `sym`, `const`). These are represented differently at each stage of lowering, but follow a common pattern:
  - `in`, `out` and `inout` all have an associated register class (`reg`) or explicit register (`"eax"`).
  - `inout` has 2 forms: one with a single expression that is both read from and written to, and one with two separate expressions for the input and output parts.
  - `out` and `inout` have a `late` flag (`lateout` / `inlateout`) to indicate that the register allocator is allowed to reuse an input register for this output.
  - `out` and the split variant of `inout` allow `_` to be specified for an output, which means that the output is discarded. This is used to allocate scratch registers for assembly code.
  - `sym` is a bit special since it only accepts a path expression, which must point to a `static` or a `fn`.

- The options set at the end of the `asm!` macro. The only one that is particularly of interest to rustc is `NORETURN` which makes `asm!` return `!` instead of `()`.
```rust
bitflags::bitflags! {
    pub struct InlineAsmOptions: u8 {
        const PURE = 1 << 0;
        const NOMEM = 1 << 1;
        const READONLY = 1 << 2;
        const PRESERVES_FLAGS = 1 << 3;
        const NORETURN = 1 << 4;
        const NOSTACK = 1 << 5;
    }
}
```

## AST

`InlineAsm` is represented as an expression in the AST:

```rust
pub struct InlineAsm {
    pub template: Vec<InlineAsmTemplatePiece>,
    pub operands: Vec<(InlineAsmOperand, Span)>,
    pub options: InlineAsmOptions,
}

pub enum InlineAsmRegOrRegClass {
    Reg(Symbol),
    RegClass(Symbol),
}

pub enum InlineAsmOperand {
    In {
        reg: InlineAsmRegOrRegClass,
        expr: P<Expr>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: Option<P<Expr>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: P<Expr>,
    },
    SplitInOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_expr: P<Expr>,
        out_expr: Option<P<Expr>>,
    },
    Const {
        expr: P<Expr>,
    },
    Sym {
        expr: P<Expr>,
    },
}
```

The `asm!` macro is implemented in librustc_builtin_macros and outputs an `InlineAsm` AST node. The template string is parsed using libfmt_macros, positional and named operands are resolved to explicit operand indicies. Since target information is not available to macro invocations, validation of the registers and register classes is deferred to AST lowering.

## HIR

`InlineAsm` is represented as an expression in the HIR:

```rust
pub struct InlineAsm<'hir> {
    pub template: &'hir [InlineAsmTemplatePiece],
    pub operands: &'hir [InlineAsmOperand<'hir>],
    pub options: InlineAsmOptions,
}

pub enum InlineAsmRegOrRegClass {
    Reg(InlineAsmReg),
    RegClass(InlineAsmRegClass),
}

pub enum InlineAsmOperand<'hir> {
    In {
        reg: InlineAsmRegOrRegClass,
        expr: Expr<'hir>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: Option<Expr<'hir>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: Expr<'hir>,
    },
    SplitInOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_expr: Expr<'hir>,
        out_expr: Option<Expr<'hir>>,
    },
    Const {
        expr: Expr<'hir>,
    },
    Sym {
        expr: Expr<'hir>,
    },
}
```

AST lowering is where `InlineAsmRegOrRegClass` is converted from `Symbol`s to an actual register or register class. If any modifiers are specified for a template string placeholder, these are validated against the set allowed for that operand type. Finally, explicit registers for inputs and outputs are checked for conflicts (same register used for different operands).

## Type checking

Each register class has a whitelist of types that it may be used with. After the types of all operands have been determined, the `intrinsicck` pass will check that these types are in the whitelist. It also checks that split `inout` operands have compatible types and that `const` operands are integers or floats. Suggestions are emitted where needed if a template modifier should be used for an operand based on the type that was passed into it.

## HAIR

`InlineAsm` is represented as an expression in the HAIR:

```rust
crate enum ExprKind<'tcx> {
    // [..]
    InlineAsm {
        template: &'tcx [InlineAsmTemplatePiece],
        operands: Vec<InlineAsmOperand<'tcx>>,
        options: InlineAsmOptions,
    },
}
crate enum InlineAsmOperand<'tcx> {
    In {
        reg: InlineAsmRegOrRegClass,
        expr: ExprRef<'tcx>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: Option<ExprRef<'tcx>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: ExprRef<'tcx>,
    },
    SplitInOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_expr: ExprRef<'tcx>,
        out_expr: Option<ExprRef<'tcx>>,
    },
    Const {
        expr: ExprRef<'tcx>,
    },
    SymFn {
        expr: ExprRef<'tcx>,
    },
    SymStatic {
        expr: ExprRef<'tcx>,
    },
}
```

The only significant change compared to HIR is that `Sym` has been lowered to either a `SymFn` whose `expr` is a `Literal` ZST of the `fn`, or a `SymStatic` whose `expr` is a `StaticRef`.

## MIR

`InlineAsm` is represented as a `Terminator` in the MIR:

```rust
pub enum TerminatorKind<'tcx> {
    // [..]

    /// Block ends with an inline assembly block. This is a terminator since
    /// inline assembly is allowed to diverge.
    InlineAsm {
        /// The template for the inline assembly, with placeholders.
        template: &'tcx [InlineAsmTemplatePiece],

        /// The operands for the inline assembly, as `Operand`s or `Place`s.
        operands: Vec<InlineAsmOperand<'tcx>>,

        /// Miscellaneous options for the inline assembly.
        options: InlineAsmOptions,

        /// Destination block after the inline assembly returns, unless it is
        /// diverging (InlineAsmOptions::NORETURN).
        destination: Option<BasicBlock>,
    },
}

pub enum InlineAsmOperand<'tcx> {
    In {
        reg: InlineAsmRegOrRegClass,
        value: Operand<'tcx>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        place: Option<Place<'tcx>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_value: Operand<'tcx>,
        out_place: Option<Place<'tcx>>,
    },
    Const {
        value: Operand<'tcx>,
    },
    SymFn {
        value: Box<Constant<'tcx>>,
    },
    SymStatic {
        value: Box<Constant<'tcx>>,
    },
}
```

As part of HAIR lowering, `InOut` and `SplitInOut` operands are lowered to a split form with a separate `in_value` and `out_place`.

Semantically, the `InlineAsm` terminator is similar to the `Call` terminator except that it has multiple output places where a `Call` only has a single return place output.

The constant promotion pass is used to ensure that `const` operands are actually constants (using the same logic as `#[rustc_args_required_const]`).

## Codegen

Operands are lowered one more time before being passed to LLVM codegen:

```rust
pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> {
    In {
        reg: InlineAsmRegOrRegClass,
        value: OperandRef<'tcx, B::Value>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        place: Option<PlaceRef<'tcx, B::Value>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_value: OperandRef<'tcx, B::Value>,
        out_place: Option<PlaceRef<'tcx, B::Value>>,
    },
    Const {
        string: String,
    },
    SymFn {
        instance: Instance<'tcx>,
    },
    SymStatic {
        def_id: DefId,
    },
}
```

The operands are lowered to LLVM operands and constraint codes as follow:
- `out` and the output part of `inout` operands are added first, as required by LLVM. Late output operands have a `=` prefix added to their constraint code, non-late output operands have a `=&` prefix added to their constraint code.
- `in` operands are added normally.
- `inout` operands are tied to the matching output operand.
- `sym` operands are passed as function pointers or pointers, using the `"s"` constraint.
- `const` operands are formatted to a string and directly inserted in the template string.

The template string is converted to LLVM form:
- `$` characters are escaped as `$$`.
- `const` operands are converted to strings and inserted directly.
- Placeholders are formatted as `${X:M}` where `X` is the operand index and `M` is the modifier character. Modifiers are converted from the Rust form to the LLVM form.

The various options are converted to clobber constraints or LLVM attributes, refer to the [RFC](https://github.com/Amanieu/rfcs/blob/inline-asm/text/0000-inline-asm.md#mapping-to-llvm-ir) for more details.

Note that LLVM is sometimes rather picky about what types it accepts for certain constraint codes so we sometimes need to insert conversions to/from a supported type. See the target-specific ISelLowering.cpp files in LLVM for details.

# Adding support for new architectures

Adding inline assembly support to an architecture is mostly a matter of defining the registers and register classes for that architecture. All the definitions for register classes are located in `src/librustc_target/asm/`.

Additionally you will need to implement lowering of these register classes to LLVM constraint codes in `src/librustc_codegen_llvm/asm.rs`.
2020-05-19 18:32:40 +00:00
Bastian Kauschke 9f7c5a80a3 update libcore, add `discriminant_kind` lang-item 2020-05-19 10:12:35 +02:00
Dylan DPC 0b63bc7b51
Rollup merge of #72290 - elichai:2020-doc-lto, r=wesleywiser
Add newer rust versions to linker-plugin-lto.md

Hi,
This doc got a bit out of date,
it's hosted here: https://doc.rust-lang.org/rustc/linker-plugin-lto.html
you can check the versions I've added via:
```bash
$ rustup install 1.38.0
$ rustc +1.38.0 -vV
rustc 1.38.0 (625451e37 2019-09-23)
binary: rustc
commit-hash: 625451e376bb2e5283fc4741caa0a3e8a2ca4d54
commit-date: 2019-09-23
host: x86_64-unknown-linux-gnu
release: 1.38.0
LLVM version: 9.0

$ rustup install 1.43.1
$ rustc +1.43.1 -vV
rustc 1.43.1 (8d69840ab 2020-05-04)
binary: rustc
commit-hash: 8d69840ab92ea7f4d323420088dd8c9775f180cd
commit-date: 2020-05-04
host: x86_64-unknown-linux-gnu
release: 1.43.1
LLVM version: 9.0
```
2020-05-18 19:04:06 +02:00
Amanieu d'Antras 09efea5f54 Update unstable book documentation with the latest RFC text 2020-05-18 14:41:35 +01:00
Amanieu d'Antras 3233565cdf Mark asm unstable book doctests as allow_fail since they don't work with system LLVM 2020-05-18 14:41:35 +01:00
Amanieu d'Antras 6f8be8cc8c Fix docs 2020-05-18 14:41:34 +01:00
Amanieu d'Antras 6ba9696f5e Add documentation for asm! 2020-05-18 14:41:34 +01:00
bors 5f472813df Auto merge of #72248 - petrochenkov:codemodel, r=Amanieu
Cleanup and document `-C code-model`

r? @Amanieu
2020-05-17 21:22:48 +00:00
Elichai Turkel 15911963ec
Update linker-plugin-lto.md to contain up to rust 1.43 2020-05-17 12:16:43 +03:00
Ralf Jung 4fe6d52d97
Rollup merge of #72094 - petrochenkov:overfeature, r=nikic
cmdline: Make target features individually overridable

Fixes https://github.com/rust-lang/rust/issues/56527

Previously `-C target-feature=+avx2 -C target-feature=+fma` was equivalent to `-C target-feature=+fma` because the later `-C target-feature` option fully overridden previous `-C target-feature`.
With this PR `-C target-feature=+avx2 -C target-feature=+fma` is equivalent to `-C target-feature=+avx2,+fma` and the options are combined.

I'm not sure where the comma-separated features in a single option came from (clang uses a scheme with single feature per-option), but logically these features are entirely independent options.
So they should be overridable individually as well to be more useful in hierarchical build system, and more consistent with other rustc options and clang behavior as well.

Target feature options have a few other issues (https://github.com/rust-lang/rust/issues/44815), but fixing those is going to be a bit more invasive.
2020-05-16 19:46:36 +02:00
Vadim Petrochenkov 59187f9771 rustc-book: Document `-C code-model` 2020-05-16 12:02:16 +03:00
Eric Huss 722b3df454 Update books 2020-05-12 11:27:03 -07:00
Vadim Petrochenkov 1899afa685 rustc-book: Document `-Z strip=val` option 2020-05-11 18:16:40 +03:00
Vadim Petrochenkov 00dcb665e7 cmdline: Make target features individually overridable 2020-05-11 02:04:53 +03:00
Stanislav Tkach 0bf269925b
Fix `strip-priv-imports` pass name in the rustdoc documentation 2020-05-07 16:22:22 +03:00
Dylan DPC 3efcba693a
Rollup merge of #71897 - alexcrichton:embed-bitcode-docs, r=nnethercote
Improve docs for embed-bitcode and linker-plugin-lto

Follow-up from #71716 I wasn't able to add in time.
2020-05-05 12:55:13 +02:00
Alex Crichton 0b35692f5e Improve docs for embed-bitcode and linker-plugin-lto
Follow-up from #71716 I wasn't able to add in time.
2020-05-04 14:46:58 -07:00
Sam Elliott cda994633e Add Option to Force Unwind Tables
When panic != unwind, `nounwind` is added to all functions for a target.
This can cause issues when a panic happens with RUST_BACKTRACE=1, as
there needs to be a way to reconstruct the backtrace. There are three
possible sources of this information: forcing frame pointers (for which
an option exists already), debug info (for which an option exists), or
unwind tables.

Especially for embedded devices, forcing frame pointers can have code
size overheads (RISC-V sees ~10% overheads, ARM sees ~2-3% overheads).
In code, it can be the case that debug info is not kept, so it is useful
to provide this third option, unwind tables, that users can use to
reconstruct the call stack. Reconstructing this stack is harder than
with frame pointers, but it is still possible.

This commit adds a compiler option which allows a user to force the
addition of unwind tables. Unwind tables cannot be disabled on targets
that require them for correctness, or when using `-C panic=unwind`.
2020-05-04 12:08:35 +01:00
mibac138 90aa62a1bf Implement RFC 2523, `#[cfg(version(..))]` 2020-05-03 02:42:07 +02:00
Alex Crichton e1832fa4e4 Rename `bitcode-in-rlib` option to `embed-bitcode`
This commit finishes work first pioneered in #70458 and started in #71528.
The `-C bitcode-in-rlib` option, which has not yet reached stable, is
renamed to `-C embed-bitcode` since that more accurately reflects what
it does now anyway. Various tests and such are updated along the way as
well.

This'll also need to be backported to the beta channel to ensure we
don't accidentally stabilize `-Cbitcode-in-rlib` as well.
2020-05-01 09:05:13 -07:00
bors 1357af3a55 Auto merge of #71528 - alexcrichton:no-more-bitcode, r=nnethercote
Store LLVM bitcode in object files, not compressed

This commit is an attempted resurrection of #70458 where LLVM bitcode
emitted by rustc into rlibs is stored into object file sections rather
than in a separate file. The main rationale for doing this is that when
rustc emits bitcode it will no longer use a custom compression scheme
which makes it both easier to interoperate with existing tools and also
cuts down on compile time since this compression isn't happening.

The blocker for this in #70458 turned out to be that native linkers
didn't handle the new sections well, causing the sections to either
trigger bugs in the linker or actually end up in the final linked
artifact. This commit attempts to address these issues by ensuring that
native linkers ignore the new sections by inserting custom flags with
module-level inline assembly.

Note that this does not currently change the API of the compiler at all.
The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate
whether the bitcode should be present in the object file or not.

Finally, note that an important consequence of this commit, which is also
one of its primary purposes, is to enable rustc's `-Clto` bitcode
loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here
is that when you're building with LTO Cargo will tell rustc to skip
codegen of all intermediate crates and only generate LLVM IR. Today
rustc will generate both object code and LLVM IR, but the object code is
later simply thrown away, wastefully.
2020-04-29 23:47:27 +00:00
Alex Crichton ef89cc8f04 Store LLVM bitcode in object files, not compressed
This commit is an attempted resurrection of #70458 where LLVM bitcode
emitted by rustc into rlibs is stored into object file sections rather
than in a separate file. The main rationale for doing this is that when
rustc emits bitcode it will no longer use a custom compression scheme
which makes it both easier to interoperate with existing tools and also
cuts down on compile time since this compression isn't happening.

The blocker for this in #70458 turned out to be that native linkers
didn't handle the new sections well, causing the sections to either
trigger bugs in the linker or actually end up in the final linked
artifact. This commit attempts to address these issues by ensuring that
native linkers ignore the new sections by inserting custom flags with
module-level inline assembly.

Note that this does not currently change the API of the compiler at all.
The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate
whether the bitcode should be present in the object file or not.

Finally, note that an important consequence of this commit, which is also
one of its primary purposes, is to enable rustc's `-Clto` bitcode
loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here
is that when you're building with LTO Cargo will tell rustc to skip
codegen of all intermediate crates and only generate LLVM IR. Today
rustc will generate both object code and LLVM IR, but the object code is
later simply thrown away, wastefully.
2020-04-29 11:57:26 -07:00
Dylan DPC b17ef8669e
Rollup merge of #71641 - ehuss:update-books, r=ehuss
Update books

## nomicon

5 commits in 6eb24d6e9c0773d4aee68ed5fca121ce3cdf676a..4d2d275997746d35eabfc4d992dfbdcce2f626ed
2020-04-06 02:21:15 +0200 to 2020-04-27 10:24:52 -0400
- Fix example in FFI, section NPO
- Update implementation code of `split_at_mut`
- Use rust-lang/rust linkchecker on CI.
- Use just `std::_` instead of `::std::_`
- Remove illegal space.

## reference

2 commits in 3ce94caed4cf967106c51ae86be5e098f7875f11..ed22e6fbfcb6ce436e9ea3b4bb4a55b2fb50a57e
2020-04-11 17:00:27 +0200 to 2020-04-24 12:46:22 -0700
- Fix grammer for tuple patterns and tuple struct patterns (rust-lang-nursery/reference#794)
- Document drop scopes (rust-lang-nursery/reference#514)

## book

2 commits in f5db319e0b19c22964398d56bc63103d669e1bba..e37c0e84e2ef73d3a4ebffda8011db6814a3b02d
2020-04-13 08:06:03 -0500 to 2020-04-26 09:31:36 -0500
- Mention short-circuiting in Appendix 02 (rust-lang/book#2318)
- Increase HTTP buffer size and add 'Content-Length' header (rust-lang/book#2246)

## rust-by-example

8 commits in c106d1683c3a2b0960f0f0fb01728cbb19807332..ffc99581689fe2455908aaef5f5cf50dd03bb8f5
2020-04-09 09:14:39 -0300 to 2020-04-24 15:05:04 -0300
- Fix Example -&gt; Examples (rust-lang/rust-by-example#1340)
- Make unsuffixed literal plural (rust-lang/rust-by-example#1335)
- Ensure example error matches the comment (rust-lang/rust-by-example#1336)
- Add missing triple backticks (rust-lang/rust-by-example#1339)
- Clarify conditional compilation (rust-lang/rust-by-example#1338)
- Clarifies how to customize lib crate name (rust-lang/rust-by-example#1337)
- Fix bytes of youkoso in shiftjis (rust-lang/rust-by-example#1333)
- Fix possible typo (rust-lang/rust-by-example#1334)

## embedded-book

4 commits in 668fb07b6160b9c468f598e839c1e044db65de30..40beccdf1bb8eb9184a2e3b42db8b8c6e394247f
2020-04-13 12:38:16 +0000 to 2020-04-26 17:44:14 +0000
- Add hint on memory config to GDB debugging section  (rust-embedded/book#215)
- Adds cargo-generate to installation instructions  (rust-embedded/book#213)
- collections: Fix example allocator  (rust-embedded/book#206)
- Flip111/patch 8  (rust-embedded/book#233)
2020-04-28 17:55:50 +02:00
Dylan DPC 3d1f958b6c
Rollup merge of #71637 - mibac138:cfg-sanitize, r=petrochenkov
Minor formatting changes in `cfg-sanitize.md`
2020-04-28 17:55:48 +02:00
Eric Huss 501dae7112 Update books 2020-04-28 07:46:36 -07:00
Vadim Petrochenkov 45dc4350c3 unstable-book: Document `-Z tls-model` 2020-04-26 23:36:00 +03:00
Vadim Petrochenkov a4199b45c2 rustc-book: Document `-C relocation-model` 2020-04-26 11:37:16 +03:00
mibac138 c3b6cc76d4 Minor formatting changes in `cfg-sanitize.md` 2020-04-24 00:40:03 +02:00
Nicholas Nethercote 4348f31e3b Alphabetize the `-C` and `-Z` options.
In the code, test, and docs, because it makes it much easier to find
things.

Other than adding the comments about alphabetical order, this commit
only moves things around.
2020-04-22 22:44:37 +10:00
Nicholas Nethercote ae322ff651 Add a new option `-Cbitcode-in-rlib`.
It defaults to true, but Cargo will set this to false whenever it can to
reduce compile times.
2020-04-22 15:22:18 +10:00
Nicholas Nethercote 3e3fd73f85 Disallow values for `-C no-*` and `-Z no-*` options again.
With the exception of `-C no-redzone`, because that could take a value
before this PR.

This partially undoes one of the earlier commits in this PR, which added
the ability to take a value to all boolean options that lacked it.

The help output for these options looks like this:
```
    -C         no-vectorize-slp=val -- disable LLVM's SLP vectorization pass
```
The "=val" part is a lie, but hopefully this will be fixed in the future.
2020-04-19 20:05:23 +10:00
Nicholas Nethercote dc06539872 Improve codegen option docs.
This commit:
- Adds "following values" indicators for all the options that are
  missing them.
- Tweaks some wording and punctuation for consistency.
- Rewords some things for clarity.
- Removes the `no-integrated-as` entry, because that option was removed
  in #70345.
2020-04-19 20:03:20 +10:00
Eric Huss 31eff9af3f Update books 2020-04-14 08:54:05 -07:00
bors 4d1fbaccb8 Auto merge of #70873 - mark-i-m:update-rdg, r=JohnTitor
Update rustc-dev-guide

This should finally fix toolstate

r? @JohnTitor
2020-04-12 12:46:47 +00:00
Eric Huss d6d0799abf Fix JSON file_name documentation for macros. 2020-04-09 18:54:53 -07:00
Mazdak Farrokhzad 09052a6d35
Rollup merge of #70918 - tobithiel:fix_forbid_override, r=davidtwco
rustc_session: forbid lints override regardless of position

Addresses the regression reported in #70819 for command line arguments, but does not address the source code flag regression.
2020-04-09 05:29:47 +02:00
mark 0d9bf52cc8 update rusct-dev-guide 2020-04-08 12:53:12 -05:00
Tobias Thiel f03db79eaa rustc_session: forbid lints override regardless of position 2020-04-07 22:05:32 -07:00
Theo Sandstrom d55c3998e0 Corrects a typo in rustdoc documentation.
Fixes rust-lang#70856
2020-04-07 18:37:35 -04:00
mark 968b2a36a5 update rustc-dev-guide 2020-04-06 21:13:39 -05:00
Linus Färnstrand d0a78ea94a Bump rust-by-example submodule 2020-04-06 22:14:35 +02:00
Linus Färnstrand e1a36e89db Bump nomicon submodule 2020-04-06 22:13:31 +02:00
bors 853c4774e2 Auto merge of #69898 - spastorino:rename-rustc-guide2, r=Xanewok
Move rustc-guide submodule to rustc-dev-guide

r? @pietroalbini
2020-04-04 18:17:14 +00:00
bors 6050e523ba Auto merge of #69718 - arlosi:debughash, r=eddyb
Add hash of source files in debug info

LLVM supports placing the hash of source files inside the debug info.
This information can be used by a debugger to verify that the source code matches
the executable.

This change adds support for both hash algorithms supported by LLVM, MD5 and SHA1, controlled by a target option.

* DWARF only supports MD5
* LLVM IR supports MD5 and SHA1 (and SHA256 in LLVM 11).
* CodeView (.PDB) supports MD5, SHA1, and SHA256.

Fixes #68980.

Tracking issue: #70401

rustc dev guide PR with further details: https://github.com/rust-lang/rustc-dev-guide/pull/623
2020-04-04 03:00:47 +00:00
bors 9e55101bb6 Auto merge of #70156 - michaelwoerister:incr-cgus, r=nikomatsakis
Make the rustc respect the `-C codegen-units` flag in incremental mode.

This PR implements (the as of yet unapproved) major change proposal at https://github.com/rust-lang/compiler-team/issues/245. See the description there for background and rationale.

The changes are pretty straightforward and should be easy to rebase if the proposal gets accepted at some point.

r? @nikomatsakis cc @pnkfelix
2020-04-03 23:50:01 +00:00
@ßd€łw@ħ@ß 56918e52d1
remove confusing about lvalues term 2020-04-02 22:20:43 +01:00
Arlo Siemsen f86b078e2d Add hash of source files in debug info
* Adds either an MD5 or SHA1 hash to the debug info.
* Adds new unstable option `-Z src-hash-algorithm` to control the hashing algorithm.
2020-04-02 14:13:19 -07:00
@ßd€łw@ħ@ß 6eccce2cc8
fix type in operands section 2020-04-02 20:30:46 +01:00
lzutao 4b66a28bb6
Add missing markdown rust annotation 2020-04-02 08:34:57 +07:00
Michael Woerister 98ead3e636 Update -Ccodegen-units docs wrt incr. comp. in rustc book. 2020-04-01 14:47:41 +02:00
lzutao e39f542c55
Add git repo address to unstable book 2020-04-01 19:10:19 +07:00
Dylan DPC 0979a2871c
Rollup merge of #70630 - ehuss:update-books, r=ehuss
Update books.

## reference

2 commits in e2f11fe4d6a5ecb471c70323197da43c70cb96b6..89dd146154474559536d5d4049a03831c501deea
2020-03-10 06:59:24 +0100 to 2020-03-31 09:42:10 -0700
- Clarify rule for end-of-line backslashes in strings (rust-lang-nursery/reference#784)
- Fix and clarify section on re-export (rust-lang-nursery/reference#780)

## book

1 commits in 6fb3705e5230311b096d47f7e2c91f9ce24393d0..c8841f2841a2d26124319ddadd1b6a245f9a1856
2020-02-12 13:48:57 -0500 to 2020-03-22 09:07:01 -0500
- Fix broken front_of_house.rs test on nightly. (rust-lang/book#2289)

## rust-by-example

7 commits in cb369ae95ca36b841960182d26f6d5d9b2e3cc18..edd2a7e687358712608896730c083cb76c7b401a
2020-03-14 12:13:22 -0500 to 2020-03-30 09:37:29 -0300
- feat: add doc attributes section to documentation (rust-lang/rust-by-example#1323)
- feat: add playpen topic (rust-lang/rust-by-example#1324)
- feat: add sentence about rustdoc & std library (rust-lang/rust-by-example#1322)
- fix: make spelling/style of rustdoc consistent (rust-lang/rust-by-example#1321)
- Rewrite section on 'static lifetime. (rust-lang/rust-by-example#1320)
- Remove deprecated `std::error::Error` functions and other minor changes (rust-lang/rust-by-example#1319)
- Remove mdbook version flags from README (rust-lang/rust-by-example#1318)

## nomicon

1 commits in 9f797e65e6bcc79419975b17aff8e21c9adc039f..411197b0e77590c967e37e8f6ec681abd359afe8
2020-03-04 03:45:13 +0100 to 2020-03-31 20:46:09 +0200
- Fix negative_impls feature. (rust-lang-nursery/nomicon#205)
2020-04-01 00:27:25 +02:00
Eric Huss 722d3d8ef0 Update books. 2020-03-31 11:53:48 -07:00
Tomasz Miąsko 6582299cdd Document ThreadSanitizer in unstable-book 2020-03-30 18:45:01 +02:00
Amanieu d'Antras d162d096dd Rename asm! to llvm_asm!
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-26 15:49:22 +00:00
Niko Matsakis cc0d6d03f6 create a tracking issue and link to it 2020-03-26 06:52:57 -04:00
Niko Matsakis fda3378e3f introduce `negative_impls` feature gate and document
They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.

This also adds docs in the unstable book for the current state of auto traits.
2020-03-26 06:52:55 -04:00
Santiago Pastorino 4387a8b96e
Move rustc-guide submodule to rustc-dev-guide 2020-03-24 15:38:53 -03:00
Mazdak Farrokhzad 0a39964ed2
Rollup merge of #69788 - ArekPiekarz:unstable_book_optin_builtin_traits, r=Dylan-DPC
Fix sequence of Type and Trait in optin-builtin-traits in Unstable Book

A simple fix in docs - the sequence of words in basic example of negative trait implementation was reversed.
2020-03-24 07:13:31 +01:00
Mazdak Farrokhzad 1bb0c929cb
Rollup merge of #70300 - aleksator:66636_reword_unused_variable_warning, r=Dylan-DPC
Reword unused variable warning

Fixes #66636
2020-03-23 19:04:54 +01:00
Mazdak Farrokhzad e37e81cad5
Rollup merge of #69494 - GuillaumeGomez:stabilize-crate-version, r=ehuss,aleksator,ollie27
Stabilize --crate-version option in rustdoc

I don't see any reason to not stabilize it anymore, so let's go!

cc @kinnison @ehuss

r? @ollie27
2020-03-23 19:04:45 +01:00
Alex Tokarev b35c30251f Reword unused variable warning 2020-03-23 12:14:45 +03:00
Eric Huss 194de274d3 Update books 2020-03-16 19:09:54 -07:00
Dylan DPC 6b50a4cebb
Rollup merge of #70014 - TimotheeGerber:small-fix-rustdoc-book, r=Dylan-DPC
Small fixes in rustdoc book

I read the `rustdoc` book today and noticed some small typos/problems. Mainly:

 - `# fn foo() {}` was displayed when not needed because fenced block code type was `text` instead of `rust`;
 - two path separators were missing and some Windows-style separators were not consistent with the rest of them (mainly Linux-style).

Here are my proposed fixes. It is my first PR for the rust project. Don't hesitate to tell me if I am doing it wrong or if you need anything else.

Have a nice day!
2020-03-16 01:30:41 +01:00
Timothée Gerber 6d521ecc62 Fix punctuation in rustdoc book 2020-03-14 23:40:29 +01:00
Timothée Gerber 131433a2c0 Change fenced code block type in rustdoc book 2020-03-14 23:31:34 +01:00
Timothée Gerber 68dc24fcbe Clean up path separator in rustdoc book 2020-03-14 23:04:33 +01:00
Kornel a5a786d00c Block version-specific docs from search engines
Stable, beta and nightly URLs remain
2020-03-14 02:29:35 +00:00
bors be055d96c4 Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrum
Optimize catch_unwind to match C++ try/catch

This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown.

https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great.

This PR, on the other hand, generates the following assembly:

```asm
# -Cpanic=unwind:
	push   rbx
	mov    ebx,0x2a
	call   QWORD PTR [rip+0x1c53c]        # <happy>
	mov    eax,ebx
	pop    rbx
	ret
	mov    rdi,rax
	call   QWORD PTR [rip+0x1c537]        # cleanup function call
	call   QWORD PTR [rip+0x1c539]        # <unfortunate>
	mov    ebx,0xd
	mov    eax,ebx
	pop    rbx
	ret

# -Cpanic=abort:
	push   rax
	call   QWORD PTR [rip+0x20a1]        # <happy>
	mov    eax,0x2a
	pop    rcx
	ret
```

Fixes #64224, and resolves #64222.
2020-03-13 22:43:06 +00:00
Mazdak Farrokhzad 39c6405097
Rollup merge of #69747 - spastorino:rename-rustc-guide, r=pietroalbini
Rename rustc guide

This is in preparation for https://github.com/rust-lang/rustc-guide/issues/470
Needs to be merged after we actually rename the guide.

Have used this to rename:

`git grep -l 'rustc_guide' | xargs sed -i 's/rustc_guide/rustc_dev_guide/g'`
`git grep -l 'rustc-guide' | xargs sed -i 's/rustc-guide/rustc-dev-guide/g'`
`git grep -l 'rustc guide' | xargs sed -i 's/rustc guide/rustc dev guide/g'`
2020-03-12 16:32:19 +01:00
Santiago Pastorino b3b32b74bc
rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
Santiago Pastorino 1ddcea3422
Rename rustc_guide to rustc_dev_guide 2020-03-10 17:08:17 -03:00
Santiago Pastorino 0037f4e37c
Rename rustc-guide to rustc-dev-guide 2020-03-10 17:08:10 -03:00
Mazdak Farrokhzad 61150353bf
Rollup merge of #69514 - GuillaumeGomez:remove-spotlight, r=kinnison
Remove spotlight

I had a few comments saying that this feature was at best misunderstood or not even used so I decided to organize a poll about on [twitter](https://twitter.com/imperioworld_/status/1232769353503956994). After 87 votes, the result is very clear: it's not useful. Considering the amount of code we have just to run it, I think it's definitely worth it to remove it.

r? @kinnison

cc @ollie27
2020-03-10 06:47:47 +01:00
Mazdak Farrokhzad 5e9888eec5
Rollup merge of #69608 - o01eg:expose-target-libdir-print, r=ehuss
Expose target libdir information via print command

With custom libdir it is required to have an access to library placement.

See https://github.com/RazrFalcon/cargo-bloat/issues/51
2020-03-08 20:54:30 +01:00
Mazdak Farrokhzad 5adfa4bd48
Rollup merge of #69641 - ehuss:update-books, r=ehuss
Update books

## nomicon

8 commits in 3e6e1001dc6e095dbd5c88005e80969f60e384e1..9f797e65e6bcc79419975b17aff8e21c9adc039f
2019-12-14 22:08:52 +0000 to 2020-03-04 03:45:13 +0100
- Rustup to latest rustc (rust-lang-nursery/nomicon#203)
- (minor) Add backticks around type names (rust-lang-nursery/nomicon#197)
- Add book.toml (rust-lang-nursery/nomicon#185)
- Rename `Alloc` to `AllocRef` (rust-lang-nursery/nomicon#188)
- Lifetimes: explain how to fix destructor example (rust-lang-nursery/nomicon#195)
- mention soundness (rust-lang-nursery/nomicon#194)
- Fix example in FFI section Calling Rust from C (rust-lang-nursery/nomicon#193)
- Removed repeated word (rust-lang-nursery/nomicon#191)

## reference

8 commits in 64239df6d173562b9deb4f012e4c3e6e960c4754..559e09caa9661043744cf7af7bd88432d966f743
2020-02-10 19:05:13 +0100 to 2020-03-02 01:17:14 +0100
- Syntax error fix (rust-lang-nursery/reference#769)
- Fix incorrect pseudocode for #[repr(C)] struct alignment (rust-lang-nursery/reference#766)
- Replace "Field-Less" with "Fieldless" (rust-lang-nursery/reference#768)
- Removed repeated word (rust-lang-nursery/reference#767)
- Update for change in const lint name. (rust-lang-nursery/reference#764)
- semantic type -&gt; resolved type (rust-lang-nursery/reference#761)
- add behavior change of relative paths without `self` in 2018 edition (rust-lang-nursery/reference#757)
- assignment operator expressions -&gt; compound assignment expressions (rust-lang-nursery/reference#759)

## rust-by-example

3 commits in 32facd5522ddbbf37baf01e4e4b6562bc55c071a..db57f899ea2a56a544c8d280cbf033438666273d
2020-02-11 09:25:06 -0300 to 2020-02-18 17:46:46 -0300
- Minor typo fix in src/mod/visibility (rust-lang/rust-by-example#1309)
- Don't suggest Into implements a reverse conversion (rust-lang/rust-by-example#1307)
- Improve grammar in example of 'in let' section (rust-lang/rust-by-example#1308)

## embedded-book

2 commits in b2e1092bf67bd4d7686c4553f186edbb7f5f92db..b81ffb7a6f4c5aaed92786e770e99db116aa4ebd
2020-01-30 08:45:46 +0000 to 2020-02-27 08:06:04 +0000
- Setting output to `high` needs a `true` argument  (rust-embedded/book#227)
- Add licence notes to index.md  (rust-embedded/book#226)
2020-03-08 11:51:15 +01:00
Mazdak Farrokhzad d4860fcff3
Rollup merge of #69561 - JohnTitor:clean-up-unstable-book, r=Mark-Simulacrum
Clean up unstable book

- #58402's feature was renamed to `tidy_test_never_used_anywhere_else` and it is now used for tidy only
- `read_initializer` link is wrong and the doc should be auto-generated so removed
- Add dummy doc for `link_cfg`
- Stop generating `compiler_builtins_lib` doc in favor of b8ccc0f8a6
- Make `rustc_attrs` tracking issue "None"
2020-03-08 11:51:12 +01:00
O01eg dbd1514353
Add new option to the documentation. 2020-03-07 07:29:23 +03:00
Arkadiusz Piekarz b90edfcc9e Fix sequence of Type and Trait in optin-builtin-traits in Unstable Book 2020-03-06 22:22:18 +01:00
Matthias Krüger 136ad015b6 fix various typos 2020-03-06 15:19:31 +01:00
Amanieu d'Antras f4f91f0b2f Remove eh_unwind_resume lang item 2020-03-05 17:36:50 +00:00
Christoph Schmidler c94c74e2d9 Opt out of CTFE if the 'const_eval_limit' is set to 0 2020-03-05 08:09:52 +01:00
Christoph Schmidler 288e142737 Add a new test to reach const_limit setting, although with wrong WARNINGs yet
rename feature to const_eval_limit
2020-03-05 08:09:52 +01:00
Christoph Schmidler 337af5ef7a Prepare const_limit feature gate and attribute 2020-03-05 08:09:52 +01:00
Eric Huss 8ea676ecca Update books 2020-03-04 08:12:24 -08:00
Amanieu d'Antras 61b67d0c19 Fix cross-DLL panics under MSVC 2020-03-02 11:43:07 +00:00
Vadim Petrochenkov e08c279eac Rename `syntax` to `rustc_ast` in source code 2020-02-29 21:59:09 +03:00
Vadim Petrochenkov 6054a30370 Make it build again 2020-02-29 20:47:10 +03:00
Yuki Okushi f9db3c243b Clean up unstable book 2020-02-29 23:30:08 +09:00
Guillaume Gomez 1244ced958 Remove "important traits" feature 2020-02-27 14:51:22 +01:00
Guillaume Gomez c57de34e8f Stabilize --crate-version option in rustdoc 2020-02-26 22:08:59 +01:00
Wesley Wiser 5b7e6c0f3c Add documentation for the `-Zself-profile-events` flag 2020-02-20 21:32:15 -05:00
Wesley Wiser 535fc0f43a Add documentation for the `-Zself-profile` flag 2020-02-17 06:41:18 -05:00
bors 5e7af4669f Auto merge of #67885 - tobithiel:fix_group_lint_allow_override, r=Mark-Simulacrum
rustc_session: allow overriding lint level of individual lints from a group

Fixes #58211 and fixes rust-lang/rust-clippy#4778 and fixes rust-lang/rust-clippy#4091

Instead of hard-coding the lint level preferences (from lowest to highest precedence: `lint::Allow -> lint::Warn -> lint::Deny -> lint::Forbid`), the position of the argument in the command line gets taken into account.

Examples:
1. Passing `-D unused -A unused-variables` denies everything in the lint group `unused` **except** `unused-variables` which is explicitly allowed.
1. Passing `-A unused-variables -D unused` denies everything in the lint group `unused` **including** `unused-variables` since the allow is specified before the deny (and therefore overridden by the deny).

This matches the behavior that is already being used when specifying `allow`/`deny` in the source code.
2020-02-16 15:28:41 +00:00
Eric Huss 1e1b6ad108 Update books. 2020-02-13 08:11:09 -08:00
Dylan DPC c8c2b2bc54
Rollup merge of #68824 - ajpaverd:cfguard-rustbuild, r=Mark-Simulacrum
Enable Control Flow Guard in rustbuild

Now that Rust supports Control Flow Guard (#68180), add a config.toml option to build the standard library with CFG enabled.

r? @nagisa
2020-02-11 16:36:57 +01:00
Andrew Paverd 87df124ba7 Enable Control Flow Guard in rustbuild 2020-02-10 19:26:25 +00:00
Dylan DPC 2f1eaeea77
Rollup merge of #68164 - tmiasko:no-sanitize, r=nikomatsakis
Selectively disable sanitizer instrumentation

Add `no_sanitize` attribute that allows to opt out from sanitizer
instrumentation in an annotated function.
2020-02-07 17:00:16 +01:00
Dylan DPC 4ce157d008
Rollup merge of #68791 - mark-i-m:proper-linkcheck, r=ehuss,JohnTitor
implement proper linkchecker hardening

r? @JohnTitor

This implements proper linkcheck filtering... we might need to fiddle with a bit to adjust what is or isn't filtered, but this seems to work reasonable locally.
2020-02-06 22:38:34 +01:00
Dylan DPC 2d8f6389d0
Rollup merge of #68524 - jonas-schievink:generator-resume-arguments, r=Zoxc
Generator Resume Arguments

cc https://github.com/rust-lang/rust/issues/43122 and https://github.com/rust-lang/rust/issues/56974

Blockers:
* [x] Fix miscompilation when resume argument is live across a yield point (https://github.com/rust-lang/rust/pull/68524#issuecomment-578459069)
* [x] Fix 10% compile time regression in `await-call-tree` benchmarks (https://github.com/rust-lang/rust/pull/68524#issuecomment-578487162)
  * [x] Fix remaining 1-3% regression (https://github.com/rust-lang/rust/pull/68524#issuecomment-579566255) - resolved (https://github.com/rust-lang/rust/pull/68524#issuecomment-581144901)
* [x] Make dropck rules account for resume arguments (https://github.com/rust-lang/rust/pull/68524#issuecomment-578541137)

Follow-up work:
* Change async/await desugaring to make use of this feature
* Rewrite [`box_region.rs`](3d8778d767/src/librustc_data_structures/box_region.rs) to use resume arguments (this shows up in profiles too)
2020-02-06 22:38:33 +01:00
Tomasz Miąsko b846b42c8d Selectively disable sanitizer instrumentation
Add `no_sanitize` attribute that allows to opt out from sanitizer
instrumentation in an annotated function.
2020-02-05 23:30:38 +01:00
Dylan DPC c0fbac58db
Rollup merge of #68846 - king6cong:doc-fix, r=GuillaumeGomez
doc fix on doc attribute

None
2020-02-05 13:14:33 +01:00
king6cong 9713b5696b doc fix on doc attribute 2020-02-05 12:56:24 +08:00
Dylan DPC 1921fc0994
Rollup merge of #68282 - tmiasko:sanitizer-example, r=steveklabnik
Instrument C / C++ in MemorySanitizer example

Modify the example to instrument C / C++ in addition to Rust, since it
will be generally required (e.g., when using libbacktrace for symbolication).
2020-02-04 21:51:48 +01:00
Mark Mansi adc8cd9680 update rustc-guide 2020-02-03 12:57:39 -06:00
Jonas Schievink 044fe0f558 Add a resume type parameter to `Generator` 2020-02-02 13:20:57 +01:00
Mark Rousskov 39e502744c Install robots.txt into rust-docs tarballs 2020-01-31 08:56:01 -05:00
bors edb3684915 Auto merge of #68572 - tmiasko:sanitizer-use-after-scope, r=nikic
Detect use-after-scope bugs with AddressSanitizer

Enable use-after-scope checks by default when using AddressSanitizer.
They allow to detect incorrect use of stack objects after their scope
have already ended. The detection is based on LLVM lifetime intrinsics.

To facilitate the use of this functionality, the lifetime intrinsics are
now emitted regardless of optimization level if enabled sanitizer makes
use of them.
2020-01-29 07:44:36 +00:00
bors b181835a6b Auto merge of #68529 - TimDiekmann:rename-alloc, r=Amanieu
Rename `Alloc` to `AllocRef`

The allocator-wg has decided to merge this change upstream in https://github.com/rust-lang/wg-allocators/issues/8#issuecomment-577122958.

This renames `Alloc` to `AllocRef` because types that implement `Alloc` are a reference, smart pointer, or ZSTs. It is not possible to have an allocator like `MyAlloc([u8; N])`, that owns the memory and also implements `Alloc`, since that would mean, that moving a `Vec<T, MyAlloc>` would need to correct the internal pointer, which is not possible as we don't have move constructors.

For further explanation please see https://github.com/rust-lang/wg-allocators/issues/8#issuecomment-489464843 and the comments after that one.

Additionally it clarifies the semantics of `Clone` on an allocator. In the case of `AllocRef`, it is clear that the cloned handle still points to the same allocator instance, and that you can free data allocated from one handle with another handle.

The initial proposal was to rename `Alloc` to `AllocHandle`, but `Ref` expresses the semantics better than `Handle`. Also, the only appearance of `Handle` in `std` are for windows specific resources, which might be confusing.

Blocked on https://github.com/rust-lang/miri/pull/1160
2020-01-28 08:44:20 +00:00