Commit Graph

166223 Commits

Author SHA1 Message Date
Jakob Degen
9b6b1a625b Add new Deinit statement kind 2022-04-11 08:55:03 -04:00
bors
d00e77078c Auto merge of #95758 - compiler-errors:issue-54771, r=estebank
Only suggest removing semicolon when expression is compatible with `impl Trait`

https://github.com/rust-lang/rust/issues/54771#issuecomment-476423690
> It still needs checking that the last statement's expr can actually conform to the trait, but the naïve behavior is there.

Only suggest removing a semicolon when the type behind the semicolon actually implements the trait in an RPIT `-> impl Trait`. Also upgrade the label that suggests removing the semicolon to a suggestion (should it be verbose?).

cc #54771
2022-04-11 08:31:37 +00:00
bors
48a9e104df Auto merge of #95754 - compiler-errors:binder-assoc-ty, r=nagisa
Better error for `for<...>` on associated type bound

With GATs just around the corner, we'll probably see more people trying out `Trait<for<'a> Assoc<'a> = ..>`.

This PR improves the syntax error slightly, and also makes it slightly easier to make this into real syntax in the future.

Feel free to push back if the reviewer thinks this should have a suggestion on how to fix it (i.e. push the `for<'a>` outside of the angle brackets), but that can also be handled in a follow-up PR.
2022-04-11 05:16:48 +00:00
bors
d12b857816 Auto merge of #94243 - compiler-errors:compiler-flags-typo, r=Mark-Simulacrum
`s/compiler-flags/compile-flags` in compiletest

Also make compiletest panic so this doesn't happen in the future! I literally always forget which it's called, so I wanted to make my life easier in the future.

Also open to the possibility of parsing both.
2022-04-11 00:58:22 +00:00
Michael Goulet
b65265b5e1 better error for binder on associated type bound 2022-04-10 16:41:15 -07:00
Michael Goulet
dfe13dbbcf only suggest removing semicolon when expr implements trait 2022-04-10 16:30:14 -07:00
bors
1f7fb6413d Auto merge of #95889 - Dylan-DPC:rollup-1cmywu4, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #95566 (Avoid duplication of doc comments in `std::char` constants and functions)
 - #95784 (Suggest replacing `typeof(...)` with an actual type)
 - #95807 (Suggest adding a local for vector to fix borrowck errors)
 - #95849 (Check for git submodules in non-git source tree.)
 - #95852 (Fix missing space in lossy provenance cast lint)
 - #95857 (Allow multiple derefs to be splitted in deref_separator)
 - #95868 (rustdoc: Reduce allocations in a `html::markdown` function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-10 21:01:13 +00:00
Dylan DPC
fcfecab2d8
Rollup merge of #95868 - vacuus:markdown-code-blocks, r=GuillaumeGomez
rustdoc: Reduce allocations in a `html::markdown` function
2022-04-10 21:03:39 +02:00
Dylan DPC
78fc931355
Rollup merge of #95857 - ouz-a:mir-opt, r=oli-obk
Allow multiple derefs to be splitted in deref_separator

Previously in #95649 only a single deref within projection was supported and multiple derefs caused a bunch of issues, this PR fixes those issues.

```@oli-obk``` helped a ton again ❤️
2022-04-10 21:03:38 +02:00
Dylan DPC
a52eb325e6
Rollup merge of #95852 - niluxv:strict-provenance-lint-fixup, r=Dylan-DPC
Fix missing space in lossy provenance cast lint

See https://github.com/rust-lang/rust/pull/95599#discussion_r846425050
2022-04-10 21:03:37 +02:00
Dylan DPC
0b871435e9
Rollup merge of #95849 - ehuss:check-submodules, r=Mark-Simulacrum
Check for git submodules in non-git source tree.

People occasionally download the source from https://github.com/rust-lang/rust/releases, but those source distributions will not work because they are missing the submodules. They will get a confusing `failed to load manifest for workspace member` error.

Unfortunately AFAIK there is no way to disable the GitHub source links. This change tries to detect this scenario and provide an error message that guides them toward a solution.

Closes #95608
2022-04-10 21:03:36 +02:00
Dylan DPC
c172544848
Rollup merge of #95807 - TaKO8Ki:suggest-local-var-for-vector, r=fee1-dead
Suggest adding a local for vector to fix borrowck errors

