]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #95984 - wcampbell0x2a:fix-spelling, r=thomcc
Dylan DPC [Wed, 13 Apr 2022 03:54:13 +0000 (05:54 +0200)]
Rollup merge of #95984 - wcampbell0x2a:fix-spelling, r=thomcc

Fix spelling in docs for `can_not_overflow`

Introduced in https://github.com/rust-lang/rust/pull/95399

2 years agoRollup merge of #95954 - AnthonyMikh:fix-broken-coverage-docs-screenshot-link, r...
Dylan DPC [Wed, 13 Apr 2022 03:54:12 +0000 (05:54 +0200)]
Rollup merge of #95954 - AnthonyMikh:fix-broken-coverage-docs-screenshot-link, r=Dylan-DPC

Fix broken link in coverage tools docs

During stabilization the link to example screenshot wad not updated, making rendered docs somewhat less useful. Move that screenshot from unstable book into rustc docs and make documentation point to that new place. Also remove `/img` in unstable book since there are no more any files there.

2 years agoRollup merge of #95441 - AlecGoncharow:issue-95204-fix, r=Mark-Simulacrum
Dylan DPC [Wed, 13 Apr 2022 03:54:11 +0000 (05:54 +0200)]
Rollup merge of #95441 - AlecGoncharow:issue-95204-fix, r=Mark-Simulacrum

Always use system `python3` on MacOS

This PR includes 2 changes:

1. Always use the system Python found at `/usr/bin/python3` on MacOS
2. Removes the hard requirement on having `python` in your system path if you didn't specify alternatives. The proposed change will instead attempt to find and use in order: `python` -> `python3` -> `python2`. This change isn't strictly necessary but without any change to this check, the original issue inspiring this change will still exist.

Fixes #95204
r? ```@jyn514```

2 years agoerrors: lazily load fallback fluent bundle
David Wood [Tue, 12 Apr 2022 08:34:40 +0000 (09:34 +0100)]
errors: lazily load fallback fluent bundle

Loading the fallback bundle in compilation sessions that won't go on to
emit any errors unnecessarily degrades compile time performance, so
lazily create the Fluent bundle when it is first required.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoPass a slice instead of a `Vec` to `transcribe`.
Nicholas Nethercote [Sun, 10 Apr 2022 23:52:34 +0000 (09:52 +1000)]
Pass a slice instead of a `Vec` to `transcribe`.

It avoids some unnecessary allocations.

2 years agoAvoid use of `Lrc` in `mbe::Frame`.
Nicholas Nethercote [Fri, 8 Apr 2022 10:36:44 +0000 (20:36 +1000)]
Avoid use of `Lrc` in `mbe::Frame`.

This is a nice performance win on some crates.

2 years ago`SequenceRepetition` and `Delimited` don't need to be `Clone`.
Nicholas Nethercote [Fri, 8 Apr 2022 10:44:57 +0000 (20:44 +1000)]
`SequenceRepetition` and `Delimited` don't need to be `Clone`.

2 years agoAuto merge of #95990 - Dylan-DPC:rollup-r9bh9t7, r=Dylan-DPC
bors [Wed, 13 Apr 2022 01:15:20 +0000 (01:15 +0000)]
Auto merge of #95990 - Dylan-DPC:rollup-r9bh9t7, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #95316 (Rustdoc: Discriminate required and provided associated constants and types)
 - #95405 (Move name resolution logic to a dedicated file)
 - #95914 (Implement tuples using recursion)
 - #95918 (Delay a bug when we see SelfCtor in ref pattern)
 - #95970 (Fix suggestions in case of `T:` bounds)
 - #95973 (prevent opaque types from appearing in impl headers)
 - #95986 (Autolabel library PRs with T-libs)

Failed merges:

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

2 years agoAuto merge of #95905 - vacuus:markdown-render, r=GuillaumeGomez
bors [Tue, 12 Apr 2022 22:56:06 +0000 (22:56 +0000)]
Auto merge of #95905 - vacuus:markdown-render, r=GuillaumeGomez

rustdoc: Reduce allocations in a `markdown` function

Not `html::markdown` this time, just `markdown`, haha.

2 years agoRollup merge of #95986 - yaahc:libs-autolabel, r=Mark-Simulacrum
Dylan DPC [Tue, 12 Apr 2022 21:17:02 +0000 (23:17 +0200)]
Rollup merge of #95986 - yaahc:libs-autolabel, r=Mark-Simulacrum

Autolabel library PRs with T-libs

Continuation of https://github.com/rust-lang/highfive/pull/389

We're trying to improve the libs team review structure and part of that is defaulting PRs to the T-libs team to act as a mini-triage team for all the libs teams / project groups. Highfive doesn't do issue tagging so we will rely on triagebot to pre-triage for t-libs to post-triage :)

2 years agoRollup merge of #95973 - oli-obk:tait_ub3, r=compiler-errors
Dylan DPC [Tue, 12 Apr 2022 21:17:01 +0000 (23:17 +0200)]
Rollup merge of #95973 - oli-obk:tait_ub3, r=compiler-errors

