Commit graph

125381 commits

Author SHA1 Message Date
bors
9b88e0a866 Auto merge of #75514 - gdhuper:gdhuper/replace_log_with_tracing, r=davidtwco
Replaced `log` with `tracing`

## Description

Replaced `log` with `tracing` in the following crates:
- [x] librustc_ast
- [x] librustc_driver
- [x]  librustc_errors
- [x] librustc_expand
- [x]  librustc_hir
- [x]  librustc_incremental
- [x]  librustc_infer
- [x]  librustc_interface
- [x]  librustc_lint
- [x]  librustc_metadata
- [x]  librustc_middle
- [x]  librustc_mir
- [x]  librustc_mir_build
- [x]  librustc_parse
- [x]  librustc_passes
- [x]  librustc_privacy
- [x]  librustc_query_system
- [x]  librustc_resolve
- [x]  librustc_save_analysis
- [x] librustc_session
- [x] librustc_span
- [x] librustc_symbol_mangling
- [x] librustc_target
- [x] librustc_trait_selection
- [x] librustc_traits
- [x] librustc_ty
- [x] librustc_typeck
- [x] compiletest

Fixes: #74747

## Checklist:
- [x] Code compiles / builds
- [x] run tidy
- [x] Cleanup any clippy warnings
- [x] Update/add docs
2020-08-15 22:00:06 +00:00
Gurpreet Singh
d2753f91b5 replaced log with tracing 2020-08-15 13:03:11 -07:00
bors
3f3250500f Auto merge of #75246 - pickfire:patch-5, r=Amanieu
Add more examples to Path ends_with

We faced a footgun when using ends_with to check extension,
showing an example could prevent that.

2c155e50b2
2020-08-15 19:51:44 +00:00
bors
f9d17312c9 Auto merge of #75560 - Mark-Simulacrum:rustc-docs, r=matthiaskrgr
Add rustc-docs as a component

Previously it was listed as a package but wasn't available in the component
lists in rustup, so wasn't actually installable.

rustc-docs is also only present for x86_64-unknown-linux-gnu. Eventually it'll
also be shipped for aarch64-gnu with current CI configuration, but that builder
isn't quite up and running yet.