closes #95574
2022-04-10 21:03:35 +02:00
Dylan DPC
54597ba11f
Rollup merge of #95784 - WaffleLapkin:typeof_cool_suggestion, r=compiler-errors
Suggest replacing `typeof(...)` with an actual type

This PR adds suggestion to replace `typeof(...)` with an actual type of `...`, for example in case of `typeof(1)` we suggest replacing it with `i32`.

If the expression
1. Is not const (`{ let a = 1; let _: typeof(a); }`)
2. Can't be found (`let _: typeof(this_variable_does_not_exist)`)
3. Or has non-suggestable type (closure, generator, error, etc)
we don't suggest anything.

The 1 one is sad, but it's not clear how to support non-consts expressions for `typeof`.

_This PR is inspired by [this tweet]._

[this tweet]: https://twitter.com/compiler_errors/status/1511945354752638976
2022-04-10 21:03:34 +02:00
Dylan DPC
c0655dec7e
Rollup merge of #95566 - eduardosm:std_char_consts_and_methods, r=Mark-Simulacrum
Avoid duplication of doc comments in `std::char` constants and functions

For those consts and functions, only the summary is kept and a reference to the `char` associated const/method is included.

Additionaly, re-exported functions have been converted to function definitions that call the previously re-exported function. This makes it easier to add a deprecated attribute to these functions in the future.
2022-04-10 21:03:34 +02:00
bors
027a232755 Auto merge of #95487 - cjgillot:menhir, r=oli-obk
Avoid accessing HIR from MIR passes

`hir_owner_nodes` contains a lot of information, and the query result is typically dirty. This forces dependent queries to be re-executed needlessly.

This PR refactors some accesses to HIR to go through more targeted queries that yield the same result.

Based on https://github.com/rust-lang/rust/pull/95435 and https://github.com/rust-lang/rust/pull/95436
2022-04-10 17:59:27 +00:00
bors
18f32b73bd Auto merge of #95848 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/95844
r? `@ghost`
2022-04-10 14:51:30 +00:00
Maybe Waffle
8412d5dc5c --bless tests 2022-04-10 16:45:09 +04:00
bors
32c2630262 Auto merge of #95253 - jyn514:cargo-run, r=Mark-Simulacrum
Make it possible to run `cargo test` for bootstrap

Note that this only runs bootstrap's self-tests, not compiler or library tests.

Helps with https://github.com/rust-lang/rust/issues/94829.
2022-04-10 12:30:26 +00:00
Camille GILLOT
bbacfcb6c4 Avoid checking HIR in variances_of. 2022-04-10 13:58:29 +02:00
Camille GILLOT
0c6e2466f2 Do not access HIR to compute symbol_name. 2022-04-10 13:42:47 +02:00
Camille GILLOT
69d8183337 Store LocalDefId in is_late_bound_map.
This allows to avoid looking at HIR from borrowck.
2022-04-10 13:36:06 +02:00
Camille GILLOT
db03a2deb0 Avoid accessing HIR from MIR queries. 2022-04-10 13:08:36 +02:00
bors
7af93292c2 Auto merge of #95621 - saethlin:remove-mpsc-transmute, r=RalfJung
Remove ptr-int transmute in std::sync::mpsc

Since https://github.com/rust-lang/rust/pull/95340 landed, Miri with `-Zmiri-check-number-validity` produces an error on the test suites of some crates which implement concurrency tools<sup>*</sup>, because it seems like such crates tend to use `std::sync::mpsc` in their tests. This fixes the problem by storing pointer bytes in a pointer.

<sup>*</sup> I have so far seen errors in the test suites of `once_cell`, `parking_lot`, and `crossbeam-utils`.
(just updating the list for fun, idk)
Also `threadpool`, `async-lock`, `futures-timer`, `fragile`, `scoped_threadpool`, `procfs`, `slog-async`, `scheduled-thread-pool`, `tokio-threadpool`, `mac`, `futures-cpupool`, `ntest`, `actix`, `zbus`, `jsonrpc-client-transports`, `fail`, `libp2p-gossipsub`, `parity-send-wrapper`, `async-broadcast,` `libp2p-relay`, `http-client`, `mockito`, `simple-mutex`, `surf`, `pollster`, and `pulse`. Then I turned the bot off.
2022-04-10 08:57:32 +00:00
bors
341883d051 Auto merge of #95502 - jyn514:doc-rustc, r=Mark-Simulacrum
Fix `x doc compiler/rustc`