prevent opaque types from appearing in impl headers

cc `@lqd`

opaque types are not distinguishable from their hidden type at the codegen stage. So we could either end up with cases where the hidden type doesn't implement the trait (which will thus ICE) or where the hidden type does implement the trait (so we'd be using its impl instead of the one written for the opaque type). This can even lead to unsound behaviour without unsafe code.

Fixes https://github.com/rust-lang/rust/issues/86411.
Fixes https://github.com/rust-lang/rust/issues/84660.

rebase of #87382 plus some diagnostic tweaks

2 years agoRollup merge of #95970 - WaffleLapkin:nicer_trait_suggestions, r=compiler-errors
Dylan DPC [Tue, 12 Apr 2022 21:17:00 +0000 (23:17 +0200)]
Rollup merge of #95970 - WaffleLapkin:nicer_trait_suggestions, r=compiler-errors

Fix suggestions in case of `T:` bounds

This PR fixes a corner case in `suggest_constraining_type_params` that was causing incorrect suggestions.

For the following functions:
```rust
fn a<T:>(t: T) { [t, t]; }
fn b<T>(t: T) where T: { [t, t]; }
```

We previously suggested the following:
```text
...
help: consider restricting type parameter `T`
  |
1 | fn a<T: Copy:>(t: T) { [t, t]; }
  |       ++++++
...
help: consider further restricting this bound
  |
2 | fn b<T>(t: T) where T: + Copy { [t, t]; }
  |                        ++++++
```

Note that neither `T: Copy:` not `where T: + Copy` is a correct bound.

With this commit the suggestions are correct:
```text
...
help: consider restricting type parameter `T`
  |
1 | fn a<T: Copy>(t: T) { [t, t]; }
  |         ++++
...
help: consider further restricting this bound
  |
2 | fn b<T>(t: T) where T: Copy { [t, t]; }
  |                        ++++
```

r? `@compiler-errors`

I've tried fixing #95898 here too, but got too confused with how `suggest_traits_to_import` works and what it does :sweat_smile:

2 years agoRollup merge of #95918 - compiler-errors:issue-95878, r=cjgillot
Dylan DPC [Tue, 12 Apr 2022 21:16:59 +0000 (23:16 +0200)]
Rollup merge of #95918 - compiler-errors:issue-95878, r=cjgillot

Delay a bug when we see SelfCtor in ref pattern

Fixes #95878

2 years agoRollup merge of #95914 - c410-f3r:meta-vars, r=petrochenkov
Dylan DPC [Tue, 12 Apr 2022 21:16:58 +0000 (23:16 +0200)]
Rollup merge of #95914 - c410-f3r:meta-vars, r=petrochenkov

Implement tuples using recursion

Because it is c00l3r™, requires less repetition and can be used as a reference for external people.

This change is non-essential and I am not sure about potential performance impacts so feel free to close this PR if desired.

r? `@petrochenkov`

2 years agoRollup merge of #95405 - cjgillot:probe, r=petrochenkov
Dylan DPC [Tue, 12 Apr 2022 21:16:56 +0000 (23:16 +0200)]
Rollup merge of #95405 - cjgillot:probe, r=petrochenkov

Move name resolution logic to a dedicated file

The code resolution logic from an Ident is scattered between several files.

The first commits creates `rustc_resolve::probe` module to hold the different mutually recursive functions together. Just a move, no code change.
The following commits attempt to make the logic a bit more readable.

The two fields `last_import_segment` and `unusable_binding` are replaced by function parameters.
In order to manage the fallout, `maybe_` variants of the function are added, dedicated to speculative resolution.

r? `@petrochenkov`

2 years agoRollup merge of #95316 - fmease:rustdoc-discr-req-prov-assoc-consts-tys, r=notriddle...
Dylan DPC [Tue, 12 Apr 2022 21:16:55 +0000 (23:16 +0200)]
Rollup merge of #95316 - fmease:rustdoc-discr-req-prov-assoc-consts-tys, r=notriddle,GuillaumeGomez

Rustdoc: Discriminate required and provided associated constants and types

