]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoUse span_suggestions instead of multipart_suggestions.
Mara Bos [Thu, 4 Nov 2021 17:12:09 +0000 (18:12 +0100)]
Use span_suggestions instead of multipart_suggestions.

2 years agoAdd new tests for compatible variant diagnostics.
Mara Bos [Thu, 4 Nov 2021 16:57:40 +0000 (17:57 +0100)]
Add new tests for compatible variant diagnostics.

2 years agoUpdate tests.
Mara Bos [Thu, 4 Nov 2021 16:57:30 +0000 (17:57 +0100)]
Update tests.

2 years agoImprove compatible enum variant suggestions.
Mara Bos [Thu, 4 Nov 2021 16:57:03 +0000 (17:57 +0100)]
Improve compatible enum variant suggestions.

2 years agoImprove suggestion for unit Option/Result at the end of a block.
Mara Bos [Thu, 4 Nov 2021 16:56:04 +0000 (17:56 +0100)]
Improve suggestion for unit Option/Result at the end of a block.

2 years agoAdd SourceMap::indentation_before.
Mara Bos [Thu, 4 Nov 2021 16:55:25 +0000 (17:55 +0100)]
Add SourceMap::indentation_before.

2 years agoAdd a regression test for #87573
Yuki Okushi [Tue, 16 Nov 2021 18:52:38 +0000 (03:52 +0900)]
Add a regression test for #87573

2 years agowindows: Return the "Not Found" error when a path is empty
Yuki Okushi [Tue, 16 Nov 2021 05:36:20 +0000 (14:36 +0900)]
windows: Return the "Not Found" error when a path is empty

2 years agoUpdate llvm submodule
Amanieu d'Antras [Tue, 16 Nov 2021 16:48:55 +0000 (16:48 +0000)]
Update llvm submodule

2 years agoUpdate compiler/rustc_passes/src/check_attr.rs
Wesley Wiser [Tue, 16 Nov 2021 14:43:10 +0000 (09:43 -0500)]
Update compiler/rustc_passes/src/check_attr.rs

Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2 years agoupdate miri
Ralf Jung [Tue, 16 Nov 2021 14:28:30 +0000 (09:28 -0500)]
update miri

2 years agoAuto merge of #90919 - nnethercote:rm-DropArena, r=Mark-Simulacrum
bors [Tue, 16 Nov 2021 11:48:37 +0000 (11:48 +0000)]
Auto merge of #90919 - nnethercote:rm-DropArena, r=Mark-Simulacrum

Remove `DropArena`.

Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a
few infrequently used ones share a `DropArena`. This sharing adds complexity
but doesn't help performance or memory usage. Perhaps it was more effective in
the past prior to some other improvements to arenas.

This commit removes `DropArena` and the sharing of arenas via the `few`
attribute of the `arena_types` macro. This change removes over 100 lines of
code and nine uses of `unsafe` (one of which affects the parallel compiler) and
makes the remaining code easier to read.

2 years agoAuto merge of #90945 - JohnTitor:rollup-wc35xss, r=JohnTitor
bors [Tue, 16 Nov 2021 08:22:55 +0000 (08:22 +0000)]
Auto merge of #90945 - JohnTitor:rollup-wc35xss, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #86455 (check where-clause for explicit `Sized` before suggesting `?Sized`)
 - #90801 (Normalize both arguments of `equate_normalized_input_or_output`)
 - #90803 (Suggest `&str.chars()` on attempt to `&str.iter()`)
 - #90819 (Fixes incorrect handling of TraitRefs when emitting suggestions.)
 - #90910 (fix getting the discriminant of a zero-variant enum)
 - #90925 (rustc_mir_build: reorder bindings)
 - #90928 (Use a different server for checking clock drift)
 - #90936 (Add a regression test for #80772)

Failed merges:

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

2 years agoIncrease tidy limit for parser by 1
5225225 [Tue, 16 Nov 2021 08:08:31 +0000 (08:08 +0000)]
Increase tidy limit for parser by 1

2 years agoInline printable function
5225225 [Sat, 13 Nov 2021 15:08:20 +0000 (15:08 +0000)]
Inline printable function

2 years agoRemove debug output from test stderr
5225225 [Sat, 13 Nov 2021 13:25:19 +0000 (13:25 +0000)]
Remove debug output from test stderr

2 years agoSuggest removing the non-printing characters
5225225 [Sat, 13 Nov 2021 12:46:22 +0000 (12:46 +0000)]
Suggest removing the non-printing characters

2 years agoPrint full char literal on error if any are non-printing
5225225 [Sat, 13 Nov 2021 11:14:17 +0000 (11:14 +0000)]
Print full char literal on error if any are non-printing

2 years agoRollup merge of #90936 - JohnTitor:issue-80772, r=Mark-Simulacrum
Yuki Okushi [Tue, 16 Nov 2021 06:59:44 +0000 (15:59 +0900)]
Rollup merge of #90936 - JohnTitor:issue-80772, r=Mark-Simulacrum

Add a regression test for #80772

Closes #80772

2 years agoRollup merge of #90928 - Mark-Simulacrum:fix-date-logging, r=pietroalbini
Yuki Okushi [Tue, 16 Nov 2021 06:59:43 +0000 (15:59 +0900)]
Rollup merge of #90928 - Mark-Simulacrum:fix-date-logging, r=pietroalbini

