]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agoRollup merge of #100970 - Xiretza:derive-multipart-suggestion, r=davidtwco
Matthias Krüger [Wed, 31 Aug 2022 05:57:54 +0000 (07:57 +0200)]
Rollup merge of #100970 - Xiretza:derive-multipart-suggestion, r=davidtwco

Allow deriving multipart suggestions

This turned into a bit more of a rewrite than I was initially hoping for... Still, I think the `SessionSubdiagnostic` derive is a little cleaner overall now, and closer to the `SessionDiagnostic` derive to make future code sharing easier.

r? ``@davidtwco``

23 months agoFix uintended diagnostic caused by `drain(..)`
Donough Liu [Mon, 29 Aug 2022 17:44:06 +0000 (18:44 +0100)]
Fix uintended diagnostic caused by `drain(..)`

23 months agoAuto merge of #101220 - JohnTitor:rollup-ov7upr7, r=JohnTitor
bors [Wed, 31 Aug 2022 02:24:44 +0000 (02:24 +0000)]
Auto merge of #101220 - JohnTitor:rollup-ov7upr7, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #100804 (Fix search results color on hover for ayu theme)
 - #100892 (Add `AsFd` implementations for stdio types on WASI.)
 - #100927 (Adding new Fuchsia rustup docs... reworking walkthrough)
 - #101088 (Set DebuginfoKind::Pdb in msvc_base)
 - #101159 (add tracking issue number to const_slice_split_at_not_mut)
 - #101192 (Remove path string)
 - #101193 (Avoid zeroing large stack buffers in stdio on Windows)
 - #101197 (:arrow_up: rust-analyzer)
 - #101200 (Add test for issue #85872)
 - #101219 (Update books)

Failed merges:

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

23 months agoRollup merge of #101219 - ehuss:update-books, r=ehuss
Yuki Okushi [Tue, 30 Aug 2022 23:47:24 +0000 (08:47 +0900)]
Rollup merge of #101219 - ehuss:update-books, r=ehuss

Update books

## nomicon

