]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agofix __rust_alloc_error_handler comment
Ralf Jung [Fri, 9 Oct 2020 09:17:08 +0000 (11:17 +0200)]
fix __rust_alloc_error_handler comment

3 years agoAuto merge of #77627 - richkadel:rust-demangler, r=tmandry
bors [Fri, 9 Oct 2020 06:15:09 +0000 (06:15 +0000)]
Auto merge of #77627 - richkadel:rust-demangler, r=tmandry

rust-demangler tool strips crate disambiguators with < 16 digits

Addresses Issue #77615.

3 years agoAuto merge of #77578 - euclio:max-suggestion, r=davidtwco
bors [Fri, 9 Oct 2020 04:22:18 +0000 (04:22 +0000)]
Auto merge of #77578 - euclio:max-suggestion, r=davidtwco

suggest `MAX` constant if -1 is assigned to unsigned type

Fixes #76413.
Fixes #77416.

3 years agoAuto merge of #77519 - jyn514:track-doc-er, r=GuillaumeGomez
bors [Fri, 9 Oct 2020 02:27:33 +0000 (02:27 +0000)]
Auto merge of #77519 - jyn514:track-doc-er, r=GuillaumeGomez

Resolve intra-doc links on additional documentation for re-exports in lexical scope

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

- Preserve the parent module of `DocFragment`s
  + Add `parent_module` to `DocFragment`
  + Require the `parent_module` of the item being inlined
  + Preserve the hir_id for ExternCrates so rustdoc can find the parent module later
  + Take an optional `parent_module` for `build_impl` and `merge_attrs`.
    Preserve the difference between parent modules for each doc-comment.
  + Support a single additional re-exports in from_ast. Originally this took a vec but I ended up not using it.
  + Don't require the parent_module for all `impl`s, just inlined items

    In particular, this will be `None` whenever the attribute is not on a
    re-export.

  + Only store the parent_module, not the HirId

    When re-exporting a re-export, the HirId is not available. Fortunately,
    `collect_intra_doc_links` doesn't actually need all the info from a
    HirId, just the parent module.

- Introduce `Divider`

  This distinguishes between documentation on the original from docs on  the re-export.

- Use the new module information for intra-doc links

  + Make the parent module conditional on whether the docs are on a re-export
  + Make `resolve_link` take `&Item` instead of `&mut Item`

    Previously the borrow checker gave an error about multiple mutable
    borrows, because `dox` borrowed from `item`.

  + Fix `crate::` for re-exports

    `crate` means something different depending on where the attribute
    came from.

  + Make it work for `#[doc]` attributes too

    This required combining several attributes as one so they would keep
    the links.

r? `@GuillaumeGomez`

3 years agoAuto merge of #76260 - xd009642:rfc/2867, r=jonas-schievink
bors [Fri, 9 Oct 2020 00:29:47 +0000 (00:29 +0000)]
Auto merge of #76260 - xd009642:rfc/2867, r=jonas-schievink

Implementation of RFC2867

https://github.com/rust-lang/rust/issues/74727

So I've started work on this, I think my next steps are to make use of the `instruction_set` value in the llvm codegen but this is the point where I begin to get a bit lost. I'm looking at the code but it would be nice to have some guidance on what I've currently done and what I'm doing next :smile:

3 years agoFix typo in error code
xd009642 [Thu, 8 Oct 2020 22:56:59 +0000 (23:56 +0100)]
Fix typo in error code

3 years agoAuto merge of #77723 - jonas-schievink:rollup-htz44r4, r=jonas-schievink
bors [Thu, 8 Oct 2020 22:37:37 +0000 (22:37 +0000)]
Auto merge of #77723 - jonas-schievink:rollup-htz44r4, r=jonas-schievink

Rollup of 8 pull requests

Successful merges:

 - #76750 (Don't discourage implementing `core::fmt::Write`)
 - #77449 (BTreeMap: comment why drain_filter's size_hint is somewhat pessimistic)
 - #77660 ((docs): make mutex error comment consistent with codebase)
 - #77663 (Add compile fail test for issue 27675)
 - #77673 (Remove unnecessary lamda on emitter map.)
 - #77701 (Make `max_log_info` easily greppable (for figuring out why debug logging is disabled))
 - #77702 (Remove not needed lambda.)
 - #77710 (Update submodule llvm to get LVI bugfix)

Failed merges:

r? `@ghost`

3 years agoImplement the instruction_set attribute
xd009642 [Thu, 8 Oct 2020 22:23:27 +0000 (23:23 +0100)]
Implement the instruction_set attribute

3 years agoRollup merge of #77710 - fortanix:raoul/bugfix-lvi, r=nikic
Jonas Schievink [Thu, 8 Oct 2020 21:23:19 +0000 (23:23 +0200)]
Rollup merge of #77710 - fortanix:raoul/bugfix-lvi, r=nikic

Update submodule llvm to get LVI bugfix

The LLVM LVI mitigations used register %rcs as a clobber register. This is problematic when rust uses this register to return (part of) function values. The problem was fixed upstream in:

    https://reviews.llvm.org/D88924
    https://reviews.llvm.org/D88925

PR https://github.com/rust-lang/llvm-project/pull/79 merged it in the llvm_project. This PR updates the submodule

Bug report: https://bugs.llvm.org/show_bug.cgi?id=47740
Fixes #77607

cc: @jethrogb

3 years agoRollup merge of #77702 - heckad:patch-3, r=lcnr
Jonas Schievink [Thu, 8 Oct 2020 21:23:17 +0000 (23:23 +0200)]
Rollup merge of #77702 - heckad:patch-3, r=lcnr

Remove not needed lambda.

3 years agoRollup merge of #77701 - jyn514:debug-logging, r=Mark-Simulacrum
Jonas Schievink [Thu, 8 Oct 2020 21:23:15 +0000 (23:23 +0200)]
Rollup merge of #77701 - jyn514:debug-logging, r=Mark-Simulacrum