We probably want to ship compiler docs for other platforms as well, though, but
this commit doesn't enable that quite yet. A future PR may do so by adding
--enable-compiler-docs to the relevant builders (but it would also need to
decide the set of builders which we'd ship on).

r? @matthiaskrgr
2020-08-15 18:01:06 +00:00
bors
5addb135ed Auto merge of #75483 - mati865:mingw-lld-flags, r=petrochenkov
Add LLD flags for MinGW

Tested locally and this now works:
- `RUSTFLAGS="-Zlink-self-contained=yes -Clinker=rust-lld" cargo b`
- `RUSTFLAGS="-Zlink-self-contained=no -Clinker=rust-lld -Zpre-link-arg=-Ld:/msys64/mingw64/x86_64-w64-mingw32/lib -Zpre-link-arg=-Ld:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0 -Zpre-link-arg=crt2.o" cargo b`

This is "harmless" part of the changes to make possible linking with bare LLD with windows-gnu target. More debatable changes should follow in next PRs soon.
2020-08-15 15:51:55 +00:00
bors
b9db927b68 Auto merge of #75537 - tmiasko:match-branch-simplify, r=oli-obk
MatchBranchSimplification: fix equal const bool assignments

The match branch simplification is applied when target blocks contain
statements that are either equal or perform a const bool assignment with
different values to the same place.

Previously, when constructing new statements, only statements from a
single block had been examined. This lead to a misoptimization when
statements are equal because the assign the *same* const bool value to
the same place.

Fix the issue by examining statements from both blocks when deciding on
replacement.

Additionally:

* Copy discriminant instead of moving it since it might be necessary to use its
  value more than once.
* Optimize when switching on copy operand

Based on #75508.

r? @oli-obk  / @JulianKnodt
2020-08-15 13:41:05 +00:00
bors
80fb3f3139 Auto merge of #74576 - myfreeweb:freebsd-sanitizers, r=oli-obk
Add sanitizer support on FreeBSD

Restarting #47337. Everything is better now, no more weird llvm problems, well not everything:

Unfortunately, the sanitizers don't have proper support for versioned symbols (https://github.com/google/sanitizers/issues/628), so `libc`'s usage of `stat@FBSD_1.0` and so on explodes, e.g. in calling `std::fs::metadata`.

Building std (now easy thanks to cargo `-Zbuild-std`) and libc with `freebsd12/13` config via the `LIBC_CI=1` env variable is a good workaround…

```
LIBC_CI=1 RUSTFLAGS="-Z sanitizer=address" cargo +san-test -Zbuild-std run --target x86_64-unknown-freebsd --verbose
```

…*except* std won't build because there's no `st_lspare` in the ino64 version of the struct, so an std patch is required:

```diff
--- i/src/libstd/os/freebsd/fs.rs
+++ w/src/libstd/os/freebsd/fs.rs
@@ -66,8 +66,6 @@ pub trait MetadataExt {
     fn st_flags(&self) -> u32;
     #[stable(feature = "metadata_ext2", since = "1.8.0")]
     fn st_gen(&self) -> u32;
-    #[stable(feature = "metadata_ext2", since = "1.8.0")]
-    fn st_lspare(&self) -> u32;
 }

 #[stable(feature = "metadata_ext", since = "1.1.0")]
@@ -136,7 +134,4 @@ impl MetadataExt for Metadata {
     fn st_flags(&self) -> u32 {
         self.as_inner().as_inner().st_flags as u32
     }
-    fn st_lspare(&self) -> u32 {
-        self.as_inner().as_inner().st_lspare as u32
-    }
 }
```

I guess std could like.. detect that `libc` isn't built for the old ABI, and replace the implementation of `st_lspare` with a panic?
2020-08-15 11:38:24 +00:00
Mark Rousskov
35f89879fb Add rustc-docs as a component
Previously it was listed as a package but wasn't available in the component
lists in rustup, so wasn't actually installable.

rustc-docs is also only present for x86_64-unknown-linux-gnu. Eventually it'll
also be shipped for aarch64-gnu with current CI configuration, but that builder
isn't quite up and running yet.

We probably want to ship compiler docs for other platforms as well, though, but
this commit doesn't enable that quite yet. A future PR may do so by adding
--enable-compiler-docs to the relevant builders (but it would also need to
decide the set of builders which we'd ship on).
2020-08-15 07:11:29 -04:00
bors
1e58871d25 Auto merge of #75518 - davidtwco:issue-75326-polymorphization-symbol-mangling-v0-predicates, r=lcnr
polymorphize: `I` used if `T` used in `I: Foo<T>`

Fixes #75326.

This PR adjusts polymorphization's handling of predicates so that after ensuring that `T` is used in `I: Foo<T>` if `I` is used, it now ensures that `I` is used if `T` is used in `I: Foo<T>`. This is necessary to mark generic parameters that only exist in impl parameters as used - thereby avoiding symbol clashes when using the new mangling scheme.

With this PR, rustc will now fully bootstrap with polymorphization and the new symbol mangling scheme enabled - not all tests pass, but I'm not sure how much of that is the interaction of the two features, I'll be looking into that soon. All tests pass with only polymorphization enabled.

r? @lcnr (this isn't sufficiently complex that I need to add to eddy's review queue)
cc @eddyb
2020-08-15 09:46:22 +00:00
Ivan Tham
446fccf1b8
Use resolve.conf as example for Path ends_with 2020-08-15 17:25:07 +08:00
bors
5205b974d5 Auto merge of #75539 - ehuss:fix-crate-version-rustdoc-bootstrap, r=Mark-Simulacrum
Fix crate-version with rustdoc in bootstrap.

Cargo will now automatically use the `--crate-version` flag (see https://github.com/rust-lang/cargo/pull/8509). Cargo has special handling to avoid passing the flag if it is passed in via RUSTDOCFLAGS, but the `rustdoc` wrapper circumvents that check. This causes a problem because rustdoc will fail if the flag is passed in twice. Fix this by using RUSTDOCFLAGS.

This will be necessary when 1.47 is promoted to beta, but should be safe to do now.
2020-08-15 07:55:58 +00:00
bors
f7aac25850 Auto merge of #75488 - ssomers:btree_revert_75257, r=Mark-Simulacrum
Revert the fundamental changes in #74762 and #75257

Before possibly going over to #75487. Also contains some added and fixed comments.

r? @Mark-Simulacrum
2020-08-15 05:43:00 +00:00
Eric Huss
85a9cfaa31 Deal with spaces in the rust version. 2020-08-14 20:15:58 -07:00
bors
45060c2a66 Auto merge of #75549 - tmandry:rollup-sxjwa0w, r=tmandry
Rollup of 4 pull requests

Successful merges:

 - #75376 (Set CMAKE_SYSTEM_NAME when cross-compiling)
 - #75448 (merge `as_local_hir_id` with `local_def_id_to_hir_id`)
 - #75513 (Recover gracefully from `struct` parse errors)
 - #75545 (std/sys/unix/time: make it easier for LLVM to optimize `Instant` subtraction.)

Failed merges:

 - #75514 (Replaced `log` with `tracing`)

r? @ghost
2020-08-15 03:08:03 +00:00
Tyler Mandry
29a946203a
Rollup merge of #75545 - eddyb:instant-sub-branchless, r=sfackler
std/sys/unix/time: make it easier for LLVM to optimize `Instant` subtraction.

This PR is the minimal change necessary to get LLVM to optimize `if self.t.tv_nsec >= other.t.tv_nsec` to branchless instructions (at least on x86_64), inspired by @m-ou-se's own attempts at optimizing `Instant` subtraction.

I stumbled over this by looking at the total number of instructions executed by `rustc -Z self-profile`, and found that after disabling ASLR, the largest source of non-determinism remaining was from this `if` taking one branch or the other, depending on the values involved.

The reason this code is even called so many times to make a difference, is that `measureme` (the `-Z self-profile` implementation) currently uses `Instant::elapsed` for its event timestamps (of which there can be millions).

I doubt it's critical to land this, although perhaps it could slightly improve some forms of benchmarking.
2020-08-14 20:07:16 -07:00
Tyler Mandry
e38eaf22d2
Rollup merge of #75513 - estebank:confused-parser, r=davidtwco
Recover gracefully from `struct` parse errors

Currently the parser tries to recover from finding a keyword where a field name was expected, but this causes extra knock down parse errors that are completely irrelevant. Instead, bail out early in the parsing of the field and consume the remaining tokens in the block. This can reduce output significantly.

_Improvements based on the narrative in https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust_
2020-08-14 20:07:13 -07:00
Tyler Mandry
28b11abc2f
Rollup merge of #75448 - lcnr:rn-as_local_hir_id, r=davidtwco
merge `as_local_hir_id` with `local_def_id_to_hir_id`

`as_local_hir_id` was defined as just calling `local_def_id_to_hir_id` and I think that having two different ways to call the same method is somewhat confusing.

Don't really care about which of these 2 methods we want to keep.

Does this require an MCP, considering that these methods are fairly frequently used?
2020-08-14 20:07:11 -07:00
Tyler Mandry
29b6b5feaa
Rollup merge of #75376 - tmiasko:cmake-system-name, r=Mark-Simulacrum
Set CMAKE_SYSTEM_NAME when cross-compiling

Configure CMAKE_SYSTEM_NAME when cross-compiling in `configure_cmake`,
to tell CMake about target system. Previously this was done only for
LLVM step and now applies more generally to steps using cmake.

Helps with #74576.
2020-08-14 20:07:10 -07:00
Eduard-Mihai Burtescu
a7ad899f9d std/sys/unix/time: make it easier for LLVM to optimize Instant subtraction. 2020-08-15 04:13:25 +03:00
bors
668a34e0f4 Auto merge of #73851 - matthewjasper:serialize-not-special, r=oli-obk
Remove most specialization use in serialization

Switching from specialization to min_specialization in the compiler made the unsoundness of how we used these traits pretty clear. This changes how the `Encodable` and `Decodable` traits work to be more friendly for types need a `TyCtxt` to deserialize.

The alternative design of having both `Encodable` and `TyEncodable` traits was considered, but doesn't really work because the following impls would conflict:

```
impl<E: Ecodable> TyEncodable for Encodable
impl<E: TyEcodable> TyEncodable for [E]
```

## How-to guide

- `Rustc(De|En)codable` is now spelled `Ty(De|En)coable` in `rustc_middle`, `Metadata(En|De)codable` in `rustc_metadata` where needed, and `(De|En)codable` everywhere else.
- Manual implementations of `(De|En)codable` shouldn't be much different.
- If you're adding a new interned type that needs to be en/decodable then the simplest thing way to handle this is:
    - Have the type be a wrapper around a reference to the interned data (i.e. do what `ty::Predicate` does, and not what all of the other interned types do)
    - Derive `Ty(En|De)codable` on the inner type
    - Implement `Encodable<impl TyEncoder>` by forwarding to the inner type.
    - Implement `Decodable<impl TyDecoder>` by decoding the inner type and then creating the wrapper around that (using the `tcx` from the decoder as needed).

cc @rust-lang/compiler for opinions on this change
r? @oli-obk
2020-08-15 00:45:13 +00:00
Tomasz Miąsko
af9b9e4ec8 MatchBranchSimplification: avoid intermediate vec allocation 2020-08-15 01:24:18 +02:00
Tomasz Miąsko
1fe2e2941d MatchBranchSimplification: fix equal const bool assignments
The match branch simplification is applied when target blocks contain
statements that are either equal or perform a const bool assignment with
different values to the same place.

Previously, when constructing new statements, only statements from a
single block had been examined. This lead to a misoptimization when
statements are equal because the assign the *same* const bool value to
the same place.

Fix the issue by examining statements from both blocks when deciding on
replacement.
2020-08-15 00:00:00 +00:00
bors
95879ad961 Auto merge of #75538 - tmandry:rollup-i8miv8q, r=tmandry
Rollup of 17 pull requests

Successful merges:

 - #73943 (Document the unsafe keyword)
 - #74062 (deny(unsafe_op_in_unsafe_fn) in libstd/ffi/c_str.rs)
 - #74185 (Remove liballoc unneeded explicit link)
 - #74192 (Improve documentation on process::Child.std* fields)
 - #74409 (Change Debug impl of SocketAddr and IpAddr to match their Display output)
 - #75195 (BTreeMap: purge innocent use of into_kv_mut)
 - #75214 (Use intra-doc links in `mem::manually_drop` & `mem::maybe_uninit`)
 - #75432 (Switch to intra-doc links in `std::process`)
 - #75482 (Clean up E0752 explanation)
 - #75501 (Move to intra doc links in std::ffi)
 - #75509 (Tweak suggestion for `this` -> `self`)
 - #75511 (Do not emit E0228 when it is implied by E0106)
 - #75515 (Bump std's libc version to 0.2.74)
 - #75517 (Promotion and const interning comments)
 - #75519 (BTreeMap: refactor splitpoint and move testing over to unit test)
 - #75530 (Switch to intra-doc links in os/raw/*.md)
 - #75531 (Migrate unit tests of btree collections to their native breeding ground)

Failed merges:

r? @ghost
2020-08-14 22:52:57 +00:00
David Wood
bf3ef26713
polymorphize: I used if T used in I: Foo<T>
This commit adjusts polymorphization's handling of predicates so that
after ensuring that `T` is used in `I: Foo<T>` if `I` is used, it now
ensures that `I` is used if `T` is used in `I: Foo<T>`. This is
necessary to mark generic parameters that only exist in impl parameters
as used - thereby avoiding symbol clashes when using the new mangling
scheme.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-14 23:01:14 +01:00
Eric Huss
73b7a04032 Fix crate-version with rustdoc in bootstrap. 2020-08-14 14:50:18 -07:00
Tyler Mandry
939befd65e
Rollup merge of #75531 - ssomers:btree_tests_migration, r=Mark-Simulacrum
Migrate unit tests of btree collections to their native breeding ground

There's one BTreeSet test case that I couldn't easily convince to come along, maybe because it truly is an integration test. But leaving it in place would mean git wouldn't see the move so I also moved it to a new file.

r? @Mark-Simulacrum
2020-08-14 14:47:04 -07:00
Tyler Mandry
6d09e29f5e
Rollup merge of #75530 - nixphix:docs/os-raw, r=jyn514
Switch to intra-doc links in os/raw/*.md

Partial fix for #75080

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

r? @jyn514
2020-08-14 14:47:03 -07:00
Tyler Mandry
2564135115
Rollup merge of #75519 - ssomers:btree_splitpoint_cleanup, r=Mark-Simulacrum
BTreeMap: refactor splitpoint and move testing over to unit test

r? @Mark-Simulacrum
2020-08-14 14:47:01 -07:00
Tyler Mandry
00e2dcbcda
Rollup merge of #75517 - RalfJung:promo-intern-comments, r=oli-obk
Promotion and const interning comments

I understood some things today which I felt should be put into comments.

Cc @rust-lang/wg-const-eval
2020-08-14 14:46:59 -07:00
Tyler Mandry
83c04392c8
Rollup merge of #75515 - workingjubilee:patch-4, r=Mark-Simulacrum
Bump std's libc version to 0.2.74

It's been a while and this should really be using a recent version, that's all. 💖
2020-08-14 14:46:57 -07:00
Tyler Mandry
0c8c3b9079
Rollup merge of #75511 - estebank:elide-trait-object-lt-error, r=lcnr
Do not emit E0228 when it is implied by E0106

Emit E0288 (lifetime bound for trait object cannot be deduced) only on bare trait objects. When the trait object is in the form of `&dyn Trait`, E0106 (missing lifetime specifier) will have been emitted, making the former redundant.
2020-08-14 14:46:56 -07:00
Tyler Mandry
2fb2af4f1d
Rollup merge of #75509 - estebank:coming-merrily-from-java-land, r=lcnr
Tweak suggestion for `this` -> `self`

* When referring to `this` in associated `fn`s always suggest `self`.
* Point at ident for `fn` lacking `self`
* Suggest adding `self` to assoc `fn`s when appropriate

_Improvements based on the narrative in https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust_
2020-08-14 14:46:54 -07:00
Tyler Mandry
ad1bfd2f3e
Rollup merge of #75501 - poliorcetics:intra-links-std-ffi, r=jyn514
Move to intra doc links in std::ffi

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-14 14:46:52 -07:00
Tyler Mandry
1cf79eca79
Rollup merge of #75482 - GuillaumeGomez:cleanup-e0752, r=pickfire
Clean up E0752 explanation

r? @Dylan-DPC

cc @pickfire
2020-08-14 14:46:51 -07:00
Tyler Mandry
b0261814f1
Rollup merge of #75432 - camelid:intra-doc-links-for-std-process, r=jyn514
Switch to intra-doc links in `std::process`

Part of #75080.
2020-08-14 14:46:49 -07:00
Tyler Mandry
ad8c5e1480
Rollup merge of #75214 - chansuke:fix-intra-doc-links, r=jyn514
Use intra-doc links in `mem::manually_drop` & `mem::maybe_uninit`

This is partial fixes for https://github.com/rust-lang/rust/issues/75080.
2020-08-14 14:46:47 -07:00
Tyler Mandry
83e75acdec
Rollup merge of #75195 - ssomers:btree_split_up_into_kv_mut, r=Mark-Simulacrum
BTreeMap: purge innocent use of into_kv_mut

Replace the use of `into_kv_mut` into more precise calls. This makes more sense if you know that the single remaining use of `into_kv_mut` is in fact evil and can be trialled in court (#75200) and sent to a correction facility (#73971).

No real performance difference reported (but functions that might benefit a tiny constant bit like `BTreeMap::get_mut` aren't benchmarked):
```
benchcmp old new --threshold 5
 name                       old ns/iter  new ns/iter  diff ns/iter  diff %  speedup
 btree::map::clone_fat_100  63,073       59,256             -3,817  -6.05%   x 1.06
 btree::map::iter_100       3,514        3,235                -279  -7.94%   x 1.09
```
2020-08-14 14:46:45 -07:00
Tyler Mandry
5b61230303
Rollup merge of #74409 - LukasKalbertodt:improve-debug-impl-of-socketaddr-ipaddr, r=Amanieu
Change Debug impl of SocketAddr and IpAddr to match their Display output

This has already been done for `SocketAddrV4`, `SocketAddrV6`, `IpAddrV4` and `IpAddrV6`. I don't see a point to keep the rather bad to read derived impl, especially so when pretty printing:

    V4(
        127.0.0.1
    )

From the `Display`, one can easily and unambiguously see if it's V4 or V6. Two examples:

```
127.0.0.1:443
[2001:db8:85a3::8a2e:370:7334]:443
```

Luckily the docs explicitly state that `Debug` output is not stable and that it may be changed at any time.

Using `Display` as `Debug` is very convenient for configuration structs (e.g. for webservers) that often just have a `derive(Debug)` and are printed that way to the one starting the server.
2020-08-14 14:46:44 -07:00
Tyler Mandry
dae020d491
Rollup merge of #74192 - xkr47:patch-1, r=Mark-Simulacrum
Improve documentation on process::Child.std* fields

As a relative beginner, it took a while for me to figure out I could just steal the references to avoid partially moving the child and thus retain ability to call functions on it (and store it in structs etc).
2020-08-14 14:46:41 -07:00
Tyler Mandry
3111a8c1e2
Rollup merge of #74185 - pickfire:liballoc-iter-doc, r=jyn514
Remove liballoc unneeded explicit link
2020-08-14 14:46:40 -07:00
Tyler Mandry
fba3989052
Rollup merge of #74062 - poliorcetics:unsafe-in-unsafe-c_str, r=Mark-Simulacrum
deny(unsafe_op_in_unsafe_fn) in libstd/ffi/c_str.rs

Partial fix of #73904.

This encloses `unsafe` operations in `unsafe fn` in `libstd/ffi/c_str.rs`.
2020-08-14 14:46:33 -07:00
Tyler Mandry
f163ec5b18
Rollup merge of #73943 - poliorcetics:unsafe-keyword, r=steveklabnik
Document the unsafe keyword

Partial fix of #34601 (just one more and it will be done 😄).

I tried to be concise and redirect as much as possible on other, longer resources, exposing only the strict necessary.

I also used `SAFETY:` comments to promote good documentation.

I would like a thorough review to ensure I did not introduce mistakes that would confuse people or worse, lead them to write unsound code.

@rustbot modify labels: T-doc,C-enhancement

Edit: this is now the last PR for the original issue: fixes #34601.
2020-08-14 14:46:31 -07:00
Alexis Bourget
0e610bb31e Document the unsafe keyword 2020-08-14 22:52:23 +02:00
Tomasz Miąsko
4fae04968e MatchBranchSimplification: copy discriminant instead of moving it
It might be necessary to use its value more than once.
2020-08-14 22:21:56 +02:00
Tomasz Miąsko
60d7d28948 MatchBranchSimplification: optimize when switching on copy operand 2020-08-14 21:58:10 +02:00
chansuke
61866bc60c Use intra-doc links in mem::manually_drop & mem::maybe_uninit 2020-08-15 02:33:39 +09:00
Alexis Bourget
e97fa1e3da libstd/ffi/c_str.rs: #![deny(unsafe_op_in_unsafe_fn)], enclose unsafe operations in unsafe blocks 2020-08-14 19:33:04 +02:00
Esteban Küber
4ecdec1fb6 review comment: suggestion message wording 2020-08-14 10:16:34 -07:00
Poliorcetics
ee4f893e27
Apply suggestions from code review
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-14 19:08:09 +02:00
Matthew Jasper
c4f91bb281 Fix rustc_serialize unit tests 2020-08-14 17:34:32 +01:00