Use a different server for checking clock drift

The detectportal.firefox.com server seems to return a random-ish date; for
example I see the following across 5 curl's done consecutively locally, where
the real date is approximately 15 Nov 2021 06:36 UTC.

Date: Mon, 15 Nov 2021 13:34:53 GMT
Date: Mon, 15 Nov 2021 12:20:21 GMT
Date: Mon, 15 Nov 2021 00:06:47 GMT
Date: Mon, 15 Nov 2021 17:14:33 GMT
Date: Mon, 15 Nov 2021 13:33:21 GMT

2 years agoRollup merge of #90925 - krasimirgg:rustc_mir_build_fix, r=petrochenkov
Yuki Okushi [Tue, 16 Nov 2021 06:59:42 +0000 (15:59 +0900)]
Rollup merge of #90925 - krasimirgg:rustc_mir_build_fix, r=petrochenkov

rustc_mir_build: reorder bindings

No functional changes intended.

I'm playing around with building compiler components using nightly rust
(2021-11-02) in a non-standard way. I encountered the following error while
trying to build rustc_mir_build:

```
error[E0597]: `wildcard` does not live long enough
    --> rust/src/nightly/compiler/rustc_mir_build/src/build/matches/mod.rs:1767:82
     |
1767 |         let mut otherwise_candidate = Candidate::new(expr_place_builder.clone(), &wildcard, false);
     |                                                                                  ^^^^^^^^^ borrowed value does not live long enough
...
1799 |     }
     |     -
     |     |
     |     `wildcard` dropped here while still borrowed
     |     borrow might be used here, when `guard_candidate` is dropped and runs the destructor for type `Candidate<'_, '_>`
     |
     = note: values in a scope are dropped in the opposite order they are defined
```

I believe this flags an issue that may become an error in the future.
Swapping the order of `wildcard` and `guard_candidate` resolves it.

2 years agoRollup merge of #90910 - RalfJung:const-discriminant-empty-enum, r=petrochenkov
Yuki Okushi [Tue, 16 Nov 2021 06:59:41 +0000 (15:59 +0900)]
Rollup merge of #90910 - RalfJung:const-discriminant-empty-enum, r=petrochenkov

fix getting the discriminant of a zero-variant enum

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

2 years agoRollup merge of #90819 - JakobDegen:issue-90804, r=petrochenkov
Yuki Okushi [Tue, 16 Nov 2021 06:59:40 +0000 (15:59 +0900)]
Rollup merge of #90819 - JakobDegen:issue-90804, r=petrochenkov

Fixes incorrect handling of TraitRefs when emitting suggestions.

Closes #90804 , although there were more issues here that were hidden by the thing that caused this ICE.

Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations.

This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.

2 years agoRollup merge of #90803 - TaKO8Ki:suggest-chars-on-attempt-to-iter, r=estebank
Yuki Okushi [Tue, 16 Nov 2021 06:59:39 +0000 (15:59 +0900)]
Rollup merge of #90803 - TaKO8Ki:suggest-chars-on-attempt-to-iter, r=estebank

Suggest `&str.chars()` on attempt to `&str.iter()`

closes #90786

2 years agoRollup merge of #90801 - b-naber:missing_normalization_equate_inputs_output, r=jackh726
Yuki Okushi [Tue, 16 Nov 2021 06:59:39 +0000 (15:59 +0900)]
Rollup merge of #90801 - b-naber:missing_normalization_equate_inputs_output, r=jackh726

Normalize both arguments of `equate_normalized_input_or_output`

Fixes https://github.com/rust-lang/rust/issues/90638
Fixes https://github.com/rust-lang/rust/issues/90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ````@jackh726````

2 years agoRollup merge of #86455 - tlyu:check-where-before-suggesting-unsized, r=estebank
Yuki Okushi [Tue, 16 Nov 2021 06:59:38 +0000 (15:59 +0900)]
Rollup merge of #86455 - tlyu:check-where-before-suggesting-unsized, r=estebank

check where-clause for explicit `Sized` before suggesting `?Sized`

Fixes #85945.

Based on #86454.

``@rustbot`` label +A-diagnostics +A-traits +A-typesystem +D-papercut +T-compiler

2 years agoAuto merge of #90845 - JakobDegen:adt-drop-perf, r=Mark-Simulacrum
bors [Tue, 16 Nov 2021 05:18:57 +0000 (05:18 +0000)]
Auto merge of #90845 - JakobDegen:adt-drop-perf, r=Mark-Simulacrum

Address performance regression introduced by #90218

As part of the changes in #90218 , the `adt_drop_tys` and friends code stopped recursing through the query system, meaning that intermediate computations did not get cached. This change adds the recursions back in without re-introducing any of the old issues.

On local benchmarks this fixes the 5% regressions in #90504 ; the wg-grammar regressions didn't seem to move too much. I may take some time later to look into those.

Not sure who to request for review here, so will leave it up to whoever gets it.

2 years agorefactor is_param_bound
Taylor Yu [Sat, 19 Jun 2021 00:24:22 +0000 (19:24 -0500)]
refactor is_param_bound

2 years agocheck where clause before suggesting unsized
Taylor Yu [Fri, 18 Jun 2021 19:13:12 +0000 (14:13 -0500)]
check where clause before suggesting unsized

