]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #81834 - ortem:fix-LLDB-hashmap-pretty-printers, r=Mark-Simulacrum
Dylan DPC [Tue, 9 Feb 2021 01:39:55 +0000 (02:39 +0100)]
Rollup merge of #81834 - ortem:fix-LLDB-hashmap-pretty-printers, r=Mark-Simulacrum

Resolve typedef in HashMap lldb pretty-printer only if possible

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

Previously, `GetTypedefedType` was invoked unconditionally.
But this did not work in case of `rust-lldb` without Rust patches since there was no typedef.

3 years agoRollup merge of #81826 - tesuji:inline-box-zeros, r=Amanieu
Dylan DPC [Tue, 9 Feb 2021 01:39:53 +0000 (02:39 +0100)]
Rollup merge of #81826 - tesuji:inline-box-zeros, r=Amanieu

Prefer match over combinators to make some Box methods inlineable

Hopefully this patch would make two snippets generated identical code: <https://rust.godbolt.org/z/fjrj4E>.

3 years agoRollup merge of #81697 - xfix:every-doc-alias, r=Mark-Simulacrum
Dylan DPC [Tue, 9 Feb 2021 01:39:51 +0000 (02:39 +0100)]
Rollup merge of #81697 - xfix:every-doc-alias, r=Mark-Simulacrum

Add "every" as a doc alias for "all".

