]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #89741 - sdroege:arc-rc-from-inner-unsafe, r=Mark-Simulacrum
Matthias Krüger [Sat, 20 Nov 2021 21:33:48 +0000 (22:33 +0100)]
Rollup merge of #89741 - sdroege:arc-rc-from-inner-unsafe, r=Mark-Simulacrum

Mark `Arc::from_inner` / `Rc::from_inner` as unsafe

While it's an internal function, it is easy to create invalid Arc/Rcs to
a dangling pointer with it.

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

2 years agoAuto merge of #91066 - camelid:externs, r=jyn514,GuillaumeGomez
bors [Sat, 20 Nov 2021 14:12:29 +0000 (14:12 +0000)]
Auto merge of #91066 - camelid:externs, r=jyn514,GuillaumeGomez

rustdoc: Remove `Crate.externs` and compute on-demand instead

r? `@GuillaumeGomez`
cc `@jyn514`

2 years agoAuto merge of #91080 - matthiaskrgr:rollup-znh88cy, r=matthiaskrgr
bors [Sat, 20 Nov 2021 10:28:05 +0000 (10:28 +0000)]
Auto merge of #91080 - matthiaskrgr:rollup-znh88cy, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #90575 (Improve suggestions for compatible variants on type mismatch.)
 - #90628 (Clarify error messages caused by re-exporting `pub(crate)` visibility to outside)
 - #90930 (Fix `non-constant value` ICE (#90878))
 - #90983 (Make scrollbar in the sidebar always visible for visual consistency)
 - #91021 (Elaborate `Future::Output` when printing opaque `impl Future` type)

Failed merges:

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

2 years agoRollup merge of #91021 - compiler-errors:print_future_output, r=estebank
Matthias Krüger [Sat, 20 Nov 2021 09:21:16 +0000 (10:21 +0100)]
Rollup merge of #91021 - compiler-errors:print_future_output, r=estebank

Elaborate `Future::Output` when printing opaque `impl Future` type

I would love to see the `Output =` type when printing type errors involving opaque `impl Future`.

[Test code](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a800b481edd31575fbcaf5771a9c3678)

Before (cut relevant part of output):
```
note: while checking the return type of the `async fn`
 --> /home/michael/test.rs:5:19
  |
5 | async fn bar() -> usize {
  |                   ^^^^^ checked the `Output` of this `async fn`, found opaque type
  = note:     expected type `usize`
          found opaque type `impl Future`
```

After:
```
note: while checking the return type of the `async fn`
 --> /home/michael/test.rs:5:19
  |
5 | async fn bar() -> usize {
  |                   ^^^^^ checked the `Output` of this `async fn`, found opaque type
  = note:     expected type `usize`
          found opaque type `impl Future<Output = usize>`
```

Note the "found opaque type `impl Future<Output = usize>`" in the new output.

----

Questions:
1. We skip printing the output type when it's a projection, since I have been seeing some types like `impl Future<Output = <[static generator@/home/michael/test.rs:2:11: 2:21] as Generator<ResumeTy>>::Return>` which are not particularly helpful and leak implementation detail.
    * Am I able to normalize this type within `rustc_middle::ty::print::pretty`? Alternatively, can we normalize it when creating the diagnostic? Otherwise, I'm fine with skipping it and falling back to the old output.
    * Should I suppress any other types? I didn't encounter anything other than this generator projection type.
2. Not sure what the formatting of this should be. Do I include spaces in `Output = `?

2 years agoRollup merge of #90983 - GuillaumeGomez:sidebar-scrollbar, r=jsha
Matthias Krüger [Sat, 20 Nov 2021 09:21:15 +0000 (10:21 +0100)]
Rollup merge of #90983 - GuillaumeGomez:sidebar-scrollbar, r=jsha

Make scrollbar in the sidebar always visible for visual consistency

Fixes #90943.

I had to add a background in `dark` and `ayu` themes, otherwise it was looking strange (like an invisible margin). So it looks like this:

![Screenshot from 2021-11-17 14-45-49](https://user-images.githubusercontent.com/3050060/142212476-18892ae0-ba4b-48e3-8c0f-4ca1dd2f851d.png)
![Screenshot from 2021-11-17 14-45-53](https://user-images.githubusercontent.com/3050060/142212482-e97b2fad-68d2-439a-b62e-b56e6ded5345.png)

Sadly, I wasn't able to add a GUI test to ensure that the scrollbar was always displayed because it seems not possible in puppeteer for whatever reason... I used this method: on small pages (like `lib2/sub_mod/index.html`), comparing `.navbar`'s `clientWidth` with `offsetWidth` (the first doesn't include the sidebar in the computed amount). When checking in the browser, it works fine but in puppeteer it almost never works...

In case anyone want to try to solve the bug, here is the puppeteer code:

<details>
More information about this: I tried another approach which was to get the element in `evaluate` directly (by calling it from `page.evaluate(() => { .. });` directly instead of `parseAssertElemProp.evaluate(e => {...});`.

```js
const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto("file:///path/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/lib2/sub_mod/index.html");
    await page.waitFor(".sidebar");
    let parseAssertElemProp = await page.$(".sidebar");
    if (parseAssertElemProp === null) { throw '".sidebar" not found'; }
    await parseAssertElemProp.evaluate(e => {
        const parseAssertElemPropDict = {"clientWidth": "192", "offsetWidth":"200"};
        for (const [parseAssertElemPropKey, parseAssertElemPropValue] of Object.entries(parseAssertElemPropDict)) {
            if (e[parseAssertElemPropKey] === undefined || String(e[parseAssertElemPropKey]) != parseAssertElemPropValue) {
                throw 'expected `' + parseAssertElemPropValue + '` for property `' + parseAssertElemPropKey + '` for selector `.sidebar`, found `' + e[parseAssertElemPropKey] + '`';
            }
        }
    }).catch(e => console.error(e));
    await browser.close();
})();
```

</details>

r? ``@jsha``

2 years agoRollup merge of #90930 - Nilstrieb:fix-non-const-value-ice, r=estebank
Matthias Krüger [Sat, 20 Nov 2021 09:21:14 +0000 (10:21 +0100)]
Rollup merge of #90930 - Nilstrieb:fix-non-const-value-ice, r=estebank

Fix `non-constant value` ICE (#90878)

This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const.

I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong.

Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE.

Asking Esteban to review since he was the last one to change the relevant code.

r? ``@estebank``

Fixes #90878

2 years agoRollup merge of #90628 - ken-matsui:clarify-error-messages-caused-by-reexporting...
Matthias Krüger [Sat, 20 Nov 2021 09:21:13 +0000 (10:21 +0100)]
Rollup merge of #90628 - ken-matsui:clarify-error-messages-caused-by-reexporting-pub-crate-visibility-to-outside, r=oli-obk

Clarify error messages caused by re-exporting `pub(crate)` visibility to outside

This PR clarifies error messages and suggestions caused by re-exporting pub(crate) visibility outside the crate.

Here is a small example ([Rust Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e2cd0bd4422d4f20e6522dcbad167d3b)):

```rust
mod m {
    pub(crate) enum E {}
}
pub use m::E;

fn main() {}
```

This code is compiled to:

```
error[E0365]: `E` is private, and cannot be re-exported
 --> prog.rs:4:9
  |
4 | pub use m::E;
  |         ^^^^ re-export of private `E`
  |
  = note: consider declaring type or module `E` with `pub`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0365`.
```

However, enum `E` is actually public to the crate, not private totally—nevertheless, rustc treats `pub(crate)` and private visibility as the same on the error messages. They are not clear and should be segmented distinctly.

By applying changes in this PR, the error message below will be the following message that would be clearer:

```
error[E0365]: `E` is only public to inside of the crate, and cannot be re-exported outside
 --> prog.rs:4:9
  |
4 | pub use m::E;
  |         ^^^^ re-export of crate public `E`
  |
  = note: consider declaring type or module `E` with `pub`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0365`.
```

2 years agoRollup merge of #90575 - m-ou-se:compatible-variant-improvements, r=estebank
Matthias Krüger [Sat, 20 Nov 2021 09:21:12 +0000 (10:21 +0100)]
Rollup merge of #90575 - m-ou-se:compatible-variant-improvements, r=estebank

Improve suggestions for compatible variants on type mismatch.

Fixes #90553.

Before:
![image](https://user-images.githubusercontent.com/783247/140385675-6ff41090-eca2-41bc-b161-99c5dabfec61.png)

After:
![image](https://user-images.githubusercontent.com/783247/140385748-20cf26b5-ea96-4e56-8af2-5fe1ab16fd3b.png)

r? `````@estebank`````

2 years agoAuto merge of #91052 - ehuss:update-stdarch, r=Amanieu
bors [Sat, 20 Nov 2021 07:20:43 +0000 (07:20 +0000)]
Auto merge of #91052 - ehuss:update-stdarch, r=Amanieu

Update stdarch

5 commits in 815d55c610dab39e92e7c83bf5fd4b7a020b4d46..cfba59fccd90b3b52a614120834320f764ab08d1
2021-11-08 00:58:47 +0000 to 2021-11-19 01:29:04 +0000
- Work-around buggy Intel chips erroneously reporting BMI1/BMI2 support (rust-lang/stdarch#1249)
- complete armv8 instructions (rust-lang/stdarch#1256)
- Fix i8mm feature with bootstrap compiler. (rust-lang/stdarch#1252)
- Fix unused link_name attribute. (rust-lang/stdarch#1251)
- Add remaining insturctions (rust-lang/stdarch#1250)

2 years agoAuto merge of #90535 - tmiasko:clone-from, r=oli-obk
bors [Sat, 20 Nov 2021 04:12:03 +0000 (04:12 +0000)]
Auto merge of #90535 - tmiasko:clone-from, r=oli-obk

Implement `clone_from` for `State`

Data flow engine uses `clone_from` for domain values.  Providing an
implementation of `clone_from` will avoid some intermediate memory
allocations.

Extracted from #90413.

r? `@oli-obk`

2 years agorustdoc: Move doc-reachability visiting back to cleaning
Noah Lev [Sat, 20 Nov 2021 03:00:37 +0000 (22:00 -0500)]
rustdoc: Move doc-reachability visiting back to cleaning

It populates `cx.cache.access_levels`, which seems to be needed during
cleaning since a bunch of tests are failing.

2 years agorustdoc: Merge visits of extern crates into one loop
Noah Lev [Sat, 20 Nov 2021 02:24:12 +0000 (21:24 -0500)]
rustdoc: Merge visits of extern crates into one loop

2 years agorustdoc: Remove `Crate.externs` and compute on-demand instead
Noah Lev [Sat, 20 Nov 2021 02:16:48 +0000 (21:16 -0500)]
rustdoc: Remove `Crate.externs` and compute on-demand instead

2 years agoClarify error messages caused by re-exporting `pub(crate)` visibility to outside
Ken Matsui [Fri, 5 Nov 2021 19:43:55 +0000 (04:43 +0900)]
Clarify error messages caused by re-exporting `pub(crate)` visibility to outside

2 years agoAuto merge of #91064 - matthiaskrgr:rollup-2ijidpt, r=matthiaskrgr
bors [Sat, 20 Nov 2021 01:06:27 +0000 (01:06 +0000)]
Auto merge of #91064 - matthiaskrgr:rollup-2ijidpt, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #88361 (Makes docs for references a little less confusing)
 - #90089 (Improve display of enum variants)
 - #90956 (Add a regression test for #87573)
 - #90999 (fix CTFE/Miri simd_insert/extract on array-style repr(simd) types)
 - #91026 (rustdoc doctest: detect `fn main` after an unexpected semicolon)
 - #91035 (Put back removed empty line)
 - #91044 (Turn all 0x1b_u8 into '\x1b' or b'\x1b')
 - #91054 (rustdoc: Fix some unescaped HTML tags in docs)

Failed merges:

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

2 years agoRollup merge of #91054 - camelid:fix-tags, r=GuillaumeGomez
Matthias Krüger [Sat, 20 Nov 2021 00:09:45 +0000 (01:09 +0100)]
Rollup merge of #91054 - camelid:fix-tags, r=GuillaumeGomez

rustdoc: Fix some unescaped HTML tags in docs

They were being interpreted literally.

2 years agoRollup merge of #91044 - r00ster91:x1b, r=joshtriplett
Matthias Krüger [Sat, 20 Nov 2021 00:09:44 +0000 (01:09 +0100)]
Rollup merge of #91044 - r00ster91:x1b, r=joshtriplett

Turn all 0x1b_u8 into '\x1b' or b'\x1b'

Supersedes #91040

2 years agoRollup merge of #91035 - GuillaumeGomez:put-back-removed-empty-line, r=camelid
Matthias Krüger [Sat, 20 Nov 2021 00:09:43 +0000 (01:09 +0100)]
Rollup merge of #91035 - GuillaumeGomez:put-back-removed-empty-line, r=camelid

Put back removed empty line

Fixes comment from https://github.com/rust-lang/rust/pull/90438#r752813630.

r? ````@camelid````

2 years agoRollup merge of #91026 - notriddle:notriddle/rustdoc-doctest-semicolon, r=jyn514
Matthias Krüger [Sat, 20 Nov 2021 00:09:42 +0000 (01:09 +0100)]
Rollup merge of #91026 - notriddle:notriddle/rustdoc-doctest-semicolon, r=jyn514

rustdoc doctest: detect `fn main` after an unexpected semicolon

Fixes #91014

The basic problem with this is that rustdoc, when hunting for `fn main`, will stop parsing after it reaches a fatal error. This unexpected semicolon was a fatal error, so in `src/test/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs`, it would wrap the doctest in an implied main function, turning it into this:

    fn main() {
        struct S {};
        fn main() {
            assert_eq!(0, 1);
        }
    }

This, as it turns out, is totally valid, and it executes no assertions, so *it passes,* even though the user wanted it to execute the assertion.

The Rust parser already has the ability to recover from these unexpected semicolons, but to do so, it needs to use the `parse_mod` function, so this PR changes it to do that.

2 years agoRollup merge of #90999 - RalfJung:miri_simd, r=oli-obk
Matthias Krüger [Sat, 20 Nov 2021 00:09:41 +0000 (01:09 +0100)]
Rollup merge of #90999 - RalfJung:miri_simd, r=oli-obk

fix CTFE/Miri simd_insert/extract on array-style repr(simd) types

The changed test would previously fail since `place_index` would just return the only field of `f32x4`, i.e., the array -- rather than *indexing into* the array which is what we have to do.

The new helper methods will also be needed for https://github.com/rust-lang/miri/issues/1912.

r? ``````@oli-obk``````

2 years agoRollup merge of #90956 - JohnTitor:issue-87573, r=Mark-Simulacrum
Matthias Krüger [Sat, 20 Nov 2021 00:09:40 +0000 (01:09 +0100)]
Rollup merge of #90956 - JohnTitor:issue-87573, r=Mark-Simulacrum

Add a regression test for #87573

Closes #87573

2 years agoRollup merge of #90089 - jsha:enum-fields-headings, r=camelid,GuillaumeGomez
Matthias Krüger [Sat, 20 Nov 2021 00:09:38 +0000 (01:09 +0100)]
Rollup merge of #90089 - jsha:enum-fields-headings, r=camelid,GuillaumeGomez

Improve display of enum variants

Use h3 and h4 for the variant name and the "Fields" subheading.
Remove the "of T" part of the "Fields" subheading.
Remove border-bottom from "Fields" subheading.
Move docblock below "Fields" listing.

Fixes #90061

Demo:

https://jacob.hoffman-andrews.com/rust/xmlparser-updated/xmlparser/enum.Token.html#variants
https://jacob.hoffman-andrews.com/rust/fix-enum-variants/std/io/enum.ErrorKind.html#variants
https://jacob.hoffman-andrews.com/rust/fix-enum-variants/std/result/enum.Result.html#variants

r? ``@camelid``

2 years agoRollup merge of #88361 - WaffleLapkin:patch-2, r=jyn514
Matthias Krüger [Sat, 20 Nov 2021 00:09:37 +0000 (01:09 +0100)]
Rollup merge of #88361 - WaffleLapkin:patch-2, r=jyn514

Makes docs for references a little less confusing

- Make clear that the `Pointer` trait is related to formatting
- Make clear that the `Pointer` trait is implemented for references (previously it was confusing to first see that it's implemented and then see it in "expect")
- Make clear that `&T` (shared reference) implements `Send` (if `T: Send + Sync`)

2 years agorustdoc: Pass DocContext to `Cache::populate`
Noah Lev [Fri, 19 Nov 2021 22:51:45 +0000 (17:51 -0500)]
rustdoc: Pass DocContext to `Cache::populate`

This will allow removing `Crate.externs`.

2 years agorustdoc: Fix some unescaped HTML tags in docs
Noah Lev [Fri, 19 Nov 2021 20:54:05 +0000 (15:54 -0500)]
rustdoc: Fix some unescaped HTML tags in docs

They were being interpreted literally.

2 years agoUpdate stdarch
Eric Huss [Fri, 19 Nov 2021 19:20:42 +0000 (11:20 -0800)]
Update stdarch

2 years agoAuto merge of #91034 - camelid:docfragment, r=jyn514
bors [Fri, 19 Nov 2021 18:04:14 +0000 (18:04 +0000)]
Auto merge of #91034 - camelid:docfragment, r=jyn514

rustdoc: Cleanup `DocFragment`

- Remove unused `DocFragment.line` field
- Avoid using `Iterator::count()` where possible

2 years agoTurn all 0x1b_u8 into '\x1b' or b'\x1b'
r00ster91 [Fri, 19 Nov 2021 17:14:18 +0000 (18:14 +0100)]
Turn all 0x1b_u8 into '\x1b' or b'\x1b'

2 years agoUse fast comparison against `kw::Empty`
Noah Lev [Fri, 19 Nov 2021 16:13:24 +0000 (11:13 -0500)]
Use fast comparison against `kw::Empty`

We think `.as_str().lines().next().is_none()` should be equivalent to
`== kw::Empty`.

Co-authored-by: Joshua Nelson <github@jyn.dev>
2 years agoRemove unnecessary doc links
Maybe Waffle [Fri, 19 Nov 2021 16:13:53 +0000 (19:13 +0300)]
Remove unnecessary doc links

2 years agoAuto merge of #90996 - the8472:obligation-hashes2, r=matthewjasper
bors [Fri, 19 Nov 2021 11:50:51 +0000 (11:50 +0000)]
Auto merge of #90996 - the8472:obligation-hashes2, r=matthewjasper

Optimize `impl Hash for ObligationCauseData` by not hashing `ObligationCauseCode` variant fields

Split out from #90913 since it's a [clear performance win](https://perf.rust-lang.org/compare.html?start=ad442399756573dccacb314b6bf8079964bcc72a&end=223f5e877fe93b5f437c2d703f883797913cd2b7) and should be easier to review.

It speeds up hashing for `Obligation` [deduplication](https://github.com/rust-lang/rust/blob/c9c4b5d7276297679387189d96a952f2b760e7ad/compiler/rustc_trait_selection/src/traits/select/mod.rs#L2355-L2356) by only hashing the discriminant of the `ObligationCauseCode` enum instead of its contents. That shouldn't affect hash quality much since there are several other fields in `Obligation` which should be unique enough, especially the predicate itself which is hashed as an interned pointer.

2 years agoPut back removed empty line
Guillaume Gomez [Fri, 19 Nov 2021 09:20:49 +0000 (10:20 +0100)]
Put back removed empty line

2 years agoAuto merge of #91033 - JohnTitor:rollup-sr9zg6o, r=JohnTitor
bors [Fri, 19 Nov 2021 06:13:29 +0000 (06:13 +0000)]
Auto merge of #91033 - JohnTitor:rollup-sr9zg6o, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #89258 (Make char conversion functions unstably const)
 - #90578 (add const generics test)
 - #90633 (Refactor single variant `Candidate` enum into a struct)
 - #90800 (bootstap: create .cargo/config only if not present)
 - #90942 (windows: Return the "Not Found" error when a path is empty)
 - #90947 (Move some tests to more reasonable directories - 9.5)
 - #90961 (Suggest removal of arguments for unit variant, not replacement)
 - #90990 (Arenas cleanup)

Failed merges:

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

2 years agoRollup merge of #90990 - nnethercote:arenas-cleanup, r=oli-obk
Yuki Okushi [Fri, 19 Nov 2021 04:06:38 +0000 (13:06 +0900)]
Rollup merge of #90990 - nnethercote:arenas-cleanup, r=oli-obk

Arenas cleanup

I was looking closely at the arenas code and here are some small improvement to readability.

2 years agoRollup merge of #90961 - estebank:suggest-removal-of-call, r=nagisa
Yuki Okushi [Fri, 19 Nov 2021 04:06:37 +0000 (13:06 +0900)]
Rollup merge of #90961 - estebank:suggest-removal-of-call, r=nagisa

Suggest removal of arguments for unit variant, not replacement

2 years agoRollup merge of #90947 - c410-f3r:testsssssss, r=petrochenkov
Yuki Okushi [Fri, 19 Nov 2021 04:06:36 +0000 (13:06 +0900)]
Rollup merge of #90947 - c410-f3r:testsssssss, r=petrochenkov

Move some tests to more reasonable directories - 9.5

cc #73494
r? `@petrochenkov`

2 years agoRollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se
Yuki Okushi [Fri, 19 Nov 2021 04:06:35 +0000 (13:06 +0900)]
Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se

windows: Return the "Not Found" error when a path is empty

Fixes #90940

2 years agoRollup merge of #90800 - aplanas:fix_cargo_config, r=Mark-Simulacrum
Yuki Okushi [Fri, 19 Nov 2021 04:06:35 +0000 (13:06 +0900)]
Rollup merge of #90800 - aplanas:fix_cargo_config, r=Mark-Simulacrum

bootstap: create .cargo/config only if not present

In some situations we should want on influence into the .cargo/config
when we use vendored source.  One example is #90764, when we want to
workaround some references to crates forked and living in git, that are
missing in the vendor/ directory.

This commit will create the .cargo/config file only when the .cargo/
directory needs to be created.

2 years agoRollup merge of #90633 - tmiasko:candidate-struct, r=nagisa
Yuki Okushi [Fri, 19 Nov 2021 04:06:34 +0000 (13:06 +0900)]
Rollup merge of #90633 - tmiasko:candidate-struct, r=nagisa

Refactor single variant `Candidate` enum into a struct

`Candidate` enum has only a single `Ref` variant.  Refactor it into a
struct and reduce overall indentation of the code by two levels.

No functional changes.

2 years agoRollup merge of #90578 - lcnr:add-test, r=Mark-Simulacrum
Yuki Okushi [Fri, 19 Nov 2021 04:06:32 +0000 (13:06 +0900)]
Rollup merge of #90578 - lcnr:add-test, r=Mark-Simulacrum

add const generics test

cc https://github.com/rust-lang/rust/pull/89829#issuecomment-948921310

r? rust-lang/project-const-generics

2 years agoRollup merge of #89258 - est31:const_char_convert, r=oli-obk
Yuki Okushi [Fri, 19 Nov 2021 04:06:31 +0000 (13:06 +0900)]
Rollup merge of #89258 - est31:const_char_convert, r=oli-obk

Make char conversion functions unstably const

The char conversion functions like `char::from_u32` do trivial computations and can easily be converted into const fns. Only smaller tricks are needed to avoid non-const standard library functions like `Result::ok` or `bool::then_some`.

Tracking issue: https://github.com/rust-lang/rust/issues/89259

2 years agorustdoc: Avoid using `Iterator::count()` where possible
Noah Lev [Fri, 19 Nov 2021 04:04:51 +0000 (23:04 -0500)]
rustdoc: Avoid using `Iterator::count()` where possible

`count()` iterates over the whole collection. Using `len()` instead, or
`.next().is_none()` when comparing to zero, should be faster.

2 years agorustdoc: Remove unused `DocFragment.line` field
Noah Lev [Fri, 19 Nov 2021 03:57:09 +0000 (22:57 -0500)]
rustdoc: Remove unused `DocFragment.line` field

2 years agoAuto merge of #90329 - nbdd0121:typeck, r=nagisa
bors [Fri, 19 Nov 2021 03:00:46 +0000 (03:00 +0000)]
Auto merge of #90329 - nbdd0121:typeck, r=nagisa

Try all stable method candidates first before trying unstable ones

Currently we try methods in this order in each step:
* Stable by value
* Unstable by value
* Stable autoref
* Unstable autoref
* ...

This PR changes it to first try pick methods without any unstable candidates, and if none is found, try again to pick unstable ones.

Fix #90320
CC #88971, hopefully would allow us to rename the "unstable_*" methods for integer impls back.

`@rustbot` label T-compiler T-libs-api

2 years agoAuto merge of #90774 - alexcrichton:tweak-const, r=m-ou-se
bors [Thu, 18 Nov 2021 23:54:14 +0000 (23:54 +0000)]
Auto merge of #90774 - alexcrichton:tweak-const, r=m-ou-se

std: Tweak expansion of thread-local const

This commit tweaks the expansion of `thread_local!` when combined with a
`const { ... }` value to help ensure that the rules which apply to
`const { ... }` blocks will be the same as when they're stabilized.
Previously with this invocation:

    thread_local!(static NAME: Type = const { init_expr });

this would generate (on supporting platforms):

    #[thread_local]
    static NAME: Type = init_expr;

instead the macro now expands to:

    const INIT_EXPR: Type = init_expr;
    #[thread_local]
    static NAME: Type = INIT_EXPR;

with the hope that because `init_expr` is defined as a `const` item then
it's not accidentally allowing more behavior than if it were put into a
`static`. For example on the stabilization issue [this example][ex] now
gives the same error both ways.

[ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298

2 years agorustdoc doctest: detect `fn main` after an unexpected semicolon
Michael Howell [Thu, 18 Nov 2021 23:15:12 +0000 (16:15 -0700)]
rustdoc doctest: detect `fn main` after an unexpected semicolon

The basic problem with this is that rustdoc, when hunting for `fn main`, will stop
parsing after it reaches a fatal error. This unexpected semicolon was a fatal error,
so in `src/test/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs`, it would wrap
the doctest in an implied main function, turning it into this:

    fn main() {
        struct S {};
        fn main() {
            assert_eq!(0, 1);
        }
    }

This, as it turns out, is totally valid, and it executes no assertions, so *it passes,*
even though the user wanted it to execute the assertion.

The Rust parser already has the ability to recover from these unexpected semicolons,
but to do so, it needs to use the `parse_mod` function, so this commit changes it to do that.

2 years agoPrint output ty for opaque future ty
Michael Goulet [Wed, 17 Nov 2021 00:16:23 +0000 (16:16 -0800)]
Print output ty for opaque future ty

2 years agoAdd some comments.
Nicholas Nethercote [Mon, 15 Nov 2021 22:49:15 +0000 (09:49 +1100)]
Add some comments.

Also use `Default::default()` in one `TypedArena::default()`, for
consistency with `DroplessArena::default()`.

2 years agoAuto merge of #91019 - JohnTitor:rollup-q95ra7r, r=JohnTitor
bors [Thu, 18 Nov 2021 20:23:26 +0000 (20:23 +0000)]
Auto merge of #91019 - JohnTitor:rollup-q95ra7r, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #90386 (Add `-Zassert-incr-state` to assert state of incremental cache)
 - #90438 (Clean up mess for --show-coverage documentation)
 - #90480 (Mention `Vec::remove` in `Vec::swap_remove`'s docs)
 - #90607 (Make slice->str conversion and related functions `const`)
 - #90750 (rustdoc: Replace where-bounded Clean impl with simple function)
 - #90895 (require full validity when determining the discriminant of a value)
 - #90989 (Avoid suggesting literal formatting that turns into member access)
 - #91002 (rustc: Remove `#[rustc_synthetic]`)

Failed merges:

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

2 years agobless nll
lcnr [Thu, 18 Nov 2021 17:44:14 +0000 (18:44 +0100)]
bless nll

2 years agoRollup merge of #91002 - petrochenkov:nosynth, r=davidtwco
Yuki Okushi [Thu, 18 Nov 2021 17:22:59 +0000 (02:22 +0900)]
Rollup merge of #91002 - petrochenkov:nosynth, r=davidtwco

rustc: Remove `#[rustc_synthetic]`

This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.

Noticed while reviewing https://github.com/rust-lang/rust/pull/90947.

2 years agoRollup merge of #90989 - notriddle:notriddle/rustc-suggest-float-ending-in-dot, r...
Yuki Okushi [Thu, 18 Nov 2021 17:22:59 +0000 (02:22 +0900)]
Rollup merge of #90989 - notriddle:notriddle/rustc-suggest-float-ending-in-dot, r=sanxiyn

Avoid suggesting literal formatting that turns into member access

Fixes #90974

2 years agoRollup merge of #90895 - RalfJung:read-discriminant-valid, r=oli-obk
Yuki Okushi [Thu, 18 Nov 2021 17:22:58 +0000 (02:22 +0900)]
Rollup merge of #90895 - RalfJung:read-discriminant-valid, r=oli-obk

require full validity when determining the discriminant of a value

This resolves (for now) the semantic question that came up in https://github.com/rust-lang/rust/pull/89764: arguably, reading the discriminant of a value is 'using' that value, so we are in our right to demand full validity. Reading a discriminant is somewhat special in that it works for values of *arbitrary* type; all the other primitive MIR operations work on specific types (e.g. `bool` or an integer) and basically implicitly require validity as part of just "doing their job".

The alternative would be to just require that the discriminant itself is valid, if any -- but then what do we do for types that do not have a discriminant, which kind of validity do we check? [This code](https://github.com/rust-lang/rust/blob/81117ff930fbf3792b4f9504e3c6bccc87b10823/compiler/rustc_codegen_ssa/src/mir/place.rs#L206-L215) means we have to at least reject uninhabited types, but I would rather not special case that.

I don't think this can be tested in CTFE (since validity is not enforced there), I will add a compile-fail test to Miri:
```rust
#[allow(enum_intrinsics_non_enums)]
fn main() {
    let i = 2u8;
    std::mem::discriminant(unsafe { &*(&i as *const _ as *const bool) }); // UB
}
```

(I tried running the check even on the CTFE machines, but then it runs during ConstProp and that causes all sorts of problems. We could run it for ConstEval but not ConstProp, but that simply does not seem worth the effort currently.)

r? ``@oli-obk``

2 years agoRollup merge of #90750 - camelid:rm-tuple-impls-1, r=jyn514
Yuki Okushi [Thu, 18 Nov 2021 17:22:57 +0000 (02:22 +0900)]
Rollup merge of #90750 - camelid:rm-tuple-impls-1, r=jyn514

rustdoc: Replace where-bounded Clean impl with simple function

This is the first step in removing the Clean impls for tuples. Either way, this
significantly simplifies the code since it reduces the amount of "trait magic".

(To clarify, I'm referring to impls like `impl Clean for (A, B)`, not Clean impls
that work on tuples in the user's program.)

cc ``@jyn514``

2 years agoRollup merge of #90607 - WaffleLapkin:const_str_from_utf8, r=oli-obk
Yuki Okushi [Thu, 18 Nov 2021 17:22:57 +0000 (02:22 +0900)]
Rollup merge of #90607 - WaffleLapkin:const_str_from_utf8, r=oli-obk

Make slice->str conversion and related functions `const`

This PR marks the following APIs as `const`:
```rust
// core::str
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error>;
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error>;
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str;

impl Utf8Error {
    pub const fn valid_up_to(&self) -> usize;
    pub const fn error_len(&self) -> Option<usize>;
}
```

Everything but `from_utf8_unchecked_mut` uses `const_str_from_utf8` feature gate, `from_utf8_unchecked_mut` uses `const_str_from_utf8_unchecked_mut` feature gate.

---

I'm not sure why `from_utf8_unchecked_mut` was left out being  non-`const`, considering that `from_utf8_unchecked` is not only `const`, but **`const` stable**.

---

r? ```@oli-obk``` (performance-only `const_eval_select` use)

2 years agoRollup merge of #90480 - r00ster91:remove, r=kennytm
Yuki Okushi [Thu, 18 Nov 2021 17:22:56 +0000 (02:22 +0900)]
Rollup merge of #90480 - r00ster91:remove, r=kennytm

Mention `Vec::remove` in `Vec::swap_remove`'s docs

Thought this was a nice addition.

2 years agoRollup merge of #90438 - GuillaumeGomez:doc-show-coverage, r=camelid
Yuki Okushi [Thu, 18 Nov 2021 17:22:55 +0000 (02:22 +0900)]
Rollup merge of #90438 - GuillaumeGomez:doc-show-coverage, r=camelid

Clean up mess for --show-coverage documentation

It was somewhat duplicated for some reasons... Anyway, this remove this duplication and clean up a bit.

r? ```@camelid```

2 years agoRollup merge of #90386 - pierwill:assert-incr-state-85864, r=Aaron1011
Yuki Okushi [Thu, 18 Nov 2021 17:22:54 +0000 (02:22 +0900)]
Rollup merge of #90386 - pierwill:assert-incr-state-85864, r=Aaron1011

Add `-Zassert-incr-state` to assert state of incremental cache

Closes #85864.

2 years agoAuto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett
bors [Thu, 18 Nov 2021 17:19:27 +0000 (17:19 +0000)]
Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett

std: Get the standard library compiling for wasm64

This commit goes through and updates various `#[cfg]` as appropriate to
get the wasm64-unknown-unknown target behaving similarly to the
wasm32-unknown-unknown target. Most of this is just updating various
conditions for `target_arch = "wasm32"` to also account for `target_arch
= "wasm64"` where appropriate. This commit also lists `wasm64` as an
allow-listed architecture to not have the `restricted_std` feature
enabled, enabling experimentation with `-Z build-std` externally.

The main goal of this commit is to enable playing around with
`wasm64-unknown-unknown` externally via `-Z build-std` in a way that's
similar to the `wasm32-unknown-unknown` target. These targets are
effectively the same and only differ in their pointer size, but wasm64
is much newer and has much less ecosystem/library support so it'll still
take time to get wasm64 fully-fledged.

2 years agoCTFE SIMD: also test 1-element array
Ralf Jung [Thu, 18 Nov 2021 16:05:30 +0000 (11:05 -0500)]
CTFE SIMD: also test 1-element array

2 years agoMove some tests to more reasonable directories
Caio [Thu, 18 Nov 2021 15:09:34 +0000 (12:09 -0300)]
Move some tests to more reasonable directories

2 years agofix CTFE/Miri simd_insert/extract on array-style repr(simd) types
Ralf Jung [Thu, 18 Nov 2021 03:29:21 +0000 (22:29 -0500)]
fix CTFE/Miri simd_insert/extract on array-style repr(simd) types

2 years agoFill in tracking issues for `const_str_from_utf8` and `const_str_from_utf8_unchecked_...
Maybe Waffle [Thu, 18 Nov 2021 11:04:01 +0000 (14:04 +0300)]
Fill in tracking issues for `const_str_from_utf8` and `const_str_from_utf8_unchecked_mut` features

2 years agoClean up mess for --show-coverage documentation
Guillaume Gomez [Mon, 8 Nov 2021 14:21:13 +0000 (15:21 +0100)]
Clean up mess for --show-coverage documentation

2 years agorustc: Remove `#[rustc_synthetic]`
Vadim Petrochenkov [Thu, 18 Nov 2021 05:25:27 +0000 (13:25 +0800)]
rustc: Remove `#[rustc_synthetic]`

This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.

2 years agoAuto merge of #90991 - ehuss:update-cargo, r=ehuss
bors [Thu, 18 Nov 2021 00:54:32 +0000 (00:54 +0000)]
Auto merge of #90991 - ehuss:update-cargo, r=ehuss

Update cargo

11 commits in 2e2a16e983f597da62bc132eb191bc3276d4b1bb..ad50d0d266213e0cc4f6e526a39d96faae9a3842
2021-11-08 15:13:38 +0000 to 2021-11-17 18:36:37 +0000
- Warn when alias shadows external subcommand (rust-lang/cargo#10082)
- Implement escaping to allow clean -p to delete all files when directory contains glob characters (rust-lang/cargo#10072)
- Match any error when failing to find executables (rust-lang/cargo#10092)
- Enhance error message for target auto-discovery (rust-lang/cargo#10090)
- Include note about bug while building on macOS in mdbook (rust-lang/cargo#10073)
- Improve the help text of the --quiet args for all commands (rust-lang/cargo#10080)
- `future-incompat-report` checks both stdout and stderr for color support (rust-lang/cargo#10024)
- Remove needless borrow to make clippy happy (rust-lang/cargo#10081)
- Describe the background color of the timing graph (rust-lang/cargo#10076)
- Make ProfileChecking comments a doc comments (rust-lang/cargo#10077)
- Fix test: hash value depends on endianness and bitness. (rust-lang/cargo#10011)

2 years agoAvoid suggesting literal formatting that turns into member access
Michael Howell [Wed, 17 Nov 2021 20:28:54 +0000 (13:28 -0700)]
Avoid suggesting literal formatting that turns into member access

Fixes #90974

2 years agoMake slice->str conversion and related functions const
Maybe Waffle [Fri, 5 Nov 2021 12:39:01 +0000 (15:39 +0300)]
Make slice->str conversion and related functions const

This commit makes the following functions from `core::str` `const fn`:
- `from_utf8[_mut]` (`feature(const_str_from_utf8)`)
- `from_utf8_unchecked_mut` (`feature(const_str_from_utf8_unchecked_mut)`)
- `Utf8Error::{valid_up_to,error_len}` (`feature(const_str_from_utf8)`)

2 years agoAdd a test with a leading newline for ICE #90878
Nilstrieb [Wed, 17 Nov 2021 21:24:42 +0000 (22:24 +0100)]
Add a test with a leading newline for ICE #90878

2 years agotidy-ignore-leading-newlines
Nilstrieb [Wed, 17 Nov 2021 21:22:48 +0000 (22:22 +0100)]
tidy-ignore-leading-newlines

2 years agoUpdate cargo
Eric Huss [Wed, 17 Nov 2021 20:58:29 +0000 (12:58 -0800)]
Update cargo

2 years agoFix emscripten tests
Alex Crichton [Wed, 17 Nov 2021 18:30:31 +0000 (10:30 -0800)]
Fix emscripten tests

2 years agoAuto merge of #90984 - matthiaskrgr:rollup-j5bs96a, r=matthiaskrgr
bors [Wed, 17 Nov 2021 17:13:41 +0000 (17:13 +0000)]
Auto merge of #90984 - matthiaskrgr:rollup-j5bs96a, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #89610 (warn on must_use use on async fn's)
 - #90667 (Improve diagnostics when a static lifetime is expected)
 - #90687 (Permit const panics in stable const contexts in stdlib)
 - #90772 (Add Vec::retain_mut)
 - #90861 (Print escaped string if char literal has multiple characters, but only one printable character)
 - #90884 (Fix span for non-satisfied trivial trait bounds)
 - #90900 (Remove workaround for the forward progress handling in LLVM)
 - #90901 (Improve ManuallyDrop suggestion)

Failed merges:

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

2 years agoadd const generics test
lcnr [Thu, 4 Nov 2021 19:21:36 +0000 (20:21 +0100)]
add const generics test

2 years agoRollup merge of #90901 - rukai:improve_manuallydrop_help, r=estebank
Matthias Krüger [Wed, 17 Nov 2021 14:58:06 +0000 (15:58 +0100)]
Rollup merge of #90901 - rukai:improve_manuallydrop_help, r=estebank

Improve ManuallyDrop suggestion

closes https://github.com/rust-lang/rust/issues/90585
* Fixes the recommended change to use ManuallyDrop as per the issue
* Changes the note to a help
* improves the span so it only points at the type.

2 years agoRollup merge of #90900 - andjo403:removeLlvm12Check, r=nikic
Matthias Krüger [Wed, 17 Nov 2021 14:58:05 +0000 (15:58 +0100)]
Rollup merge of #90900 - andjo403:removeLlvm12Check, r=nikic

Remove workaround for the forward progress handling in LLVM

this workaround was only needed for LLVM < 12 and the minimum LLVM version was updated to 12 in #90175

2 years agoRollup merge of #90884 - Nilstrieb:fix-span-trivial-trait-bound, r=estebank
Matthias Krüger [Wed, 17 Nov 2021 14:58:04 +0000 (15:58 +0100)]
Rollup merge of #90884 - Nilstrieb:fix-span-trivial-trait-bound, r=estebank

Fix span for non-satisfied trivial trait bounds

The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before.
Now they only reference the obligation itself (`String: Copy`)

Address #90869

2 years agoRollup merge of #90861 - 5225225:nonprinting-char, r=davidtwco
Matthias Krüger [Wed, 17 Nov 2021 14:58:02 +0000 (15:58 +0100)]
Rollup merge of #90861 - 5225225:nonprinting-char, r=davidtwco

Print escaped string if char literal has multiple characters, but only one printable character

Fixes #90857

I'm not sure about the error message here, it could get rather long and *maybe* using the names of characters would be better? That wouldn't help the length any, though.

2 years agoRollup merge of #90772 - GuillaumeGomez:vec-retain-mut, r=joshtriplett
Matthias Krüger [Wed, 17 Nov 2021 14:58:01 +0000 (15:58 +0100)]
Rollup merge of #90772 - GuillaumeGomez:vec-retain-mut, r=joshtriplett

Add Vec::retain_mut

This is to continue the discussion started in #83218.

Original comment was:

> Take 2 of #34265, since I needed this today.

The reason I think why we should add `retain_mut` is for coherency and for discoverability. For example we have `chunks` and `chunks_mut` or `get` and `get_mut` or `iter` and `iter_mut`, etc. When looking for mutable `retain`, I would expect `retain_mut` to exist. It took me a while to find out about `drain_filter`. So even if it provides an API close to `drain_filter`, just for the discoverability, I think it's worth it.

cc ``````@m-ou-se`````` ``````@jonas-schievink`````` ``````@Mark-Simulacrum``````

2 years agoRollup merge of #90687 - jhpratt:const_panic, r=oli-obk
Matthias Krüger [Wed, 17 Nov 2021 14:58:00 +0000 (15:58 +0100)]
Rollup merge of #90687 - jhpratt:const_panic, r=oli-obk

Permit const panics in stable const contexts in stdlib

Without this change, it is not possible to use `panic!` and similar (including `assert!`) in stable const contexts inside of stdlib. See #89542 for a real-world case that currently fails for this reason. This does _not_ affect any user code.

For example, this snippet currently fails to compile:

```rust
#[stable(feature = "foo", since = "1.0.0")]
#[rustc_const_stable(feature = "foo", since = "1.0.0")]
const fn foo() {
    assert!(false);
    assert!(false, "foo");
}
```

With the addition of `#[rustc_const_unstable]` to `core::panicking::panic`, the error no longer occurs. This snippet has been added verbatim in this PR as a UI test.

To avoid needing to add `#![feature(core_panic)]` to libcore, the two instances of direct calls to `core::panicking::panic` have been switched to use the `panic!` macro.

I am requesting prioritization because this is holding up other stabilizations such as #89542 (which is otherwise ready to merge and succeeds with this change)

2 years agoRollup merge of #90667 - rukai:improve_static_lifetime_diagnostics, r=estebank
Matthias Krüger [Wed, 17 Nov 2021 14:57:57 +0000 (15:57 +0100)]
Rollup merge of #90667 - rukai:improve_static_lifetime_diagnostics, r=estebank

Improve diagnostics when a static lifetime is expected

Makes progress towards https://github.com/rust-lang/rust/issues/90600

The diagnostics here were previously entirely removed due to giving a misleading suggestion but if we instead provide an informative label in that same location it should better help the user understand the situation.

I included the example from the issue as it demonstrates an area where the diagnostics are still lacking.
Happy to remove that if its just adding noise atm.

2 years agoRollup merge of #89610 - guswynn:must_use_future, r=wesleywiser
Matthias Krüger [Wed, 17 Nov 2021 14:57:56 +0000 (15:57 +0100)]
Rollup merge of #89610 - guswynn:must_use_future, r=wesleywiser

warn on must_use use on async fn's

As referenced in #78149

This only works on `async` fn's for now, I can also look into if I can get `Box<dyn Future>` and `impl Future` working at this level (hir)

2 years agoAuto merge of #90954 - Amanieu:fix-aarch64-asm, r=nikic
bors [Wed, 17 Nov 2021 14:07:42 +0000 (14:07 +0000)]
Auto merge of #90954 - Amanieu:fix-aarch64-asm, r=nikic

Update llvm submodule

- [DIArgList] Re-unique after changing operands to fix non-determinism
- [AArch64][GlobalISel] Fix an crash in RBS due to a new regclass being added.

2 years agoMake scrollbar in the sidebar always visible for visual consistency
Guillaume Gomez [Wed, 17 Nov 2021 13:45:17 +0000 (14:45 +0100)]
Make scrollbar in the sidebar always visible for visual consistency

2 years agoAuto merge of #90966 - matthiaskrgr:rollup-4akzcrh, r=matthiaskrgr
bors [Wed, 17 Nov 2021 02:58:29 +0000 (02:58 +0000)]
Auto merge of #90966 - matthiaskrgr:rollup-4akzcrh, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #90733 (Build musl dist artifacts with debuginfo enabled)
 - #90787 (Add `#[inline]`s to `SortedIndexMultiMap`)
 - #90920 (:arrow_up: rust-analyzer)
 - #90933 (Fix await suggestion on non-future type)
 - #90935 (Alphabetize language features)
 - #90949 (update miri)
 - #90958 (Mark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn`)

Failed merges:

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

2 years agoRollup merge of #90958 - WaffleLapkin:const_align_offset, r=oli-obk
Matthias Krüger [Tue, 16 Nov 2021 22:58:27 +0000 (23:58 +0100)]
Rollup merge of #90958 - WaffleLapkin:const_align_offset, r=oli-obk

Mark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn`

This PR marks the following APIs as `const`:
```rust
impl<T> *const T {
    pub const fn align_offset(self, align: usize) -> usize;
}

impl<T> *mut T {
    pub const fn align_offset(self, align: usize) -> usize;
}
```

`const` implementation simply returns `usize::MAX`.

---

Previous discussion: https://github.com/rust-lang/rust/pull/90607#discussion_r743638164

---

r? `@oli-obk`

2 years agoRollup merge of #90949 - RalfJung:miri, r=RalfJung
Matthias Krüger [Tue, 16 Nov 2021 22:58:26 +0000 (23:58 +0100)]
Rollup merge of #90949 - RalfJung:miri, r=RalfJung

update miri

This is needed to fix https://github.com/rust-lang/miri-test-libstd
r? ````@ghost````

2 years agoRollup merge of #90935 - jhpratt:alphabetize-features, r=joshtriplett
Matthias Krüger [Tue, 16 Nov 2021 22:58:25 +0000 (23:58 +0100)]
Rollup merge of #90935 - jhpratt:alphabetize-features, r=joshtriplett

Alphabetize language features

This should significantly reduce the frequency of merge conflicts.

r? ````@joshtriplett````

````@rustbot```` label: +A-contributor-roadblock +S-waiting-on-review

2 years agoRollup merge of #90933 - compiler-errors:master, r=estebank
Matthias Krüger [Tue, 16 Nov 2021 22:58:24 +0000 (23:58 +0100)]
Rollup merge of #90933 - compiler-errors:master, r=estebank

Fix await suggestion on non-future type

Remove a match block that would suggest to add `.await` in the case where the expected type's `Future::Output` equals the found type. We only want to suggest `.await`ing in the opposite case (the found type's `Future::Output` equals the expected type).

The code sample is here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6ba6b83d4dddda263553b79dca9f6bcb

Before:
```
➜  ~ rustc --edition=2021 --crate-type=lib test.rs
error[E0308]: `match` arms have incompatible types
 --> test.rs:4:14
  |
2 |       let x = match 1 {
  |  _____________-
3 | |         1 => other(),
  | |              ------- this is found to be of type `impl Future`
4 | |         2 => other().await,
  | |              ^^^^^^^^^^^^^ expected opaque type, found enum `Result`
5 | |     };
  | |_____- `match` arms have incompatible types
  |
  = note: expected type `impl Future`
             found enum `Result<(), ()>`
help: consider `await`ing on the `Future`
  |
4 |         2 => other().await.await,
  |                           ++++++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
```

After:
```
➜  ~ rustc +stage1 --edition=2021 --crate-type=lib test.rs
error[E0308]: `match` arms have incompatible types
 --> test.rs:4:14
  |
2 |       let x = match 1 {
  |  _____________-
3 | |         1 => other(),
  | |              ------- this is found to be of type `impl Future`
4 | |         2 => other().await,
  | |              ^^^^^^^^^^^^^ expected opaque type, found enum `Result`
5 | |     };
  | |_____- `match` arms have incompatible types
  |
  = note: expected type `impl Future`
             found enum `Result<(), ()>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
```

Fixes #90931

2 years agoRollup merge of #90920 - lnicola:rust-analyzer-2021-11-15, r=lnicola
Matthias Krüger [Tue, 16 Nov 2021 22:58:23 +0000 (23:58 +0100)]
Rollup merge of #90920 - lnicola:rust-analyzer-2021-11-15, r=lnicola

:arrow_up: rust-analyzer

r? ``@ghost``

2 years agoRollup merge of #90787 - JohnTitor:inline-sorted-index-map, r=oli-obk
Matthias Krüger [Tue, 16 Nov 2021 22:58:22 +0000 (23:58 +0100)]
Rollup merge of #90787 - JohnTitor:inline-sorted-index-map, r=oli-obk

Add `#[inline]`s to `SortedIndexMultiMap`

They're small enough and good candidates to add `#[inline]` generally.

2 years agoRollup merge of #90733 - wesleywiser:musl_debuginfo, r=Mark-Simulacrum
Matthias Krüger [Tue, 16 Nov 2021 22:58:21 +0000 (23:58 +0100)]
Rollup merge of #90733 - wesleywiser:musl_debuginfo, r=Mark-Simulacrum

Build musl dist artifacts with debuginfo enabled

Since our musl targets link to a version of musl we build and bundle
with the targets, if users need to debug into musl or generate
backtraces which contain parts of the musl library, they will be unable
to do so unless we enable and ship the debug info.

This patch changes our dist builds so they enabled debug info when
building musl. This patch also includes a fix for CFI detection in
musl's `configure` script which has been [posted upstream](https://www.openwall.com/lists/musl/2021/10/21/2).

The net effect of this is that we now ship debug info for musl in those
targets. This adds ~90kb to those artifacts but running `strip` on
binaries produced removes all of that. For a "hello world" Rust binary
on x86_64, the numbers are:

|                        | debug | release | release + strip |
|           -            |   -   |    -    |        -        |
| without musl debuginfo | 507kb |  495kb  |      410kb      |
| with musl debuginfo    | 595kb | 584kb | 410kb |

Once stripped, the final binaries are the same size (down to the byte).

Fixes #90103

r? `@Mark-Simulacrum`

2 years agoRemove unnecessary lifetime argument from arena macros.
Nicholas Nethercote [Mon, 15 Nov 2021 22:28:26 +0000 (09:28 +1100)]
Remove unnecessary lifetime argument from arena macros.

Because it's always `'tcx`. In fact, some of them use a mixture of
passed-in `$tcx` and hard-coded `'tcx`, so no other lifetime would even
work.

This makes the code easier to read.

2 years agoFix await suggestion better
Michael Goulet [Tue, 16 Nov 2021 06:51:20 +0000 (22:51 -0800)]
Fix await suggestion better

2 years agoFix case where ICE #90878 was still triggered by a leading newline
Nilstrieb [Tue, 16 Nov 2021 21:16:47 +0000 (22:16 +0100)]
Fix case where ICE #90878 was still triggered by a leading newline

I cannot provide a test for that thanks to tidy.

2 years agoAdd emscripten to the "wasm" family of targets
Alex Crichton [Tue, 16 Nov 2021 21:10:35 +0000 (13:10 -0800)]
Add emscripten to the "wasm" family of targets

2 years agoFill in tracking issue for feature `const_align_offset`
Maybe Waffle [Tue, 16 Nov 2021 20:58:40 +0000 (23:58 +0300)]
Fill in tracking issue for feature `const_align_offset`

2 years agoSuggest removal of arguments for unit variant, not replacement
Esteban Kuber [Tue, 16 Nov 2021 20:35:26 +0000 (20:35 +0000)]
Suggest removal of arguments for unit variant, not replacement

2 years agoMark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn`
Maybe Waffle [Tue, 16 Nov 2021 20:03:28 +0000 (23:03 +0300)]
Mark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn`

2 years agoUpdate test output.
Mara Bos [Tue, 16 Nov 2021 18:57:12 +0000 (19:57 +0100)]
Update test output.