Currently, rustdoc merely separates required and provided associated _functions_ (i.e. methods). This PR extends this to constants (fixes #94652) and types. This makes the documentation of all three kinds of associated items more alike and consistent.

As an aside, associated types may actually be provided / have a default when users enable the unstable feature `associated_type_defaults`.

| Before | After |
|---|---|
| ![image](https://user-images.githubusercontent.com/14913065/160631832-d5862d13-b395-4d86-b45c-3873ffd4cd4e.png) | ![image](https://user-images.githubusercontent.com/14913065/160631903-33909a03-b6ee-4d75-9cbc-d188f7f8602e.png) |
| ![image](https://user-images.githubusercontent.com/14913065/160632173-040d4139-76f4-4410-851b-d8c1cef014d2.png) | ![image](https://user-images.githubusercontent.com/14913065/160632233-6fd3fe73-cadc-4291-b104-59d2e45366a6.png) |

### `clean::types::ItemKind` modification

* `ItemKind::TypedefItem(.., true)` → `ItemKind::AssocTypeItem(..)`
* `ItemKind::TypedefItem(.., false)` → `ItemKind::TypedefItem(..)`

Further, I added `ItemKind::TyAssoc{Const,Type}Item`, the “required” variant of `ItemKind::Assoc{Const,Type}Item`, analogous to `ItemKind::TyMethodItem` with `ItemKind::MethodItem`. These new variants don't contain new information really, they are just the result of me getting rid of the `Option<_>` field in `AssocConstItem` and `AssocTypeItem`.

**Goal**: Make associated items more consistent.
Originally I thought modifying `ItemKind` was necessary to achieve the new functionality of this PR but in retrospect, it does not. If you don't like the changes to `ItemKind`, I think I _can_ get rid of them.

This change is the root cause of those tiny changes in a lot of different files.

 ### Concerns and Open Questions

* **breaking changes** to hyperlinks: Some heading IDs change:
  * `associated-const` (sic!) -> `{provided,required}-associated-consts`
  * `associated-types` -> `{provided,required}-associated-types`
* **verbosity** of the headings _{Required,Provided} Associated {Constants,Types}_
* For some files, I am not sure if the changes I made are correct. So please take extra care when reviewing `conversions.rs` (conversion to JSON), `cache.rs`/`fold_item`, `stripper.rs`/`fold_item`, `check_doc_test_visibility.rs`/`should_have_doc_example`, `collect_intra_doc_links.rs`/`from_assoc_item`
* JSON output: I still map `AssocTypeItem`s to `Typedef` etc. (FIXME)

2 years agoBless tests.
Camille GILLOT [Tue, 12 Apr 2022 20:44:19 +0000 (22:44 +0200)]
Bless tests.

2 years agoHandle `unusable_binding` more compactly.
Vadim Petrochenkov [Tue, 12 Apr 2022 17:18:08 +0000 (20:18 +0300)]
Handle `unusable_binding` more compactly.

2 years agoApply suggestions from code review
Oli Scherer [Tue, 12 Apr 2022 19:36:09 +0000 (21:36 +0200)]
Apply suggestions from code review

Co-authored-by: Michael Goulet <michael@errs.io>
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2 years agoImplement tuples using recursion
Caio [Tue, 12 Apr 2022 19:23:36 +0000 (16:23 -0300)]
Implement tuples using recursion

2 years agoregression test for spurrious "help: store this in the heap"
Michael Howell [Tue, 12 Apr 2022 19:14:32 +0000 (12:14 -0700)]
regression test for spurrious "help: store this in the heap"

Closes #82446

2 years agoAuto merge of #95987 - m-ou-se:rollup-sdevd9b, r=m-ou-se
bors [Tue, 12 Apr 2022 18:44:05 +0000 (18:44 +0000)]
Auto merge of #95987 - m-ou-se:rollup-sdevd9b, r=m-ou-se

Rollup of 4 pull requests

Successful merges:

 - #95783 (rustdoc doctest: include signal number in exit status)
 - #95794 (`parse_tt`: a few more tweaks)
 - #95963 ([bootstrap] Grab the right FileCheck binary for dist when cross-compiling.)
 - #95975 (Don't test -Cdefault-linker-libraries=yes when cross compiling.)

Failed merges:

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

2 years agoAdd Rustdoc book link to scrape examples help. Remove remaining panic
Will Crichton [Tue, 12 Apr 2022 18:05:07 +0000 (11:05 -0700)]
Add Rustdoc book link to scrape examples help. Remove remaining panic
locations in scrape examples.

2 years agoRemove NodeIdHashingMode.
Camille GILLOT [Mon, 4 Apr 2022 20:19:25 +0000 (22:19 +0200)]
Remove NodeIdHashingMode.

2 years agoRollup merge of #95975 - m-ou-se:test-70093-no-cross, r=joshtriplett
Mara Bos [Tue, 12 Apr 2022 17:58:18 +0000 (19:58 +0200)]
Rollup merge of #95975 - m-ou-se:test-70093-no-cross, r=joshtriplett

Don't test -Cdefault-linker-libraries=yes when cross compiling.

See https://github.com/rust-lang/rust/pull/95727#issuecomment-1096603163 and the five comments below that.

Unblocks #95727.

2 years agoRollup merge of #95963 - luqmana:llvm-dist-cross-filecheck, r=Mark-Simulacrum
Mara Bos [Tue, 12 Apr 2022 17:58:17 +0000 (19:58 +0200)]
Rollup merge of #95963 - luqmana:llvm-dist-cross-filecheck, r=Mark-Simulacrum

[bootstrap] Grab the right FileCheck binary for dist when cross-compiling.

Fixes #95862

We were using the target dir for all the other LLVM tools (`llvm-config`, `llvm-ar`, etc) but the build target dir for `FileCheck`. This meant for targets which are cross-compiled, we were copying the wrong binary.

2 years agoRollup merge of #95794 - nnethercote:parse_tt-a-few-more-tweaks, r=petrochenkov
Mara Bos [Tue, 12 Apr 2022 17:58:16 +0000 (19:58 +0200)]
Rollup merge of #95794 - nnethercote:parse_tt-a-few-more-tweaks, r=petrochenkov

`parse_tt`: a few more tweaks

r? `@petrochenkov`

2 years agoRollup merge of #95783 - notriddle:notriddle/doctest-signal, r=GuillaumeGomez
Mara Bos [Tue, 12 Apr 2022 17:58:15 +0000 (19:58 +0200)]
Rollup merge of #95783 - notriddle:notriddle/doctest-signal, r=GuillaumeGomez

rustdoc doctest: include signal number in exit status

Related to #95601

2 years agoFix imports.
Camille GILLOT [Tue, 12 Apr 2022 17:55:47 +0000 (19:55 +0200)]
Fix imports.

2 years agoMove diagnostic methods to the dedicated module.
Camille GILLOT [Fri, 8 Apr 2022 20:52:18 +0000 (22:52 +0200)]
Move diagnostic methods to the dedicated module.

2 years agoSimplify error reporting.
Camille GILLOT [Fri, 8 Apr 2022 20:52:07 +0000 (22:52 +0200)]
Simplify error reporting.

2 years agoMove path resolution error to rustc_resolve::diagnostics.
Camille GILLOT [Fri, 8 Apr 2022 20:51:55 +0000 (22:51 +0200)]
Move path resolution error to rustc_resolve::diagnostics.

2 years agoMake the logic more explicit with let chains.
Camille GILLOT [Fri, 8 Apr 2022 20:51:44 +0000 (22:51 +0200)]
Make the logic more explicit with let chains.

2 years agoDo not record Res when builing a suggestion.
Camille GILLOT [Fri, 8 Apr 2022 20:51:27 +0000 (22:51 +0200)]
Do not record Res when builing a suggestion.

2 years agoInsert error after checking for binding usability.
Camille GILLOT [Fri, 8 Apr 2022 20:51:13 +0000 (22:51 +0200)]
Insert error after checking for binding usability.

2 years agoPass last_import_segment and unusable_binding as parameters.
Camille GILLOT [Fri, 8 Apr 2022 20:50:56 +0000 (22:50 +0200)]
Pass last_import_segment and unusable_binding as parameters.

2 years agoSimplify binding finalization.
Camille GILLOT [Fri, 8 Apr 2022 20:50:32 +0000 (22:50 +0200)]
Simplify binding finalization.

2 years agoMove ident resolution to a dedicated module.
Camille GILLOT [Sat, 26 Mar 2022 19:59:09 +0000 (20:59 +0100)]
Move ident resolution to a dedicated module.

2 years agoAutotag library PRs with T-libs
Jane Lusby [Tue, 12 Apr 2022 17:48:56 +0000 (10:48 -0700)]
Autotag library PRs with T-libs

2 years agoFix spelling in docs for can_not_overflow
wcampbell [Tue, 12 Apr 2022 17:29:56 +0000 (13:29 -0400)]
Fix spelling in docs for can_not_overflow

2 years agoAuto merge of #95867 - cjgillot:fixed-size, r=oli-obk
bors [Tue, 12 Apr 2022 16:12:48 +0000 (16:12 +0000)]
Auto merge of #95867 - cjgillot:fixed-size, r=oli-obk

Skip `Lazy` for some metadata tables

Some metadata tables encode their entries indirectly, through the Lazy construct. This is useful when dealing with variable length encoding, but incurs the extra cost of one u32.

Meanwhile, some fields can be encoded in a single u8, or can use a short fixed-length encoding. This PR proposes to do so, and avoid the overhead.

2 years agoOptimize line offset parsing in <SourceFile as Decodable>::decode
Martin Gammelsæter [Tue, 12 Apr 2022 14:31:03 +0000 (16:31 +0200)]
Optimize line offset parsing in <SourceFile as Decodable>::decode

By inverting parsing loop, avoiding continually re-checking bytes_per_diff.

2 years agoportable-simd: use simd_arith_offset to avoid ptr-int transmutation
Ralf Jung [Tue, 12 Apr 2022 15:01:22 +0000 (11:01 -0400)]
portable-simd: use simd_arith_offset to avoid ptr-int transmutation

2 years agoadd simd_arith_offset intrinsics
Ralf Jung [Tue, 12 Apr 2022 15:00:55 +0000 (11:00 -0400)]
add simd_arith_offset intrinsics

2 years agoRemove a `format` invocation
Roc Yu [Tue, 12 Apr 2022 15:04:37 +0000 (11:04 -0400)]
Remove a `format` invocation

2 years agorustdoc: discr. required+provided assoc consts+tys
León Orell Valerian Liehr [Tue, 29 Mar 2022 17:30:54 +0000 (19:30 +0200)]
rustdoc: discr. required+provided assoc consts+tys

2 years agoUpdate src/test/rustdoc-ui/failed-doctest-output-windows.rs
Michael Howell [Tue, 12 Apr 2022 13:37:00 +0000 (06:37 -0700)]
Update src/test/rustdoc-ui/failed-doctest-output-windows.rs

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2 years agoAuto merge of #95974 - fee1-dead:rollup-2fr55cs, r=fee1-dead
bors [Tue, 12 Apr 2022 13:06:49 +0000 (13:06 +0000)]
Auto merge of #95974 - fee1-dead:rollup-2fr55cs, r=fee1-dead

Rollup of 5 pull requests

Successful merges:

 - #95671 (feat: Allow usage of sudo [while not accessing root] in x.py)
 - #95716 (sess: warn w/out fluent bundle w/ user sysroot)
 - #95820 (simplify const params diagnostic on stable)
 - #95900 (Fix documentation for wasm32-unknown-unknown)
 - #95947 (`impl const Default for Box<[T]>` and `Box<str>`)

Failed merges:

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

2 years agoDon't test -Cdefault-linker-libraries=yes when cross compiling.
Mara Bos [Tue, 12 Apr 2022 13:00:44 +0000 (15:00 +0200)]
Don't test -Cdefault-linker-libraries=yes when cross compiling.

2 years agoRollup merge of #95947 - cuviper:default-box, r=dtolnay
fee1-dead [Tue, 12 Apr 2022 12:44:45 +0000 (22:44 +1000)]
Rollup merge of #95947 - cuviper:default-box, r=dtolnay

`impl const Default for Box<[T]>` and `Box<str>`

The unstable `const_default_impls` (#87864) already include empty `Vec<T>` and `String`. Now we extend that concept to `Box<[T]>` and `Box<str>` as well.

This obviates a hack in `rustc_ast`'s `P::<[T]>::new`.

2 years agoRollup merge of #95900 - o01eg:fix-wasm-doc, r=Mark-Simulacrum
fee1-dead [Tue, 12 Apr 2022 12:44:44 +0000 (22:44 +1000)]
Rollup merge of #95900 - o01eg:fix-wasm-doc, r=Mark-Simulacrum

Fix documentation for wasm32-unknown-unknown

Fixes https://github.com/rust-lang/rust/issues/76526#issuecomment-1094208720

2 years agoRollup merge of #95820 - OliverMD:95150, r=lcnr
fee1-dead [Tue, 12 Apr 2022 12:44:43 +0000 (22:44 +1000)]
Rollup merge of #95820 - OliverMD:95150, r=lcnr

simplify const params diagnostic on stable

Resolves #95150

2 years agoRollup merge of #95716 - davidtwco:translation-custom-sysroot-only-warn, r=oli-obk
fee1-dead [Tue, 12 Apr 2022 12:44:42 +0000 (22:44 +1000)]
Rollup merge of #95716 - davidtwco:translation-custom-sysroot-only-warn, r=oli-obk

sess: warn w/out fluent bundle w/ user sysroot

Addresses https://github.com/rust-lang/rust/pull/95512#issuecomment-1088467139.

When a custom sysroot is requested, then don't error when translation resources are not found, only warn.

r? `@bjorn3`

2 years agoRollup merge of #95671 - gimbles:master, r=Mark-Simulacrum
fee1-dead [Tue, 12 Apr 2022 12:44:41 +0000 (22:44 +1000)]
Rollup merge of #95671 - gimbles:master, r=Mark-Simulacrum

feat: Allow usage of sudo [while not accessing root] in x.py

# Fixes
This PR should fix #93344
# Info
Allows usage of sudo (while not accessing root) in x.py

2 years agoExplain the span search logic
Oli Scherer [Tue, 12 Apr 2022 12:31:00 +0000 (12:31 +0000)]
Explain the span search logic

2 years agoCompute a more precise span for opaque type impls
Oli Scherer [Tue, 12 Apr 2022 12:28:31 +0000 (12:28 +0000)]
Compute a more precise span for opaque type impls

2 years agoAuto merge of #95966 - matthiaskrgr:rollup-hhy4nod, r=matthiaskrgr
bors [Tue, 12 Apr 2022 10:25:49 +0000 (10:25 +0000)]
Auto merge of #95966 - matthiaskrgr:rollup-hhy4nod, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #95320 (Document the current MIR semantics that are clear from existing code)
 - #95722 (pre-push.sh: Use python3 if python is not found)
 - #95881 (Use `to_string` instead of `format!`)
 - #95909 (rustdoc: Reduce allocations in a `theme` function)
 - #95910 (Fix crate_type attribute to not warn on duplicates)
 - #95920 (use `Span::find_ancestor_inside` to get right span in CastCheck)
 - #95936 (Fix a bad error message for `relative paths are not supported in visibilities` error)

Failed merges:

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

2 years agosess: try sysroot candidates for fluent bundle
David Wood [Wed, 6 Apr 2022 03:16:07 +0000 (04:16 +0100)]
sess: try sysroot candidates for fluent bundle

Instead of checking only the user provided sysroot or the default (when
no sysroot is provided), search user provided sysroot and then check
default sysroots for locale requested by the user.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoAdd test for `T:` suggestions
Maybe Waffle [Tue, 12 Apr 2022 08:14:43 +0000 (12:14 +0400)]
Add test for `T:` suggestions

2 years agoFix wrong suggestions for `T:`
Maybe Waffle [Tue, 12 Apr 2022 07:29:23 +0000 (11:29 +0400)]
Fix wrong suggestions for `T:`

This commit fixes a corner case in `suggest_constraining_type_params`
that was causing incorrect suggestions.

For the following functions:
```rust
fn a<T:>(t: T) { [t, t]; }
fn b<T>(t: T) where T: { [t, t]; }
```
We previously suggested the following:
```text
...
help: consider restricting type parameter `T`
  |
1 | fn a<T: Copy:>(t: T) { [t, t]; }
  |       ++++++
...
help: consider further restricting this bound
  |
2 | fn b<T>(t: T) where T: + Copy { [t, t]; }
  |                        ++++++
```
Note that neither `T: Copy:` not `where T: + Copy` is a correct bound.

With this commit the suggestions are correct:
```text
...
help: consider restricting type parameter `T`
  |
1 | fn a<T: Copy>(t: T) { [t, t]; }
  |         ++++
...
help: consider further restricting this bound
  |
2 | fn b<T>(t: T) where T: Copy { [t, t]; }
  |                        ++++
```

2 years agoRollup merge of #95936 - TaKO8Ki:fix-relative-paths-error-message, r=Dylan-DPC
Matthias Krüger [Tue, 12 Apr 2022 06:47:01 +0000 (08:47 +0200)]
Rollup merge of #95936 - TaKO8Ki:fix-relative-paths-error-message, r=Dylan-DPC

Fix a bad error message for `relative paths are not supported in visibilities` error

closes #95638

2 years agoRollup merge of #95920 - compiler-errors:cast-suggestion-span, r=oli-obk
Matthias Krüger [Tue, 12 Apr 2022 06:47:00 +0000 (08:47 +0200)]
Rollup merge of #95920 - compiler-errors:cast-suggestion-span, r=oli-obk

use `Span::find_ancestor_inside` to get right span in CastCheck

This is a quick fix. This bad suggestion likely lives in other places... but thought it would be useful to fix all of the CastCheck ones first.

Let me know if reviewer would prefer I add more tests for each of the diagnostics in CastCheck, or would like to do a more thorough review of other suggestions that use spans in typeck. I would also be open to further suggestions on how to better expose an API that gives us the "best" span for a diagnostic suggestion.

Fixed #95919

2 years agoRollup merge of #95910 - ehuss:fix-crate-type-duplicate, r=Dylan-DPC
Matthias Krüger [Tue, 12 Apr 2022 06:46:59 +0000 (08:46 +0200)]
Rollup merge of #95910 - ehuss:fix-crate-type-duplicate, r=Dylan-DPC

Fix crate_type attribute to not warn on duplicates

In #88681 I accidentally marked the `crate_type` attribute as only allowing a single attribute. However, multiple attributes are allowed (they are joined together [here](https://github.com/rust-lang/rust/blob/027a232755fa9728e9699337267f6675dfd0a8ba/compiler/rustc_interface/src/util.rs#L530-L542)). This fixes it to not report a warning if duplicates are found.

Closes #95902

2 years agoRollup merge of #95909 - vacuus:theme-build-rule, r=GuillaumeGomez
Matthias Krüger [Tue, 12 Apr 2022 06:46:58 +0000 (08:46 +0200)]
Rollup merge of #95909 - vacuus:theme-build-rule, r=GuillaumeGomez

rustdoc: Reduce allocations in a `theme` function

`str::replace` allocates a new `String`...

This could probably be made more efficient, but I think it'd have to be clunky imperative code to achieve that.

2 years agoRollup merge of #95881 - TaKO8Ki:use-to-string-instead-of-format, r=compiler-errors
Matthias Krüger [Tue, 12 Apr 2022 06:46:57 +0000 (08:46 +0200)]
Rollup merge of #95881 - TaKO8Ki:use-to-string-instead-of-format, r=compiler-errors

Use `to_string` instead of `format!`

2 years agoRollup merge of #95722 - xu-cheng:pre-push, r=Mark-Simulacrum
Matthias Krüger [Tue, 12 Apr 2022 06:46:56 +0000 (08:46 +0200)]
Rollup merge of #95722 - xu-cheng:pre-push, r=Mark-Simulacrum

pre-push.sh: Use python3 if python is not found

Since Python 2 has reached EOL, `python` may not be available in certain systems (e.g., recent macOS). We should use `python3` in this case to avoid error like `python: No such file or directory`.

2 years agoRollup merge of #95320 - JakobDegen:mir-docs, r=oli-obk
Matthias Krüger [Tue, 12 Apr 2022 06:46:56 +0000 (08:46 +0200)]
Rollup merge of #95320 - JakobDegen:mir-docs, r=oli-obk

Document the current MIR semantics that are clear from existing code

This PR adds documentation to places, operands, rvalues, statementkinds, and terminatorkinds that describes their existing semantics and requirements. In many places the semantics depend on the Rust memory model or other T-Lang decisions - when this is the case, it is just noted as such with links to UCG issues where possible. I'm hopeful that none of the documentation added here can be used to justify optimizations that depend on the memory model. The documentation for places and operands probably comes closest to running afoul of this - if people think that it cannot be merged as is, it can definitely also be taken out.

The goal here is to only document parts of MIR that seem to be decided already, or are at least depended on by existing code. That leaves quite a number of open questions - those are marked as "needs clarification." I'm not sure what to do with those in this PR - we obviously can't decide all these questions here. Should I just leave them in as is? Take them out? Keep them in but as `//` instead of `///` comments?

If this is too big to review at once, I can split this up.

r? rust-lang/mir-opt

2 years agoAdd missing unsafe marker.
Mara Bos [Mon, 11 Apr 2022 12:06:18 +0000 (14:06 +0200)]
Add missing unsafe marker.

This is now necessary because of deny(unsafe_op_in_unsafe_fn).

2 years agoAllow cvt_nz to be unused on some platforms.
Mara Bos [Sat, 9 Apr 2022 14:13:25 +0000 (16:13 +0200)]
Allow cvt_nz to be unused on some platforms.

2 years agoAdd #[deny(unsafe_op_in_unsafe_fn)] to thread_local!(const).
Mara Bos [Wed, 6 Apr 2022 20:22:43 +0000 (22:22 +0200)]
Add #[deny(unsafe_op_in_unsafe_fn)] to thread_local!(const).

This avoids 'unused unsafe' warnings when using this feature inside std.

2 years agoAdd debug asserts to futex ReentrantMutex impl.
Mara Bos [Wed, 6 Apr 2022 20:15:43 +0000 (22:15 +0200)]
Add debug asserts to futex ReentrantMutex impl.

2 years agoInitialize thread local with const{}.
Mara Bos [Wed, 6 Apr 2022 20:14:43 +0000 (22:14 +0200)]
Initialize thread local with const{}.

2 years agoMove current_thread_unique_ptr to the only module that uses it.
Mara Bos [Wed, 6 Apr 2022 20:12:47 +0000 (22:12 +0200)]
Move current_thread_unique_ptr to the only module that uses it.

2 years agoMake current_thread_unique_ptr work during thread destruction.
Mara Bos [Wed, 6 Apr 2022 11:50:45 +0000 (13:50 +0200)]
Make current_thread_unique_ptr work during thread destruction.

Otherwise we can't use println!() within atexit handlers etc.

2 years agoAdd futex-based ReentrantMutex on Linux.
Mara Bos [Wed, 6 Apr 2022 10:50:02 +0000 (12:50 +0200)]
Add futex-based ReentrantMutex on Linux.

2 years agoAdd current_thread_unique_ptr() in std::sys_common.
Mara Bos [Wed, 6 Apr 2022 10:49:46 +0000 (12:49 +0200)]
Add current_thread_unique_ptr() in std::sys_common.

2 years agoAuto merge of #95399 - gilescope:plan_b, r=scottmcm
bors [Tue, 12 Apr 2022 05:54:50 +0000 (05:54 +0000)]
Auto merge of #95399 - gilescope:plan_b, r=scottmcm

Faster parsing for lower numbers for radix up to 16 (cont.)

( Continuation of https://github.com/rust-lang/rust/pull/83371 )

With LingMan's change I think this is potentially ready.

2 years agoAuto merge of #95893 - luqmana:no-prepopulate-passes-tweaks, r=nikic
bors [Tue, 12 Apr 2022 03:26:53 +0000 (03:26 +0000)]
Auto merge of #95893 - luqmana:no-prepopulate-passes-tweaks, r=nikic

Respect -Z verify-llvm-ir and other flags that add extra passes when combined with -C no-prepopulate-passes in the new LLVM Pass Manager.

As part of the switch to the new LLVM Pass Manager the behaviour of flags such as `-Z verify-llvm-ir` (e.g. sanitizer, instrumentation) was modified when combined with `-C no-prepopulate-passes`. With the old PM, rustc was the one manually constructing the pipeline and respected those flags but in the new pass manager, those flags are used to build a list of callbacks that get invoked at certain extension points in the pipeline. Unfortunately, `-C no-prepopulate-passes` would skip building the pipeline altogether meaning we'd never add the corresponding passes. The fix here is to just manually invoke those callbacks as needed.

Fixes #95874

Demonstrating the current vs fixed behaviour using the bug in #95864
```console
$ rustc +nightly asm-miscompile.rs --edition 2021 --emit=llvm-ir -C no-prepopulate-passes -Z verify-llvm-ir
$ echo $?
0
$ rustc +stage1 asm-miscompile.rs --edition 2021 --emit=llvm-ir -C no-prepopulate-passes -Z verify-llvm-ir
Basic Block in function '_ZN14asm_miscompile3foo28_$u7b$$u7b$closure$u7d$$u7d$17h360e2f7eee1275c5E' does not have terminator!
label %bb1
LLVM ERROR: Broken module found, compilation aborted!
```

2 years agoDocument that DirEntry holds the directory open
Martin Pool [Tue, 12 Apr 2022 02:00:29 +0000 (19:00 -0700)]
Document that DirEntry holds the directory open

2 years agoBump stdarch
Jacob Pratt [Tue, 12 Apr 2022 01:40:31 +0000 (21:40 -0400)]
Bump stdarch

2 years ago[bootstrap] Grab the right FileCheck binary for dist when cross-compiling.
Luqman Aden [Tue, 12 Apr 2022 01:31:42 +0000 (21:31 -0400)]
[bootstrap] Grab the right FileCheck binary for dist when cross-compiling.

2 years agoAuto merge of #93408 - liangyongrui:master, r=scottmcm
bors [Tue, 12 Apr 2022 00:18:51 +0000 (00:18 +0000)]
Auto merge of #93408 - liangyongrui:master, r=scottmcm

fix Layout struct member naming style

2 years agofix broken link in coverage tools docs
AnthonyMikh [Mon, 11 Apr 2022 23:23:40 +0000 (02:23 +0300)]
fix broken link in coverage tools docs

2 years agouse `to_string` instead of `format!`
Takayuki Maeda [Sun, 10 Apr 2022 11:39:02 +0000 (20:39 +0900)]
use `to_string` instead of `format!`

2 years agoAuto merge of #95944 - Dylan-DPC:rollup-idggkrh, r=Dylan-DPC
bors [Mon, 11 Apr 2022 21:55:58 +0000 (21:55 +0000)]
Auto merge of #95944 - Dylan-DPC:rollup-idggkrh, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #95008 ([`let_chains`] Forbid `let` inside parentheses)
 - #95801 (Replace RwLock by a futex based one on Linux)
 - #95864 (Fix miscompilation of inline assembly with outputs in cases where we emit an invoke instead of call instruction.)
 - #95894 (Fix formatting error in pin.rs docs)
 - #95895 (Clarify str::from_utf8_unchecked's invariants)
 - #95901 (Remove duplicate aliases for `check codegen_{cranelift,gcc}` and fix `build codegen_gcc`)
 - #95927 (CI: do not compile libcore twice when performing LLVM PGO)

Failed merges:

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

2 years agoFix line numbers
Michael Howell [Mon, 11 Apr 2022 16:26:05 +0000 (09:26 -0700)]
Fix line numbers

2 years agosimplify const params diagnostic on stable
Oliver Downard [Fri, 8 Apr 2022 18:10:07 +0000 (19:10 +0100)]
simplify const params diagnostic on stable

2 years agoRemove rule that place loads may not happen with variant index set
Jakob Degen [Sat, 9 Apr 2022 14:00:19 +0000 (10:00 -0400)]
Remove rule that place loads may not happen with variant index set

2 years agoAdd more clarifications in response to Ralf's comments
Jakob Degen [Fri, 8 Apr 2022 19:53:08 +0000 (15:53 -0400)]
Add more clarifications in response to Ralf's comments

2 years agoAddress various comments and change some details around place to value conversions
Jakob Degen [Sun, 27 Mar 2022 00:46:56 +0000 (20:46 -0400)]
Address various comments and change some details around place to value conversions

2 years agoImprove MIR phases documentation with summaries of changes
Jakob Degen [Sat, 26 Mar 2022 00:08:35 +0000 (20:08 -0400)]
Improve MIR phases documentation with summaries of changes

2 years agoAdjust MIR validator to check a few more things for terminators
Jakob Degen [Sat, 26 Mar 2022 00:00:33 +0000 (20:00 -0400)]
Adjust MIR validator to check a few more things for terminators

2 years agoImprove documentation for MIR terminators
Jakob Degen [Sat, 26 Mar 2022 00:00:16 +0000 (20:00 -0400)]
Improve documentation for MIR terminators

2 years agoImprove documentation for MIR statement kinds.
Jakob Degen [Fri, 25 Mar 2022 06:17:05 +0000 (02:17 -0400)]
Improve documentation for MIR statement kinds.

2 years agoExtend the MIR validator to check many more things around rvalues.
Jakob Degen [Fri, 25 Mar 2022 02:30:23 +0000 (22:30 -0400)]
Extend the MIR validator to check many more things around rvalues.

2 years agoAdd documentation for the semantics of MIR rvalues
Jakob Degen [Fri, 25 Mar 2022 02:29:33 +0000 (22:29 -0400)]
Add documentation for the semantics of MIR rvalues

2 years agoAdjust computation of place types to detect more invalid places
Jakob Degen [Thu, 24 Mar 2022 22:25:37 +0000 (18:25 -0400)]
Adjust computation of place types to detect more invalid places

2 years agoImprove documentation of `Place` and `Operand`
Jakob Degen [Thu, 24 Mar 2022 22:25:03 +0000 (18:25 -0400)]
Improve documentation of `Place` and `Operand`

2 years agoUse const Box::default in P::<[T]>::new
Josh Stone [Mon, 11 Apr 2022 18:44:13 +0000 (11:44 -0700)]
Use const Box::default in P::<[T]>::new

2 years agoimpl const Default for Box<[T]> and Box<str>
Josh Stone [Mon, 11 Apr 2022 18:43:21 +0000 (11:43 -0700)]
impl const Default for Box<[T]> and Box<str>