This matches [Array#every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) in JavaScript.

Oddly enough, `core::iter::Iterator::all` appears twice. This appears to be a rustdoc bug which I decided to fill in as #81696.

![image](https://user-images.githubusercontent.com/1297598/106717890-94f43e80-6600-11eb-9428-2cd425823df9.png)

3 years agoRollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikomatsakis
Dylan DPC [Tue, 9 Feb 2021 01:39:50 +0000 (02:39 +0100)]
Rollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikomatsakis

Allow Trait inheritance with cycles on associated types take 2

This reverts the revert of #79209 and fixes the ICEs that's occasioned by that PR exposing some problems that are addressed in #80648 and #79811.
For easier review I'd say, check only the last commit, the first one is just a revert of the revert of #79209 which was already approved.

This also could be considered part or the actual fix of #79560 but I guess for that to be closed and fixed completely we would need to land #80648 and #79811 too.

r? `@nikomatsakis`
cc `@Aaron1011`

3 years agoRollup merge of #72209 - Nemo157:lint-no-mangle-in-unsafe-code, r=nikomatsakis
Dylan DPC [Tue, 9 Feb 2021 01:39:45 +0000 (02:39 +0100)]
Rollup merge of #72209 - Nemo157:lint-no-mangle-in-unsafe-code, r=nikomatsakis

Add checking for no_mangle to unsafe_code lint

fixes #72188

r? `@estebank`

3 years agoAuto merge of #81889 - m-ou-se:rollup-k63log3, r=m-ou-se
bors [Mon, 8 Feb 2021 20:52:54 +0000 (20:52 +0000)]
Auto merge of #81889 - m-ou-se:rollup-k63log3, r=m-ou-se

Rollup of 9 pull requests

Successful merges:

 - #71531 (Move treat err as bug tests to ui)
 - #81356 (libtest: allow multiple filters)
 - #81735 (faster few span methods)
 - #81779 (improve error message for disallowed ptr-to-int casts in const eval)
 - #81817 (Add option to emit compiler stderr per bitwidth.)
 - #81828 (parse_format: treat r" as a literal)
 - #81840 (fix formatting of std::iter::Map)
 - #81861 (Show MIR bytes separately in -Zmeta-stats output)
 - #81865 (Clean up weird Option mapping)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoAnonymize late bound regions on transitive bounds that define assoc type
Santiago Pastorino [Fri, 5 Feb 2021 18:52:57 +0000 (15:52 -0300)]
Anonymize late bound regions on transitive bounds that define assoc type

3 years agoRollup merge of #81865 - bugadani:typeck2, r=jyn514
Mara Bos [Mon, 8 Feb 2021 18:28:25 +0000 (19:28 +0100)]
Rollup merge of #81865 - bugadani:typeck2, r=jyn514

Clean up weird Option mapping

3 years agoRollup merge of #81861 - tmiasko:mir-bytes, r=wesleywiser
Mara Bos [Mon, 8 Feb 2021 18:28:23 +0000 (19:28 +0100)]
Rollup merge of #81861 - tmiasko:mir-bytes, r=wesleywiser

Show MIR bytes separately in -Zmeta-stats output

The size of serialized MIR is substantial enough to deserve its own category.

3 years agoRollup merge of #81840 - ibraheemdev:patch-1, r=dtolnay
Mara Bos [Mon, 8 Feb 2021 18:28:22 +0000 (19:28 +0100)]
Rollup merge of #81840 - ibraheemdev:patch-1, r=dtolnay

fix formatting of std::iter::Map

3 years agoRollup merge of #81828 - davidhewitt:capture-raw-format-strings, r=estebank
Mara Bos [Mon, 8 Feb 2021 18:28:20 +0000 (19:28 +0100)]
Rollup merge of #81828 - davidhewitt:capture-raw-format-strings, r=estebank

parse_format: treat r" as a literal

This PR changes `format_args!` internal parsing machinery to treat raw strings starting `r"` as a literal.

Currently `"` and `r#` are recognised as valid starting combinations for string literals, but `r"` is not.

This was noticed when debugging https://github.com/rust-lang/rust/issues/67984#issuecomment-753413156

As well as fixing the behavior observed in that comment, this improves diagnostic spans for `r"` formatting strings.

3 years agoRollup merge of #81817 - hameerabbasi:mcp-635, r=oli-obk
Mara Bos [Mon, 8 Feb 2021 18:28:18 +0000 (19:28 +0100)]
Rollup merge of #81817 - hameerabbasi:mcp-635, r=oli-obk

Add option to emit compiler stderr per bitwidth.

See rust-lang/compiler-team#365

r? `@oli-obk`

3 years agoRollup merge of #81779 - geogriff:const-ptr-to-int-error, r=lcnr
Mara Bos [Mon, 8 Feb 2021 18:28:17 +0000 (19:28 +0100)]
Rollup merge of #81779 - geogriff:const-ptr-to-int-error, r=lcnr

improve error message for disallowed ptr-to-int casts in const eval

Improves an error message as [suggested](https://github.com/rust-lang/rust/issues/80875#issuecomment-762754580) in #80875.

Does the wording make enough sense? I tried to follow precedent for error message style while maintaining brevity.

It seems like the rest of the `ConstEvalErrKind::NeedsRfc` error messages could be improved as well. I could give that a go if this approach works.

Closes #80875

3 years agoRollup merge of #81735 - klensy:span-fix, r=varkor
Mara Bos [Mon, 8 Feb 2021 18:28:15 +0000 (19:28 +0100)]
Rollup merge of #81735 - klensy:span-fix, r=varkor

faster few span methods

Touched few methods, so it should be (hopefully) faster.

First two changes: instead splitting string from start and taking only last piece, split it from the end.
Last: swapped conditions, to first check boolean parameter.

3 years agoRollup merge of #81356 - ehuss:libtest-filters, r=m-ou-se
Mara Bos [Mon, 8 Feb 2021 18:28:13 +0000 (19:28 +0100)]
Rollup merge of #81356 - ehuss:libtest-filters, r=m-ou-se

libtest: allow multiple filters

Libtest ignores any filters after the first. This changes it so that if multiple filters are passed, it will test against all of them.

This also affects compiletest to do the same.

Closes #30422

3 years agoRollup merge of #71531 - spastorino:move-treat-err-as-bug-tests-to-ui, r=oli-obk
Mara Bos [Mon, 8 Feb 2021 18:28:09 +0000 (19:28 +0100)]
Rollup merge of #71531 - spastorino:move-treat-err-as-bug-tests-to-ui, r=oli-obk

Move treat err as bug tests to ui

cc `@oli-obk`

3 years agoAuto merge of #81313 - LeSeulArtichaut:revert-32558, r=jyn514
bors [Mon, 8 Feb 2021 10:46:10 +0000 (10:46 +0000)]
Auto merge of #81313 - LeSeulArtichaut:revert-32558, r=jyn514

Restore linking to itself in implementors section of trait page

Reverts #32558 as proposed in [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Trait.20implementation.20self-links/near/223773273)
r? `@jyn514` cc `@camelid`

3 years agoAuto merge of #79245 - ssomers:btree_curb_ord_bound, r=dtolnay
bors [Mon, 8 Feb 2021 07:56:04 +0000 (07:56 +0000)]
Auto merge of #79245 - ssomers:btree_curb_ord_bound, r=dtolnay

BTree: remove Ord bound where it is absent elsewhere

Some btree methods don't really need an Ord bound and don't have one, while some methods that more obviously don't need it, do have one.

An example of the former is `iter`, even though it explicitly exposes the work of the Ord implementation (["sorted by key"](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.iter) - but I'm not suggesting it should have the Ord bound). An example of the latter is `new`, which doesn't involve any keys whatsoever.

3 years agoAuto merge of #80962 - jhpratt:const_int_fn-stabilization, r=dtolnay
bors [Mon, 8 Feb 2021 05:05:55 +0000 (05:05 +0000)]
Auto merge of #80962 - jhpratt:const_int_fn-stabilization, r=dtolnay

Stabilize remaining integer methods as `const fn`

This pull request stabilizes the following methods as `const fn`:

- `i*::checked_div`
- `i*::checked_div_euclid`
- `i*::checked_rem`
- `i*::checked_rem_euclid`
- `i*::div_euclid`
- `i*::overflowing_div`
- `i*::overflowing_div_euclid`
- `i*::overflowing_rem`
- `i*::overflowing_rem_euclid`
- `i*::rem_euclid`
- `i*::wrapping_div`
- `i*::wrapping_div_euclid`
- `i*::wrapping_rem`
- `i*::wrapping_rem_euclid`
- `u*::checked_div`
- `u*::checked_div_euclid`
- `u*::checked_rem`
- `u*::checked_rem_euclid`
- `u*::div_euclid`
- `u*::overflowing_div`
- `u*::overflowing_div_euclid`
- `u*::overflowing_rem`
- `u*::overflowing_rem_euclid`
- `u*::rem_euclid`
- `u*::wrapping_div`
- `u*::wrapping_div_euclid`
- `u*::wrapping_rem`
- `u*::wrapping_rem_euclid`

These can all be implemented on the current stable (1.49). There are two unstable details: const likely/unlikely and unchecked division/remainder. Both of these are for optimizations, and are in no way required to make the methods function; there is no exposure of these details publicly. Per comments below, it seems best practice is to stabilize the intrinsics. As such, `intrinsics::unchecked_div` and `intrinsics::unchecked_rem` have been stabilized as `const` as part of this pull request as well. The methods themselves remain unstable.

I believe part of the reason these were not stabilized previously was the behavior around division by 0 and modulo 0. After testing on nightly, the diagnostic for something like `const _: i8 = 5i8 % 0i8;` is similar to that of `const _: i8 = 5i8.rem_euclid(0i8);` (assuming the appropriate feature flag is enabled). As such, I believe these methods are ready to be stabilized as `const fn`.

This pull request represents the final methods mentioned in #53718. As such, this PR closes #53718.

`@rustbot` modify labels to +A-const-fn, +T-libs

3 years agoAuto merge of #72603 - jsgf:extern-loc, r=nikomatsakis
bors [Mon, 8 Feb 2021 02:23:17 +0000 (02:23 +0000)]
Auto merge of #72603 - jsgf:extern-loc, r=nikomatsakis

Implement `--extern-location`

This PR implements `--extern-location` as a followup to #72342 as part of the implementation of #57274. The goal of this PR is to allow rustc, in coordination with the build system, to present a useful diagnostic about how to remove an unnecessary dependency from a dependency specification file (eg Cargo.toml).

EDIT: Updated to current PR state.

The location is specified for each named crate - that is, for a given `--extern foo[=path]` there can also be `--extern-location foo=<location>`. It supports ~~three~~ two styles of location:
~~1. `--extern-location foo=file:<path>:<line>` - a file path and line specification
1. `--extern-location foo=span:<path>:<start>:<end>` - a span specified as a file and start and end byte offsets~~
1. `--extern-location foo=raw:<anything>` - a raw string which is included in the output
1. `--extern-location foo=json:<anything>` - an arbitrary Json structure which is emitted via Json diagnostics in a `tool_metadata` field.

~~1 & 2 are turned into an internal `Span`, so long as the path exists and is readable, and the location is meaningful (within the file, etc). This is used as the `Span` for a fix suggestion which is reported like other fix suggestions.~~

`raw` and `json` are for the case where the location isn't best expressed as a file and location within that file. For example, it could be a rule name and the name of a dependency within that rule. `rustc` makes no attempt to parse the raw string, and simply includes it in the output diagnostic text. `json` is only included in json diagnostics. `raw` is emitted as text and also as a json string in `tool_metadata`.

If no `--extern-location` option is specified then it will emit a default json structure consisting of `{"name": name, "path": path}` corresponding to the name and path in `--extern name=path`.

This is a prototype/RFC to make some of the earlier conversations more concrete. It doesn't stand on its own - it's only useful if implemented by Cargo and other build systems. There's also a ton of implementation details which I'd appreciate a second eye on as well.

~~**NOTE** The first commit in this PR is #72342 and should be ignored for the purposes of review. The first commit is a very simplistic implementation which is basically raw-only, presented as a MVP. The second implements the full thing, and subsequent commits are incremental fixes.~~

cc `@ehuss` `@est31` `@petrochenkov` `@estebank`

3 years agofix formatting of std::iter::Map
Ibraheem Ahmed [Sat, 6 Feb 2021 20:47:12 +0000 (15:47 -0500)]
fix formatting of std::iter::Map

3 years agoClean up weird option mapping
Dániel Buga [Sun, 7 Feb 2021 22:05:15 +0000 (23:05 +0100)]
Clean up weird option mapping

3 years agoMake sure all fields are accounted for in `encode_fields!`
Jeremy Fitzhardinge [Sun, 7 Feb 2021 04:29:04 +0000 (20:29 -0800)]
Make sure all fields are accounted for in `encode_fields!`

This will make sure the encoder will get updated if any new fields are
added to Diagnostic.

3 years agoImplement Encoder for Diagnostic manually
Jeremy Fitzhardinge [Mon, 18 Jan 2021 22:10:31 +0000 (14:10 -0800)]
Implement Encoder for Diagnostic manually

...so we can skip serializing `tool_metadata` if it hasn't been set.
This makes the output a bit cleaner, and avoiding having to update a
bunch of unrelated tests.

3 years agoAdd `--extern-loc` to augment unused crate dependency diagnostics
Jeremy Fitzhardinge [Mon, 25 May 2020 23:21:25 +0000 (16:21 -0700)]
Add `--extern-loc` to augment unused crate dependency diagnostics

This allows a build system to indicate a location in its own dependency
specification files (eg Cargo's `Cargo.toml`) which can be reported
along side any unused crate dependency.

This supports several types of location:
 - 'json' - provide some json-structured data, which is included in the json diagnostics
     in a `tool_metadata` field
 - 'raw' - emit the provided string into the output. This also appears as a json string in
     `tool_metadata`.

If no `--extern-location` is explicitly provided then a default json entry of the form
`"tool_metadata":{"name":<cratename>,"path":<cratepath>}` is emitted.

3 years agoAuto merge of #80652 - calebzulawski:simd-lanes, r=nagisa
bors [Sun, 7 Feb 2021 22:25:14 +0000 (22:25 +0000)]
Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa

Improve SIMD type element count validation

Resolves rust-lang/stdsimd#53.

These changes are motivated by `stdsimd` moving in the direction of const generic vectors, e.g.:
```rust
#[repr(simd)]
struct SimdF32<const N: usize>([f32; N]);
```

This makes a few changes:
* Establishes a maximum SIMD lane count of 2^16 (65536).  This value is arbitrary, but attempts to validate lane count before hitting potential errors in the backend.  It's not clear what LLVM's maximum lane count is, but cranelift's appears to be much less than `usize::MAX`, at least.
* Expands some SIMD intrinsics to support arbitrary lane counts.  This resolves the ICE in the linked issue.
* Attempts to catch invalid-sized vectors during typeck when possible.

Unresolved questions:
* Generic-length vectors can't be validated in typeck and are only validated after monomorphization while computing layout.  This "works", but the errors simply bail out with no context beyond the name of the type.  Should these errors instead return `LayoutError` or otherwise provide context in some way?  As it stands, users of `stdsimd` could trivially produce monomorphization errors by making zero-length vectors.

cc `@bjorn3`

3 years agoAuto merge of #79078 - petrochenkov:derattr, r=Aaron1011
bors [Sun, 7 Feb 2021 19:36:10 +0000 (19:36 +0000)]
Auto merge of #79078 - petrochenkov:derattr, r=Aaron1011

expand/resolve: Turn `#[derive]` into a regular macro attribute

This PR turns `#[derive]` into a regular attribute macro declared in libcore and defined in `rustc_builtin_macros`, like it was previously done with other "active" attributes in https://github.com/rust-lang/rust/pull/62086, https://github.com/rust-lang/rust/pull/62735 and other PRs.
This PR is also a continuation of #65252, #69870 and other PRs linked from them, which layed the ground for converting `#[derive]` specifically.

`#[derive]` still asks `rustc_resolve` to resolve paths inside `derive(...)`, and `rustc_expand` gets those resolution results through some backdoor (which I'll try to address later), but otherwise `#[derive]` is treated as any other macro attributes, which simplifies the resolution-expansion infra pretty significantly.

The change has several observable effects on language and library.
Some of the language changes are **feature-gated** by [`feature(macro_attributes_in_derive_output)`](https://github.com/rust-lang/rust/issues/81119).

#### Library

- `derive` is now available through standard library as `{core,std}::prelude::v1::derive`.

#### Language

- `derive` now goes through name resolution, so it can now be renamed - `use derive as my_derive; #[my_derive(Debug)] struct S;`.
- `derive` now goes through name resolution, so this resolution can fail in corner cases. Crater found one such regression, where import `use foo as derive` goes into a cycle with `#[derive(Something)]`.
- **[feature-gated]** `#[derive]` is now expanded as any other attributes in left-to-right order. This allows to remove the restriction on other macro attributes following `#[derive]` (https://github.com/rust-lang/reference/issues/566). The following macro attributes become a part of the derive's input (this is not a change, non-macro attributes following `#[derive]` were treated in the same way previously).
- `#[derive]` is now expanded as any other attributes in left-to-right order. This means two derive attributes `#[derive(Foo)] #[derive(Bar)]` are now expanded separately rather than together. It doesn't generally make difference, except for esoteric cases. For example `#[derive(Foo)]` can now produce an import bringing `Bar` into scope, but previously both `Foo` and `Bar` were required to be resolved before expanding any of them.
- **[feature-gated]** `#[derive()]` (with empty list in parentheses) actually becomes useful. For historical reasons `#[derive]` *fully configures* its input, eagerly evaluating `cfg` everywhere in its target, for example on fields.
Expansion infra doesn't do that for other attributes, but now when macro attributes attributes are allowed to be written after `#[derive]`, it means that derive can *fully configure* items for them.
    ```rust
#[derive()]
#[my_attr]
struct S {
#[cfg(FALSE)] // this field in removed by `#[derive()]` and not observed by `#[my_attr]`
field: u8
}
    ```
- `#[derive]` on some non-item targets is now prohibited. This was accidentally allowed as noop in the past, but was warned about since early 2018 (#50092), despite that crater found a few such cases in unmaintained crates.
- Derive helper attributes used before their introduction are now reported with a deprecation lint. This change is long overdue (since macro modularization, https://github.com/rust-lang/rust/issues/52226#issuecomment-422605033), but it was hard to do without fixing expansion order for derives. The deprecation is tracked by #79202.
```rust
    #[trait_helper] // warning: derive helper attribute is used before it is introduced
    #[derive(Trait)]
    struct S {}
```

Crater analysis: https://github.com/rust-lang/rust/pull/79078#issuecomment-731436821

3 years agoRemove treat-err-as-bug delay_span_bug test from run-make-fulldeps
Santiago Pastorino [Sun, 7 Feb 2021 04:50:17 +0000 (01:50 -0300)]
Remove treat-err-as-bug delay_span_bug test from run-make-fulldeps

3 years agoCreate ui test for -Ztreat-err-as-bug delay_span_bug
Santiago Pastorino [Sun, 7 Feb 2021 04:44:29 +0000 (01:44 -0300)]
Create ui test for -Ztreat-err-as-bug delay_span_bug

3 years agoAddress review comments
Vadim Petrochenkov [Sun, 7 Feb 2021 16:26:33 +0000 (19:26 +0300)]
Address review comments

3 years agoFeature gate macro attributes in `#[derive]` output
Vadim Petrochenkov [Sun, 17 Jan 2021 13:05:02 +0000 (16:05 +0300)]
Feature gate macro attributes in `#[derive]` output

3 years agoexpand/resolve: Turn `#[derive]` into a regular macro attribute
Vadim Petrochenkov [Sat, 14 Nov 2020 11:47:14 +0000 (14:47 +0300)]
expand/resolve: Turn `#[derive]` into a regular macro attribute

3 years agoAuto merge of #80632 - Nadrieril:fix-80501, r=varkor
bors [Sun, 7 Feb 2021 16:48:57 +0000 (16:48 +0000)]
Auto merge of #80632 - Nadrieril:fix-80501, r=varkor

Identify unreachable subpatterns more reliably

In https://github.com/rust-lang/rust/pull/80104 I used `Span`s to identify unreachable sub-patterns in the presence of or-patterns during exhaustiveness checking. In https://github.com/rust-lang/rust/issues/80501 it was revealed that `Span`s are complicated and that this was not a good idea.
Instead, this PR identifies subpatterns logically: as a path in the tree of subpatterns of a given pattern. I made a struct that captures a set of such subpatterns. This is a bit complex, but thankfully self-contained; the rest of the code does not need to know anything about it.
Fixes https://github.com/rust-lang/rust/issues/80501. I think I managed to keep the perf neutral.

r? `@varkor`

3 years agoAuto merge of #81853 - GuillaumeGomez:rollup-xzh1z4v, r=GuillaumeGomez
bors [Sun, 7 Feb 2021 13:57:24 +0000 (13:57 +0000)]
Auto merge of #81853 - GuillaumeGomez:rollup-xzh1z4v, r=GuillaumeGomez

Rollup of 5 pull requests

Successful merges:

 - #81526 (btree: use Option's unwrap_unchecked())
 - #81742 (Add a note about the correctness and the effect on unsafe code to the `ExactSizeIterator` docs)
 - #81830 (Add long error explanation for E0542)
 - #81835 (Improve long explanation for E0546)
 - #81843 (Add regression test for #29821)

Failed merges:

 - #81836 (Add long explanation for E0547)

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #81843 - bstrie:issue-29821, r=lcnr
Guillaume Gomez [Sun, 7 Feb 2021 13:45:56 +0000 (14:45 +0100)]
Rollup merge of #81843 - bstrie:issue-29821, r=lcnr

Add regression test for #29821

Closes #29821

3 years agoRollup merge of #81835 - jesusprubio:improve-long-eplanation-e0546, r=GuillaumeGomez
Guillaume Gomez [Sun, 7 Feb 2021 13:45:54 +0000 (14:45 +0100)]
Rollup merge of #81835 - jesusprubio:improve-long-eplanation-e0546, r=GuillaumeGomez

Improve long explanation for E0546

Helps with #61137

3 years agoRollup merge of #81830 - jesusprubio:add-log-explanation-e0542, r=GuillaumeGomez
Guillaume Gomez [Sun, 7 Feb 2021 13:45:53 +0000 (14:45 +0100)]
Rollup merge of #81830 - jesusprubio:add-log-explanation-e0542, r=GuillaumeGomez

Add long error explanation for E0542

Helps with #61137

3 years agoRollup merge of #81742 - sdroege:exact-size-iterator-correctness, r=kennytm
Guillaume Gomez [Sun, 7 Feb 2021 13:45:51 +0000 (14:45 +0100)]
Rollup merge of #81742 - sdroege:exact-size-iterator-correctness, r=kennytm

Add a note about the correctness and the effect on unsafe code to the `ExactSizeIterator` docs

As it is a safe trait it does not provide any guarantee that the
returned length is correct and as such unsafe code must not rely on it.

That's why `TrustedLen` exists.

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

3 years agoRollup merge of #81526 - ojeda:btree-use-unwrap_unchecked, r=scottmcm
Guillaume Gomez [Sun, 7 Feb 2021 13:45:46 +0000 (14:45 +0100)]
Rollup merge of #81526 - ojeda:btree-use-unwrap_unchecked, r=scottmcm

btree: use Option's unwrap_unchecked()

Now that https://github.com/rust-lang/rust/issues/81383 is available, start using it.

3 years agoAuto merge of #81502 - CraftSpider:method-abi, r=jyn514
bors [Sun, 7 Feb 2021 10:59:41 +0000 (10:59 +0000)]
Auto merge of #81502 - CraftSpider:method-abi, r=jyn514

Add abi field to `Method`

Also bumps version and adds a test (Will conflict with #81500, whichever is merged first)

Rationale: It's possible for methods to have an ABI. This should be exposed in the JSON.

3 years agoAuto merge of #81498 - thomaseizinger:ice-workaround-56935-rustc-index, r=matthewjasper
bors [Sun, 7 Feb 2021 08:09:58 +0000 (08:09 +0000)]
Auto merge of #81498 - thomaseizinger:ice-workaround-56935-rustc-index, r=matthewjasper

Apply workaround from #72003 for #56935 to allow for cross-compilation of `rustc_index` crate

This patch applies the same workaround as #72003 to the `rustc_index` crate. This allows recent versions of rustfmt to compile to wasm again.

Related: #72017.

3 years agoAuto merge of #81462 - osa1:issue75158, r=Mark-Simulacrum
bors [Sun, 7 Feb 2021 05:22:14 +0000 (05:22 +0000)]
Auto merge of #81462 - osa1:issue75158, r=Mark-Simulacrum

Add test for #75158

This also shifts some type-size related tests into a new directory, so that we keep the number of files at the root down.

Closes #75158

3 years agoRemove treat-err-as-bug err test from run-make-fulldeps
Santiago Pastorino [Sun, 7 Feb 2021 04:49:35 +0000 (01:49 -0300)]
Remove treat-err-as-bug err test from run-make-fulldeps

3 years agoCreate ui test for -Ztreat-err-as-bug err
Santiago Pastorino [Fri, 24 Apr 2020 20:22:55 +0000 (17:22 -0300)]
Create ui test for -Ztreat-err-as-bug err

3 years agoAuto merge of #81821 - nikic:update-wasm32, r=sanxiyn
bors [Sun, 7 Feb 2021 02:36:08 +0000 (02:36 +0000)]
Auto merge of #81821 - nikic:update-wasm32, r=sanxiyn

Upgrade wasm32 image to Ubuntu 20.04

This switches the wasm32 image, which is used to test
wasm32-unknown-emscripten, to Ubuntu 20.04. While at it, enable
most of the excluded tests, as they seem to work fine with some
minor fixes.

3 years agoShow MIR bytes separately in -Zmeta-stats output
Tomasz Miąsko [Sun, 7 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Show MIR bytes separately in -Zmeta-stats output

3 years agoAuto merge of #78052 - da-x:path-trimming-type-aliases, r=davidtwco
bors [Sat, 6 Feb 2021 23:44:42 +0000 (23:44 +0000)]
Auto merge of #78052 - da-x:path-trimming-type-aliases, r=davidtwco

path trimming: ignore type aliases

Continuation of #73996.

3 years agoRemove accidentally left-behind git mark
Rune Tynan [Sat, 6 Feb 2021 22:37:36 +0000 (17:37 -0500)]
Remove accidentally left-behind git mark

3 years agoAdd regression test for #29821
bstrie [Sat, 6 Feb 2021 21:58:52 +0000 (16:58 -0500)]
Add regression test for #29821

Closes #29821

3 years agoAuto merge of #80883 - GuillaumeGomez:remove-some-function-fields, r=ollie27
bors [Sat, 6 Feb 2021 20:55:36 +0000 (20:55 +0000)]
Auto merge of #80883 - GuillaumeGomez:remove-some-function-fields, r=ollie27

Remove some function fields

Same kind as #80845.

This PR removes the `all_types` and `ret_types` from the `clean::Function` type.

Another change that I had to do was implementing the `From` trait to be able to convert `hir::def::DefKind` into `clean::TypeKind` without requiring `DocContext` (and so I updated the `clean` method so that it's taken into account).

The last two commits improve a bit the `get_real_types` function and the `Type::generics` method.

r? `@jyn514`

3 years agoRestore linking to itself in implementors section of trait page
LeSeulArtichaut [Sat, 23 Jan 2021 22:51:06 +0000 (23:51 +0100)]
Restore linking to itself in implementors section of trait page

3 years agoTypo fix
Jesus Rubio [Sat, 6 Feb 2021 18:45:43 +0000 (19:45 +0100)]
Typo fix

3 years agoReferences added
Jesus Rubio [Sat, 6 Feb 2021 18:44:09 +0000 (19:44 +0100)]
References added

3 years agoComments updated to keep the consistency
Jesus Rubio [Sat, 6 Feb 2021 18:41:03 +0000 (19:41 +0100)]
Comments updated to keep the consistency

3 years agoAuto merge of #81832 - jonas-schievink:rollup-3nw53p0, r=jonas-schievink
bors [Sat, 6 Feb 2021 18:03:37 +0000 (18:03 +0000)]
Auto merge of #81832 - jonas-schievink:rollup-3nw53p0, r=jonas-schievink

Rollup of 7 pull requests

Successful merges:

 - #81402 (tidy: Run tidy style against markdown files.)
 - #81434 (BTree: fix documentation of unstable public members)
 - #81680 (Refactor `PrimitiveTypeTable` for Clippy)
 - #81737 (typeck: Emit structured suggestions for tuple struct syntax)
 - #81738 (Miscellaneous small diagnostics cleanup)
 - #81766 (Enable 'task list' markdown extension)
 - #81812 (Add a test for escaping LLVMisms in inline asm)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoImprove long explanation for E0546
Jesus Rubio [Sat, 6 Feb 2021 17:27:19 +0000 (18:27 +0100)]
Improve long explanation for E0546

3 years agoResolve typedef in HashMap lldb pretty-printer only if possible
ortem [Sat, 6 Feb 2021 17:20:25 +0000 (20:20 +0300)]
Resolve typedef in HashMap lldb pretty-printer only if possible

Previously, `GetTypedefedType` was invoked unconditionally.
But this did not work in case of `rust-lldb` without Rust patches
since there was no typedef actually.

3 years agoFormat fixes
Jesus Rubio [Sat, 6 Feb 2021 17:05:21 +0000 (18:05 +0100)]
Format fixes

3 years agoUpdate compiler/rustc_error_codes/src/error_codes/E0542.md
Jesús Rubio [Sat, 6 Feb 2021 16:39:11 +0000 (17:39 +0100)]
Update compiler/rustc_error_codes/src/error_codes/E0542.md

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
3 years agoRollup merge of #81812 - nagisa:nagisa/escape-the-escape-hatch, r=Amanieu
Jonas Schievink [Sat, 6 Feb 2021 16:01:52 +0000 (17:01 +0100)]
Rollup merge of #81812 - nagisa:nagisa/escape-the-escape-hatch, r=Amanieu

Add a test for escaping LLVMisms in inline asm

We escape certain LLVM-specific features when passing the inline
assembly string to the LLVM. Until now, however, there was no test
making sure this behaviour stays intact. This commit adds such a test!

r? `@Amanieu`
cc `@joshtriplett`

3 years agoRollup merge of #81766 - jyn514:task-lists, r=GuillaumeGomez
Jonas Schievink [Sat, 6 Feb 2021 16:01:50 +0000 (17:01 +0100)]
Rollup merge of #81766 - jyn514:task-lists, r=GuillaumeGomez

Enable 'task list' markdown extension

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

3 years agoRollup merge of #81738 - camelid:misc-small-diag-cleanup, r=lcnr
Jonas Schievink [Sat, 6 Feb 2021 16:01:49 +0000 (17:01 +0100)]
Rollup merge of #81738 - camelid:misc-small-diag-cleanup, r=lcnr

Miscellaneous small diagnostics cleanup

3 years agoRollup merge of #81737 - camelid:typeck-structure-sugg, r=lcnr
Jonas Schievink [Sat, 6 Feb 2021 16:01:47 +0000 (17:01 +0100)]
Rollup merge of #81737 - camelid:typeck-structure-sugg, r=lcnr

typeck: Emit structured suggestions for tuple struct syntax

And tuple variant syntax, but that didn't fit in the subject :)

Now the fact that these are suggestions is exposed both to the layout
engine and to IDEs and rustfix for automatic application.

3 years agoRollup merge of #81680 - camsteffen:primty, r=oli-obk
Jonas Schievink [Sat, 6 Feb 2021 16:01:45 +0000 (17:01 +0100)]
Rollup merge of #81680 - camsteffen:primty, r=oli-obk

Refactor `PrimitiveTypeTable` for Clippy

I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.

3 years agoRollup merge of #81434 - ssomers:btree_drain_filter_doc_update, r=dtolnay
Jonas Schievink [Sat, 6 Feb 2021 16:01:43 +0000 (17:01 +0100)]
Rollup merge of #81434 - ssomers:btree_drain_filter_doc_update, r=dtolnay

BTree: fix documentation of unstable public members

As rightfully requested in #62924 & #70530.
r? `@Mark-Simulacrum`

3 years agoRollup merge of #81402 - ehuss:md-tidy, r=jyn514
Jonas Schievink [Sat, 6 Feb 2021 16:01:42 +0000 (17:01 +0100)]
Rollup merge of #81402 - ehuss:md-tidy, r=jyn514

tidy: Run tidy style against markdown files.

This adds tidy checks for markdown files.  I think it is useful to have some style enforcement (for the same reasons the style is enforced on other files).  I think it is worthwhile to avoid `ignore` on rust examples since having broken code in documentation is frustrating.  Avoiding trailing whitespace is good because it has semantic meaning in markdown, which I think should be avoided.

3 years agoAdd long error explanation for E0542
Jesus Rubio [Sat, 6 Feb 2021 15:42:34 +0000 (16:42 +0100)]
Add long error explanation for E0542

3 years agoAuto merge of #81824 - RalfJung:miri, r=RalfJung
bors [Sat, 6 Feb 2021 15:14:44 +0000 (15:14 +0000)]
Auto merge of #81824 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/81770
Cc `@rust-lang/miri` r? `@ghost`

3 years agoparse_format: treat r" as a literal
David Hewitt [Sat, 6 Feb 2021 15:01:07 +0000 (15:01 +0000)]
parse_format: treat r" as a literal

3 years agoPrefer match intead of combinators to make some Box function inlineable
Lzu Tao [Sat, 6 Feb 2021 13:33:29 +0000 (13:33 +0000)]
Prefer match intead of combinators to make some Box function inlineable

3 years agoAdd option to emit compiler stderr per bitwidth.
Hameer Abbasi [Sat, 6 Feb 2021 06:33:07 +0000 (06:33 +0000)]
Add option to emit compiler stderr per bitwidth.

See rust-lang/compiler-team#365

3 years agoAdd a test for escaping LLVMisms in inline asm
Simonas Kazlauskas [Sat, 6 Feb 2021 00:26:35 +0000 (02:26 +0200)]
Add a test for escaping LLVMisms in inline asm

We escape certain LLVM-specific features when passing the inline
assembly string to the LLVM. Until now, however, there was no test
making sure this behaviour stays intact. This commit adds such a test!

3 years agoupdate Miri
Ralf Jung [Sat, 6 Feb 2021 12:18:51 +0000 (13:18 +0100)]
update Miri

3 years agoUpgrade wasm32 image to Ubuntu 20.04
Nikita Popov [Fri, 5 Feb 2021 14:52:49 +0000 (15:52 +0100)]
Upgrade wasm32 image to Ubuntu 20.04

This switches the wasm32 image, which is used to test
wasm32-unknown-emscripten to Ubuntu 20.04. While at it, enable
most of the excluded tests, as they seem to work fine with some
minor fixes.

3 years agopath trimming: disable on src/test/run-make-fulldeps/coverage-spanview
Dan Aloni [Thu, 28 Jan 2021 06:47:53 +0000 (08:47 +0200)]
path trimming: disable on src/test/run-make-fulldeps/coverage-spanview

3 years agopath trimming: ignore type aliases
Dan Aloni [Thu, 28 Jan 2021 16:01:36 +0000 (18:01 +0200)]
path trimming: ignore type aliases

3 years agoBTreeMap: remove Ord bound where it is absent elsewhere
Stein Somers [Fri, 20 Nov 2020 20:29:00 +0000 (21:29 +0100)]
BTreeMap: remove Ord bound where it is absent elsewhere

3 years agoAuto merge of #81792 - pietroalbini:bump-nightly, r=Mark-Simulacrum
bors [Sat, 6 Feb 2021 07:55:28 +0000 (07:55 +0000)]
Auto merge of #81792 - pietroalbini:bump-nightly, r=Mark-Simulacrum

Bump nightly version to 1.52.0

cc `@rust-lang/release`

3 years agoEnable 'task list' markdown extension
Joshua Nelson [Thu, 4 Feb 2021 23:10:33 +0000 (18:10 -0500)]
Enable 'task list' markdown extension

- Add documentation about task lists

3 years agoAuto merge of #81810 - m-ou-se:rollup-q3nborp, r=m-ou-se
bors [Sat, 6 Feb 2021 04:55:09 +0000 (04:55 +0000)]
Auto merge of #81810 - m-ou-se:rollup-q3nborp, r=m-ou-se

Rollup of 7 pull requests

Successful merges:

 - #80011 (Stabilize `peekable_next_if`)
 - #81580 (Document how `MaybeUninit<Struct>` can be initialized.)
 - #81610 (BTreeMap: make Ord bound explicit, compile-test its absence)
 - #81664 (Avoid a hir access inside get_static)
 - #81675 (Make rustdoc respect `--error-format short` in doctests)
 - #81753 (Never MIR inline functions with a different instruction set)
 - #81795 (Small refactor with Iterator::reduce)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoAdd abi field to `Method`
Rune Tynan [Fri, 29 Jan 2021 06:07:50 +0000 (01:07 -0500)]
Add abi field to `Method`

3 years agoBTreeMap: fix documentation of unstable public members
Stein Somers [Wed, 27 Jan 2021 12:21:02 +0000 (13:21 +0100)]
BTreeMap: fix documentation of unstable public members

3 years agoBump clippy version
Mark Rousskov [Fri, 5 Feb 2021 23:29:05 +0000 (18:29 -0500)]
Bump clippy version

3 years agoRollup merge of #81795 - camsteffen:diagnostics-reduce, r=oli-obk
Mara Bos [Fri, 5 Feb 2021 23:14:17 +0000 (00:14 +0100)]
Rollup merge of #81795 - camsteffen:diagnostics-reduce, r=oli-obk

Small refactor with Iterator::reduce

3 years agoRollup merge of #81753 - tmiasko:inline-instruction-set, r=oli-obk
Mara Bos [Fri, 5 Feb 2021 23:14:16 +0000 (00:14 +0100)]
Rollup merge of #81753 - tmiasko:inline-instruction-set, r=oli-obk

Never MIR inline functions with a different instruction set

3 years agoRollup merge of #81675 - poliorcetics:respect-shortness, r=jyn514
Mara Bos [Fri, 5 Feb 2021 23:14:14 +0000 (00:14 +0100)]
Rollup merge of #81675 - poliorcetics:respect-shortness, r=jyn514

Make rustdoc respect `--error-format short` in doctests

Note that this will not work with `cargo test`, only with `rustdoc --test`, I'll have to modify `cargo` as well.

Fix #81662.

`@rustbot` label +T-rustdoc +A-doctests

3 years agoRollup merge of #81664 - bjorn3:no_codegen_hir, r=lcnr
Mara Bos [Fri, 5 Feb 2021 23:14:13 +0000 (00:14 +0100)]
Rollup merge of #81664 - bjorn3:no_codegen_hir, r=lcnr

Avoid a hir access inside get_static

Together with #81056 this ensures that the codegen unit DepNode doesn't have a direct dependency on any part of the hir.

3 years agoRollup merge of #81610 - ssomers:btree_emphasize_ord_bound, r=dtolnay
Mara Bos [Fri, 5 Feb 2021 23:14:11 +0000 (00:14 +0100)]
Rollup merge of #81610 - ssomers:btree_emphasize_ord_bound, r=dtolnay

BTreeMap: make Ord bound explicit, compile-test its absence

Most `BTreeMap` and `BTreeSet` members are subject to an `Ord` bound but a fair number of methods are not. To better convey and perhaps later tune the `Ord` bound, make it stand out in individual `where` clauses, instead of once far away at the beginning of an `impl` block. This PR does not introduce or remove any bounds.

Also adds compilation test cases checking that the bound doesn't creep in unintended on the historically unbounded methods.

3 years agoRollup merge of #81580 - rodrimati1992:patch-2, r=dtolnay
Mara Bos [Fri, 5 Feb 2021 23:14:09 +0000 (00:14 +0100)]
Rollup merge of #81580 - rodrimati1992:patch-2, r=dtolnay

Document how `MaybeUninit<Struct>` can be initialized.

3 years agoRollup merge of #80011 - Stupremee:stabilize-peekable-next-if, r=dtolnay
Mara Bos [Fri, 5 Feb 2021 23:14:06 +0000 (00:14 +0100)]
Rollup merge of #80011 - Stupremee:stabilize-peekable-next-if, r=dtolnay

Stabilize `peekable_next_if`

This PR stabilizes the `peekable_next_if` feature

Resolves #72480

3 years agoAuto merge of #79253 - rcvalle:fix-rustc-sysroot-cas, r=nagisa
bors [Fri, 5 Feb 2021 22:58:13 +0000 (22:58 +0000)]
Auto merge of #79253 - rcvalle:fix-rustc-sysroot-cas, r=nagisa

Fix rustc sysroot in systems using CAS

Change filesearch::get_or_default_sysroot() to check if sysroot is found using env::args().next() if rustc in argv[0] is a symlink; otherwise, or if it is not found, use env::current_exe() to imply sysroot. This makes the rustc binary able to locate Rust libraries in systems using content-addressable storage (CAS).

3 years agoBump peekable_next_if to rust 1.51.0
David Tolnay [Fri, 5 Feb 2021 22:25:21 +0000 (14:25 -0800)]
Bump peekable_next_if to rust 1.51.0

3 years agoAdapt to latest master changes by using PredicateKind
Santiago Pastorino [Tue, 2 Feb 2021 16:52:01 +0000 (13:52 -0300)]
Adapt to latest master changes by using PredicateKind

3 years agoAdd regression test for ICE that happened on incr comp
Santiago Pastorino [Tue, 2 Feb 2021 16:34:08 +0000 (13:34 -0300)]
Add regression test for ICE that happened on incr comp

An ICE happened when certain code is compiled in incremental compilation
mode and there are two `Ident`s that have the same `StableHash` value
but are considered different by `Eq` and `Hash`.

The `Ident` issue is now fixed.

3 years agoRevert "Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simul...
Santiago Pastorino [Thu, 3 Dec 2020 23:10:55 +0000 (20:10 -0300)]
Revert "Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simulacrum"

This reverts commit b4def89d76896eec73b4af33642ba7e5eb53c567, reversing
changes made to 7dc1e852d43cb8c9e77dc1e53014f0eb85d2ebfb.

3 years agoAuto merge of #81215 - cjgillot:defkey-mir, r=oli-obk
bors [Fri, 5 Feb 2021 18:21:47 +0000 (18:21 +0000)]
Auto merge of #81215 - cjgillot:defkey-mir, r=oli-obk

Encode MIR metadata by iterating on DefId instead of traversing the HIR tree

Split out of https://github.com/rust-lang/rust/pull/80347.

This part only traverses `mir_keys` and encodes MIR according to the def kind.

r? `@oli-obk`

3 years agofix ui tests referencing pointer-to-integer cast error message
Jeffrey Griffin [Fri, 5 Feb 2021 16:49:59 +0000 (08:49 -0800)]
fix ui tests referencing pointer-to-integer cast error message

3 years agoRemove unneeded From trait impl for DefKind
Guillaume Gomez [Tue, 2 Feb 2021 23:46:48 +0000 (00:46 +0100)]
Remove unneeded From trait impl for DefKind

3 years agoRemove unused cache argument
Guillaume Gomez [Tue, 2 Feb 2021 23:42:39 +0000 (00:42 +0100)]
Remove unused cache argument

3 years agoImprove code
Guillaume Gomez [Fri, 29 Jan 2021 13:45:03 +0000 (14:45 +0100)]
Improve code