2 years agoSuggest where feature should be placed
Jacob Pratt [Tue, 16 Nov 2021 02:11:15 +0000 (21:11 -0500)]
Suggest where feature should be placed

2 years agoAlphabetize language features
Jacob Pratt [Tue, 16 Nov 2021 00:27:42 +0000 (19:27 -0500)]
Alphabetize language features

This should significantly reduce the frequency of merge conflicts.

2 years agoAuto merge of #90934 - JohnTitor:rollup-5soqo0j, r=JohnTitor
bors [Tue, 16 Nov 2021 02:23:42 +0000 (02:23 +0000)]
Auto merge of #90934 - JohnTitor:rollup-5soqo0j, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #85766 (Stabilize File::options())
 - #88601 (Implement `Termination` for `Result<Infallible, E>`)
 - #90058 (Stabilize -Z strip as -C strip)
 - #90790 (Fix standard library test with read_link)
 - #90834 (Android is not GNU)
 - #90835 (Rename WASI's `is_character_device` to `is_char_device`.)
 - #90837 (Move some tests to more reasonable directories - 9)
 - #90848 (Remove bigint_helper_methods for *signed* types)
 - #90892 (fix ICE on Miri/CTFE copy of half a pointer)
 - #90909 (disable portable SIMD tests in Miri)

Failed merges:

 - #90128 (Stabilize -Z symbol-mangling-version=v0 as -C symbol-mangling-version=v0)

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

2 years agoAdd a regression test for #80772
Yuki Okushi [Tue, 16 Nov 2021 00:38:43 +0000 (09:38 +0900)]
Add a regression test for #80772

2 years agoRollup merge of #90909 - RalfJung:miri-no-portable-simd, r=workingjubilee
Yuki Okushi [Tue, 16 Nov 2021 00:14:23 +0000 (09:14 +0900)]
Rollup merge of #90909 - RalfJung:miri-no-portable-simd, r=workingjubilee

disable portable SIMD tests in Miri

Until https://github.com/rust-lang/miri/issues/1912 is resolved, we'll have to skip these tests in Miri.

2 years agoRollup merge of #90892 - RalfJung:miri-partial-ptr-copy, r=oli-obk
Yuki Okushi [Tue, 16 Nov 2021 00:14:22 +0000 (09:14 +0900)]
Rollup merge of #90892 - RalfJung:miri-partial-ptr-copy, r=oli-obk

fix ICE on Miri/CTFE copy of half a pointer

Fixes https://github.com/rust-lang/miri/issues/1910
r? `````@oli-obk`````

2 years agoRollup merge of #90848 - scottmcm:remove-signed-bigint-helpers, r=joshtriplett
Yuki Okushi [Tue, 16 Nov 2021 00:14:21 +0000 (09:14 +0900)]
Rollup merge of #90848 - scottmcm:remove-signed-bigint-helpers, r=joshtriplett

Remove bigint_helper_methods for *signed* types

This PR inspired by `@cuviper's` comment @ https://github.com/rust-lang/rust/issues/90541#issuecomment-967309808

These are working well for *unsigned* types, so keep those, but for the the *signed* ones there are a bunch of questions about what the semantics and API should be.  For the main "helpers for big integer implementations" use, there's no need for the signed versions anyway.  There are plenty of other methods which exist for unsigned types but not signed ones, like `next_power_of_two`, so this isn't unusual.

Fixes #90541
Tracking issue #85532

2 years agoRollup merge of #90837 - c410-f3r:testsssssss, r=petrochenkov
Yuki Okushi [Tue, 16 Nov 2021 00:14:20 +0000 (09:14 +0900)]
Rollup merge of #90837 - c410-f3r:testsssssss, r=petrochenkov

Move some tests to more reasonable directories - 9

cc #73494
r? `@petrochenkov`

2 years agoRollup merge of #90835 - sunfishcode:sunfishcode/wasi-char-device, r=alexcrichton
Yuki Okushi [Tue, 16 Nov 2021 00:14:19 +0000 (09:14 +0900)]
Rollup merge of #90835 - sunfishcode:sunfishcode/wasi-char-device, r=alexcrichton

Rename WASI's `is_character_device` to `is_char_device`.

Rename WASI's `FileTypeExt::is_character_device` to
`FileTypeExt::is_char_device`, for consistency with the Unix
`FileTypeExt::is_char_device`.

Also, add a `FileTypeExt::is_socket` function, for consistency with the
Unix `FileTypeExt::is_socket` function.

r? `@alexcrichton`

2 years agoRollup merge of #90834 - cuviper:android-gnu, r=petrochenkov
Yuki Okushi [Tue, 16 Nov 2021 00:14:18 +0000 (09:14 +0900)]
Rollup merge of #90834 - cuviper:android-gnu, r=petrochenkov

Android is not GNU

For a long time, the Android targets had `target_env=""`, but this changed to `"gnu"` in Rust 1.49.0. I tracked this down to #77729 which started setting `"gnu"` in the `linux_base` target options, and this was inherited by `android_base`. Then #78929 split the env into `linux_gnu_base`, but `android_base` was also changed to follow that. Android was not specifically mentioned in either pull request, so I believe this was an accident. Moving it back to `linux_base` will use an empty `env` again.

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

