]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoAdd period to Pattern docs
Ivan Tham [Mon, 13 Apr 2020 14:24:58 +0000 (22:24 +0800)]
Add period to Pattern docs

4 years agoAuto merge of #70882 - tmiasko:llvm-version-suffix, r=Mark-Simulacrum
bors [Mon, 13 Apr 2020 07:34:11 +0000 (07:34 +0000)]
Auto merge of #70882 - tmiasko:llvm-version-suffix, r=Mark-Simulacrum

Make LLVM version suffix independent of rustc version on dev channel

Remove rustc version from LLVM version suffix on dev channel,
avoiding the need for full rebuilds when switching between
branches with different LLVM submodule & rustc version.

Note: To avoid full rebuild, on subsequent LLVM submodule update, copy the
current value of `LLVM_VERSION_SUFFIX` from `build/*/llvm/build/CMakeCache.txt`,
to `version-suffix` in `config.toml`.

4 years agoAuto merge of #71056 - matthiaskrgr:submodule_upd, r=Dylan-DPC
bors [Mon, 13 Apr 2020 04:16:08 +0000 (04:16 +0000)]
Auto merge of #71056 - matthiaskrgr:submodule_upd, r=Dylan-DPC

submodules: update clippy from d342cee7 to af5940b7

Changes:
````
Allow UUID style formatting for `inconsistent_digit_grouping` lint
rustup https://github.com/rust-lang/rust/pull/70986
rustup https://github.com/rust-lang/rust/pull/69745
Rustup to https://github.com/rust-lang/rust/pull/70913
compare with the second largest instead of the smallest variant
Revert "Downgrade new_ret_no_self to pedantic"
Check for clone-on-copy in argument positions
Check fn header along with decl when suggesting to implement trait
Downgrade implicit_hasher to pedantic
Move cognitive_complexity to nursery
Run fmt and update test
Use int assoc consts in MANUAL_SATURATING_ARITHMETIC
Use int assoc consts in checked_conversions lint
Use primitive type assoc consts in more tests
Use integer assoc consts in more lint example code
Don't import primitive type modules
Use assoc const NAN for zero_div_zero lint
Fix float cmp to use assoc fxx::EPSILON
Fix NAN comparison lint to use assoc NAN
Refine lint message.
Lint on opt.as_ref().map(|x| &**x).
Include OpAssign in suspicious_op_assign_impl
result_map_or_into_option: fix syntax error in example
result_map_or_into: fix dogfood_clippy error => {h,l}int
CONTRIBUTING.md: fix broken triage link
result_map_or_into_option: fix `cargo dev fmt --check` errors
result_map_or_into_option: move arg checks into tuple assignment
result_map_or_into_option: add `opt.map_or(None, |_| Some(y))` test
result_map_or_into_option: destructure lint tuple or return early
result_map_or_into_option: add good and bad examples
result_map_or_into_option: explicitly note absence of known problems
Downgrade new_ret_no_self to pedantic
Downgrade unreadable_literal to pedantic
Update CONTRIBUTING.md
Rename rustc -> rustc_middle in doc links
result_map_or_into_option: add lint to catch manually adpating Result -> Option
Move matches test in matches module
Run update_lints
Make lint modules private
Don't filter lints in code generation functions
Build lint lists once and the reuse them to update files
Get rid of Lint::is_internal method
Clean up update_lints
Downgrade inefficient_to_string to pedantic
Downgrade trivially_copy_pass_by_ref to pedantic
Downgrade let_unit_value to pedantic
````
Fixes #70993

r? @Dylan-DPC

4 years agoAuto merge of #71023 - mati865:mingw-unwind-linking-cleanup, r=Amanieu
bors [Mon, 13 Apr 2020 00:59:36 +0000 (00:59 +0000)]
Auto merge of #71023 - mati865:mingw-unwind-linking-cleanup, r=Amanieu

[windows] Add testscase for self-contained executables and fix pthread linking

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

4 years agoAuto merge of #71079 - Dylan-DPC:rollup-g7yh3sn, r=Dylan-DPC
bors [Sun, 12 Apr 2020 21:48:24 +0000 (21:48 +0000)]
Auto merge of #71079 - Dylan-DPC:rollup-g7yh3sn, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #67766 (Fix warning for unused variables in or pattern (issue #67691))
 - #71013 (Pass the `PlaceElem::Index` local to `visit_local`)
 - #71064 (fix issue 69130)
 - #71069 (Remove some usage of `DUMMY_HIR_ID`)

Failed merges:

r? @ghost

4 years agoRollup merge of #71069 - marmeladema:dummy-hir-id-obligation-clause, r=eddyb
Dylan DPC [Sun, 12 Apr 2020 21:47:41 +0000 (23:47 +0200)]
Rollup merge of #71069 - marmeladema:dummy-hir-id-obligation-clause, r=eddyb

Remove some usage of `DUMMY_HIR_ID`

Use `ObligationClause::dummy()` when appropriate or replace `hir::DUMMY_HIR_ID`by `hir::CRATE_HIR_ID`, as used in `ObligationClause::dummy()`.

4 years agoRollup merge of #71064 - dwrensha:issue-69130, r=eddyb
Dylan DPC [Sun, 12 Apr 2020 21:47:39 +0000 (23:47 +0200)]
Rollup merge of #71064 - dwrensha:issue-69130, r=eddyb

fix issue 69130

Closes #69130.

4 years agoRollup merge of #71013 - jonas-schievink:visit-projection, r=eddyb
Dylan DPC [Sun, 12 Apr 2020 21:47:38 +0000 (23:47 +0200)]
Rollup merge of #71013 - jonas-schievink:visit-projection, r=eddyb

Pass the `PlaceElem::Index` local to `visit_local`

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

cc @rust-lang/wg-mir-opt

r? @spastorino