1 commits in 8e6aa3448515a0654e347b5e2510f1d4bc4d5a64..d880e6ac2acf133dce640da24b9fb692844f02d4
2022-08-15 15:36:13 -0700 to 2022-08-24 12:42:34 -0700
- Update lifetimes.md (rust-lang/nomicon#372)

## reference

2 commits in e647eb102890e8927f488bea12672b079eff8d9d..f62e93c28323ed9637d0a205a0c256498674a509
2022-08-16 11:35:27 -0700 to 2022-08-28 10:01:28 -0700
- Update examples of what implements `Termination` (rust-lang/reference#1256)
- allow to quickly edit a page directly on github (rust-lang/reference#1254)

## book

7 commits in 42ca0ef484fcc8437a0682cee23abe4b7c407d52..0a5421ceb238357b3634fb75234eba4d1dad643c
2022-08-12 21:52:02 -0400 to 2022-08-28 19:51:04 -0400
- Add a missing line generated by 'cargo new'
- Clarify ThreadPool-Worker analogy wording
- Fixed incorrect mutex lock usage
- Merge remote-tracking branch 'origin/pr/3314'
- Put interactive book notice in a blockquote box to draw attention to it
- Remove the word 'new' because someday it won't be new anymore
- Merge remote-tracking branch 'origin/pr/3304'

## rustc-dev-guide

27 commits in d3daa1f28e169087becbc5e2b49ac91ca0405a44..04892c1a6fc145602ac7367945fda9d4ee83c9fb
2022-08-13 10:00:38 +0900 to 2022-08-29 20:07:51 +0200
- Fix the link to `Parser` struct
- Remove a dangling link on "The `#[test]` attribute"
- Update the stabilization guide to refer to the new placeholder system
- Refine the lintstore section (rust-lang/rustc-dev-guide#1429)
- typo
- Updates text to refer to LLVM documentation.
- Updates LLVM prereqs since upgrade to C++17.
- we got 3 (rust-lang/rustc-dev-guide#1447)
- A few corrections
- Update some statements
- correct typo in parallel-rustc.md
- Correct some statements in parallel-rustc.md
- update parallel-rustc.md
- address review comment
- make date-check more easy to use
- update thir output (rust-lang/rustc-dev-guide#1445)
- do not offer option to run code (rust-lang/rustc-dev-guide#1442)
- fix quick-edit link (rust-lang/rustc-dev-guide#1441)
- Document changes introduced by kind-less SessionDiagnostics
- diagnostics: fix outdated use of string slugs (rust-lang/rustc-dev-guide#1436)
- Add missing lifetime (rust-lang/rustc-dev-guide#1439)
- more syntax fixes
- fix incorrect #[note] syntax
- Update slug style to use _ instead of - (rust-lang/rustc-dev-guide#1426)
- remove incorrect info (rust-lang/rustc-dev-guide#1435)
- fix lifetime name (rust-lang/rustc-dev-guide#1431)
- Update the date reference around Git submodule bug (rust-lang/rustc-dev-guide#1430)

23 months agoRollup merge of #101200 - nikic:issue-85872, r=compiler-errors
Yuki Okushi [Tue, 30 Aug 2022 23:47:23 +0000 (08:47 +0900)]
Rollup merge of #101200 - nikic:issue-85872, r=compiler-errors

Add test for issue #85872

This has been fixed by the LLVM 15 upgrade, add a codegen test.

Fixes #85872.

23 months agoRollup merge of #101197 - lnicola:rust-analyzer-2022-08-30, r=lnicola
Yuki Okushi [Tue, 30 Aug 2022 23:47:22 +0000 (08:47 +0900)]
Rollup merge of #101197 - lnicola:rust-analyzer-2022-08-30, r=lnicola

:arrow_up: rust-analyzer

r? ``@ghost``

23 months agoRollup merge of #101193 - thomcc:win-stdio-nozero, r=ChrisDenton
Yuki Okushi [Tue, 30 Aug 2022 23:47:21 +0000 (08:47 +0900)]
Rollup merge of #101193 - thomcc:win-stdio-nozero, r=ChrisDenton

Avoid zeroing large stack buffers in stdio on Windows

Does what it says on the tin, using `[MaybeUninit<u16>; N]` instead of `[0u16; N]`. These buffers seem to be around 8kb, which is big enough that this is likely to be a very nice perf boost to stdio-heavy windows code.

r? ``@ChrisDenton``

*(Note: this PR also has a commit that adds windows to CI, but as it mentions I'll revert that after it comes out green -- I can only do a check build on the machine I'm typing this on)*

23 months agoRollup merge of #101192 - TaKO8Ki:remove-path-string, r=compiler-errors
Yuki Okushi [Tue, 30 Aug 2022 23:47:20 +0000 (08:47 +0900)]
Rollup merge of #101192 - TaKO8Ki:remove-path-string, r=compiler-errors

Remove path string

23 months agoRollup merge of #101159 - tspiteri:track-const-slice-split_at, r=Mark-Simulacrum
Yuki Okushi [Tue, 30 Aug 2022 23:47:19 +0000 (08:47 +0900)]
Rollup merge of #101159 - tspiteri:track-const-slice-split_at, r=Mark-Simulacrum

add tracking issue number to const_slice_split_at_not_mut

Add issue number #101158 to `const_slice_split_at_not_mut` feature.

23 months agoRollup merge of #101088 - nicholasbishop:bishop-uefi-pdb, r=davidtwco
Yuki Okushi [Tue, 30 Aug 2022 23:47:18 +0000 (08:47 +0900)]
Rollup merge of #101088 - nicholasbishop:bishop-uefi-pdb, r=davidtwco

Set DebuginfoKind::Pdb in msvc_base

This PDB setting was added to `windows_msvc_base` in
https://github.com/rust-lang/rust/pull/98051. It's also needed for the
UEFI targets, and since `uefi_msvc_base` and `windows_msvc_base` are the
only things that inherit from `msvc_base`, just move the PDB setting up
to `mscv_base` to cover both.

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

23 months agoRollup merge of #100927 - andrewpollack:fuchsia-docs-rustup, r=tmandry
Yuki Okushi [Tue, 30 Aug 2022 23:47:17 +0000 (08:47 +0900)]
Rollup merge of #100927 - andrewpollack:fuchsia-docs-rustup, r=tmandry

Adding new Fuchsia rustup docs... reworking walkthrough

Docs improvements:
* Adding new `rustup` target add for Fuchsia targets
* Reworking walkthrough to show directory building as it happens
* Reworking walkthrough to use `hello_fuchsia_pkg/` directory

cc. `@djkoloski`

23 months agoRollup merge of #100892 - sunfishcode:wasi-stdio-asfd, r=joshtriplett
Yuki Okushi [Tue, 30 Aug 2022 23:47:15 +0000 (08:47 +0900)]
Rollup merge of #100892 - sunfishcode:wasi-stdio-asfd, r=joshtriplett

Add `AsFd` implementations for stdio types on WASI.

This mirrors the implementations on Unix platforms, and also mirrors the
existing `AsRawFd` impls.

23 months agoRollup merge of #100804 - GuillaumeGomez:search-results-color-ayu, r=notriddle
Yuki Okushi [Tue, 30 Aug 2022 23:47:14 +0000 (08:47 +0900)]
Rollup merge of #100804 - GuillaumeGomez:search-results-color-ayu, r=notriddle

Fix search results color on hover for ayu theme

Before:

![image](https://user-images.githubusercontent.com/3050060/185747851-038d2333-8b01-44a8-a104-ceb7410ac089.png)

After:

![image](https://user-images.githubusercontent.com/3050060/185747869-53b502f5-5800-470f-b897-2683f1cdb7ee.png)

You can test it [here](https://rustdoc.crud.net/imperio/search-results-color-ayu/foo/index.html?search=item).

r? ``@jsha``

23 months agoAuto merge of #99102 - JakobDegen:reorder-generators, r=oli-obk
bors [Tue, 30 Aug 2022 23:43:33 +0000 (23:43 +0000)]
Auto merge of #99102 - JakobDegen:reorder-generators, r=oli-obk

Rework definition of MIR phases to more closely reflect semantic concerns

Implements most of rust-lang/compiler-team#522 .

I tried my best to restrict this PR to the "core" parts of the MCP. In other words, this includes just enough changes to make the new definition of `MirPhase` make sense. That means there are a couple of FIXMEs lying around. Depending on what reviewers prefer, I can either fix them in this PR or send follow up PRs. There are also a couple other refactorings of the `rustc_mir_transform/src/lib.rs` file that I want to do in follow ups that I didn't leave explicit FIXMEs for.

23 months agoUpdate books
Eric Huss [Tue, 30 Aug 2022 23:18:42 +0000 (16:18 -0700)]
Update books

23 months agoUpdate src/doc/rustc/src/platform-support/fuchsia.md
andrewpollack [Tue, 30 Aug 2022 23:06:36 +0000 (16:06 -0700)]
Update src/doc/rustc/src/platform-support/fuchsia.md

Co-authored-by: Tyler Mandry <tmandry@gmail.com>
23 months agoUpdate src/doc/rustc/src/platform-support/fuchsia.md
andrewpollack [Tue, 30 Aug 2022 23:06:27 +0000 (16:06 -0700)]
Update src/doc/rustc/src/platform-support/fuchsia.md

Co-authored-by: Tyler Mandry <tmandry@gmail.com>
23 months agoUse in-page links for sanitizer docs.
Eric Huss [Tue, 30 Aug 2022 21:54:37 +0000 (14:54 -0700)]
Use in-page links for sanitizer docs.

23 months agoAdding new Fuchsia rustup docs... reworking walkthrough
Andrew Pollack [Tue, 23 Aug 2022 19:06:49 +0000 (19:06 +0000)]
Adding new Fuchsia rustup docs... reworking walkthrough

23 months agoAuto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJung
bors [Tue, 30 Aug 2022 20:39:01 +0000 (20:39 +0000)]
Auto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJung

Strengthen invalid_value lint to forbid uninit primitives, adjust docs to say that's UB

For context: https://github.com/rust-lang/rust/issues/66151#issuecomment-1174477404=

This does not make it a FCW, but it does explicitly state in the docs that uninit integers are UB.

This also doesn't affect any runtime behavior, uninit u32's will still successfully be created through mem::uninitialized.

23 months agoUPDATE - to support diag introduced in PR #100765
Jhonny Bill Mena [Sun, 21 Aug 2022 15:09:00 +0000 (11:09 -0400)]
UPDATE - to support diag introduced in PR #100765

23 months agoADD - diagnostics lints to symbol_mangling module
Jhonny Bill Mena [Sun, 21 Aug 2022 04:57:52 +0000 (00:57 -0400)]
ADD - diagnostics lints to symbol_mangling module

23 months agoADD - migrate InvalidDefPath to new diagnostics infra
Jhonny Bill Mena [Sun, 21 Aug 2022 04:51:33 +0000 (00:51 -0400)]
ADD - migrate InvalidDefPath to new diagnostics infra

23 months agoUPDATE - accept String instead of unused 'str
Jhonny Bill Mena [Sun, 21 Aug 2022 04:42:59 +0000 (00:42 -0400)]
UPDATE - accept String instead of unused 'str

23 months agoADD - migrate InvalidTraitItem and AltInvalidTraitItem errors
Jhonny Bill Mena [Sun, 21 Aug 2022 04:38:23 +0000 (00:38 -0400)]
ADD - migrate InvalidTraitItem and AltInvalidTraitItem errors

Thought of doing this by having a struct and an enum with Default and Alt cases, but not sure if we wanted to have the text in code instead of having “demangling()” and “demangling-alt()” in the ftl file.

Don’t like the current way of having structs representing the same-ish and using long names to distinguish their expectations, instead of putting this in an enum and handling the different cases inside the type.

I am fine with whichever option the team prefers; also understand having them as separate structs keeps it simple.

23 months agoADD - InvalidSymbolName to migrate symbol-name({}) error to new diagnostics infraestr...
Jhonny Bill Mena [Sat, 27 Aug 2022 04:24:13 +0000 (00:24 -0400)]
ADD - InvalidSymbolName to migrate symbol-name({}) error to new diagnostics infraestructure

ADD - dependencies needed to port a module to new Diagnostics infra (rustc_macros, rustc_errors, errors file, and fluent file)

23 months agoClean up render_assoc_items_inner a bit
Guillaume Gomez [Tue, 30 Aug 2022 15:11:07 +0000 (17:11 +0200)]
Clean up render_assoc_items_inner a bit

23 months agoAuto merge of #9373 - lukaslueg:result_large_err, r=Alexendoo
bors [Tue, 30 Aug 2022 18:20:45 +0000 (18:20 +0000)]
Auto merge of #9373 - lukaslueg:result_large_err, r=Alexendoo

Initial implementation `result_large_err`

This is a shot at #6560, #4652, and #3884. The lint checks for `Result` being returned from functions/methods where the `Err` variant is larger than a configurable threshold (the default of which is 128 bytes). There has been some discussion around this, which I'll try to quickly summarize:

* A large `Err`-variant may force an equally large `Result` if `Err` is actually bigger than `Ok`.
* There is a cost involved in large `Result`, as LLVM may choose to `memcpy` them around above a certain size.
* We usually expect the `Err` variant to be seldomly used, but pay the cost every time.
* `Result` returned from library code has a high chance of bubbling up the call stack, getting stuffed into `MyLibError { IoError(std::io::Error), ParseError(parselib::Error), ...}`, exacerbating the problem.

This PR deliberately does not take into account comparing the `Ok` to the `Err` variant (e.g. a ratio, or one being larger than the other). Rather we choose an absolute threshold for `Err`'s size, above which we warn. The reason for this is that `Err`s probably get `map_err`'ed further up the call stack, and we can't draw conclusions from the ratio at the point where the `Result` is returned. A relative threshold would also be less predictable, while not accounting for the cost of LLVM being forced to generate less efficient code if the `Err`-variant is _large_ in absolute terms.

We lint private functions as well as public functions, as the perf-cost applies to in-crate code as well.

In order to account for type-parameters, I conjured up `fn approx_ty_size`. The function relies on `LateContext::layout_of` to compute the actual size, and in case of failure (e.g. due to generics) tries to come up with an "at least size". In the latter case, the size of obviously wrong, but the inspected size certainly can't be smaller than that. Please give the approach a heavy dose of review, as I'm not actually familiar with the type-system at all (read: I have no idea what I'm doing).

The approach does, however flimsy it is, allow us to successfully lint situations like

```rust
pub union UnionError<T: Copy> {
    _maybe: T,
    _or_perhaps_even: (T, [u8; 512]),
}

// We know `UnionError<T>` will be at least 512 bytes, no matter what `T` is
pub fn param_large_union<T: Copy>() -> Result<(), UnionError<T>> {
    Ok(())
}
```

I've given some refactoring to `functions/result_unit_err.rs` to re-use some bits. This is also the groundwork for #6409

The default threshold is 128 because of https://github.com/rust-lang/rust-clippy/issues/4652#issue-505670554

`lintcheck` does not trigger this lint for a threshold of 128. It does warn for 64, though.

The suggestion currently is the following, which is just a placeholder for discussion to be had. I did have the computed size in a `span_label`. However, that might cause both ui-tests here and lints elsewhere to become flaky wrt to their output (as the size is platform dependent).

```
error: the `Err`-variant returned via this `Result` is very large
  --> $DIR/result_large_err.rs:36:34
   |
LL | pub fn param_large_error<R>() -> Result<(), (u128, R, FullyDefinedLargeError)> {
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The `Err` variant is unusually large, at least 128 bytes
```

changelog: Add [`result_large_err`] lint

23 months agoAuto merge of #101203 - fortanix:raoul/remove_rls_from_git_submodule_update, r=jyn514
bors [Tue, 30 Aug 2022 17:33:24 +0000 (17:33 +0000)]
Auto merge of #101203 - fortanix:raoul/remove_rls_from_git_submodule_update, r=jyn514

Avoid bootstrap from updating rls submodule

Our CI performing tests of the `x86_64-fortanix-unknown-sgx` failed with:
```
21:00:53 + ./configure --enable-lld --disable-rpath --set llvm.ninja=false --set rust.verbose-tests=true
21:00:53 + ./x.py test --stage=1 --target=x86_64-fortanix-unknown-sgx library/std --host= --no-doc --exclude src/tools/linkchecker
21:00:53 Building rustbuild
21:00:53     Finished dev [unoptimized] target(s) in 0.11s
21:00:53 Updating submodule src/tools/rls
21:00:54 Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
21:00:54     Updating crates.io index
21:00:55     Updating git repository `[https://github.com/rust-lang/cargo`](https://github.com/rust-lang/cargo%60)
...
21:00:55     Updating git repository `[https://github.com/rust-lang/rust-clippy`](https://github.com/rust-lang/rust-clippy%60)
21:00:56     Updating git repository `[https://github.com/rust-lang/rustfmt`](https://github.com/rust-lang/rustfmt%60)
21:00:56 error: failed to select a version for `libgit2-sys`.
21:00:56     ... required by package `cargo v0.65.0 (https://github.com/rust-lang/cargo?rev=5514f1e0e1b3650ed8a78306198e90b66b292693#5514f1e0)`
21:00:56     ... which satisfies git dependency `cargo` of package `rls v1.41.0 (/home/jenkins/workspace/rust-sgx-ci/rust/src/tools/rls)`
21:00:56 versions that meet the requirements `^0.13.2` are: 0.13.4+1.4.2, 0.13.3+1.4.2, 0.13.2+1.4.2
21:00:56
21:00:56 the package `libgit2-sys` links to the native library `git2`, but it conflicts with a previous package which links to `git2` as well:
21:00:56 package `libgit2-sys v0.14.0+1.5.0`
21:00:56     ... which satisfies dependency `libgit2-sys = "^0.14.0"` of package `cargo v0.66.0 (/home/jenkins/workspace/rust-sgx-ci/rust/src/tools/cargo)`
21:00:56 Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='libgit2-sys' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.
21:00:56
21:00:56 failed to select a version for `libgit2-sys` which could resolve this conflict
```
This is related to the version bump of `libgit2-sys` in #11004, but the root cause is the RLS is sunset (#100863). When the bootstrapper manages the git submodules, the wrong repo commit is checked out. This PR removes rls from the list of rust submodules.

23 months agorustdoc: Resugar async fn return type in `clean`, not `html`
Nixon Enraght-Moony [Tue, 30 Aug 2022 14:29:41 +0000 (15:29 +0100)]
rustdoc: Resugar async fn return type in `clean`, not `html`

This way it also happens for json output.

Fixes #101199

23 months agoHandle MIR in a single place.
Camille GILLOT [Sun, 3 Jul 2022 17:59:37 +0000 (19:59 +0200)]
Handle MIR in a single place.

23 months agoRemove fn_has_self_parameter table.
Camille GILLOT [Thu, 4 Aug 2022 20:03:16 +0000 (22:03 +0200)]
Remove fn_has_self_parameter table.

23 months agoSeparate macro_rules and macro_definition.
Camille GILLOT [Wed, 6 Jul 2022 09:11:11 +0000 (11:11 +0200)]
Separate macro_rules and macro_definition.

23 months agoRemove EntryKind.
Camille GILLOT [Sun, 3 Jul 2022 16:02:35 +0000 (18:02 +0200)]
Remove EntryKind.

23 months agoCreate a module-reexports table.
Camille GILLOT [Sun, 3 Jul 2022 15:54:15 +0000 (17:54 +0200)]
Create a module-reexports table.

23 months agoFix the panic message.
Camille GILLOT [Sun, 3 Jul 2022 15:49:13 +0000 (17:49 +0200)]
Fix the panic message.

23 months agoCreate a table for fn_has_self_parameter.
Camille GILLOT [Sun, 3 Jul 2022 15:49:06 +0000 (17:49 +0200)]
Create a table for fn_has_self_parameter.

23 months agoUse tables for macros.
Camille GILLOT [Wed, 8 Jun 2022 19:38:04 +0000 (21:38 +0200)]
Use tables for macros.

23 months agoMove AssocContainer to a metadata table.
Camille GILLOT [Wed, 8 Jun 2022 19:11:08 +0000 (21:11 +0200)]
Move AssocContainer to a metadata table.

23 months agoMove VariantData to a metadata table.
Camille GILLOT [Wed, 8 Jun 2022 18:59:59 +0000 (20:59 +0200)]
Move VariantData to a metadata table.

23 months agoSimplify recursion scheme.
Camille GILLOT [Sun, 3 Apr 2022 16:43:33 +0000 (18:43 +0200)]
Simplify recursion scheme.

23 months agoEncode consts in metadata main loop.
Camille GILLOT [Wed, 8 Jun 2022 18:32:51 +0000 (20:32 +0200)]
Encode consts in metadata main loop.

23 months agoEncode type in the main loop.
Camille GILLOT [Sun, 3 Apr 2022 12:50:56 +0000 (14:50 +0200)]
Encode type in the main loop.

23 months agoInitial implementation of `result_large_err`
Lukas Lueg [Wed, 24 Aug 2022 21:11:19 +0000 (23:11 +0200)]
Initial implementation of `result_large_err`

23 months agoAuto merge of #101195 - Dylan-DPC:rollup-rhjaz6r, r=Dylan-DPC
bors [Tue, 30 Aug 2022 14:52:02 +0000 (14:52 +0000)]
Auto merge of #101195 - Dylan-DPC:rollup-rhjaz6r, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #99517 (Display raw pointer as *{mut,const} T instead of *-ptr in errors)
 - #99928 (Do not leak type variables from opaque type relation)
 - #100473 (Attempt to normalize `FnDef` signature in `InferCtxt::cmp`)
 - #100653 (Move the cast_float_to_int fallback code to GCC)
 - #100941 (Point at the string inside literal and mention if we need string inte…)

Failed merges:

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

23 months agoAvoid bootstrap from updating rls submodule
Raoul Strackx [Tue, 30 Aug 2022 13:43:25 +0000 (15:43 +0200)]
Avoid bootstrap from updating rls submodule

23 months agoAvoid `MaybeUninit::uninit_array()`
Thom Chiovoloni [Tue, 30 Aug 2022 13:10:55 +0000 (06:10 -0700)]
Avoid `MaybeUninit::uninit_array()`

23 months agoAdd test for issue #85872
Nikita Popov [Tue, 30 Aug 2022 13:03:22 +0000 (15:03 +0200)]
Add test for issue #85872

This has been fixed by the LLVM 15 upgrade, add a codegen test.

Fixes #85872.

23 months agoChange fatal diagnostic to an error.
JeanCASPAR [Tue, 30 Aug 2022 12:26:09 +0000 (14:26 +0200)]
Change fatal diagnostic to an error.

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
23 months agoFix UB in Windows `DirBuffIter` (provenance and alignment)
Thom Chiovoloni [Tue, 30 Aug 2022 08:45:30 +0000 (01:45 -0700)]
Fix UB in Windows `DirBuffIter` (provenance and alignment)

23 months ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 30 Aug 2022 11:51:24 +0000 (14:51 +0300)]
:arrow_up: rust-analyzer

23 months agoRollup merge of #100941 - lyming2007:issue-100584, r=oli-obk
Dylan DPC [Tue, 30 Aug 2022 11:26:10 +0000 (16:56 +0530)]
Rollup merge of #100941 - lyming2007:issue-100584, r=oli-obk

Point at the string inside literal and mention if we need string inte…

…rpolation

modified:   compiler/rustc_passes/src/liveness.rs

23 months agoRollup merge of #100653 - cuviper:fptoint_sat, r=michaelwoerister,antoyo
Dylan DPC [Tue, 30 Aug 2022 11:26:09 +0000 (16:56 +0530)]
Rollup merge of #100653 - cuviper:fptoint_sat, r=michaelwoerister,antoyo

Move the cast_float_to_int fallback code to GCC

Now that we require at least LLVM 13, that codegen backend is always
using its intrinsic `fptosi.sat` and `fptoui.sat` conversions, so it
doesn't need the manual implementation. However, the GCC backend still
needs it, so we can move all of that code down there.

23 months agoRollup merge of #100473 - compiler-errors:normalize-the-fn-def-sig-plz, r=lcnr
Dylan DPC [Tue, 30 Aug 2022 11:26:08 +0000 (16:56 +0530)]
Rollup merge of #100473 - compiler-errors:normalize-the-fn-def-sig-plz, r=lcnr

Attempt to normalize `FnDef` signature in `InferCtxt::cmp`

Stashes a normalization callback in `InferCtxt` so that the signature we get from `tcx.fn_sig(..).subst(..)` in `InferCtxt::cmp` can be properly normalized, since we cannot expect for it to have normalized types since it comes straight from astconv.

This is kind of a hack, but I will say that `@jyn514` found the fact that we present unnormalized types to be very confusing in real life code, and I agree with that feeling. Though altogether I am still a bit unsure about whether this PR is worth the effort, so I'm open to alternatives and/or just closing it outright.

On the other hand, this isn't a ridiculously heavy implementation anyways -- it's less than a hundred lines of changes, and half of that is just miscellaneous cleanup.

This is stacked onto #100471 which is basically unrelated, and it can be rebased off of that when that lands or if needed.

---

The code:
```rust
trait Foo { type Bar; }

impl<T> Foo for T {
    type Bar = i32;
}

fn foo<T>(_: <T as Foo>::Bar) {}

fn needs_i32_ref_fn(f: fn(&'static i32)) {}

fn main() {
    needs_i32_ref_fn(foo::<()>);
}
```

Before:
```
   = note: expected fn pointer `fn(&'static i32)`
                 found fn item `fn(<() as Foo>::Bar) {foo::<()>}`
```

After:
```
   = note: expected fn pointer `fn(&'static i32)`
                 found fn item `fn(i32) {foo::<()>}`
```

23 months agoRollup merge of #99928 - compiler-errors:issue-99914, r=oli-obk
Dylan DPC [Tue, 30 Aug 2022 11:26:07 +0000 (16:56 +0530)]
Rollup merge of #99928 - compiler-errors:issue-99914, r=oli-obk

Do not leak type variables from opaque type relation

The "root cause" is that we call `InferCtxt::resolve_vars_if_possible` (3d9dd681f520d1d59f38aed0056cf9474894cc74) on the types we get back in `TypeError::Sorts` since I added a call to it in `InferCtxt::same_type_modulo_infer`. However if this `TypeError` comes from a `InferCtxt::commit_if_ok`, then it may reference type variables that do not exist anymore, which is problematic.

We avoid this by substituting the `TypeError` with the types we had before being generalized while handling opaques.

This is kinda gross, and I feel like we can get the same issue from other places where we generalize type/const inference variables. Maybe not? I don't know.

Fixes #99914
Fixes #99970
Fixes #100463

23 months agoRollup merge of #99517 - Nilstrieb:display-raw-ptr, r=compiler-errors
Dylan DPC [Tue, 30 Aug 2022 11:26:06 +0000 (16:56 +0530)]
Rollup merge of #99517 - Nilstrieb:display-raw-ptr, r=compiler-errors

Display raw pointer as *{mut,const} T instead of *-ptr in errors

The `*-ptr` is rather confusing, and we have the full information for properly displaying the information.

23 months agoAuto merge of #98100 - bjorn3:use_object_for_bitcode_reading, r=wesleywiser
bors [Tue, 30 Aug 2022 11:13:58 +0000 (11:13 +0000)]
Auto merge of #98100 - bjorn3:use_object_for_bitcode_reading, r=wesleywiser

Use object instead of LLVM for reading bitcode from rlibs

Together with changes I plan to make as part of https://github.com/rust-lang/rust/pull/97485 this will allow entirely removing usage of LLVM's archive reader and thus allow removing `archive_ro.rs` and `ArchiveWrapper.cpp`.

23 months agoRework SessionSubdiagnostic derive to support multipart_suggestion
Xiretza [Tue, 23 Aug 2022 05:54:06 +0000 (07:54 +0200)]
Rework SessionSubdiagnostic derive to support multipart_suggestion

23 months agoAvoid zeroing large stack buffers in stdio on Windows
Thom Chiovoloni [Tue, 30 Aug 2022 10:06:22 +0000 (03:06 -0700)]
Avoid zeroing large stack buffers in stdio on Windows

23 months agoremove path string
Takayuki Maeda [Tue, 30 Aug 2022 10:06:19 +0000 (19:06 +0900)]
remove path string

23 months agoMake docs formulation more consistent for NonZero{int}
yjhn [Tue, 30 Aug 2022 09:29:18 +0000 (12:29 +0300)]
Make docs formulation more consistent for NonZero{int}

Use third person, as it is used for other std documentation.

23 months agoSimplify pass manager's `run_passes` logic
Jakob Degen [Mon, 8 Aug 2022 00:19:16 +0000 (17:19 -0700)]
Simplify pass manager's `run_passes` logic

23 months agoRefactor MIR phases
Jakob Degen [Sun, 10 Jul 2022 01:04:38 +0000 (18:04 -0700)]
Refactor MIR phases

23 months agoAuto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPC
bors [Tue, 30 Aug 2022 08:29:42 +0000 (08:29 +0000)]
Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #95376 (Add `vec::Drain{,Filter}::keep_rest`)
 - #100092 (Fall back when relating two opaques by substs in MIR typeck)
 - #101019 (Suggest returning closure as `impl Fn`)
 - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`)
 - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information)
 - #101123 (Remove `register_attr` feature)
 - #101175 (Don't --bless in pre-push hook)
 - #101176 (rustdoc: remove unused CSS selectors for `.table-display`)
 - #101180 (Add another MaybeUninit array test with const)

Failed merges:

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

23 months agoReplace `AlignedAs` with a more specific `Align8` type
Thom Chiovoloni [Tue, 30 Aug 2022 08:15:59 +0000 (01:15 -0700)]
Replace `AlignedAs` with a more specific `Align8` type

23 months agoUnify indentation in subdiagnostic-derive test
Xiretza [Fri, 26 Aug 2022 09:17:42 +0000 (11:17 +0200)]
Unify indentation in subdiagnostic-derive test

23 months agoSessionSubdiagnostic: make `#[applicability]` optional
Xiretza [Fri, 26 Aug 2022 09:09:06 +0000 (11:09 +0200)]
SessionSubdiagnostic: make `#[applicability]` optional

23 months agoUse span_suggestion_with_style in SessionSubdiagnostic derive
Xiretza [Mon, 22 Aug 2022 16:18:54 +0000 (18:18 +0200)]
Use span_suggestion_with_style in SessionSubdiagnostic derive

23 months agoCode deduplication in tool_only_multipart_suggestion
Xiretza [Mon, 22 Aug 2022 11:38:08 +0000 (13:38 +0200)]
Code deduplication in tool_only_multipart_suggestion

23 months agoFix UWP and use `AlignedReparseBuf` in `symlink_junction_inner`
Thom Chiovoloni [Tue, 30 Aug 2022 07:16:53 +0000 (00:16 -0700)]
Fix UWP and use `AlignedReparseBuf` in `symlink_junction_inner`

23 months agoTweak WellFormedLocs a bit
Michael Goulet [Tue, 30 Aug 2022 06:19:48 +0000 (06:19 +0000)]
Tweak WellFormedLocs a bit

23 months agoRollup merge of #101180 - SUPERCILEX:const-maybeuninit, r=TaKO8Ki
Dylan DPC [Tue, 30 Aug 2022 05:56:55 +0000 (11:26 +0530)]
Rollup merge of #101180 - SUPERCILEX:const-maybeuninit, r=TaKO8Ki

Add another MaybeUninit array test with const

This is another possible syntax and I just want to be absolutely sure it behaves correctly.

23 months agoRollup merge of #101176 - notriddle:notriddle/rustdoc-table-display, r=jsha
Dylan DPC [Tue, 30 Aug 2022 05:56:54 +0000 (11:26 +0530)]
Rollup merge of #101176 - notriddle:notriddle/rustdoc-table-display, r=jsha

rustdoc: remove unused CSS selectors for `.table-display`

This class was added to support the function signature [src] lockup. That lockup was changed in 34bd2b845b3acd84c5a9bddae3ff8081c19ec5e9 to use flexbox instead, leaving these selectors unused.

Continuation of #101046

23 months agoRollup merge of #101175 - tmandry:curse-push-hook, r=jyn514
Dylan DPC [Tue, 30 Aug 2022 05:56:53 +0000 (11:26 +0530)]
Rollup merge of #101175 - tmandry:curse-push-hook, r=jyn514

Don't --bless in pre-push hook

Running with --bless causes the push to succeed if there are fixable
formatting changes, but the changes don't make it into the push.

We should have the user rerun with --bless (or x.py fmt) and commit the
changes themselves (they might want to amend a particular commit, for
instance).

23 months agoRollup merge of #101123 - JohnTitor:rm-register-attr, r=TaKO8Ki
Dylan DPC [Tue, 30 Aug 2022 05:56:52 +0000 (11:26 +0530)]
Rollup merge of #101123 - JohnTitor:rm-register-attr, r=TaKO8Ki

Remove `register_attr` feature

Closes #66080

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
23 months agoRollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obk
Dylan DPC [Tue, 30 Aug 2022 05:56:51 +0000 (11:26 +0530)]
Rollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obk

interpret: make read-pointer-as-bytes a CTFE-only error with extra information

Next step in the reaction to https://github.com/rust-lang/rust/issues/99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes https://github.com/rust-lang/miri/issues/2456.

Pointer-to-int transmutation during CTFE now produces a message like this:
```
   = help: this code performed an operation that depends on the underlying bytes representing a pointer
   = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
```

r? ``@oli-obk``

23 months agoRollup merge of #101022 - compiler-errors:issue-101020, r=jackh726
Dylan DPC [Tue, 30 Aug 2022 05:56:50 +0000 (11:26 +0530)]
Rollup merge of #101022 - compiler-errors:issue-101020, r=jackh726

Erase late bound regions before comparing types in `suggest_dereferences`

Fixes #101020

23 months agoRollup merge of #101019 - compiler-errors:return-closure-suggestion, r=cjgillot
Dylan DPC [Tue, 30 Aug 2022 05:56:49 +0000 (11:26 +0530)]
Rollup merge of #101019 - compiler-errors:return-closure-suggestion, r=cjgillot

Suggest returning closure as `impl Fn`

Fixes #100936

23 months agoRollup merge of #100092 - compiler-errors:issue-100075, r=oli-obk
Dylan DPC [Tue, 30 Aug 2022 05:56:48 +0000 (11:26 +0530)]
Rollup merge of #100092 - compiler-errors:issue-100075, r=oli-obk

Fall back when relating two opaques by substs in MIR typeck

This is certainly _one_ way to fix #100075. Not really confident it's the _best_ way to do it, though.

The root cause of this issue is that during MIR type-check, we end up trying to equate an opaque against the same opaque def-id but with different substs. Because of the way that we replace RPITs during (HIR) typeck with an inference variable, we don't end up emitting a type-checking error, so the delayed MIR bug causes an ICE.

See the `src/test/ui/impl-trait/issue-100075-2.rs` test below to make that clear -- in that example, we try to equate `{impl Sized} substs=[T]` and `{impl Sized} substs=[Option<T>]`, which causes an ICE. This new logic will instead cause us to infer `{impl Sized} substs=[Option<T>]` as the hidden type for `{impl Sized} substs=[T]`, which causes a proper error to be emitted later on when we check that an opaque isn't recursive.

I'm open to closing this in favor of something else. Ideally we'd fix this in typeck, but the thing we do to ensure backwards compatibility with weird RPIT cases makes that difficult. Also open to discussing this further.

23 months agoRollup merge of #95376 - WaffleLapkin:drain_keep_rest, r=dtolnay
Dylan DPC [Tue, 30 Aug 2022 05:56:47 +0000 (11:26 +0530)]
Rollup merge of #95376 - WaffleLapkin:drain_keep_rest, r=dtolnay

Add `vec::Drain{,Filter}::keep_rest`

This PR adds `keep_rest` methods to `vec::Drain` and `vec::DrainFilter` under `drain_keep_rest` feature gate:
```rust
// mod alloc::vec

impl<T, A: Allocator> Drain<'_, T, A> {
    pub fn keep_rest(self);
}

impl<T, F, A: Allocator> DrainFilter<'_, T, F, A>
where
    F: FnMut(&mut T) -> bool,
{
    pub fn keep_rest(self);
}
```

Both these methods cancel draining of elements that were not yet yielded from the iterators. While this needs more testing & documentation, I want at least start the discussion. This may be a potential way out of the "should `DrainFilter` exhaust itself on drop?" argument.

23 months agoAuto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum
bors [Tue, 30 Aug 2022 05:48:22 +0000 (05:48 +0000)]
Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum

Revert let_chains stabilization

This is the revert against master, the beta revert was already done in #100538.

Bumps the stage0 compiler which already has it reverted.

23 months agoFix the order of `trait_duplication_in_bounds`
Jason Newcomb [Tue, 30 Aug 2022 04:33:56 +0000 (00:33 -0400)]
Fix the order of `trait_duplication_in_bounds`
* Emit the lint in source order
* Make suggestions with multiple traits be in source order rather than alphabetical

23 months agoUse more `into_iter` rather than `drain(..)`
Donough Liu [Mon, 29 Aug 2022 18:06:36 +0000 (19:06 +0100)]
Use more `into_iter` rather than `drain(..)`

23 months agoAdd another MaybeUninit array test with const
Alex Saveau [Tue, 30 Aug 2022 03:09:25 +0000 (23:09 -0400)]
Add another MaybeUninit array test with const

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
23 months agoadd UI test for unpretty
yukang [Tue, 30 Aug 2022 01:31:52 +0000 (09:31 +0800)]
add UI test for unpretty

23 months agoAuto merge of #9394 - lukaslueg:issue9391, r=Jarcho
bors [Tue, 30 Aug 2022 00:37:45 +0000 (00:37 +0000)]
Auto merge of #9394 - lukaslueg:issue9391, r=Jarcho

Fix missing parens in `suboptimal_flops` suggestion

Fixes #9391. The problem is simple enough, I didn't check if the same problem occurs elsewhere, though.

changelog: fix missing parenthesis in `suboptimal_flops` suggestion

23 months agorustdoc: remove unused CSS selectors for `.table-display`
Michael Howell [Tue, 30 Aug 2022 00:25:43 +0000 (17:25 -0700)]
rustdoc: remove unused CSS selectors for `.table-display`

This class was added to support the function signature [src] lockup. That
lockup was changed in 34bd2b845b3acd84c5a9bddae3ff8081c19ec5e9 to use flexbox
instead, leaving these selectors unused.

23 months agoDon't --bless in pre-push hook
Tyler Mandry [Mon, 29 Aug 2022 23:43:47 +0000 (16:43 -0700)]
Don't --bless in pre-push hook

Running with --bless causes the push to succeed if there are fixable
formatting changes, but the changes don't make it into the push.

We should have the user rerun with --bless (or x.py fmt) and commit the
changes themselves (they might want to amend a particular commit, for
instance).

23 months agoIgnore cargo target folder in src/bootstrap
Tyler Mandry [Sat, 27 Aug 2022 02:29:39 +0000 (19:29 -0700)]
Ignore cargo target folder in src/bootstrap

Needed after changes in #97513.

23 months agobootstrap: Add llvm-has-rust-patches target option
Tyler Mandry [Sat, 27 Aug 2022 02:24:41 +0000 (19:24 -0700)]
bootstrap: Add llvm-has-rust-patches target option

This is so you can check out an upstream commit in src/llvm-project and
have everything just work.

23 months agoFix some possible UB in std::sys::windows
Thom Chiovoloni [Mon, 29 Aug 2022 22:36:01 +0000 (15:36 -0700)]
Fix some possible UB in std::sys::windows

23 months agoAuto merge of #101167 - matthiaskrgr:rollup-yt3jdmp, r=matthiaskrgr
bors [Mon, 29 Aug 2022 22:49:04 +0000 (22:49 +0000)]
Auto merge of #101167 - matthiaskrgr:rollup-yt3jdmp, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #100898 (Do not report too many expr field candidates)
 - #101056 (Add the syntax of references to their documentation summary.)
 - #101106 (Rustdoc-Json: Retain Stripped Modules when they are imported, not when they have items)
 - #101131 (CTFE: exposing pointers and calling extern fn is just impossible)
 - #101141 (Simplify `get_trait_ref` fn used for `virtual_function_elimination`)
 - #101146 (Various changes to logging of borrowck-related code)
 - #101156 (Remove `Sync` requirement from lint pass objects)

Failed merges:

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

23 months agoFix more parens for `suboptimal_flops` suggs
Lukas Lueg [Mon, 29 Aug 2022 20:36:11 +0000 (22:36 +0200)]
Fix more parens for `suboptimal_flops` suggs

23 months agoFix tests due to stricter invalid_value
5225225 [Mon, 29 Aug 2022 20:28:35 +0000 (21:28 +0100)]
Fix tests due to stricter invalid_value

23 months agoAuto merge of #9395 - Alexendoo:suspicious-to-owned-test, r=Manishearth
bors [Mon, 29 Aug 2022 19:26:22 +0000 (19:26 +0000)]
Auto merge of #9395 - Alexendoo:suspicious-to-owned-test, r=Manishearth

Fix `suspicious_to_owned` test when `c_char` is `u8`

e.g. on aarch64 linux

changelog: none

23 months agoRollup merge of #101156 - Jarcho:remove_sync_lint_pass, r=compiler-errors
Matthias Krüger [Mon, 29 Aug 2022 19:13:00 +0000 (21:13 +0200)]
Rollup merge of #101156 - Jarcho:remove_sync_lint_pass, r=compiler-errors

Remove `Sync` requirement from lint pass objects

This is blocking the clippy sync (#101140). One of the lint passes contains a `Cell` in order to make lifetimes work. It could be worked around, but this is the easier change to make if there are no objections.

Rational for removing the requirement
* All lint pass methods take `&mut self` arguments.
* Many passes depend on running is visitor order.
* Lint passes are created on demand so they're only ever stored in a local.
* `Send` is enough to lint different passes in parallel.

`LintStore` remains `Sync` with this. The constructor functions it contains still maintain their `Sync` requirement.

r? rust-lang/compiler

23 months agoRollup merge of #101146 - jackh726:borrowck-logging, r=compiler-errors
Matthias Krüger [Mon, 29 Aug 2022 19:12:59 +0000 (21:12 +0200)]
Rollup merge of #101146 - jackh726:borrowck-logging, r=compiler-errors

Various changes to logging of borrowck-related code

Cleanups found when doing other changes

r? `@compiler-errors`

23 months agoRollup merge of #101141 - compiler-errors:get-trait-ref-is-a-misleading-name, r=oli-obk
Matthias Krüger [Mon, 29 Aug 2022 19:12:58 +0000 (21:12 +0200)]
Rollup merge of #101141 - compiler-errors:get-trait-ref-is-a-misleading-name, r=oli-obk

Simplify `get_trait_ref` fn used for `virtual_function_elimination`

1. The name `get_trait_ref` is misleading, so I renamed it to something more like `expect_...` because it ICEs if used incorrectly.
2. No need to manually go through the existential trait refs, we already have `.principal()` for that.

23 months agoRollup merge of #101131 - RalfJung:ctfe-no-needs-rfc, r=oli-obk
Matthias Krüger [Mon, 29 Aug 2022 19:12:57 +0000 (21:12 +0200)]
Rollup merge of #101131 - RalfJung:ctfe-no-needs-rfc, r=oli-obk

CTFE: exposing pointers and calling extern fn is just impossible

The remaining "needs RFC" errors are just needlessly confusing, I think -- time to get rid of that error variant. They are anyway only reachable with miri-unleashed (if at all).

r? `@oli-obk`

23 months agoRollup merge of #101106 - aDotInTheVoid:rdj-stripped-mod, r=GuillaumeGomez
Matthias Krüger [Mon, 29 Aug 2022 19:12:56 +0000 (21:12 +0200)]
Rollup merge of #101106 - aDotInTheVoid:rdj-stripped-mod, r=GuillaumeGomez

Rustdoc-Json: Retain Stripped Modules when they are imported, not when they have items

Fixes #101103
Fixes #100973

r? `@GuillaumeGomez`