2 years agoRollup merge of #90790 - tamaroning:fix-lib-std-test, r=Mark-Simulacrum
Yuki Okushi [Tue, 16 Nov 2021 00:14:17 +0000 (09:14 +0900)]
Rollup merge of #90790 - tamaroning:fix-lib-std-test, r=Mark-Simulacrum

Fix standard library test with read_link

closes #90669
resolve this issue by comparing between Paths instead of strs

2 years agoRollup merge of #90058 - joshtriplett:stabilize-strip, r=wesleywiser
Yuki Okushi [Tue, 16 Nov 2021 00:14:16 +0000 (09:14 +0900)]
Rollup merge of #90058 - joshtriplett:stabilize-strip, r=wesleywiser

Stabilize -Z strip as -C strip

Leave -Z strip available temporarily as an alias, to avoid breaking
cargo until cargo transitions to using -C strip.

2 years agoRollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahc
Yuki Okushi [Tue, 16 Nov 2021 00:14:15 +0000 (09:14 +0900)]
Rollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahc

Implement `Termination` for `Result<Infallible, E>`

As noted in #43301, `Result<!, E>` is not usable on stable.

2 years agoRollup merge of #85766 - workingjubilee:file-options, r=yaahc
Yuki Okushi [Tue, 16 Nov 2021 00:14:14 +0000 (09:14 +0900)]
Rollup merge of #85766 - workingjubilee:file-options, r=yaahc

Stabilize File::options()

Renames File::with_options to File::options, per consensus in
rust-lang/rust#65439, and stabilizes it.

2 years agoAuto merge of #90827 - matthewjasper:assoc-item-cleanup-2, r=cjgillot
bors [Mon, 15 Nov 2021 23:27:59 +0000 (23:27 +0000)]
Auto merge of #90827 - matthewjasper:assoc-item-cleanup-2, r=cjgillot

Assoc item cleanup Part 2

- Remove `AssocItem` from `RegionVariableOrigin::AutoRef`
- Use the `associated_item_def_ids` query instead of the `associated_items` query when possible

The change to `ObligationCauseCode` from #90639 is omitted because it caused a perf regression.

r? `@cjgillot`

2 years agoAuto merge of #90821 - scottmcm:new-slice-reverse, r=Mark-Simulacrum
bors [Mon, 15 Nov 2021 20:19:23 +0000 (20:19 +0000)]
Auto merge of #90821 - scottmcm:new-slice-reverse, r=Mark-Simulacrum

MIRI says `reverse` is UB, so replace it with something LLVM can vectorize

For small types with padding, the current implementation is UB because it does integer operations on uninit values.
```
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
   --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:836:5
    |
836 | /     uint_impl! { u32, u32, i32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
837 | |     "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" }
    | |________________________________________________________________________________________________^ using uninitialized data, but this operation requires initialized memory
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

    = note: inside `core::num::<impl u32>::rotate_left` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs:211:13
    = note: inside `core::slice::<impl [Foo]>::reverse` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs:701:58
```
<https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=340739f22ca5b457e1da6f361768edc6>

But LLVM has gotten smarter since I wrote the previous implementation in 2017, so this PR removes all the manual magic and just writes it in such a way that LLVM will vectorize.  This code is much simpler and has very little `unsafe`, and is actually faster to boot!

If you're curious to see the codegen: <https://rust.godbolt.org/z/Pcn13Y9E3>

Before:
```
running 7 tests
test slice::reverse_simd_f64x4                           ... bench:      17,940 ns/iter (+/- 481) = 58448 MB/s
test slice::reverse_u128                                 ... bench:      17,758 ns/iter (+/- 205) = 59048 MB/s
test slice::reverse_u16                                  ... bench:     158,234 ns/iter (+/- 6,876) = 6626 MB/s
test slice::reverse_u32                                  ... bench:      62,047 ns/iter (+/- 1,117) = 16899 MB/s
test slice::reverse_u64                                  ... bench:      31,582 ns/iter (+/- 552) = 33201 MB/s
test slice::reverse_u8                                   ... bench:      81,253 ns/iter (+/- 1,510) = 12905 MB/s
test slice::reverse_u8x3                                 ... bench:     270,615 ns/iter (+/- 11,463) = 3874 MB/s
```

After:
```
running 7 tests
test slice::reverse_simd_f64x4                           ... bench:      17,731 ns/iter (+/- 306) = 59137 MB/s
test slice::reverse_u128                                 ... bench:      17,919 ns/iter (+/- 239) = 58517 MB/s
test slice::reverse_u16                                  ... bench:      43,160 ns/iter (+/- 607) = 24295 MB/s
test slice::reverse_u32                                  ... bench:      21,065 ns/iter (+/- 371) = 49778 MB/s
test slice::reverse_u64                                  ... bench:      21,118 ns/iter (+/- 482) = 49653 MB/s
test slice::reverse_u8                                   ... bench:      76,878 ns/iter (+/- 1,688) = 13639 MB/s
test slice::reverse_u8x3                                 ... bench:     264,723 ns/iter (+/- 5,544) = 3961 MB/s
```

Those are the existing benches, <https://github.com/rust-lang/rust/blob/14a2fd640e0df9ee8cc1e04280b0c3aff93c42da/library/alloc/benches/slice.rs#L322-L346>