This also has a few cleanups to `doc.rs`. The last two commits I don't care about, but the first commit I'd like to keep - it will be very useful for https://github.com/rust-lang/rust/issues/44293.

Fixes https://github.com/rust-lang/rust/issues/95447.
2022-04-10 06:28:40 +00:00
bors
f7b4824731 Auto merge of #95254 - jyn514:fix-windows-builds, r=Mark-Simulacrum
Fix `cargo run` on Windows

Fixes the following error:
```
error: failed to run custom build command for `bootstrap v0.0.0 (C:\Users\Walther\git\rust\src\bootstrap)`

Caused by:
  process didn't exit successfully: `C:\Users\Walther\git\rust\target\debug\build\bootstrap-7757a4777dec0f86\build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-env-changed=RUSTC
  cargo:rustc-env=BUILD_TRIPLE=x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PATH

  --- stderr
  thread 'main' panicked at 'assertion failed: rustc.is_absolute()', src\bootstrap\build.rs:22:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
```

The problem was that the `dir.join` check only works with `rustc.exe`, not `rustc`.

Thanks `@Walther` for the help testing the fix!

Helps with https://github.com/rust-lang/rust/issues/94829.
2022-04-10 03:58:54 +00:00
Roc Yu
8e15b6cfde
rustdoc: Reduce allocations in a html::markdown function 2022-04-09 19:14:29 -04:00
bors
559c01931b Auto merge of #95435 - cjgillot:one-name, r=oli-obk
Make def names and HIR names consistent.

The name in the `DefKey` is interned to create the `DefId`, so it does not
require any query to access.  This can be leveraged to avoid a few useless
HIR accesses for names.

~In order to achieve that, generic parameters created from universal
impl-trait are given the pretty-printed ast as a name, instead of
`{{opaque}}`.~

~Drive-by: the `TyCtxt::opt_item_name` used a dummy span for non-local
definitions.  We have access to `def_ident_span`, so we use it.~
2022-04-09 22:48:00 +00:00
bors
8bf93e9b67 Auto merge of #95855 - Dylan-DPC:rollup-h45xmpw, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #94794 (Clarify indexing into Strings)
 - #95361 (Make non-power-of-two alignments a validity error in `Layout`)
 - #95369 (Fix `x test src/librustdoc` with `download-rustc` enabled )
 - #95805 (Left overs of #95761)
 - #95808 (expand: Remove `ParseSess::missing_fragment_specifiers`)
 - #95817 (hide another #[allow] directive from a docs example)
 - #95831 (Use bitwise XOR in to_ascii_uppercase)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-09 20:13:28 +00:00
ouz-a
80afd9db2e remove the if block 2022-04-09 22:23:49 +03:00
ouz-a
cc57656969 support multiple derefs 2022-04-09 20:38:06 +03:00
Joshua Nelson
a0de44f469 Make it possible to run cargo test for bootstrap
Note that this only runs bootstrap's self-tests, not compiler or library tests.
2022-04-09 11:40:35 -05:00
Dylan DPC
7726265ae0
Rollup merge of #95831 - redzic:xor-uppercase, r=workingjubilee
Use bitwise XOR in to_ascii_uppercase

This saves an instruction compared to the previous approach, which
was to unset the fifth bit with bitwise OR.

Comparison of generated assembly on x86: https://godbolt.org/z/GdfvdGs39

This can also affect autovectorization, saving SIMD instructions as well: https://godbolt.org/z/cnPcz75T9

Not sure if `u8::to_ascii_lowercase` should also be changed, since using bitwise OR for that function does not require an extra bitwise negate since the code is setting a bit rather than unsetting a bit. `char::to_ascii_uppercase` already uses XOR, so no change seems to be required there.
2022-04-09 18:26:30 +02:00
Dylan DPC
2464ea2510
Rollup merge of #95817 - oconnor663:doc_comment2, r=yaahc
hide another #[allow] directive from a docs example

This is a repeat for Rc of e0e64a8930,
which cleaned up the same thing for Arc.
2022-04-09 18:26:29 +02:00
Dylan DPC
17157c717e
Rollup merge of #95808 - petrochenkov:fragspec, r=nnethercote
expand: Remove `ParseSess::missing_fragment_specifiers`

It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.

cc https://github.com/rust-lang/rust/pull/95747#issuecomment-1091619403
r? ``@nnethercote``
2022-04-09 18:26:28 +02:00
Dylan DPC
5092946041
Rollup merge of #95805 - c410-f3r:meta-vars, r=petrochenkov
Left overs of #95761

These are just nits. Feel free to close this PR if all modifications are not worth merging.

* `#![feature(decl_macro)]` is not needed anymore in `rustc_expand`
* `tuple_impls` does not require `$Tuple:ident`. I guess it is there to enhance readability?