Make `max_log_info` easily greppable (for figuring out why debug logging is disabled)

Follow-up to https://github.com/rust-lang/rust/pull/77678#issuecomment-705545608. I'll make a PR to the dev-guide shortly changing `debug = true` to `debug-logging = true` and using this text.

Ideally wouldn't be merged before https://github.com/rust-lang/rust/pull/77678, but it practice it won't hurt anything.

r? @Mark-Simulacrum

3 years agoRollup merge of #77673 - heckad:patch-2, r=lcnr
Jonas Schievink [Thu, 8 Oct 2020 21:23:13 +0000 (23:23 +0200)]
Rollup merge of #77673 - heckad:patch-2, r=lcnr

Remove unnecessary lamda on emitter map.

3 years agoRollup merge of #77663 - HeroicKatora:regression-tests-27675-object-safe, r=Aaron1011
Jonas Schievink [Thu, 8 Oct 2020 21:23:12 +0000 (23:23 +0200)]
Rollup merge of #77663 - HeroicKatora:regression-tests-27675-object-safe, r=Aaron1011

Add compile fail test for issue 27675

A recently merged PR (#73905) strengthened the checks on bounds of associated items. This rejects the attack path of #27675 which consisted of constructing a `dyn Trait<Item=T>` where `T` would not fulfill the bounds required on `Item` of the `Trait` behind the dyn object.

This regression test, extracted from [the weaponized instance](https://github.com/rust-lang/rust/issues/27675#issuecomment-696956878), checks that this is rejected.

3 years agoRollup merge of #77660 - nilslice:patch-1, r=jyn514
Jonas Schievink [Thu, 8 Oct 2020 21:23:10 +0000 (23:23 +0200)]
Rollup merge of #77660 - nilslice:patch-1, r=jyn514

(docs): make mutex error comment consistent with codebase

Although exceptionally minor, I found this stands out from other error reporting language used in doc comments. With the existence of the `failure` crate, I suppose this could be slightly ambiguous. In any case, this change brings the particular comment into a consistent state with other mentions of returning errors.

3 years agoRollup merge of #77449 - ssomers:btree_drain_filter_size_hint, r=Mark-Simulacrum
Jonas Schievink [Thu, 8 Oct 2020 21:23:08 +0000 (23:23 +0200)]
Rollup merge of #77449 - ssomers:btree_drain_filter_size_hint, r=Mark-Simulacrum

BTreeMap: comment why drain_filter's size_hint is somewhat pessimistic

The `size_hint` of the `DrainFilter` iterator doesn't adjust as you iterate. This hardly seems important to me, but there has been a comparable PR #64383 in the past. I guess a scenario is that you first iterate half the map manually and keep most of the key/value pairs in the map, and then tell the predicate to drain most of the key/value pairs and `.collect` the iterator over the remaining half of the map.

I am totally ambivalent whether this is better or not.

r? @Mark-Simulacrum

3 years agoRollup merge of #76750 - camelid:dont-discourage-core-fmt-write, r=Mark-Simulacrum
Jonas Schievink [Thu, 8 Oct 2020 21:23:07 +0000 (23:23 +0200)]
Rollup merge of #76750 - camelid:dont-discourage-core-fmt-write, r=Mark-Simulacrum

Don't discourage implementing `core::fmt::Write`

Fixes #76729.

Explain when you should use it and when you should not.

3 years agoAuto merge of #77110 - lzutao:e0596-amp_mut, r=davidtwco
bors [Thu, 8 Oct 2020 20:43:01 +0000 (20:43 +0000)]
Auto merge of #77110 - lzutao:e0596-amp_mut, r=davidtwco

Suggest removing `&mut` from a `&mut borrow`

Modify the code added in #54720.

Closes  #75871

3 years agorust-demangler tool strips crate disambiguators with < 16 digits
Rich Kadel [Tue, 6 Oct 2020 19:47:19 +0000 (12:47 -0700)]
rust-demangler tool strips crate disambiguators with < 16 digits

Addresses Issue #77615.

3 years agoDon't discourage implementing `core::fmt::Write`
Camelid [Tue, 15 Sep 2020 17:22:48 +0000 (10:22 -0700)]
Don't discourage implementing `core::fmt::Write`

Explain when you should use it and when you should not.

3 years agoAuto merge of #77346 - Caduser2020:master, r=Mark-Simulacrum
bors [Thu, 8 Oct 2020 17:36:25 +0000 (17:36 +0000)]
Auto merge of #77346 - Caduser2020:master, r=Mark-Simulacrum

`#[deny(unsafe_op_in_unsafe_fn)]` in sys/sgx

This is part of #73904.

Enclose unsafe operations in unsafe blocks in `libstd/sys/sgx`.

3 years agosuggest `MAX` constant if -1 is assigned to unsigned type
Andy Russell [Mon, 5 Oct 2020 16:23:36 +0000 (12:23 -0400)]
suggest `MAX` constant if -1 is assigned to unsigned type

3 years agoUpdate submodule llvm to get LVI bugfix
Raoul Strackx [Thu, 8 Oct 2020 15:43:26 +0000 (17:43 +0200)]
Update submodule llvm to get LVI bugfix

3 years ago`#[deny(unsafe_op_in_unsafe_fn)]` in sys/sgx
Caduser2020 [Tue, 29 Sep 2020 20:27:56 +0000 (15:27 -0500)]
`#[deny(unsafe_op_in_unsafe_fn)]` in sys/sgx

Run `./x.py` fmt

Add reference link

Fix reference link

Apply review suggestions.

3 years agoSuggest removing &mut from borrow of &mut
Lzu Tao [Thu, 8 Oct 2020 14:21:12 +0000 (14:21 +0000)]
Suggest removing &mut from borrow of &mut

Fix a typo: minding -> binding
Add test for &mut &mut

3 years agoAuto merge of #77678 - jyn514:tracing, r=Mark-Simulacrum
bors [Thu, 8 Oct 2020 13:38:29 +0000 (13:38 +0000)]
Auto merge of #77678 - jyn514:tracing, r=Mark-Simulacrum

Upgrade to tracing-subscriber 0.2.13

The primary motivation is to get the changes from
https://github.com/tokio-rs/tracing/pull/990. Example output:

```
$ RUSTDOC_LOG=debug rustdoc +rustc2
warning: some trace filter directives would enable traces that are disabled statically
 | `debug` would enable the DEBUG level for all targets
 = note: the static max level is `info`
 = help: to enable DEBUG logging, remove the `max_level_info` feature
```

r? `@Mark-Simulacrum`
cc `@hawkw` ❤️

3 years agoRemove not needed lambda.
Kazantcev Andrey [Thu, 8 Oct 2020 13:22:31 +0000 (16:22 +0300)]
Remove not needed lambda.

3 years agoMake `max_log_info` easily greppable
Joshua Nelson [Thu, 8 Oct 2020 13:16:27 +0000 (09:16 -0400)]
Make `max_log_info` easily greppable

3 years agoAuto merge of #77581 - ecstatic-morse:dataflow-dump-mir-graphviz, r=davidtwco
bors [Thu, 8 Oct 2020 11:42:24 +0000 (11:42 +0000)]
Auto merge of #77581 - ecstatic-morse:dataflow-dump-mir-graphviz, r=davidtwco

Use `pretty::create_dump_file` for dumping dataflow results

The old code wasn't incorporating promoteds into the path, meaning other `dot` files could get clobbered. Use the MIR dump infrastructure to generate paths so that this doesn't occur in the future.

3 years agoCommit suggestion
Kazantcev Andrey [Thu, 8 Oct 2020 10:58:51 +0000 (13:58 +0300)]
Commit suggestion

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoAuto merge of #77682 - Mark-Simulacrum:bump-stage0, r=pietroalbini
bors [Thu, 8 Oct 2020 09:50:35 +0000 (09:50 +0000)]
Auto merge of #77682 - Mark-Simulacrum:bump-stage0, r=pietroalbini

Bump to 1.48 bootstrap compiler

r? `@pietroalbini` (but anyone can feel free to review)

3 years agoAuto merge of #77644 - GuillaumeGomez:fix-tooltip-text-display, r=jyn514
bors [Thu, 8 Oct 2020 07:55:19 +0000 (07:55 +0000)]
Auto merge of #77644 - GuillaumeGomez:fix-tooltip-text-display, r=jyn514

Fix tooltip text display

Currently, when we hover the icon, the text doesn't show up:

![Screenshot from 2020-10-07 11-30-44](https://user-images.githubusercontent.com/3050060/95313768-cc402200-0890-11eb-95a4-a1ae8e38aee1.png)

The bug was spotted by `@Nemo157`

r? `@jyn514`

3 years agoAdd compile fail test for issue 27675
Andreas Molzer [Wed, 7 Oct 2020 17:49:52 +0000 (19:49 +0200)]
Add compile fail test for issue 27675

3 years agoAuto merge of #77631 - jyn514:helpful-changelog, r=RalfJung
bors [Thu, 8 Oct 2020 05:50:49 +0000 (05:50 +0000)]
Auto merge of #77631 - jyn514:helpful-changelog, r=RalfJung

Make src/bootstrap/CHANGELOG.md more helpful

Addresses https://github.com/rust-lang/rust/commit/fe6fc555acd51bd7ba8755d9fbc7060feb67be25#r42949241.

r? `@RalfJung`
cc `@Mark-Simulacrum`

3 years agoUse the new module information for intra-doc links
Joshua Nelson [Sun, 4 Oct 2020 15:56:55 +0000 (11:56 -0400)]
Use the new module information for intra-doc links

- Make the parent module conditional on whether the docs are on a re-export
- Make `resolve_link` take `&Item` instead of `&mut Item`

  Previously the borrow checker gave an error about multiple mutable
  borrows, because `dox` borrowed from `item`.

- Fix `crate::` for re-exports

  `crate` means something different depending on where the attribute
  came from.

- Make it work for `#[doc]` attributes too

  This required combining several attributes as one so they would keep
  the links.

3 years agoIntroduce `Divider`
Joshua Nelson [Sun, 4 Oct 2020 15:15:45 +0000 (11:15 -0400)]
Introduce `Divider`

This distinguishes between documentation on the original from docs on
the re-export

3 years agoPreserve the parent module of `DocFragment`s
Joshua Nelson [Sun, 4 Oct 2020 00:06:30 +0000 (20:06 -0400)]
Preserve the parent module of `DocFragment`s

- Add `parent_module` to `DocFragment`
- Require the `parent_module` of the item being inlined
- Preserve the hir_id for ExternCrates so rustdoc can find the parent module later
- Take an optional `parent_module` for `build_impl` and `merge_attrs`.
  Preserve the difference between parent modules for each doc-comment.
- Support arbitrarily many re-exports in from_ast. In retrospect this is
  probably not used and could be simplified to a single
  `Option<(Attrs, DefId)>`.
- Don't require the parent_module for all `impl`s, just inlined items

  In particular, this will be `None` whenever the attribute is not on a
  re-export.

- Only store the parent_module, not the HirId

  When re-exporting a re-export, the HirId is not available. Fortunately,
  `collect_intra_doc_links` doesn't actually need all the info from a
  HirId, just the parent module.

3 years agoAuto merge of #77683 - jyn514:git-hook, r=Mark-Simulacrum
bors [Thu, 8 Oct 2020 03:58:55 +0000 (03:58 +0000)]
Auto merge of #77683 - jyn514:git-hook, r=Mark-Simulacrum

Unset GIT_DIR in pre-commit hook

Works around https://github.com/rust-lang/rust/issues/77620. This won't help any other hooks you write manually, but hopefully people won't feel the need to do that now there's an 'official' one.

r? `@Mark-Simulacrum`
cc `@caass`

3 years agoAuto merge of #75470 - estebank:bare-type-expr, r=davidtwco
bors [Thu, 8 Oct 2020 01:37:27 +0000 (01:37 +0000)]
Auto merge of #75470 - estebank:bare-type-expr, r=davidtwco

Detect blocks that could be struct expr bodies

This approach lives exclusively in the parser, so struct expr bodies
that are syntactically correct on their own but are otherwise incorrect
will still emit confusing errors, like in the following case:

```rust
fn foo() -> Foo {
    bar: Vec::new()
}
```

```
error[E0425]: cannot find value `bar` in this scope
 --> src/file.rs:5:5
  |
5 |     bar: Vec::new()
  |     ^^^ expecting a type here because of type ascription

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 --> src/file.rs:5:15
  |
5 |     bar: Vec::new()
  |               ^^^^^ only `Fn` traits may use parentheses

error[E0107]: wrong number of type arguments: expected 1, found 0
 --> src/file.rs:5:10
  |
5 |     bar: Vec::new()
  |          ^^^^^^^^^^ expected 1 type argument
  ```

If that field had a trailing comma, that would be a parse error and it
would trigger the new, more targetted, error:

```
error: struct literal body without path
 --> file.rs:4:17
  |
4 |   fn foo() -> Foo {
  |  _________________^
5 | |     bar: Vec::new(),
6 | | }
  | |_^
  |
help: you might have forgotten to add the struct literal inside the block
  |
4 | fn foo() -> Foo { Path {
5 |     bar: Vec::new(),
6 | } }
  |
```

Partially address last remaining part of #34255.

3 years agoBump to 1.48 bootstrap compiler
Mark Rousskov [Wed, 7 Oct 2020 22:56:26 +0000 (18:56 -0400)]
Bump to 1.48 bootstrap compiler

3 years agoUnset GIT_DIR in pre-commit hook
Joshua Nelson [Wed, 7 Oct 2020 23:50:27 +0000 (19:50 -0400)]
Unset GIT_DIR in pre-commit hook

Works around https://github.com/rust-lang/rust/issues/77620

3 years agoAuto merge of #77597 - simonvandel:uninhabited-hashset, r=jonas-schievink
bors [Wed, 7 Oct 2020 23:44:57 +0000 (23:44 +0000)]
Auto merge of #77597 - simonvandel:uninhabited-hashset, r=jonas-schievink

perf: UninhabitedEnumBranching avoid n^2

Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants

I have only profiled locally against `match-stress-enum`, so we should have it perf tested to make sure it does not regress other crates.

3 years agoUpgrade to tracing 0.2.13
Joshua Nelson [Wed, 7 Oct 2020 22:45:59 +0000 (18:45 -0400)]
Upgrade to tracing 0.2.13

The primary motivation is to get the changes from
https://github.com/tokio-rs/tracing/pull/990. Example output:

```
$ RUSTDOC_LOG=debug rustdoc +rustc2
warning: some trace filter directives would enable traces that are disabled statically
 | `debug` would enable the DEBUG level for all targets
 = note: the static max level is `info`
 = help: to enable DEBUG logging, remove the `max_level_info` feature
```

- Remove useless test

  This was testing for an ICE when passing `RUST_LOG=rustc_middle`.  I
  noticed it because it started giving the tracing warning (because tests
  are not run with debug-logging enabled). Since this bug seems unlikely
  to re-occur, I just removed it altogether.

3 years agoAuto merge of #76985 - hbina:clone_check, r=estebank
bors [Wed, 7 Oct 2020 21:51:12 +0000 (21:51 +0000)]
Auto merge of #76985 - hbina:clone_check, r=estebank

Prevent stack overflow in deeply nested types.

Related issue #75577 (?)

Unfortunately, I am unable to test whether this actually solves the problem because apparently, 12GB RAM + 2GB swap is not enough to compile the (admittedly toy) source file.

3 years agoRemove unnecessary lamda on emitter map.
Kazantcev Andrey [Wed, 7 Oct 2020 21:29:20 +0000 (00:29 +0300)]
Remove unnecessary lamda on emitter map.

3 years agoDetect blocks that could be struct expr bodies
Esteban Küber [Wed, 12 Aug 2020 22:39:15 +0000 (15:39 -0700)]
Detect blocks that could be struct expr bodies

This approach lives exclusively in the parser, so struct expr bodies
that are syntactically correct on their own but are otherwise incorrect
will still emit confusing errors, like in the following case:

```rust
fn foo() -> Foo {
    bar: Vec::new()
}
```

```
error[E0425]: cannot find value `bar` in this scope
 --> src/file.rs:5:5
  |
5 |     bar: Vec::new()
  |     ^^^ expecting a type here because of type ascription

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 --> src/file.rs:5:15
  |
5 |     bar: Vec::new()
  |               ^^^^^ only `Fn` traits may use parentheses

error[E0107]: wrong number of type arguments: expected 1, found 0
 --> src/file.rs:5:10
  |
5 |     bar: Vec::new()
  |          ^^^^^^^^^^ expected 1 type argument
  ```

If that field had a trailing comma, that would be a parse error and it
would trigger the new, more targetted, error:

```
error: struct literal body without path
 --> file.rs:4:17
  |
4 |   fn foo() -> Foo {
  |  _________________^
5 | |     bar: Vec::new(),
6 | | }
  | |_^
  |
help: you might have forgotten to add the struct literal inside the block
  |
4 | fn foo() -> Foo { Path {
5 |     bar: Vec::new(),
6 | } }
  |
```

Partially address last part of #34255.

3 years agoperf: UninhabitedEnumBranching void n^2
Simon Vandel Sillesen [Mon, 5 Oct 2020 21:58:46 +0000 (23:58 +0200)]
perf: UninhabitedEnumBranching void n^2

Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants

3 years agoAuto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk
bors [Wed, 7 Oct 2020 19:59:52 +0000 (19:59 +0000)]
Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk

Give `impl Trait` in a `const fn` its own feature gate

...previously it was gated under `#![feature(const_fn)]`.

I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer.

cc #77463

r? `@oli-obk`

3 years ago(docs): make mutex error comment consistent with codebase
Steve Manuel [Wed, 7 Oct 2020 17:48:26 +0000 (11:48 -0600)]
(docs): make mutex error comment consistent with codebase

3 years agoAuto merge of #77617 - AnthonyMikh:slice_windows_no_bounds_checking, r=lcnr
bors [Wed, 7 Oct 2020 17:31:56 +0000 (17:31 +0000)]
Auto merge of #77617 - AnthonyMikh:slice_windows_no_bounds_checking, r=lcnr

Eliminate bounds checking in slice::Windows

This is how `<core::slice::Windows as Iterator>::next` looks right now:

```rust
fn next(&mut self) -> Option<&'a [T]> {
    if self.size > self.v.len() {
        None
    } else {
        let ret = Some(&self.v[..self.size]);
        self.v = &self.v[1..];
        ret
    }
}
```

The line with `self.v = &self.v[1..];` relies on assumption that `self.v` is definitely not empty at this point. Else branch is taken when `self.size <= self.v.len()`, so `self.v` can be empty if `self.size` is zero. In practice, since `Windows` is never created directly but rather trough `[T]::windows` which panics when `size` is zero, `self.size` is never zero. However, the compiler doesn't know about this check, so it keeps the code which checks bounds and panics.

Using `NonZeroUsize` lets the compiler know about this invariant and reliably eliminate bounds checking without `unsafe` on `-O2`. Here is assembly of `Windows<'a, u32>::next` before and after this change ([goldbolt](https://godbolt.org/z/xrefzx)):

<details>
<summary>Before</summary>

```
example::next:
        push    rax
        mov     rcx, qword ptr [rdi + 8]
        mov     rdx, qword ptr [rdi + 16]
        cmp     rdx, rcx
        jbe     .LBB0_2
        xor     eax, eax
        pop     rcx
        ret
.LBB0_2:
        test    rcx, rcx
        je      .LBB0_5
        mov     rax, qword ptr [rdi]
        mov     rsi, rax
        add     rsi, 4
        add     rcx, -1
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rcx
        pop     rcx
        ret
.LBB0_5:
        lea     rdx, [rip + .L__unnamed_1]
        mov     edi, 1
        xor     esi, esi
        call    qword ptr [rip + core::slice::slice_index_order_fail@GOTPCREL]
        ud2

.L__unnamed_2:
        .ascii  "./example.rs"

.L__unnamed_1:
        .quad   .L__unnamed_2
        .asciz  "\f\000\000\000\000\000\000\000\016\000\000\000\027\000\000"
```

</details>

<details>
<summary>After</summary>

```
example::next:
        mov     rcx, qword ptr [rdi + 8]
        mov     rdx, qword ptr [rdi + 16]
        cmp     rdx, rcx
        jbe     .LBB0_2
        xor     eax, eax
        ret
.LBB0_2:
        mov     rax, qword ptr [rdi]
        lea     rsi, [rax + 4]
        add     rcx, -1
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rcx
        ret
```

</details>

Note the lack of call to `core::slice::slice_index_order_fail` in second snippet.

#### Possible reasons _not_ to merge this PR:

* this changes the error message on panic in `[T]::windows`. However, AFAIK this messages are not covered by backwards compatibility policy.

3 years agoAuto merge of #77341 - davidtwco:issue-73427-you-might-have-meant-variant, r=estebank
bors [Wed, 7 Oct 2020 15:37:47 +0000 (15:37 +0000)]
Auto merge of #77341 - davidtwco:issue-73427-you-might-have-meant-variant, r=estebank

resolve: improve "try using the enum's variant"

Fixes #73427.

This PR improves the "try using the enum's variant" suggestion:

- Variants in suggestions would not result in more errors (e.g. use of a struct variant is only suggested if the suggestion can trivially construct that variant). Therefore, suggestions are only   emitted for variants that have no fields (since the suggestion can't know what value fields would have).
- Suggestions include the syntax for constructing the variant. If a struct or tuple variant is suggested, then it is constructed in the suggestion - unless in pattern-matching or when arguments are already provided.
- A help message is added which mentions the variants which are no longer suggested.

All of the diagnostic logic introduced by this PR is separated from the normal code path for a successful compilation.

r? `@estebank`

3 years agoAdd codegen test
AnthonyMikh [Tue, 6 Oct 2020 17:18:10 +0000 (20:18 +0300)]
Add codegen test

3 years agoAuto merge of #77595 - petrochenkov:asmident, r=oli-obk
bors [Wed, 7 Oct 2020 11:51:51 +0000 (11:51 +0000)]
Auto merge of #77595 - petrochenkov:asmident, r=oli-obk

builtin_macros: Fix use of interpolated identifiers in `asm!`

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

3 years agoAuto merge of #77119 - GuillaumeGomez:unclosed-html-tag-lint, r=jyn514
bors [Wed, 7 Oct 2020 09:56:51 +0000 (09:56 +0000)]
Auto merge of #77119 - GuillaumeGomez:unclosed-html-tag-lint, r=jyn514

Unclosed html tag lint

Part of #67799.

I think `@ollie27` will be interested (`@Manishearth` too since they opened the issue ;) ).

r? `@jyn514`

3 years agoFix tooltip text display
Guillaume Gomez [Wed, 7 Oct 2020 09:31:15 +0000 (11:31 +0200)]
Fix tooltip text display

3 years agoAuto merge of #77637 - ehuss:update-cargo, r=ehuss
bors [Wed, 7 Oct 2020 05:12:28 +0000 (05:12 +0000)]
Auto merge of #77637 - ehuss:update-cargo, r=ehuss

Update cargo

3 commits in 75615f8e69f748d7ef0df7bc0b064a9b1f5c78b2..9d1a4863abd9237dbf9d1b74c78632b6a205f6bb
2020-09-29 18:42:19 +0000 to 2020-10-05 18:29:52 +0000
- Add LTO to the metadata filename hash. (rust-lang/cargo#8755)
- Fix dylib+rlib with LTO. (rust-lang/cargo#8754)
- Homepage doc cargo metadata (rust-lang/cargo#8744)

3 years agoAuto merge of #77626 - tamird:parse-scope-id, r=dtolnay
bors [Wed, 7 Oct 2020 03:11:06 +0000 (03:11 +0000)]
Auto merge of #77626 - tamird:parse-scope-id, r=dtolnay

Parse SocketAddrV6::scope_id

r? `@dtolnay`

3 years agoAuto merge of #74194 - mbrubeck:slice-eq, r=sfackler
bors [Wed, 7 Oct 2020 01:20:11 +0000 (01:20 +0000)]
Auto merge of #74194 - mbrubeck:slice-eq, r=sfackler

Add PartialEq impls for Vec <-> slice

This is a follow-up to #71660 and rust-lang/rfcs#2917 to add two more missing vec/slice PartialEq impls:

```
impl<A, B> PartialEq<[B]> for Vec<A> where A: PartialEq<B> { .. }
impl<A, B> PartialEq<Vec<B>> for [A] where A: PartialEq<B> { .. }
```

Since this is insta-stable, it should go through the `@rust-lang/libs` FCP process.  Note that I used version 1.47.0 for the `stable` attribute because I assume this will not merge before the 1.46.0 branch is cut next week.

3 years agoUpdate cargo
Eric Huss [Wed, 7 Oct 2020 00:45:56 +0000 (17:45 -0700)]
Update cargo

3 years agoAuto merge of #77630 - Dylan-DPC:rollup-kfwl55z, r=Dylan-DPC
bors [Tue, 6 Oct 2020 23:07:17 +0000 (23:07 +0000)]
Auto merge of #77630 - Dylan-DPC:rollup-kfwl55z, r=Dylan-DPC

Rollup of 11 pull requests

Successful merges:

 - #76784 (Add some docs to rustdoc::clean::inline and def_id functions)
 - #76911 (fix VecDeque::iter_mut aliasing issues)
 - #77400 (Fix suggestions for x.py setup)
 - #77515 (Update to chalk 0.31)
 - #77568 (inliner: use caller param_env)
 - #77571 (Use matches! for core::char methods)
 - #77582 (Move `EarlyOtherwiseBranch` to mir-opt-level 2)
 - #77590 (Update RLS and Rustfmt)
 - #77605 (Fix rustc_def_path to show the full path and not the trimmed one)
 - #77614 (Let backends access span information)
 - #77624 (Add c as a shorthand check alternative for new options #77603)

Failed merges:

r? `@ghost`

3 years agoMake src/bootstrap/CHANGELOG.md more helpful
Joshua Nelson [Tue, 6 Oct 2020 22:28:01 +0000 (18:28 -0400)]
Make src/bootstrap/CHANGELOG.md more helpful

3 years agoRollup merge of #77624 - akoptelov:c-all-targets-fix, r=jyn514
Dylan DPC [Tue, 6 Oct 2020 22:16:16 +0000 (00:16 +0200)]
Rollup merge of #77624 - akoptelov:c-all-targets-fix, r=jyn514

Add c as a shorthand check alternative for new options #77603

There is a missing "c" that is a shorthand for "check" in newly added match arm for handling check-specific options.

3 years agoRollup merge of #77614 - khyperia:set_span, r=eddyb
Dylan DPC [Tue, 6 Oct 2020 22:16:14 +0000 (00:16 +0200)]
Rollup merge of #77614 - khyperia:set_span, r=eddyb

Let backends access span information

Sometimes, a backend may need to emit warnings, errors, or otherwise need to know the span of the current item in a basic block. So, add a `set_span` method to give the backend that information.

The `set_source_location` method already partially does this, however, it's disabled when debug info is disabled. There needs to be a way to unconditionally provide the span.

3 years agoRollup merge of #77605 - da-x:fix-rustc-def-path, r=petrochenkov
Dylan DPC [Tue, 6 Oct 2020 22:16:12 +0000 (00:16 +0200)]
Rollup merge of #77605 - da-x:fix-rustc-def-path, r=petrochenkov

Fix rustc_def_path to show the full path and not the trimmed one

Follow-up fix for #73996.

3 years agoRollup merge of #77590 - Xanewok:update-rls, r=dtolnay
Dylan DPC [Tue, 6 Oct 2020 22:16:10 +0000 (00:16 +0200)]
Rollup merge of #77590 - Xanewok:update-rls, r=dtolnay

Update RLS and Rustfmt

refs: https://github.com/rust-lang/rls/pull/1701

cc @calebcartwright

r? @dtolnay

3 years agoRollup merge of #77582 - ecstatic-morse:disable-early-otherwise-branch, r=wesleywiser
Dylan DPC [Tue, 6 Oct 2020 22:16:08 +0000 (00:16 +0200)]
Rollup merge of #77582 - ecstatic-morse:disable-early-otherwise-branch, r=wesleywiser

Move `EarlyOtherwiseBranch` to mir-opt-level 2

cc #75119

This didn't have an [effect in most cases](https://perf.rust-lang.org/compare.html?start=81e02708f1f4760244756548981277d5199baa9a&end=2e0edc0f28c5647141bedba02e7a222d3a5dc9c3&stat=instructions:u), and is not trivially sound. Let it bake at `mir-opt-level=2` for a while.

Also, this missed the cutoff for beta, so we'll have to backport this.
r? @wesleywiser

3 years agoRollup merge of #77571 - pickfire:patch-6, r=cramertj
Dylan DPC [Tue, 6 Oct 2020 22:16:07 +0000 (00:16 +0200)]
Rollup merge of #77571 - pickfire:patch-6, r=cramertj

Use matches! for core::char methods

3 years agoRollup merge of #77568 - lcnr:mir-inline-def-id, r=ecstatic-morse
Dylan DPC [Tue, 6 Oct 2020 22:16:05 +0000 (00:16 +0200)]
Rollup merge of #77568 - lcnr:mir-inline-def-id, r=ecstatic-morse

inliner: use caller param_env

We used the callee param env instead of the caller param env by accident in #77430, this PR fixes that and caches it in the `Inliner` struct.

fixes #77564

r? @ecstatic-morse

3 years agoRollup merge of #77515 - jackh726:chalk-0.31, r=matthewjasper
Dylan DPC [Tue, 6 Oct 2020 22:16:03 +0000 (00:16 +0200)]
Rollup merge of #77515 - jackh726:chalk-0.31, r=matthewjasper

Update to chalk 0.31

Gonna assign @nikomatsakis to the review here, but since he is pretty busy recently, if anyone else wants to review this, that would be much appreciated.

r? @nikomatsakis

3 years agoRollup merge of #77400 - alarsyo:xpy-setup-suggestions, r=jyn514
Dylan DPC [Tue, 6 Oct 2020 22:16:01 +0000 (00:16 +0200)]
Rollup merge of #77400 - alarsyo:xpy-setup-suggestions, r=jyn514

Fix suggestions for x.py setup

#76631 introduced a new `setup` command to x.py

By default the command prompts for a profile to use:

```
Welcome to the Rust project! What do you want to do with x.py?
a) Contribute to the standard library
b) Contribute to the compiler
c) Contribute to the compiler, and also modify LLVM or codegen
d) Install Rust from source
```

and then displays command suggestions, depending on which profile was chosen. However [the mapping between chosen profile](https://github.com/rust-lang/rust/blob/9cba260df0f1c67ea3690035cd5611a7465a1560/src/bootstrap/setup.rs#L75-L85) and [suggestion](https://github.com/rust-lang/rust/blob/9cba260df0f1c67ea3690035cd5611a7465a1560/src/bootstrap/setup.rs#L42-L47) isn't exact, leading to suggestions not being shown if the user presses `c` or `d`. (because "c" is translated to "llvm" and "d" to "maintainer", but suggestions trigger for "codegen" and "user" respectively)

A more thorough refactor would stop using "strings-as-type" to make sure this kind of error doesn't happen, but it may be overkill for that kind of "script" program?

Tagging the setup command author: @jyn514

3 years agoRollup merge of #76911 - RalfJung:vecdeque-aliasing, r=oli-obk
Dylan DPC [Tue, 6 Oct 2020 22:15:59 +0000 (00:15 +0200)]
Rollup merge of #76911 - RalfJung:vecdeque-aliasing, r=oli-obk

fix VecDeque::iter_mut aliasing issues

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

3 years agoRollup merge of #76784 - lzutao:rd_doc, r=GuillaumeGomez
Dylan DPC [Tue, 6 Oct 2020 22:15:58 +0000 (00:15 +0200)]
Rollup merge of #76784 - lzutao:rd_doc, r=GuillaumeGomez

Add some docs to rustdoc::clean::inline and def_id functions

Split from #76571 .

3 years agoParse SocketAddrV6::scope_id
Tamir Duberstein [Sun, 4 Oct 2020 21:56:48 +0000 (21:56 +0000)]
Parse SocketAddrV6::scope_id

3 years agoAvoid unused return
Tamir Duberstein [Sun, 4 Oct 2020 21:46:49 +0000 (21:46 +0000)]
Avoid unused return

3 years agoAuto merge of #77386 - joshtriplett:static-glibc, r=petrochenkov
bors [Tue, 6 Oct 2020 21:11:04 +0000 (21:11 +0000)]
Auto merge of #77386 - joshtriplett:static-glibc, r=petrochenkov

Support static linking with glibc and target-feature=+crt-static

With this change, it's possible to build on a linux-gnu target and pass
RUSTFLAGS='-C target-feature=+crt-static' or the equivalent via a
`.cargo/config.toml` file, and get a statically linked executable.

Update to libc 0.2.78, which adds support for static linking with glibc.

Add `crt_static_respected` to the `linux_base` target spec.

Update `android_base` and `linux_musl_base` accordingly. Avoid enabling
crt_static_respected on Android platforms, since that hasn't been
tested.

Closes https://github.com/rust-lang/rust/issues/65447.

3 years agoAdd c as a shorthand check alternative for new options #77603
Alexander Koptelov [Tue, 6 Oct 2020 19:04:14 +0000 (22:04 +0300)]
Add c as a shorthand check alternative for new options #77603

3 years agoUpdate error code page
Dylan MacKenzie [Tue, 6 Oct 2020 04:45:55 +0000 (21:45 -0700)]
Update error code page

3 years agoUpdate to chalk 0.31. Implement some unimplemented. Ignore some tests in compare...
Jack Huey [Sun, 4 Oct 2020 00:45:12 +0000 (20:45 -0400)]
Update to chalk 0.31. Implement some unimplemented. Ignore some tests in compare mode chalk don't finish.

3 years agoEliminate bounds checking in slice::Windows
AnthonyMikh [Tue, 6 Oct 2020 15:23:37 +0000 (18:23 +0300)]
Eliminate bounds checking in slice::Windows

3 years agoAuto merge of #76356 - caass:hooks, r=jyn514
bors [Tue, 6 Oct 2020 14:51:51 +0000 (14:51 +0000)]
Auto merge of #76356 - caass:hooks, r=jyn514

Add a command to install a git hook to automatically run `x.py test tidy --bless`

Some folks (such as myself) would probably find a lot of convenience in a pre-commit hook that automatically runs tidy before committing, to avoid burning CI time learning that your commit wasn't tidy.

I'm absolutely positive I have missed some stuff. I basically just got this to where you can run `./x.py run install-git-hook` and then clicked the commit button. Please let me know what else you'd like me to add before this can be merged!

[rustc-dev-guide companion PR](https://github.com/rust-lang/rustc-dev-guide/pull/848)

3 years agoUse String type for Profile parse error
Antoine Martin [Mon, 5 Oct 2020 16:03:54 +0000 (18:03 +0200)]
Use String type for Profile parse error

3 years agoShow available profiles on error
Antoine Martin [Mon, 5 Oct 2020 15:55:14 +0000 (17:55 +0200)]
Show available profiles on error

3 years agoUse Profile enum for x.py setup
Antoine Martin [Mon, 5 Oct 2020 15:27:42 +0000 (17:27 +0200)]
Use Profile enum for x.py setup

3 years agoFix suggestions for x.py setup
Antoine Martin [Thu, 1 Oct 2020 14:08:05 +0000 (16:08 +0200)]
Fix suggestions for x.py setup

3 years agoLet backends access span information
khyperia [Tue, 6 Oct 2020 13:39:12 +0000 (15:39 +0200)]
Let backends access span information

Sometimes, a backend may need to emit warnings, errors, or otherwise
need to know the span of the current item in a basic block. So, add a
set_span method to give the backend that information.

3 years agoAuto merge of #73905 - matthewjasper:projection-bounds-2, r=nikomatsakis
bors [Tue, 6 Oct 2020 12:26:54 +0000 (12:26 +0000)]
Auto merge of #73905 - matthewjasper:projection-bounds-2, r=nikomatsakis

Separate projection bounds and predicates

Follow up to #72788.

- Rename `projection_predicates` to `item_bounds`
- Separate bounds on associated types (the things after the `:` in `type X: ...`) and opaque types (the things after `impl`)  from predicates.
- Projection candidates now have the correct nested obligations
- Trait object candidates now check that the associated types on the trait object satisfy their bounds as nested obligations
- Type alias impl trait types are now checked (#73035)
- `feature(generic_associated_types)` no longer changes how we handle bounds (#73816)

Opening for a perf and crater runs.

r? `@nikomatsakis`

3 years agoFix NLL compare mode tests
Matthew Jasper [Tue, 6 Oct 2020 07:39:49 +0000 (08:39 +0100)]
Fix NLL compare mode tests

3 years agoDeduplicate some code
Matthew Jasper [Mon, 5 Oct 2020 16:19:24 +0000 (17:19 +0100)]
Deduplicate some code

3 years agoFix tests from rebase
Matthew Jasper [Mon, 7 Sep 2020 09:01:45 +0000 (10:01 +0100)]
Fix tests from rebase

3 years agoAvoid creating useless projection predicate
Matthew Jasper [Mon, 7 Sep 2020 08:38:09 +0000 (09:38 +0100)]
Avoid creating useless projection predicate

3 years agoFix rebase
Matthew Jasper [Sun, 6 Sep 2020 19:04:52 +0000 (20:04 +0100)]
Fix rebase

3 years agoDeduplicate item bounds after normalization
Matthew Jasper [Sat, 15 Aug 2020 19:31:07 +0000 (20:31 +0100)]
Deduplicate item bounds after normalization

3 years agoDon't require lifetime super-bounds on traits apply to trait objects of that trait
Matthew Jasper [Sat, 15 Aug 2020 11:29:23 +0000 (12:29 +0100)]
Don't require lifetime super-bounds on traits apply to trait objects of that trait

3 years agoNormalize super trait bounds when confirming object candidates
Matthew Jasper [Fri, 14 Aug 2020 20:51:28 +0000 (21:51 +0100)]
Normalize super trait bounds when confirming object candidates

3 years agoFix rebase
Matthew Jasper [Fri, 14 Aug 2020 20:41:20 +0000 (21:41 +0100)]
Fix rebase

3 years agoDon't immediately error for recursive projections
Matthew Jasper [Sat, 25 Jul 2020 20:27:34 +0000 (21:27 +0100)]
Don't immediately error for recursive projections

3 years agoFix bootstrap
Matthew Jasper [Sat, 25 Jul 2020 14:14:12 +0000 (15:14 +0100)]
Fix bootstrap

3 years agoHandle multiple trait-def projection candidates
Matthew Jasper [Sat, 25 Jul 2020 13:00:13 +0000 (14:00 +0100)]
Handle multiple trait-def projection candidates

3 years agoAvoid cycles from projection bounds
Matthew Jasper [Sat, 25 Jul 2020 12:41:53 +0000 (13:41 +0100)]
Avoid cycles from projection bounds

Only check the own predicates of associated types when confirming
projection candidates.
Also consider implied bounds when comparing trait and impl methods.

3 years agoAvoid cycle with projections from object types
Matthew Jasper [Fri, 24 Jul 2020 20:59:43 +0000 (21:59 +0100)]
Avoid cycle with projections from object types

Normalizing `<dyn Iterator<Item = ()> as Iterator>::Item` no longer
requires selecting `dyn Iterator<Item = ()>: Iterator`. This was
previously worked around by using a special type-folder to normalize
things.

3 years agoNormalize projection bounds when considering candidates
Matthew Jasper [Fri, 24 Jul 2020 18:10:22 +0000 (19:10 +0100)]
Normalize projection bounds when considering candidates

This unfortunately requires some winnowing hacks to avoid
now ambiguous candidates.