2 years agoFix `non-constant value` ICE (#90878)
Nilstrieb [Mon, 15 Nov 2021 19:40:29 +0000 (20:40 +0100)]
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.

2 years agoUse a different server for checking clock drift
Mark Rousskov [Mon, 15 Nov 2021 18:35:06 +0000 (13:35 -0500)]
Use a different server for checking clock drift

The detectportal.firefox.com server seems to return a random-ish date; for
example I see the following across 5 curl's done consecutively locally, where
the real date is approximaly 15 Nov 2021 06:36 UTC.

Date: Mon, 15 Nov 2021 13:34:53 GMT
Date: Mon, 15 Nov 2021 12:20:21 GMT
Date: Mon, 15 Nov 2021 00:06:47 GMT
Date: Mon, 15 Nov 2021 17:14:33 GMT
Date: Mon, 15 Nov 2021 13:33:21 GMT

2 years agoAuto merge of #90473 - joshtriplett:stabilize-format-args-capture, r=Mark-Simulacrum
bors [Mon, 15 Nov 2021 16:10:19 +0000 (16:10 +0000)]
Auto merge of #90473 - joshtriplett:stabilize-format-args-capture, r=Mark-Simulacrum

stabilize format args capture

Works as expected, and there are widespread reports of success with it, as well as interest in it.

RFC: rust-lang/rfcs#2795
Tracking issue: https://github.com/rust-lang/rust/issues/67984

Addressing items from the tracking issue:

- We don't support capturing arguments from a non-literal format string like `format_args!(concat!(...))`. We could add that in a future enhancement, or we can decide that it isn't supported (as suggested in https://github.com/rust-lang/rust/issues/67984#issuecomment-801394736 ).
- I've updated the documentation.
- `panic!` now supports capture as well.
- There are potentially opportunities to further improve diagnostics for invalid usage, such as if it looks like the user tried to use an expression rather than a variable. However, such cases are all already caught and provide reasonable syntax errors now, and we can always provided even friendlier diagnostics in the future.

2 years agorustc_mir_build: reorder bindings
Krasimir Georgiev [Mon, 15 Nov 2021 15:23:02 +0000 (16:23 +0100)]
rustc_mir_build: reorder bindings

No functional changes intended.

I'm playing around with building compiler components using nightly rust
(2021-11-02) in a non-standard way. I encountered the following error while
trying to build rustc_mir_build:

```
error[E0597]: `wildcard` does not live long enough
    --> rust/src/nightly/compiler/rustc_mir_build/src/build/matches/mod.rs:1767:82
     |
1767 |         let mut otherwise_candidate = Candidate::new(expr_place_builder.clone(), &wildcard, false);
     |                                                                                  ^^^^^^^^^ borrowed value does not live long enough
...
1799 |     }
     |     -
     |     |
     |     `wildcard` dropped here while still borrowed
     |     borrow might be used here, when `guard_candidate` is dropped and runs the destructor for type `Candidate<'_, '_>`
     |
     = note: values in a scope are dropped in the opposite order they are defined
```

I believe this flags an issue that may become an error in the future.
Swapping the order of `wildcard` and `guard_candidate` resolves it.

2 years agoAuto merge of #90717 - kit-981:fix-ld64-flags, r=petrochenkov
bors [Mon, 15 Nov 2021 11:18:44 +0000 (11:18 +0000)]
Auto merge of #90717 - kit-981:fix-ld64-flags, r=petrochenkov

Fix ld64 flags

- The `-exported_symbols_list` argument appears to be malformed for `ld64` (if you are not going through `clang`).
- The `-dynamiclib` argument isn't support for `ld64`. It should be guarded behind a compiler flag.

These problems are fixed by these changes. I have also refactored the way linker arguments are generated to be ld/compiler agnostic and therefore less error prone.

These changes are necessary to support cross-compilation to darwin targets.

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 15 Nov 2021 10:46:22 +0000 (12:46 +0200)]
:arrow_up: rust-analyzer

2 years agoStabilize -Z strip as -C strip
Josh Triplett [Thu, 21 Oct 2021 11:19:46 +0000 (13:19 +0200)]
Stabilize -Z strip as -C strip

Leave -Z strip available temporarily as an alias, to avoid breaking
cargo until cargo transitions to using -C strip. (If the user passes
both, the -C version wins.)

2 years agoSupport having -Z and -C options with the same name
Josh Triplett [Thu, 21 Oct 2021 11:18:59 +0000 (13:18 +0200)]
Support having -Z and -C options with the same name

Tweak the `options!` macro to allow for -Z and -C options with the same
name without generating conflicting internal parsing functions.

Split out of the commit stabilizing -Z strip as -C strip.

2 years agoUpdate test output
Josh Triplett [Mon, 1 Nov 2021 16:51:54 +0000 (17:51 +0100)]
Update test output

2 years agoStabilize format_args_capture
Josh Triplett [Mon, 1 Nov 2021 15:18:36 +0000 (16:18 +0100)]
Stabilize format_args_capture

Works as expected, and there are widespread reports of success with it,
as well as interest in it.

2 years agoGive examples of format args capture in the fmt module documentation
Josh Triplett [Mon, 1 Nov 2021 14:24:39 +0000 (15:24 +0100)]
Give examples of format args capture in the fmt module documentation

2 years agoRemove `DropArena`.
Nicholas Nethercote [Mon, 15 Nov 2021 06:15:42 +0000 (17:15 +1100)]
Remove `DropArena`.

Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a
few infrequently used ones share a `DropArena`. This sharing adds complexity
but doesn't help performance or memory usage. Perhaps it was more effective in
the past prior to some other improvements to arenas.

This commit removes `DropArena` and the sharing of arenas via the `few`
attribute of the `arena_types` macro. This change removes over 100 lines of
code and nine uses of `unsafe` (one of which affects the parallel compiler) and
makes the remaining code easier to read.

2 years agoAuto merge of #90645 - terrarier2111:master, r=estebank
bors [Mon, 15 Nov 2021 06:55:01 +0000 (06:55 +0000)]
Auto merge of #90645 - terrarier2111:master, r=estebank

Implement diagnostic for String conversion

This is my first real contribution to rustc, any feedback is highly appreciated.
This should fix https://github.com/rust-lang/rust/issues/89856

Thanks to `@estebank` for guiding me.

2 years agofeedback
Lucas Kent [Mon, 15 Nov 2021 03:47:36 +0000 (14:47 +1100)]
feedback

2 years agosuggest `&str.chars()` on attempt to `&str.iter()`
Takayuki Maeda [Thu, 11 Nov 2021 16:47:43 +0000 (01:47 +0900)]
suggest `&str.chars()` on attempt to `&str.iter()`

check if `String` or `&String` or `&str`

Update compiler/rustc_typeck/src/check/method/suggest.rs

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
remove some trailing whitespace

2 years agoAuto merge of #90684 - jyn514:dist-aliases, r=Mark-Simulacrum
bors [Mon, 15 Nov 2021 03:19:01 +0000 (03:19 +0000)]
Auto merge of #90684 - jyn514:dist-aliases, r=Mark-Simulacrum

Change paths for `dist` command to match the components they generate

Before, you could have the confusing situation where the command to
generate a component had no relation to the name of that component (e.g.
the `rustc` component was generated with `src/librustc`). This changes
the name to make them match up.

2 years agoAdd regression test for issue 90320
Gary Guo [Tue, 26 Oct 2021 22:24:45 +0000 (23:24 +0100)]
Add regression test for issue 90320

2 years agoTry all stable candidates first before trying unstable ones
Gary Guo [Tue, 26 Oct 2021 22:24:23 +0000 (23:24 +0100)]
Try all stable candidates first before trying unstable ones

2 years agoAdd self ty to pick
Gary Guo [Tue, 26 Oct 2021 20:55:01 +0000 (21:55 +0100)]
Add self ty to pick

2 years agoDon't run the codegen test when `debug_assert` is enabled
Scott McMurray [Mon, 15 Nov 2021 00:24:31 +0000 (16:24 -0800)]
Don't run the codegen test when `debug_assert` is enabled

2 years agoexpand comment
Ralf Jung [Mon, 15 Nov 2021 00:03:32 +0000 (19:03 -0500)]
expand comment

2 years agoSimplify ObligationCauseData hash to skip ObligationCauseCode
The8472 [Sun, 14 Nov 2021 22:49:57 +0000 (23:49 +0100)]
Simplify ObligationCauseData hash to skip ObligationCauseCode

selection deduplicates obligations through a hashset at some point, computing the hashes for ObligationCauseCode
appears to dominate the hashing cost. bodyid + span + discriminant hash hopefully will sufficiently unique
unique enough.

2 years agoAuto merge of #88282 - Neutron3529:patch-4, r=Mark-Simulacrum
bors [Sun, 14 Nov 2021 18:47:42 +0000 (18:47 +0000)]
Auto merge of #88282 - Neutron3529:patch-4, r=Mark-Simulacrum

Optimize BinaryHeap::extend from Vec

This improves the performance of extending `BinaryHeap`s from vectors directly. Future work may involve extending this optimization to other, similar, cases where the length of the added elements is well-known, but this is not yet done in this PR.

2 years agofix getting the discriminant of a zero-variant enum
Ralf Jung [Sun, 14 Nov 2021 18:28:47 +0000 (13:28 -0500)]
fix getting the discriminant of a zero-variant enum

2 years agorequire full validity when determining the discriminant of a value
Ralf Jung [Sun, 14 Nov 2021 18:08:51 +0000 (13:08 -0500)]
require full validity when determining the discriminant of a value

2 years agoMove some tests to more reasonable directories
Caio [Sun, 14 Nov 2021 17:38:42 +0000 (14:38 -0300)]
Move some tests to more reasonable directories

2 years agodisable portable SIMD tests in Miri
Ralf Jung [Sun, 14 Nov 2021 16:56:52 +0000 (11:56 -0500)]
disable portable SIMD tests in Miri

2 years agobootstap: create .cargo/config only if not present
Alberto Planas [Thu, 11 Nov 2021 15:05:32 +0000 (16:05 +0100)]
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 agoRemove workaround for the forward progress handling in LLVM
Andreas Jonson [Sun, 14 Nov 2021 13:01:30 +0000 (14:01 +0100)]
Remove workaround for the forward progress handling in LLVM

2 years agoAuto merge of #90596 - the8472:path-hash-opt, r=Mark-Simulacrum
bors [Sun, 14 Nov 2021 15:18:26 +0000 (15:18 +0000)]
Auto merge of #90596 - the8472:path-hash-opt, r=Mark-Simulacrum

Optimize Eq and Hash for Path/PathBuf

```
# new

test path::tests::bench_hash_path_long                            ... bench:          86 ns/iter (+/- 1)
test path::tests::bench_hash_path_short                           ... bench:          13 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:         197 ns/iter (+/- 6)
test path::tests::bench_path_hashset_miss                         ... bench:          94 ns/iter (+/- 4)

# old

test path::tests::bench_hash_path_long                            ... bench:         192 ns/iter (+/- 2)
test path::tests::bench_hash_path_short                           ... bench:          33 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:       1,121 ns/iter (+/- 24)
test path::tests::bench_path_hashset_miss                         ... bench:         273 ns/iter (+/- 6)
```

2 years agoImprove ManuallyDrop suggestion
Lucas Kent [Sun, 14 Nov 2021 11:04:25 +0000 (22:04 +1100)]
Improve ManuallyDrop suggestion

2 years agoAuto merge of #90839 - pierwill:docs-rustc-newtype-index, r=jackh726
bors [Sun, 14 Nov 2021 12:17:32 +0000 (12:17 +0000)]
Auto merge of #90839 - pierwill:docs-rustc-newtype-index, r=jackh726

Generate documentation in rustc `rustc_index::newtype_index` macro

The macro now documents all generated items. Documentation notes possible panics and unsafety.

2 years agoFix span for non-satisfied trivial trait bounds
Nilstrieb [Sat, 13 Nov 2021 22:56:22 +0000 (23:56 +0100)]
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 agoAuto merge of #90757 - GuillaumeGomez:search-index-performance, r=camelid
bors [Sun, 14 Nov 2021 08:57:27 +0000 (08:57 +0000)]
Auto merge of #90757 - GuillaumeGomez:search-index-performance, r=camelid

Remove unneeded FIXMEs comments in search index generation

Original comment:

> Instead of recreating a new `vec` for each arguments, we re-use the same. The impact on performance should be minor but worth a try.

After testing it, we reached the conclusion that the code readability drop wasn't worth the almost unnoticeable performance improvement.

r? `@camelid`

2 years agoOnly use the -dynamiclib flag when the linker is not ld
kit [Mon, 8 Nov 2021 23:44:49 +0000 (10:44 +1100)]
Only use the -dynamiclib flag when the linker is not ld

This is not a valid flag for ld64. When the ld64 linker is explicitly
provided through `config.toml`, rustc will not successfully compile.

2 years agoRefactor linker argument generation
kit [Mon, 8 Nov 2021 23:36:47 +0000 (10:36 +1100)]
Refactor linker argument generation

This commit refactors linker argument generation to leverage a helper
function that abstracts away details governing how these arguments are
transformed and provided to the linker.

This fixes the misuse of the `-exported_symbols_list` when an ld-like
linker is used rather than a compiler. A compiler would expect
`-Wl,-exported_symbols_list,path` but ld would expect
`-exported_symbols_list` and `path` as two seperate arguments. Prior
to this change, an ld-like linker was given
`-exported_symbols_list,path`.

2 years agoAdd a helper method for linker arguments
kit [Mon, 8 Nov 2021 09:45:04 +0000 (20:45 +1100)]
Add a helper method for linker arguments

Linker arguments must transformed when Rust is interacting with the
linker through a compiler. This commit introduces a helper function
that abstracts away details of this transformation.

2 years agoAuto merge of #90867 - hi-rustin:rustin-patch-rustdoc, r=CraftSpider
bors [Sun, 14 Nov 2021 05:50:54 +0000 (05:50 +0000)]
Auto merge of #90867 - hi-rustin:rustin-patch-rustdoc, r=CraftSpider

Delete rustdoc::doctree

close https://github.com/rust-lang/rust/issues/90864

2 years agofix ICE on Miri/CTFE copy of half a pointer
Ralf Jung [Sun, 14 Nov 2021 01:55:33 +0000 (20:55 -0500)]
fix ICE on Miri/CTFE copy of half a pointer

2 years agoAuto merge of #90883 - matthiaskrgr:rollup-iu9k5pe, r=matthiaskrgr
bors [Sun, 14 Nov 2021 01:06:05 +0000 (01:06 +0000)]
Auto merge of #90883 - matthiaskrgr:rollup-iu9k5pe, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #90771 (Fix trait object error code)
 - #90840 (relate lifetime in `TypeOutlives` bounds on drop impls)
 - #90853 (rustdoc: Use an empty Vec instead of Option<Vec>)

Failed merges:

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

2 years agoImprove diagnostics when a static lifetime is expected
Lucas Kent [Sat, 13 Nov 2021 05:43:43 +0000 (16:43 +1100)]
Improve diagnostics when a static lifetime is expected

2 years agoGenerate documentation in rustc `rustc_index::newtype_index` macro
pierwill [Fri, 12 Nov 2021 19:35:42 +0000 (13:35 -0600)]
Generate documentation in rustc `rustc_index::newtype_index` macro

The macro now documents all generated items. Documentation notes
possible panics and unsafety.

2 years agoRollup merge of #90853 - notriddle:notriddle/option-vec, r=GuillaumeGomez
Matthias Krüger [Sat, 13 Nov 2021 21:35:05 +0000 (22:35 +0100)]
Rollup merge of #90853 - notriddle:notriddle/option-vec, r=GuillaumeGomez

rustdoc: Use an empty Vec instead of Option<Vec>

2 years agoRollup merge of #90840 - BoxyUwU:lolripme, r=jackh726
Matthias Krüger [Sat, 13 Nov 2021 21:35:04 +0000 (22:35 +0100)]
Rollup merge of #90840 - BoxyUwU:lolripme, r=jackh726

relate lifetime in `TypeOutlives` bounds on drop impls

Fixes #90838

2 years agoRollup merge of #90771 - asterycs:fix/trait-object-error-code, r=michaelwoerister
Matthias Krüger [Sat, 13 Nov 2021 21:35:03 +0000 (22:35 +0100)]
Rollup merge of #90771 - asterycs:fix/trait-object-error-code, r=michaelwoerister

Fix trait object error code

closes #90768

I `grep`:d and changed the occurrences that seemed relevant. Please let me know what you think and if anything is missing!

2 years agoFix handling of substitutions and binders when deciding whether to suggest references
Jakob Degen [Thu, 11 Nov 2021 23:28:19 +0000 (18:28 -0500)]
Fix handling of substitutions and binders when deciding whether to suggest references

When suggesting references, substitutions were being forgotten and some types were misused. This led to at
least one ICE and other incorrectly emitted diagnostics. This has been fixed; in some cases this leads to
diagnostics changing, and tests have been adjusted.

2 years agoAuto merge of #90385 - mfrw:mfrw/librustdoc, r=GuillaumeGomez
bors [Sat, 13 Nov 2021 20:11:58 +0000 (20:11 +0000)]
Auto merge of #90385 - mfrw:mfrw/librustdoc, r=GuillaumeGomez

rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()

For: #90187

r? `@jyn514`

2 years agoRecurse through query system when checking ADT drop types, hopefully improving perf
Jakob Degen [Fri, 12 Nov 2021 21:39:44 +0000 (16:39 -0500)]
Recurse through query system when checking ADT drop types, hopefully improving perf

2 years agoAuto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk
bors [Sat, 13 Nov 2021 17:10:15 +0000 (17:10 +0000)]
Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk

Stabilize `const_raw_ptr_deref` for `*const T`

This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is behind the
same feature gate as mutable references.

closes https://github.com/rust-lang/rust/issues/51911

2 years agoImplement diagnostic for String conversion
threadexception [Sat, 6 Nov 2021 09:31:46 +0000 (10:31 +0100)]
Implement diagnostic for String conversion

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2 years agoAuto merge of #90542 - the8472:privatize-the-means-of-rawvec-production, r=joshtriplett
bors [Sat, 13 Nov 2021 13:57:00 +0000 (13:57 +0000)]
Auto merge of #90542 - the8472:privatize-the-means-of-rawvec-production, r=joshtriplett

Make RawVec private to alloc

RawVec was previously exposed for compiler-internal use (libarena specifically) in 1acbb0a9350560d951359cc359361b87992a6f2b

Since it is unstable, doc-hidden and has no associated tracking issue it was never meant for public use. And since
it is no longer used outside alloc itself it can be made private again.

Also remove some functions that are dead due to lack of internal users.

2 years agoDelete rustdoc::doctree
hi-rustin [Sat, 13 Nov 2021 13:50:13 +0000 (21:50 +0800)]
Delete rustdoc::doctree

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoChange paths for `dist` command to match the components they generate
Joshua Nelson [Mon, 8 Nov 2021 04:37:28 +0000 (04:37 +0000)]
Change paths for `dist` command to match the components they generate

Before, you could have the confusing situation where the command to
generate a component had no relation to the name of that component (e.g.
the `rustc` component was generated with `src/librustc`). This changes
the name to make them match up.

2 years agoAuto merge of #87264 - mystor:expand_literal, r=petrochenkov
bors [Sat, 13 Nov 2021 08:22:52 +0000 (08:22 +0000)]
Auto merge of #87264 - mystor:expand_literal, r=petrochenkov

proc_macro: Add an expand_expr method to TokenStream

This feature is aimed at giving proc macros access to powers similar to those used by builtin macros such as `format_args!` or `concat!`. These macros are able to accept macros in place of string literal parameters, such as the format string, as they perform recursive macro expansion while being expanded.

This can be especially useful in many cases thanks to helper macros like `concat!`, `stringify!` and `include_str!` which are often used to construct string literals at compile-time in user code.

For now, this method only allows expanding macros which produce literals, although more expressions will be supported before the method is stabilized.

In earlier versions of this PR, this method exclusively returned `Literal`, and spans on returned literals were stripped of expansion context before being returned to be as conservative as possible about permission leakage. The method's naming has been generalized to eventually support arbitrary expressions, and the context stripping has been removed (https://github.com/rust-lang/rust/pull/87264#discussion_r674863279), which should allow for more general APIs like "format_args_implicits" (https://github.com/rust-lang/rust/issues/67984) to be supported as well.

## API Surface

```rust
impl TokenStream {
    pub fn expand_expr(&self) -> Result<TokenStream, ExpandError>;
}

#[non_exhaustive]
pub struct ExpandError;

impl Debug for ExpandError { ... }
impl Display for ExpandError { ... }
impl Error for ExpandError {}
impl !Send for ExpandError {}
impl !Sync for ExpandError {}
```

2 years agoUse an empty Vec instead of Option<Vec>
Michael Howell [Sat, 13 Nov 2021 05:25:31 +0000 (22:25 -0700)]
Use an empty Vec instead of Option<Vec>