r? ```@petrochenkov```
2022-04-09 18:26:27 +02:00
Dylan DPC
198a1548ea
Rollup merge of #95369 - jyn514:test-rustdoc, r=Mark-Simulacrum
Fix `x test src/librustdoc` with `download-rustc` enabled

The problem was two-fold:
- Bootstrap was hard-coding that unit tests should always run with stage1, not stage2, and
- It hard-coded the sysroot layout in stage1, which puts libLLVM.so in `lib/rustlib/` instead of just `lib/`.

This also takes the liberty of fixing `test src/librustdoc --no-doc`, which has been broken since it was first added. It would be nice at some point to unify this logic with other tests; I opened a Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Inconsistency.20in.20.60x.20test.60

Fixes https://github.com/rust-lang/rust/issues/91071.
2022-04-09 18:26:26 +02:00
Dylan DPC
e4b4bf1535
Rollup merge of #95361 - scottmcm:valid-align, r=Mark-Simulacrum
Make non-power-of-two alignments a validity error in `Layout`

Inspired by the zulip conversation about how `Layout` should better enforce `size <= isize::MAX as usize`, this uses an N-variant enum on N-bit platforms to require at the validity level that the existing invariant of "must be a power of two" is upheld.

This was MIRI can catch it, and means there's a more-specific type for `Layout` to store than just `NonZeroUsize`.

It's left as `pub(crate)` here; a future PR could consider giving it a tracking issue for non-internal usage.
2022-04-09 18:26:25 +02:00
Dylan DPC
1ced0b61a4
Rollup merge of #94794 - mlodato517:mlodato517-clarify-string-indexing-docs, r=Mark-Simulacrum
Clarify indexing into Strings

**This Commit**
Adds some clarity around indexing into Strings.

**Why?**
I was reading through the `Range` documentation and saw an
implementation for `SliceIndex<str>`. I was surprised to see this and
went to read the [`String`][0] documentation and, to me, it seemed to
say (at least) three things:

1. you cannot index into a `String`
2. indexing into a `String` could not be constant-time
3. indexing into a `String` does not have an obvious return type

I absolutely agree with the last point but the first two seemed
contradictory to the documentation around [`SliceIndex<str>`][1]
which mention:

1. you can do substring slicing (which is probably different than
   "indexing" but, because the method is called `index` and I associate
   anything with square brackets with "indexing" it was enough to
   confuse me)
2. substring slicing is constant-time (this may be algorithmic ignorance
   on my part but if `&s[i..i+1]` is O(1) then it seems confusing that
   `&s[i]` _could not possibly_ be O(1))

So I was hoping to clarify a couple things and, hopefully, in this PR
review learn a little more about the nuances here that confused me in
the first place.

[0]: https://doc.rust-lang.org/stable/std/string/struct.String.html#utf-8
[1]: https://doc.rust-lang.org/stable/std/slice/trait.SliceIndex.html#impl-SliceIndex%3Cstr%3E
2022-04-09 18:26:25 +02:00
niluxv
1834c21f88 Fix missing space in lossy provenance cast lint 2022-04-09 17:39:07 +02:00
Eric Huss
ca9ef27ed1 Check for git submodules in non-git source tree. 2022-04-09 08:10:34 -07:00
Ralf Jung
161b0bfe1c update Miri 2022-04-09 10:15:41 -04:00
Mark Lodato
9cf35a6c06 Rework String UTF-8 Documentation
**This Commit**
Adds some clarity around indexing into Strings and the constraints
driving various decisions there.

**Why?**
The [`String` documentation][0] mentions how `String`s can't be indexed
but `Range` has an implementation for `SliceIndex<str>`. This can be
confusing. There are also several statements to explain the lack of
`String` indexing:

- the inability to index into a `String` is an implication of UTF-8
  encoding
- indexing into a `String` could not be constant-time with UTF-8
  encoding
- indexing into a `String` does not have an obvious return type

This last statement made sense but the first two seemed contradictory to
the documentation around [`SliceIndex<str>`][1] which mention:

- one can index into a `String` with a `Range` (also called substring
  slicing but it uses the same syntax and the method name is `index`)
- `Range` indexing into a `String` is constant-time

To resolve this seeming contradiction the documentation is reworked to
more clearly explain what factors drive the decision to disallow
indexing into a `String` with a single number.

[0]: https://doc.rust-lang.org/stable/std/string/struct.String.html#utf-8
[1]: https://doc.rust-lang.org/stable/std/slice/trait.SliceIndex.html#impl-SliceIndex%3Cstr%3E
2022-04-09 09:27:32 -04:00
bors
8c1fb2eb23 Auto merge of #95697 - klensy:no-strings, r=petrochenkov
refactor: simplify few string related interactions

Few small optimizations:

check_doc_keyword: don't alloc string for emptiness check
check_doc_alias_value: get argument as Symbol to prevent needless string convertions
check_doc_attrs: don't alloc vec, iterate over slice.
replace as_str() check with symbol check
get_single_str_from_tts: don't prealloc string
trivial string to str replace
LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String>
AssertModuleSource use FxHashSet<Symbol> instead of BTreeSet<String>
CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-09 13:15:26 +00:00
Vadim Petrochenkov
379ae12a1d expand: Remove ParseSess::missing_fragment_specifiers
It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.
2022-04-09 15:44:19 +03:00
bors
fbdb10f9fa Auto merge of #95840 - Dylan-DPC:rollup-erz5u6w, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #95308 (Reduce the amount of unstable features used in libproc_macro)
 - #95676 (Update RLS)
 - #95769 (Hide cross-crate `#[doc(hidden)]` associated items in trait impls)
 - #95785 (interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal)
 - #95802 (fix unused constant warning on some Windows targets)
 - #95810 (Use `format-args-capture` and remove unnecessary nested blocks)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-09 11:05:30 +00:00
Dylan DPC
ece6b97f19
Rollup merge of #95810 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesting-in-rustc-borrowck, r=davidtwco
Use `format-args-capture` and remove unnecessary nested blocks
2022-04-09 12:52:07 +02:00
Dylan DPC
af895b0715
Rollup merge of #95802 - RalfJung:unused-win, r=Dylan-DPC
fix unused constant warning on some Windows targets

When none of those `cfg_if!` apply (and on Miri), the constant remains unused.
2022-04-09 12:52:06 +02:00
Dylan DPC
dfb4194e3b
Rollup merge of #95785 - RalfJung:interpret-size-mismatch, r=oli-obk
interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal

We did this a while ago already for `to_i32()` and friends, but missed this one. That became quite annoying when I was debugging an ICE caused by `read_pointer` in a Miri shim where the code was passing an argument at the wrong type.

Having `scalar_to_ptr` be fallible is consistent with all the other `Scalar::to_*` methods being fallible. I added `unwrap` only in code outside the interpreter, which is no worse off than before now in terms of panics.

r? ````@oli-obk````
2022-04-09 12:52:05 +02:00
Dylan DPC
24fa80dbb2
Rollup merge of #95769 - fmease:fix-issue-95717, r=GuillaumeGomez
Hide cross-crate `#[doc(hidden)]` associated items in trait impls

Fixes #95717.

r? ```@GuillaumeGomez```
This is the bug I ran into in #95316.

```@rustbot``` label T-rustdoc A-cross-crate-reexports
2022-04-09 12:52:04 +02:00
Dylan DPC
0aaeb4dd1b
Rollup merge of #95676 - pietroalbini:pa-bump-rls, r=pietroalbini
Update RLS

This PR updates RLS to include the following PRs:

* https://github.com/rust-lang/rls/pull/1766
* https://github.com/rust-lang/rls/pull/1767
* https://github.com/rust-lang/rls/pull/1771
* https://github.com/rust-lang/rls/pull/1772

It also updates racer to fix RLS compilation with the parallel compiler enabled.
2022-04-09 12:52:03 +02:00