4 years agoRollup merge of #67766 - sapir:fix-unused-in-or-pattern-warning, r=matthewjasper
Dylan DPC [Sun, 12 Apr 2020 21:47:36 +0000 (23:47 +0200)]
Rollup merge of #67766 - sapir:fix-unused-in-or-pattern-warning, r=matthewjasper

Fix warning for unused variables in or pattern (issue #67691)

Is this a good way to fix it?

Also, the tests fail, the "fixed" code output says `{ i, j }` instead of `{ i, j: _ }`, how can I fix that?

4 years agoRemove usage of `DUMMY_HIR_ID` in `Scope::hir_id`
marmeladema [Sun, 12 Apr 2020 19:59:13 +0000 (20:59 +0100)]
Remove usage of `DUMMY_HIR_ID` in `Scope::hir_id`

4 years agoRemove usage of `DUMMY_HIR_ID` in `CheckAttrVisitor::check_inline`
marmeladema [Sun, 12 Apr 2020 19:57:43 +0000 (20:57 +0100)]
Remove usage of `DUMMY_HIR_ID` in `CheckAttrVisitor::check_inline`

4 years agoRemove usage of `DUMMY_HIR_ID` in `CheckLoopVisitor`
marmeladema [Sun, 12 Apr 2020 18:20:07 +0000 (19:20 +0100)]
Remove usage of `DUMMY_HIR_ID` in `CheckLoopVisitor`

4 years agoRemove usage of `DUMMY_HIR_ID` in calls to `ObligationClause::misc`
marmeladema [Sun, 12 Apr 2020 17:42:45 +0000 (18:42 +0100)]
Remove usage of `DUMMY_HIR_ID` in calls to `ObligationClause::misc`

Use `ObligationClause::dummy()` when appropriate or replace
`hir::DUMMY_HIR_ID` by `hir::CRATE_HIR_ID`, as used in
`ObligationClause::dummy()`.

4 years ago[windows-gnu] Link pthread statically
Mateusz Mikuła [Sun, 12 Apr 2020 16:11:11 +0000 (18:11 +0200)]
[windows-gnu] Link pthread statically

4 years agoAuto merge of #71059 - Dylan-DPC:rollup-zgu6jmx, r=Dylan-DPC
bors [Sun, 12 Apr 2020 18:09:46 +0000 (18:09 +0000)]
Auto merge of #71059 - Dylan-DPC:rollup-zgu6jmx, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #71029 (Partial work on building with Cargo)
 - #71034 (Clean up E0515 explanation)
 - #71041 (Update links of `rustc guide`)
 - #71048 (Normalize source when loading external foreign source into SourceMap)
 - #71053 (Add some basic docs to `sym` and `kw` modules)
 - #71057 (Clean up E0516 explanation)

Failed merges:

r? @ghost

4 years agofix issue 69130
David Renshaw [Sun, 12 Apr 2020 15:36:37 +0000 (11:36 -0400)]
fix issue 69130

4 years agoRollup merge of #71057 - GuillaumeGomez:cleanup-e0516, r=Dylan-DPC
Dylan DPC [Sun, 12 Apr 2020 12:49:10 +0000 (14:49 +0200)]
Rollup merge of #71057 - GuillaumeGomez:cleanup-e0516, r=Dylan-DPC

Clean up E0516 explanation

r? @Dylan-DPC

4 years agoRollup merge of #71053 - phansch:update_kw_sym_docs, r=Dylan-DPC
Dylan DPC [Sun, 12 Apr 2020 12:49:08 +0000 (14:49 +0200)]
Rollup merge of #71053 - phansch:update_kw_sym_docs, r=Dylan-DPC

Add some basic docs to `sym` and `kw` modules

I was looking into improving some Clippy documentation but was missing a
place that explains the `kw` and `sym` modules from rustc.

This adds some very basic usage documentation to these modules.

4 years agoRollup merge of #71048 - arlosi:normalize_ext_src, r=eddyb
Dylan DPC [Sun, 12 Apr 2020 12:49:06 +0000 (14:49 +0200)]
Rollup merge of #71048 - arlosi:normalize_ext_src, r=eddyb

Normalize source when loading external foreign source into SourceMap

The compiler normalizes source when reading files initially (removes BOMs, etc), but not when loading external sources.

This leads to the external source matching according to the `src_hash`, but differing internally because it was not normalized.

Fixes #70874.

4 years agoRollup merge of #71041 - JohnTitor:rustc-dev-guide, r=jonas-schievink
Dylan DPC [Sun, 12 Apr 2020 12:49:05 +0000 (14:49 +0200)]
Rollup merge of #71041 - JohnTitor:rustc-dev-guide, r=jonas-schievink

Update links of `rustc guide`

Picks up the things we left behind in the transition, hopefully they're last ones.

r? @spastorino

4 years agoRollup merge of #71034 - GuillaumeGomez:cleanup-e0515, r=Dylan-DPC
Dylan DPC [Sun, 12 Apr 2020 12:49:03 +0000 (14:49 +0200)]
Rollup merge of #71034 - GuillaumeGomez:cleanup-e0515, r=Dylan-DPC

Clean up E0515 explanation

r? @Dylan-DPC

4 years agoRollup merge of #71029 - Mark-Simulacrum:cargo-build, r=Mark-Simulacrum
Dylan DPC [Sun, 12 Apr 2020 12:49:01 +0000 (14:49 +0200)]
Rollup merge of #71029 - Mark-Simulacrum:cargo-build, r=Mark-Simulacrum

Partial work on building with Cargo

This cherry picks the commits I'm directly approving from #70999, I want to land them so that that PR is smaller.

4 years agoAuto merge of #70873 - mark-i-m:update-rdg, r=JohnTitor
bors [Sun, 12 Apr 2020 12:46:47 +0000 (12:46 +0000)]
Auto merge of #70873 - mark-i-m:update-rdg, r=JohnTitor

Update rustc-dev-guide

This should finally fix toolstate

r? @JohnTitor

4 years agoClean up E0516 explanation
Guillaume Gomez [Sun, 12 Apr 2020 11:58:05 +0000 (13:58 +0200)]
Clean up E0516 explanation

4 years agosubmodules: update clippy from d342cee7 to af5940b7
Matthias Krüger [Sun, 12 Apr 2020 11:08:47 +0000 (13:08 +0200)]
submodules: update clippy from d342cee7 to af5940b7

Changes:
````
Allow UUID style formatting for `inconsistent_digit_grouping` lint
rustup https://github.com/rust-lang/rust/pull/70986
rustup https://github.com/rust-lang/rust/pull/69745
Rustup to https://github.com/rust-lang/rust/pull/70913
compare with the second largest instead of the smallest variant
Revert "Downgrade new_ret_no_self to pedantic"
Check for clone-on-copy in argument positions
Check fn header along with decl when suggesting to implement trait
Downgrade implicit_hasher to pedantic
Move cognitive_complexity to nursery
Run fmt and update test
Use int assoc consts in MANUAL_SATURATING_ARITHMETIC
Use int assoc consts in checked_conversions lint
Use primitive type assoc consts in more tests
Use integer assoc consts in more lint example code
Don't import primitive type modules
Use assoc const NAN for zero_div_zero lint
Fix float cmp to use assoc fxx::EPSILON
Fix NAN comparison lint to use assoc NAN
Refine lint message.
Lint on opt.as_ref().map(|x| &**x).
Include OpAssign in suspicious_op_assign_impl
result_map_or_into_option: fix syntax error in example
result_map_or_into: fix dogfood_clippy error => {h,l}int
CONTRIBUTING.md: fix broken triage link
result_map_or_into_option: fix `cargo dev fmt --check` errors
result_map_or_into_option: move arg checks into tuple assignment
result_map_or_into_option: add `opt.map_or(None, |_| Some(y))` test
result_map_or_into_option: destructure lint tuple or return early
result_map_or_into_option: add good and bad examples
result_map_or_into_option: explicitly note absence of known problems
Downgrade new_ret_no_self to pedantic
Downgrade unreadable_literal to pedantic
Update CONTRIBUTING.md
Rename rustc -> rustc_middle in doc links
result_map_or_into_option: add lint to catch manually adpating Result -> Option
Move matches test in matches module
Run update_lints
Make lint modules private
Don't filter lints in code generation functions
Build lint lists once and the reuse them to update files
Get rid of Lint::is_internal method
Clean up update_lints
Downgrade inefficient_to_string to pedantic
Downgrade trivially_copy_pass_by_ref to pedantic
Downgrade let_unit_value to pedantic
````
Fixes #70993

4 years agoAdd some basic docs to `sym` and `kw` modules
Philipp Hansch [Sun, 12 Apr 2020 07:45:08 +0000 (09:45 +0200)]
Add some basic docs to `sym` and `kw` modules

I was looking into improving some Clippy documentation but was missing a
place that explains the `kw` and `sym` modules from rustc.

4 years agoAuto merge of #69707 - estebank:impl-trait-missing-bounds, r=Centril
bors [Sun, 12 Apr 2020 06:32:45 +0000 (06:32 +0000)]
Auto merge of #69707 - estebank:impl-trait-missing-bounds, r=Centril

Handle `impl Trait` where `Trait` has an assoc type with missing bounds

When encountering a type parameter that needs more bounds the trivial case is `T` `where T: Bound`, but it can also be an `impl Trait` param that needs to be decomposed to a type param for cleaner code. For example, given

```rust
fn foo(constraints: impl Iterator) {
    for constraint in constraints {
        println!("{:?}", constraint);
    }
}
```

the previous output was

```
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
 --> src/main.rs:3:26
  |
1 | fn foo(constraints: impl Iterator) {
  |                                    - help: consider further restricting the associated type: `where <impl Iterator as std::iter::Iterator>::Item: std::fmt::Debug`
2 |     for constraint in constraints {
3 |         println!("{:?}", constraint);
  |                          ^^^^^^^^^^ `<impl Iterator as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
  |
  = help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
  = note: required by `std::fmt::Debug::fmt`
```

which is incorrect as `where <impl Iterator as std::iter::Iterator>::Item: std::fmt::Debug` is not valid syntax nor would it restrict the positional `impl Iterator` parameter if it were.

The output being introduced is

```
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
 --> src/main.rs:3:26
  |
3 |         println!("{:?}", constraint);
  |                          ^^^^^^^^^^ `<impl Iterator as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
  |
  = help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
  = note: required by `std::fmt::Debug::fmt`
help: introduce a type parameter with a trait bound instead of using `impl Trait`
   |
LL | fn foo<T: Iterator>(constraints: T) where <T as std::iter::Iterator>::Item: std::fmt::Debug  {
   |       ^^^^^^^^^^^^^              ^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

This suggestion is correct and lead the user in the right direction: because you have an associated type restriction you can no longer use `impl Trait`, the only reasonable alternative is to introduce a named type parameter, bound by `Trait` and with a `where` binding on the associated type for the new type parameter `as Trait` for the missing bound.

*Ideally*, we would want to suggest something like the following, but that is not valid syntax today

```
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
 --> src/main.rs:3:26
  |
3 |         println!("{:?}", constraint);
  |                          ^^^^^^^^^^ `<impl Iterator as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
  |
  = help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
  = note: required by `std::fmt::Debug::fmt`
help: introduce a type parameter with a trait bound instead of using `impl Trait`
   |
LL | fn foo(constraints: impl Iterator<Item: std::fmt::Debug>) {
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

Fix #69638.

4 years agoNormalize source when loading external foreign source into SourceMap
Arlo Siemsen [Sun, 12 Apr 2020 03:21:51 +0000 (20:21 -0700)]
Normalize source when loading external foreign source into SourceMap

The compiler normalizes source when reading files initially (removes BOMs, etc), but not when loading external sources.

Fixes #70874 by normalizing when loading external sources too. Adds a test to verify normalization.

4 years agoAuto merge of #69926 - RoccoDev:master, r=estebank,varkor
bors [Sun, 12 Apr 2020 00:31:11 +0000 (00:31 +0000)]
Auto merge of #69926 - RoccoDev:master, r=estebank,varkor

rustc: Add a warning count upon completion

This adds a `build completed with one warning/x warnings` message, similar to the already present `aborted due to previous error` message.

4 years agofix rebase
Esteban Küber [Sat, 11 Apr 2020 21:59:15 +0000 (14:59 -0700)]
fix rebase

4 years agoMake panic-unwind a default feature for libstd
Luca Barbieri [Fri, 10 Apr 2020 20:42:20 +0000 (22:42 +0200)]
Make panic-unwind a default feature for libstd

x.py sets it unconditionally, so want it for plain "cargo build".

We need to load one of the panic runtimes that is in src (vs. pre-built in the
compiler's sysroot) to ensure that we don't load libpanic_unwind from the
sysroot. That would lead to a load of libcore, also from the sysroot, and create
lots of errors about duplicate lang items.

4 years agoDon't emit rerun-if-changed on llvm-config if using system LLVM
Luca Barbieri [Fri, 10 Apr 2020 20:42:19 +0000 (22:42 +0200)]
Don't emit rerun-if-changed on llvm-config if using system LLVM

The code was broken because it printed "llvm-config" instead of the
absolute path to the llvm-config executable, causing Cargo to always
rebuild librustc_llvm if using system LLVM.

Also, it's not the build system's job to rebuild when a system library
changes, so we simply don't emit "rerun-if-changed" if a path to LLVM
was not explicitly provided.

4 years agoRequire compiler-rt root at ../src/llvm-project/compiler-rt
Luca Barbieri [Fri, 10 Apr 2020 20:42:19 +0000 (22:42 +0200)]
Require compiler-rt root at ../src/llvm-project/compiler-rt

4 years agoDepend on getopts from crates.io
Luca Barbieri [Fri, 10 Apr 2020 20:42:19 +0000 (22:42 +0200)]
Depend on getopts from crates.io

rustc_session exports it for other crates to avoid mismatching
crate versions.

4 years agoreview comments
Esteban Küber [Fri, 10 Apr 2020 17:40:47 +0000 (10:40 -0700)]
review comments

4 years agoreview comments
Esteban Küber [Sun, 5 Apr 2020 22:33:33 +0000 (15:33 -0700)]
review comments

4 years agoTry to use the first char in the trait name as type param
Esteban Küber [Sun, 5 Apr 2020 21:55:06 +0000 (14:55 -0700)]
Try to use the first char in the trait name as type param

4 years agoAccount for existing names when suggesting adding a type param
Esteban Küber [Sun, 5 Apr 2020 20:13:13 +0000 (13:13 -0700)]
Account for existing names when suggesting adding a type param

4 years agoAccount for type params with bounds
Esteban Küber [Sun, 5 Apr 2020 19:32:34 +0000 (12:32 -0700)]
Account for type params with bounds

4 years agoreview comments
Esteban Küber [Sun, 5 Apr 2020 17:52:54 +0000 (10:52 -0700)]
review comments

4 years agoreview comments
Esteban Küber [Sun, 5 Apr 2020 00:31:32 +0000 (17:31 -0700)]
review comments

4 years agoHandle `impl Trait` where `Trait` has an assoc type with missing bounds
Esteban Küber [Wed, 4 Mar 2020 18:50:05 +0000 (10:50 -0800)]
Handle `impl Trait` where `Trait` has an assoc type with missing bounds

Fix #69638.

4 years agoAuto merge of #71031 - Dylan-DPC:rollup-zr8hh86, r=Dylan-DPC
bors [Sat, 11 Apr 2020 21:19:28 +0000 (21:19 +0000)]
Auto merge of #71031 - Dylan-DPC:rollup-zr8hh86, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #70644 (Clean up `ModuleConfig` initialization)
 - #70937 (Fix staticlib name for *-pc-windows-gnu targets)
 - #70996 (Add or_insert_with_key to Entry of HashMap/BTreeMap)
 - #71020 (Store UNICODE_VERSION as a tuple)
 - #71021 (Use write!-style syntax for MIR assert terminator)

Failed merges:

r? @ghost

4 years agoUpdate links of `rustc guide`
Yuki Okushi [Sat, 11 Apr 2020 20:02:35 +0000 (05:02 +0900)]
Update links of `rustc guide`

4 years ago[windows] Add testcase to make sure executables are self-contained
Mateusz Mikuła [Sat, 11 Apr 2020 11:22:21 +0000 (13:22 +0200)]
[windows] Add testcase to make sure executables are self-contained

4 years agoClean up E0515 explanation
Guillaume Gomez [Sat, 11 Apr 2020 16:58:03 +0000 (18:58 +0200)]
Clean up E0515 explanation

4 years agoRollup merge of #71021 - robojumper:71000-mir-assert-syntax, r=jonas-schievink
Dylan DPC [Sat, 11 Apr 2020 15:52:14 +0000 (17:52 +0200)]
Rollup merge of #71021 - robojumper:71000-mir-assert-syntax, r=jonas-schievink

Use write!-style syntax for MIR assert terminator

Fixes #71000.

r? @jonas-schievink

4 years agoRollup merge of #71020 - pyfisch:unicode-version, r=sfackler
Dylan DPC [Sat, 11 Apr 2020 15:52:13 +0000 (17:52 +0200)]
Rollup merge of #71020 - pyfisch:unicode-version, r=sfackler

Store UNICODE_VERSION as a tuple

Remove the UnicodeVersion struct containing
major, minor and update fields and replace it with
a 3-tuple containing the version number.
As the value of each field is limited to 255
use u8 to store them.

4 years agoRollup merge of #70996 - ChaiTRex:master, r=Amanieu
Dylan DPC [Sat, 11 Apr 2020 15:52:11 +0000 (17:52 +0200)]
Rollup merge of #70996 - ChaiTRex:master, r=Amanieu

Add or_insert_with_key to Entry of HashMap/BTreeMap

Going along with `or_insert_with`, `or_insert_with_key` provides the `Entry`'s key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time.

This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda.

---

I'm fairly new to Rust, so any optimizations, corrections to types, better names, better documentation, or whatever else would be appreciated. I'd like to thank Arnavion on freenode for helping me to implement a very similar method when I found that `or_insert_with_key` was unavailable.

As a somewhat-related note, this implements https://github.com/rust-lang/rfcs/issues/1202 from 2015, so if this pull request is accepted, that should be closed.

4 years agoRollup merge of #70937 - mati865:mingw-staticlib-suffix, r=petrochenkov
Dylan DPC [Sat, 11 Apr 2020 15:52:10 +0000 (17:52 +0200)]
Rollup merge of #70937 - mati865:mingw-staticlib-suffix, r=petrochenkov

Fix staticlib name for *-pc-windows-gnu targets

Fix https://github.com/rust-lang/rust/issues/69904

Guess this will need FCP but opened PR anyway to bring the attention.

In short Rust has been using wrong `foo.lib` format for static libraries when building for `*-pc-windows-gnu` since version [1.8.0](https://github.com/rust-lang/rust/commit/34b4e66736a0fb65235feadbb5178d42bd09ed67).
[LD](https://github.com/bminor/binutils-gdb/blob/f4a220077b03af3a1f905b7dc6dc84c0a06d582f/ld/emultempl/pe.em#L2224-L2227) and [LLD](https://github.com/llvm/llvm-project/blob/0605f5fbe755326e3dbc8daa4fc34453b8c5ac0e/lld/MinGW/Driver.cpp#L140-L141) agree in that regard and only accept static libraries with `libfoo.a` format. So the only thing to break here is when somebody added a hack to rename created library to proper format (like [here](https://gitlab.gnome.org/GNOME/librsvg/-/commit/ad86ab8580c8779fc3eb2bee2422bb116919844e#d5b4de16d947214ec306bd57bed1bd23a939b5f9_197_194)).

4 years agoRollup merge of #70644 - nnethercote:clean-up-ModuleConfig-init, r=Mark-Simulacrum
Dylan DPC [Sat, 11 Apr 2020 15:52:08 +0000 (17:52 +0200)]
Rollup merge of #70644 - nnethercote:clean-up-ModuleConfig-init, r=Mark-Simulacrum

Clean up `ModuleConfig` initialization

Because it's currently a mess.

r? @Mark-Simulacrum

4 years agoAuto merge of #70161 - cjgillot:query-arena, r=nikomatsakis
bors [Sat, 11 Apr 2020 15:31:54 +0000 (15:31 +0000)]
Auto merge of #70161 - cjgillot:query-arena, r=nikomatsakis

Allocate some query results on an arena

This avoids a cloning few `Lrc` and `Vec`s in the queries.

4 years agoDepend on libc from crates.io
Luca Barbieri [Fri, 10 Apr 2020 20:42:19 +0000 (22:42 +0200)]
Depend on libc from crates.io

4 years agorustc: Add a warning count upon completion
RoccoDev [Wed, 11 Mar 2020 15:30:09 +0000 (16:30 +0100)]
rustc: Add a warning count upon completion

4 years agoChange issue number to point to tracking issue
Chai T. Rex [Sat, 11 Apr 2020 12:46:12 +0000 (08:46 -0400)]
Change issue number to point to tracking issue

4 years agoAuto merge of #71014 - Centril:rollup-3lc8cnt, r=Centril
bors [Sat, 11 Apr 2020 12:22:00 +0000 (12:22 +0000)]
Auto merge of #71014 - Centril:rollup-3lc8cnt, r=Centril

Rollup of 5 pull requests

Successful merges:

 - #69573 (tests encoding current behavior for various cases of "binding" to _.)
 - #70881 (bootstrap: work around "unused attribute" errors in incremental stdlib rebuilds.)
 - #70957 (Normalize MIR locals' types for generator layout computation.)
 - #70962 (added machine hooks to track deallocations)
 - #70982 (Normalize function signature in function casting check procedure)

Failed merges:

r? @ghost

4 years agoUse write!-style syntax for MIR assert terminator
robojumper [Sat, 11 Apr 2020 10:59:19 +0000 (12:59 +0200)]
Use write!-style syntax for MIR assert terminator

4 years agoStore UNICODE_VERSION as a tuple
Pyfisch [Sat, 11 Apr 2020 10:56:25 +0000 (12:56 +0200)]
Store UNICODE_VERSION as a tuple

Remove the UnicodeVersion struct containing
major, minor and update fields and replace it with
a 3-tuple containing the version number.
As the value of each field is limited to 255
use u8 to store them.

4 years agoAuto merge of #69573 - pnkfelix:issue-53114-add-tests, r=Centril
bors [Sat, 11 Apr 2020 06:44:47 +0000 (06:44 +0000)]
Auto merge of #69573 - pnkfelix:issue-53114-add-tests, r=Centril

tests encoding current behavior for various cases of "binding" to _.

The `_` binding form is special, in that it encodes a "no-op": nothing is actually bound, and thus nothing is moved or borrowed in this scenario. Usually we do the "right" thing in all such cases. The exceptions are explicitly pointed out in this test case, so that we keep track of whether they are eventually fixed.

Cc #53114.

(This does not close the aforementioned issue; it just adds the tests encoding the current behavior, which we hope to eventually fix.)

4 years agoRollup merge of #70982 - ldm0:fncoerce, r=eddyb
Mazdak Farrokhzad [Fri, 10 Apr 2020 23:52:29 +0000 (01:52 +0200)]
Rollup merge of #70982 - ldm0:fncoerce, r=eddyb

Normalize function signature in function casting check procedure

Fixes #54094
```rust
trait Zoo {
    type X;
}

impl Zoo for u16 {
    type X = usize;
}

fn foo(abc: <u16 as Zoo>::X) {}

fn main() {
    let x: *const u8 = foo as _;
}
```

Currently a `FnDef` need to be checked if it's able to cast to `FnPtr` before it is actually casted. But the signature of `FnPtr` target's associated types are not normalized:

https://github.com/rust-lang/rust/blob/96d77f0e5f103612d62b85938aacfb33f5768433/src/librustc_typeck/check/cast.rs#L536-L553
However, during the coercion check, the signature of `FnPtr` target's associated types are normalized (The `<u16 as Zoo>::X` turns into `usize`).

https://github.com/rust-lang/rust/blob/96d77f0e5f103612d62b85938aacfb33f5768433/src/librustc_typeck/check/coercion.rs#L687-L729

This inconsistency leads to the error:`Err(Sorts(ExpectedFound { expected: <u16 as Zoo>::X, found: usize }))`.

4 years agoRollup merge of #70962 - KrishnaSannasi:track-dealloc, r=RalfJung
Mazdak Farrokhzad [Fri, 10 Apr 2020 23:52:27 +0000 (01:52 +0200)]
Rollup merge of #70962 - KrishnaSannasi:track-dealloc, r=RalfJung

added machine hooks to track deallocations

This is part of rust-lang/miri#1314 in order to allow miri to show stack traces for on deallocation in order to debug use-after-free bugs

4 years agoRollup merge of #70957 - oli-obk:lazy_repeat_length_eval_ice, r=matthewjasper
Mazdak Farrokhzad [Fri, 10 Apr 2020 23:52:26 +0000 (01:52 +0200)]
Rollup merge of #70957 - oli-obk:lazy_repeat_length_eval_ice, r=matthewjasper

Normalize MIR locals' types for generator layout computation.

fixes #70905

4 years agoRollup merge of #70881 - eddyb:stage0-hide-incremental-unused-attrs, r=Mark-Simulacrum
Mazdak Farrokhzad [Fri, 10 Apr 2020 23:52:24 +0000 (01:52 +0200)]
Rollup merge of #70881 - eddyb:stage0-hide-incremental-unused-attrs, r=Mark-Simulacrum

bootstrap: work around "unused attribute" errors in incremental stdlib rebuilds.

This should alleviate #58633 separately from a proper fix.

r? @Mark-Simulacrum

4 years agoRollup merge of #69573 - pnkfelix:issue-53114-add-tests, r=Centril
Mazdak Farrokhzad [Fri, 10 Apr 2020 23:52:23 +0000 (01:52 +0200)]
Rollup merge of #69573 - pnkfelix:issue-53114-add-tests, r=Centril

tests encoding current behavior for various cases of "binding" to _.

The `_` binding form is special, in that it encodes a "no-op": nothing is actually bound, and thus nothing is moved or borrowed in this scenario. Usually we do the "right" thing in all such cases. The exceptions are explicitly pointed out in this test case, so that we keep track of whether they are eventually fixed.

Cc #53114.

(This does not close the aforementioned issue; it just adds the tests encoding the current behavior, which we hope to eventually fix.)

4 years agoPass the `PlaceElem::Index` local to `visit_local`
Jonas Schievink [Fri, 10 Apr 2020 23:39:50 +0000 (01:39 +0200)]
Pass the `PlaceElem::Index` local to `visit_local`

4 years agoAuto merge of #70986 - marmeladema:issue70853/librustc_middle-local-def-id, r=eddyb
bors [Fri, 10 Apr 2020 23:13:13 +0000 (23:13 +0000)]
Auto merge of #70986 - marmeladema:issue70853/librustc_middle-local-def-id, r=eddyb

rustc_middle: return `LocalDefId` where possible in hir::map module

This changes the return type of the following functions to return a `LocalDefId` instead of a `DefId`:
* opt_local_def_id_from_node_id
* opt_local_def_id
* body_owner_def_id
* local_def_id_from_node_id
* get_parent_id

This is another step in the right direction for #70853

This pull request will be followed by another (substantial one) which changes the return type of `local_def_id` function but this change being more invasive, we might want to wait for #70956 or #70961 (or some other form it) to land first.

4 years agoAuto merge of #70994 - Centril:rollup-lftv0a3, r=Centril
bors [Fri, 10 Apr 2020 19:28:38 +0000 (19:28 +0000)]
Auto merge of #70994 - Centril:rollup-lftv0a3, r=Centril

Rollup of 9 pull requests

Successful merges:

 - #69745 (Use `PredicateObligation`s instead of `Predicate`s)
 - #70938 (Add ThreadSanitizer test case)
 - #70973 (Use forward traversal for unconditional recursion lint)
 - #70978 (compiletest: let config flags overwrite -A unused)
 - #70979 (Follow up on BTreeMap comments)
 - #70981 (Rearrange BTreeMap::into_iter to match range_mut.)
 - #70985 (Clean up E0512 explanation)
 - #70988 (Setup the `@rustbot prioritize` command)
 - #70991 (fix rustc-dev-guide's url in src/librustc_codegen_ssa)

Failed merges:

r? @ghost

4 years agoFixed doc tests for added methods
Chai T. Rex [Fri, 10 Apr 2020 17:39:35 +0000 (13:39 -0400)]
Fixed doc tests for added methods

4 years agoadded machine hooks to track deallocations
Ozaren [Thu, 9 Apr 2020 18:48:06 +0000 (14:48 -0400)]
added machine hooks to track deallocations

4 years agoAdd or_insert_with_key to Entry of HashMap/BTreeMap
Chai T. Rex [Fri, 10 Apr 2020 16:10:05 +0000 (12:10 -0400)]
Add or_insert_with_key to Entry of HashMap/BTreeMap

Going along with or_insert_with, or_insert_with_key provides the
Entry's key to the lambda, avoiding the need to either clone the
key or the need to reimplement this body of this method from
scratch each time.

This is useful when the initial value for a map entry is derived
from the key. For example, the introductory Rust book has an
example Cacher struct that takes an expensive-to-compute lambda and
then can, given an argument to the lambda, produce either the
cached result or execute the lambda.

4 years ago--bless you
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:22:24 +0000 (18:22 +0200)]
--bless you

4 years agoRollup merge of #70991 - longfangsong:master, r=jonas-schievink
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:29 +0000 (18:15 +0200)]
Rollup merge of #70991 - longfangsong:master, r=jonas-schievink

fix rustc-dev-guide's url in src/librustc_codegen_ssa

Change the backend-agnostic chapter's url in rustc-dev-guide from [url](https://rustc-dev-guide.rust-lang.org/codegen/backend-agnostic.html), which is 404 now, to [the right one](https://rustc-dev-guide.rust-lang.org/backend/backend-agnostic.html).

Sorry for disturbing.

4 years agoRollup merge of #70988 - LeSeulArtichaut:triagebot-prioritize, r=Mark-Simulacrum
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:27 +0000 (18:15 +0200)]
Rollup merge of #70988 - LeSeulArtichaut:triagebot-prioritize, r=Mark-Simulacrum

Setup the `@rustbot prioritize` command

See rust-lang/triagebot#453

r? @Mark-Simulacrum can you confirm that the `t-compiler/wg-prioritization` stream ID is `227806`?
cc @spastorino

4 years agoRollup merge of #70985 - GuillaumeGomez:cleanup-e0512, r=Dylan-DPC
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:26 +0000 (18:15 +0200)]
Rollup merge of #70985 - GuillaumeGomez:cleanup-e0512, r=Dylan-DPC

Clean up E0512 explanation

r? @Dylan-DPC

4 years agoRollup merge of #70981 - ssomers:btreemap_into_into_iter, r=Mark-Simulacrum
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:24 +0000 (18:15 +0200)]
Rollup merge of #70981 - ssomers:btreemap_into_into_iter, r=Mark-Simulacrum

Rearrange BTreeMap::into_iter to match range_mut.

r? @Mark-Simulacrum
I wondered why you catered for the optional root differently in `into_iter` than in `range_mut`.

4 years agoRollup merge of #70979 - ssomers:btreemap_the_alice_merton_variations, r=Amanieu
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:22 +0000 (18:15 +0200)]
Rollup merge of #70979 - ssomers:btreemap_the_alice_merton_variations, r=Amanieu

Follow up on BTreeMap comments

r? @Amanieu (for the first commit)

4 years agoRollup merge of #70978 - RalfJung:compiletest-flags, r=Mark-Simulacrum
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:21 +0000 (18:15 +0200)]
Rollup merge of #70978 - RalfJung:compiletest-flags, r=Mark-Simulacrum

compiletest: let config flags overwrite -A unused

Cc https://github.com/laumann/compiletest-rs/issues/216

4 years agoRollup merge of #70973 - ecstatic-morse:recursion-lint, r=jonas-schievink
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:19 +0000 (18:15 +0200)]
Rollup merge of #70973 - ecstatic-morse:recursion-lint, r=jonas-schievink

Use forward traversal for unconditional recursion lint

While reviewing #70822, I noted that #54444 could be solved without requiring the predecessor graph and without allocating a `Vec<Span>` for every basic block. The unconditional recursion lint is not a performance bottleneck however, so I approved #70822 as it was.

Nevertheless, I wanted to try implementing my idea using `TriColorDepthFirstSearch`, which is a DFS that can differentiate between [forward/tree edges and backward ones](https://en.wikipedia.org/wiki/Depth-first_search#Output_of_a_depth-first_search). I found this approach more straightforward than the existing one, so I'm opening this PR to see if it is desirable.

The pass is now just a DFS across the control-flow graph. We ignore false edges and false unwinds, as well as the successors of recursive calls, just like existing pass does. If we see a back-edge (loop) or a terminator that would cause us to yield control-flow back to the caller (`Return`, `Resume`, etc.), we know that the function does not unconditionally recurse.

r? @jonas-schievink

4 years agoRollup merge of #70938 - tmiasko:thread-test-case, r=hanna-kruppe
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:18 +0000 (18:15 +0200)]
Rollup merge of #70938 - tmiasko:thread-test-case, r=hanna-kruppe

Add ThreadSanitizer test case

4 years agoRollup merge of #69745 - estebank:predicate-obligations-3, r=nikomatsakis,eddyb
Mazdak Farrokhzad [Fri, 10 Apr 2020 16:15:16 +0000 (18:15 +0200)]
Rollup merge of #69745 - estebank:predicate-obligations-3, r=nikomatsakis,eddyb

Use `PredicateObligation`s instead of `Predicate`s

Keep more information about trait binding failures. Use more specific spans by pointing at bindings that introduce obligations.

Subset of #69709.

r? @eddyb

4 years agoAuto merge of #66605 - GuillaumeGomez:drop-python2, r=Mark-Simulacrum
bors [Fri, 10 Apr 2020 16:13:20 +0000 (16:13 +0000)]
Auto merge of #66605 - GuillaumeGomez:drop-python2, r=Mark-Simulacrum

Stop explicitly depending on python 2

This PR revises our previous policy of officially only supporting and testing with python 2 in the CI environment to instead test with python 3. It also changes the defaults to python 3 in our various scripts (usually, by way of `python` rather than `python3` to preserve compatibility with systems that do not have a python 3 available).

The effect of this is that we expect all new patches to support python 3 (and will test as such). We explicitly also expect that patches support python 2.7 as well -- and test as such, though only on one builder. This is intended as a temporary, though likely long-lived, measure to preserve compatibility while looking towards the future which is likely to be a python 3 only world. We do not at this point set a timeline for when we'll drop support for python 2.7; it's plausible that this is months or years into the future, depending on how quickly the ecosystem drops support and how painful it is for us to maintain that support over time.

Closes #65063 (as far as I can tell; please file explicit and separate issues or PRs if not).

4 years agocopy test cases to `if let` as well.
Felix S. Klock II [Thu, 5 Mar 2020 19:06:40 +0000 (14:06 -0500)]
copy test cases to `if let` as well.

4 years agoUpdate src/test/ui/binding/issue-53114-safety-checks.rs
Felix S Klock II [Thu, 5 Mar 2020 18:52:10 +0000 (13:52 -0500)]
Update src/test/ui/binding/issue-53114-safety-checks.rs

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
4 years agoUpdate src/test/ui/binding/issue-53114-borrow-checks.rs
Felix S Klock II [Thu, 5 Mar 2020 18:51:48 +0000 (13:51 -0500)]
Update src/test/ui/binding/issue-53114-borrow-checks.rs

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
4 years agotests encoding current behavior for various cases of "binding" to _.
Felix S. Klock II [Sat, 29 Feb 2020 03:56:37 +0000 (22:56 -0500)]
tests encoding current behavior for various cases of "binding" to _.

The `_` binding form is special, in that it encodes a "no-op": nothing is
actually bound, and thus nothing is moved or borrowed in this scenario. Usually
we do the "right" thing in all such cases. The exceptions are explicitly pointed
out in this test case, so that we keep track of whether they are eventually
fixed.

4 years agofix rustc-dev-guide url in src/librustc_codegen_ssa
longfangsong [Fri, 10 Apr 2020 14:48:34 +0000 (22:48 +0800)]
fix rustc-dev-guide url in src/librustc_codegen_ssa

4 years agoAdd ThreadSanitizer test case
Tomasz Miąsko [Thu, 9 Apr 2020 00:00:00 +0000 (00:00 +0000)]
Add ThreadSanitizer test case

4 years agoSetup the `@rustbot prioritize` command
LeSeulArtichaut [Fri, 10 Apr 2020 13:22:40 +0000 (15:22 +0200)]
Setup the `@rustbot prioritize` command

4 years agoEnforce Python 3 as much as possible
Guillaume Gomez [Thu, 21 Nov 2019 12:57:40 +0000 (13:57 +0100)]
Enforce Python 3 as much as possible

4 years agoAuto merge of #70983 - Centril:rollup-npabk7c, r=Centril
bors [Fri, 10 Apr 2020 13:05:05 +0000 (13:05 +0000)]
Auto merge of #70983 - Centril:rollup-npabk7c, r=Centril

Rollup of 8 pull requests

Successful merges:

 - #70784 (Consider methods on fundamental `impl` when method is not found on numeric type)
 - #70843 (Remove the Ord bound that was plaguing drain_filter)
 - #70913 (Replace "rc"/"arc" lang items with Rc/Arc diagnostic items.)
 - #70932 (De-abuse TyKind::Error in pattern type checking)
 - #70952 (Clean up E0511 explanation)
 - #70964 (rustc_session CLI lint parsing: mark a temporary hack as such)
 - #70969 (Fix JSON file_name documentation for macros.)
 - #70975 (Fix internal doc comment nits.)

Failed merges:

r? @ghost

4 years agoClean up E0512 explanation
Guillaume Gomez [Fri, 10 Apr 2020 11:19:49 +0000 (13:19 +0200)]
Clean up E0512 explanation

4 years agolibrustc_middle: return LocalDefId instead of DefId in get_parent_did
marmeladema [Wed, 8 Apr 2020 14:42:53 +0000 (15:42 +0100)]
librustc_middle: return LocalDefId instead of DefId in get_parent_did

4 years agolibrustc_middle: return LocalDefId instead of DefId in local_def_id_from_node_id
marmeladema [Wed, 8 Apr 2020 14:09:38 +0000 (15:09 +0100)]
librustc_middle: return LocalDefId instead of DefId in local_def_id_from_node_id

4 years agolibrustc_middle: return LocalDefId instead of DefId in body_owner_def_id
marmeladema [Wed, 8 Apr 2020 13:53:06 +0000 (14:53 +0100)]
librustc_middle: return LocalDefId instead of DefId in body_owner_def_id

4 years agolibrustc_middle: return LocalDefId instead of DefId in opt_local_def_id
marmeladema [Wed, 8 Apr 2020 11:33:38 +0000 (12:33 +0100)]
librustc_middle: return LocalDefId instead of DefId in opt_local_def_id

4 years agolibrustc_middle: return LocalDefId instead of DefId in opt_local_def_id_from_node_id
marmeladema [Wed, 8 Apr 2020 11:22:19 +0000 (12:22 +0100)]
librustc_middle: return LocalDefId instead of DefId in opt_local_def_id_from_node_id

4 years agoTidy fix
Donough Liu [Fri, 10 Apr 2020 10:51:27 +0000 (18:51 +0800)]
Tidy fix

4 years agoRollup merge of #70975 - lcnr:ok, r=petrochenkov
Mazdak Farrokhzad [Fri, 10 Apr 2020 10:48:53 +0000 (12:48 +0200)]
Rollup merge of #70975 - lcnr:ok, r=petrochenkov

Fix internal doc comment nits.

4 years agoRollup merge of #70969 - ehuss:json-filename-macros, r=eddyb
Mazdak Farrokhzad [Fri, 10 Apr 2020 10:48:51 +0000 (12:48 +0200)]
Rollup merge of #70969 - ehuss:json-filename-macros, r=eddyb

Fix JSON file_name documentation for macros.

JSON `file_name` paths were changed in #66364 for macros to point to actual source files instead of using `<MACRONAME macros>`.

Closes #70396

4 years agoRollup merge of #70964 - RalfJung:mark-cli-lint-hack, r=petrochenkov
Mazdak Farrokhzad [Fri, 10 Apr 2020 10:48:50 +0000 (12:48 +0200)]
Rollup merge of #70964 - RalfJung:mark-cli-lint-hack, r=petrochenkov

rustc_session CLI lint parsing: mark a temporary hack as such

This code was added in https://github.com/rust-lang/rust/pull/70918, but it should not be necessary any more once `forbid` works as expected for in-code attributes.

Cc @tobithiel @davidtwco