]> git.lizzy.rs Git - rust.git/log
rust.git
17 months agoRollup merge of #106564 - Folyd:feat-repeatn, r=scottmcm
Matthias Krüger [Sat, 7 Jan 2023 19:43:23 +0000 (20:43 +0100)]
Rollup merge of #106564 - Folyd:feat-repeatn, r=scottmcm

Change to immutable borrow when cloning element of RepeatN

17 months agoRollup merge of #106556 - notriddle:notriddle/margin-left-content-mobile, r=Guillaume...
Matthias Krüger [Sat, 7 Jan 2023 19:43:23 +0000 (20:43 +0100)]
Rollup merge of #106556 - notriddle:notriddle/margin-left-content-mobile, r=GuillaumeGomez

rustdoc: remove no-op mobile CSS `.content { margin-left: 0 }`

This rule was added to override non-zero left margin on `.content`, which was removed in 135281ed1525db15edd8ebd092aa10aa40df2386 and the margin-left was put on the docblock.

17 months agoRollup merge of #106553 - Ezrashaw:fix-hashset-doctest, r=JohnTitor
Matthias Krüger [Sat, 7 Jan 2023 19:43:22 +0000 (20:43 +0100)]
Rollup merge of #106553 - Ezrashaw:fix-hashset-doctest, r=JohnTitor

docs: make `HashSet::retain` doctest more clear

Fixes #106535

Extremely simple fix suggested by ``@compiler-errors`` in the linked issue.

17 months agoRollup merge of #106509 - estebank:closure-in-block, r=davidtwco
Matthias Krüger [Sat, 7 Jan 2023 19:43:22 +0000 (20:43 +0100)]
Rollup merge of #106509 - estebank:closure-in-block, r=davidtwco

Detect closures assigned to binding in block

Fix #58497.

17 months agoRollup merge of #105859 - compiler-errors:hr-lifetime-add, r=davidtwco
Matthias Krüger [Sat, 7 Jan 2023 19:43:21 +0000 (20:43 +0100)]
Rollup merge of #105859 - compiler-errors:hr-lifetime-add, r=davidtwco

Point out span where we could introduce higher-ranked lifetime

Somewhat addresses #105422, but not really. We don't have that much useful information here since we're still in resolution :^(

Maybe this suggestion isn't worth it. If the reviewer has an idea how we can get a more succinct binder information for a structured suggestion, it would be appreciated.

17 months agoRollup merge of #105517 - pcc:process-panic-after-fork, r=davidtwco
Matthias Krüger [Sat, 7 Jan 2023 19:43:20 +0000 (20:43 +0100)]
Rollup merge of #105517 - pcc:process-panic-after-fork, r=davidtwco

Fix process-panic-after-fork.rs to pass on newer versions of Android.

The test process-panic-after-fork.rs was checking that abort() resulted in SIGSEGV on Android. This non-standard behavior was fixed back in 2013, so let's fix the test to also accept the standard behavior on Android.

17 months agoRollup merge of #105128 - Sp00ph:vec_vec_deque_conversion, r=dtolnay
Matthias Krüger [Sat, 7 Jan 2023 19:43:20 +0000 (20:43 +0100)]
Rollup merge of #105128 - Sp00ph:vec_vec_deque_conversion, r=dtolnay

Add O(1) `Vec -> VecDeque` conversion guarantee

(See #105072)

17 months agoRollup merge of #104543 - JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs...
Matthias Krüger [Sat, 7 Jan 2023 19:43:19 +0000 (20:43 +0100)]
Rollup merge of #104543 - JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs-pt3, r=davidtwco

Migrate `codegen_ssa` to diagnostics structs - [Part 3]

Completes migrating `codegen_ssa` module except 2 outstanding errors that depend on other crates:
1. [`rustc_middle::mir::interpret::InterpError`](https://github.com/rust-lang/rust/blob/b6097f2e1b2ca62e188ba53cf43bd66b06b36915/compiler/rustc_middle/src/mir/interpret/error.rs#L475): I saw `rustc_middle` is unassigned, I am open to take this work.

2.  `codegen_llvm`'s use of `fn span_invalid_monomorphization_error`, which I started to replace in the [last commit](https://github.com/rust-lang/rust/commit/9a31b3cdda78a2c0891828254fe9886e0a1cfd16) of this PR, but would like to know the team's preference on how we should keep replacing the other macros:
2.1. Update macros to expect a `Diagnostic`
2.2. Remove macros and expand the code on each use.
See [some examples of the different options in this experimental commit](https://github.com/JhonnyBillM/rust/commit/64aee83e80857dcfa450f0c6e31d5f29c6d577e6)

_Part 2 - https://github.com/rust-lang/rust/pull/103792_

r? ``@davidtwco``
Cc ``@compiler-errors``

17 months agoRollup merge of #104081 - joshlf:patch-6, r=dtolnay
Matthias Krüger [Sat, 7 Jan 2023 19:43:19 +0000 (20:43 +0100)]
Rollup merge of #104081 - joshlf:patch-6, r=dtolnay

PhantomData layout guarantees

17 months agoRollup merge of #101936 - IntQuant:issue-100717-infer-4, r=compiler-errors
Matthias Krüger [Sat, 7 Jan 2023 19:43:18 +0000 (20:43 +0100)]
Rollup merge of #101936 - IntQuant:issue-100717-infer-4, r=compiler-errors

Migrating rustc_infer to session diagnostics (part 3)

``@rustbot`` label +A-translation
r? rust-lang/diagnostics
cc https://github.com/rust-lang/rust/issues/100717

Seems like a part of static_impl_trait.rs emits suggestions in a loop, and note.rs needs to have two instances of the same subdiagnostic, so these will need to wait until we have eager translation/list support.
Other than that, there is only error_reporting/mod.rs left to migrate.

17 months agoAuto merge of #105323 - cjgillot:simplify-const-prop, r=davidtwco
bors [Sat, 7 Jan 2023 16:13:18 +0000 (16:13 +0000)]
Auto merge of #105323 - cjgillot:simplify-const-prop, r=davidtwco

Perform SimplifyLocals before ConstProp.

MIR before `ConstProp` may have a lot of dead writes, this makes `ConstProp` do unnecessary work.

r? `@ghost`

17 months agoChange to immutable borrow when cloning element of RepeatN
Folyd [Sat, 7 Jan 2023 15:50:07 +0000 (23:50 +0800)]
Change to immutable borrow when cloning element of RepeatN

17 months agoAuto merge of #106519 - estebank:tail-unit, r=cjgillot
bors [Sat, 7 Jan 2023 13:24:12 +0000 (13:24 +0000)]
Auto merge of #106519 - estebank:tail-unit, r=cjgillot

Detect bindings assigned blocks without tail expressions

Fix #44173.

17 months agoAuto merge of #106283 - JulianKnodt:enum_err, r=cjgillot
bors [Sat, 7 Jan 2023 10:04:39 +0000 (10:04 +0000)]
Auto merge of #106283 - JulianKnodt:enum_err, r=cjgillot

Add help diag. for `const = Enum` missing braces around `Enum`

Previously it was not clear why this errored or if it was even supported, as there was no diagnostic that suggested wrapping it in braces.

Thus, add a simple diagnostic that suggests wrapping enum variants in braces.

Fixes #105927

17 months agoAuto merge of #106558 - compiler-errors:rollup-lkii3j3, r=compiler-errors
bors [Sat, 7 Jan 2023 06:54:47 +0000 (06:54 +0000)]
Auto merge of #106558 - compiler-errors:rollup-lkii3j3, r=compiler-errors

Rollup of 4 pull requests

Successful merges:

 - #106525 (Report WF error for chalk *and* new solver)
 - #106533 (Use smaller spans for missing lifetime/generic args)
 - #106543 (rustdoc: remove no-op CSS `.rustdoc.source .sidebar { width: 0 }`)
 - #106554 (Fix a typo in the explanation of E0588)

Failed merges:

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

17 months agoRollup merge of #106554 - LingMan:explanation_typo, r=compiler-errors
Michael Goulet [Sat, 7 Jan 2023 05:54:01 +0000 (21:54 -0800)]
Rollup merge of #106554 - LingMan:explanation_typo, r=compiler-errors

Fix a typo in the explanation of E0588

17 months agoRollup merge of #106543 - notriddle:notriddle/source-sidebar-width-zero, r=GuillaumeGomez
Michael Goulet [Sat, 7 Jan 2023 05:54:00 +0000 (21:54 -0800)]
Rollup merge of #106543 - notriddle:notriddle/source-sidebar-width-zero, r=GuillaumeGomez

rustdoc: remove no-op CSS `.rustdoc.source .sidebar { width: 0 }`

This CSS was added in dc2c9723343c985740be09919236a6e96c4e4433, before 6a5f8b1aef1417d7dc85b5d0a229d2db1930eb7c when the sidebars were merged.

Now that they are merged, the source sidebar is being pushed off-screen anyway, so giving it zero width doesn't do much.

17 months agoRollup merge of #106533 - TaKO8Ki:use-smaller-span-for-missing-lifetime/generic-args...
Michael Goulet [Sat, 7 Jan 2023 05:54:00 +0000 (21:54 -0800)]
Rollup merge of #106533 - TaKO8Ki:use-smaller-span-for-missing-lifetime/generic-args, r=compiler-errors

Use smaller spans for missing lifetime/generic args

We can remove ident from suggestions.

17 months agoRollup merge of #106525 - compiler-errors:new-solver-wf, r=jackh726
Michael Goulet [Sat, 7 Jan 2023 05:53:59 +0000 (21:53 -0800)]
Rollup merge of #106525 - compiler-errors:new-solver-wf, r=jackh726

Report WF error for chalk *and* new solver

addressing this nit https://github.com/rust-lang/rust/pull/106385#discussion_r1062571070

No test yet because new solver is currently unusable, lol

r? `@lcnr`

17 months agorustdoc: remove no-op mobile CSS `.content { margin-left: 0 }`
Michael Howell [Sat, 7 Jan 2023 05:21:54 +0000 (22:21 -0700)]
rustdoc: remove no-op mobile CSS `.content { margin-left: 0 }`

This rule was added to override non-zero left margin on `.content`,
which was removed in 135281ed1525db15edd8ebd092aa10aa40df2386 and
the margin-left was put on the docblock.

17 months agoFix a typo in the explanation of E0588
LingMan [Sat, 7 Jan 2023 04:10:53 +0000 (05:10 +0100)]
Fix a typo in the explanation of E0588

17 months agodocs: make `HashSet::retain` doctest more clear
Ezra Shaw [Sat, 7 Jan 2023 04:08:04 +0000 (17:08 +1300)]
docs: make `HashSet::retain` doctest more clear

17 months agoAuto merge of #106538 - aDotInTheVoid:strip-use-doc-hidden, r=notriddle
bors [Sat, 7 Jan 2023 04:00:24 +0000 (04:00 +0000)]
Auto merge of #106538 - aDotInTheVoid:strip-use-doc-hidden, r=notriddle

rustdoc: Strip imports of items which are `#[doc(hidden)]`

Closes #106379

17 months agoAuto merge of #106544 - matthiaskrgr:rollup-e9prjed, r=matthiaskrgr
bors [Sat, 7 Jan 2023 00:53:19 +0000 (00:53 +0000)]
Auto merge of #106544 - matthiaskrgr:rollup-e9prjed, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #106287 (Add some docs to `bug`, `span_bug` and `delay_span_bug`)
 - #106341 (refactor: clean up `errors.rs` and `error_codes_check.rs`)
 - #106453 (Improve include macro documentation)
 - #106466 (Fix rustdoc source code rendering for `#[path = "../path/to/mod.rs"]` links)
 - #106528 (Tiny formatting fix)
 - #106534 (rustdoc-gui: Use new block syntax for define-function in goml scripts)
 - #106542 (Add default and latest stable edition to --edition in rustc (attempt 2))

Failed merges:

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

17 months agoAuto merge of #106415 - Nilstrieb:where-is-my-master-branch, r=jyn514
bors [Fri, 6 Jan 2023 21:51:44 +0000 (21:51 +0000)]
Auto merge of #106415 - Nilstrieb:where-is-my-master-branch, r=jyn514

Handle non-existent upstream master branches in `x fmt`

People who do have a remote for `rust-lang/rust` but don't have the master branch checked out there used to get this error when running `x fmt`:
> fatal: ambiguous argument 'rust/master': unknown revision or path not in the working tree.
> Use '--' to separate paths from revisions, like this:
> 'git <command> [<revision>...] -- [<file>...]'
> rust/master

Which is not exactly helpful.

Now, we fall back to `origin/master` (hoping that at least that remote exists) for that case. If there is still some error, we just fall back to `x fmt .` and print a warning.

r? `@jyn514`

17 months agoRollup merge of #106542 - sigaloid:master, r=bjorn3
Matthias Krüger [Fri, 6 Jan 2023 20:26:12 +0000 (21:26 +0100)]
Rollup merge of #106542 - sigaloid:master, r=bjorn3

Add default and latest stable edition to --edition in rustc (attempt 2)

Fixes #106041

No longer leaks string like my first attempt PR, #106094 - uses LazyLock to construct a `&'static str`

It will now output the default edition and latest stable edition in the help message for the `--edition` flag.

Going to request the same reviewer as the first attempt for continuity - r? `@Nilstrieb`

17 months agoRollup merge of #106534 - GuillaumeGomez:block-syntax, r=notriddle
Matthias Krüger [Fri, 6 Jan 2023 20:26:12 +0000 (21:26 +0100)]
Rollup merge of #106534 - GuillaumeGomez:block-syntax, r=notriddle

rustdoc-gui: Use new block syntax for define-function in goml scripts

r? `@notriddle`

17 months agoRollup merge of #106528 - estebank:quick-fix, r=TaKO8Ki
Matthias Krüger [Fri, 6 Jan 2023 20:26:11 +0000 (21:26 +0100)]
Rollup merge of #106528 - estebank:quick-fix, r=TaKO8Ki

Tiny formatting fix

17 months agoRollup merge of #106466 - clubby789:relative-module-fix, r=notriddle
Matthias Krüger [Fri, 6 Jan 2023 20:26:11 +0000 (21:26 +0100)]
Rollup merge of #106466 - clubby789:relative-module-fix, r=notriddle

Fix rustdoc source code rendering for `#[path = "../path/to/mod.rs"]` links

Fixes #103517

While generating the location for modules source HTML to be saved at, a `..` path component appeared to be translated to `/up/`.
Additionally, while generating the navigation sidebar, `..` path components were ignored. This means that (as in the issue above), a *real* directory structure of:
```
sys/
  unix/
    mod.rs  <-- contains #![path = "../unix/mod.rs]
    cmath.rs
```
was rendered as:
```
sys/
  unix/
    mod.rs
    unix/
      cmath.rs  <-- links to sys/unix/unix/cmath.rs.html, 404
```
While the *files* were stored as
```
sys/
  unix/
    mod.rs.html
    up/
      unix/
        cmath.rs.html
```

17 months agoRollup merge of #106453 - coastalwhite:master, r=GuillaumeGomez
Matthias Krüger [Fri, 6 Jan 2023 20:26:10 +0000 (21:26 +0100)]
Rollup merge of #106453 - coastalwhite:master, r=GuillaumeGomez

Improve include macro documentation

As outlined in #106118, the `include!` macro is a SEO problem when it comes to the Rust documentation. Beginners may see it as a replacement to `include` syntax in other languages. I feel like this documentation should quite explicitly link to the modules' documentation.

The primary goal of this PR is to address that issue by adding a warning to the documentation. While I was here, I also added some other parts. This included a `Uses` section and some (intra doc) links to other relevant topics.

I hope this can help beginners to Rust more quickly understand some multi-file project intricacies.

# References
- Syntax for the warning: https://github.com/tokio-rs/tracing/blob/58accc6da3f04af3f6144fbe6d68af7225c70c02/tracing/src/lib.rs#L55

17 months agoRollup merge of #106341 - Ezrashaw:refactor-error-code-tidy-check, r=mejrs,klensy...
Matthias Krüger [Fri, 6 Jan 2023 20:26:10 +0000 (21:26 +0100)]
Rollup merge of #106341 - Ezrashaw:refactor-error-code-tidy-check, r=mejrs,klensy,GuillaumeGomez

refactor: clean up `errors.rs` and `error_codes_check.rs`

`errors.rs` is basically unused now, `error_codes_check.rs` is useful but not well commented, etc. It also doesn't check certain things which are certainly not correct. For example, `E0505` has a UI test in `src/test/ui/error-codes/` but that test actually outputs `E0504`?! Other issues like these exist. I've implemented these with "warnings" which are a bit rough around the edges but should be removed eventually.

r? `@GuillaumeGomez` (again not sure if you want to review but its relevant to you)

17 months agoRollup merge of #106287 - Nilstrieb:its-bugging-me-how-we-dont-have-docs, r=jyn514
Matthias Krüger [Fri, 6 Jan 2023 20:26:09 +0000 (21:26 +0100)]
Rollup merge of #106287 - Nilstrieb:its-bugging-me-how-we-dont-have-docs, r=jyn514

Add some docs to `bug`, `span_bug` and `delay_span_bug`

cc `@mejrs` as you wanted me to do this, does this look good and understandable?

17 months agorustdoc: remove no-op CSS `.rustdoc.source .sidebar { width: 0 }`
Michael Howell [Fri, 6 Jan 2023 19:20:03 +0000 (12:20 -0700)]
rustdoc: remove no-op CSS `.rustdoc.source .sidebar { width: 0 }`

This CSS was added in dc2c9723343c985740be09919236a6e96c4e4433,
before 6a5f8b1aef1417d7dc85b5d0a229d2db1930eb7c when the sidebars
were merged.

Now that they are merged, the source sidebar is being pushed
off-screen anyway, so giving it zero width doesn't do much.

17 months agoUpdate compiler/rustc_session/src/config.rs
Matthew E [Fri, 6 Jan 2023 19:36:52 +0000 (14:36 -0500)]
Update compiler/rustc_session/src/config.rs

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
17 months agoHandle non-existant upstream master branches in `x fmt`
Nilstrieb [Tue, 3 Jan 2023 17:18:06 +0000 (18:18 +0100)]
Handle non-existant upstream master branches in `x fmt`

17 months agoAdd default and latest stable edition to --edition in rustc
Matthew Esposito [Fri, 6 Jan 2023 19:07:12 +0000 (14:07 -0500)]
Add default and latest stable edition to --edition in rustc

17 months agorustdoc: Strip imports of items which are `#[doc(hidden)]`
Nixon Enraght-Moony [Fri, 6 Jan 2023 17:57:03 +0000 (17:57 +0000)]
rustdoc: Strip imports of items which are `#[doc(hidden)]`

Closes #106379

17 months agoAuto merge of #106501 - cjgillot:resolved-elided-apit, r=compiler-errors
bors [Fri, 6 Jan 2023 18:15:56 +0000 (18:15 +0000)]
Auto merge of #106501 - cjgillot:resolved-elided-apit, r=compiler-errors

Correct detection of elided lifetimes in impl-trait.

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

r? `@compiler-errors`
cc `@pnkfelix`

17 months agoUse new block syntax for define-function in goml scripts
Guillaume Gomez [Fri, 6 Jan 2023 14:18:51 +0000 (15:18 +0100)]
Use new block syntax for define-function in goml scripts

17 months agoUpdate tests
clubby789 [Thu, 5 Jan 2023 04:17:57 +0000 (04:17 +0000)]
Update tests

17 months agoCorrectly render sidebar for relative module paths
clubby789 [Wed, 4 Jan 2023 20:56:46 +0000 (20:56 +0000)]
Correctly render sidebar for relative module paths

17 months agoAuto merge of #106474 - erikdesjardins:noalias, r=bjorn3
bors [Fri, 6 Jan 2023 15:20:58 +0000 (15:20 +0000)]
Auto merge of #106474 - erikdesjardins:noalias, r=bjorn3

cleanup: handle -Zmutable-noalias like -Zbox-noalias

r? `@bjorn3`

cc `@RalfJung` this will conflict with #106180

17 months agoUpdate browser-ui-test version
Guillaume Gomez [Fri, 6 Jan 2023 14:18:36 +0000 (15:18 +0100)]
Update browser-ui-test version

17 months agouse smaller spans for missing lifetime/generic args
Takayuki Maeda [Fri, 6 Jan 2023 11:55:10 +0000 (20:55 +0900)]
use smaller spans for missing lifetime/generic args

fix rustdoc ui test

17 months agoRemove HTML tags around warning
Gijs Burghoorn [Fri, 6 Jan 2023 12:20:58 +0000 (13:20 +0100)]
Remove HTML tags around warning

17 months agoAuto merge of #105805 - yanchen4791:issue-105227-fix, r=estebank
bors [Fri, 6 Jan 2023 12:08:49 +0000 (12:08 +0000)]
Auto merge of #105805 - yanchen4791:issue-105227-fix, r=estebank

Suggest adding named lifetime when the return contains value borrowed from more than one lifetimes of function inputs

fix for #105227.

The problem: The suggestion of adding an explicit `'_` lifetime bound is **incorrect** when the function's return type contains a value which could be borrowed from more than one lifetimes of the function's inputs. Instead, a named lifetime parameter can be introduced in such a case.

The solution: Checking the number of elided lifetimes in the function signature. If more than one lifetimes found in the function inputs when the suggestion of adding explicit `'_` lifetime, change it to using named lifetime parameter `'a` instead.

17 months agoAuto merge of #106529 - Dylan-DPC:rollup-mvncmrk, r=Dylan-DPC
bors [Fri, 6 Jan 2023 09:17:14 +0000 (09:17 +0000)]
Auto merge of #106529 - Dylan-DPC:rollup-mvncmrk, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #106400 (Point at expressions where inference refines an unexpected type)
 - #106491 (Fix error-index redirect to work with the back button.)
 - #106494 (Add regression test for #58355)
 - #106499 (fix [type error] for error E0029 and E0277)
 - #106502 (rustdoc: remove legacy user-select CSS)

Failed merges:

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

17 months agoRollup merge of #106502 - notriddle:notriddle/user-select, r=GuillaumeGomez
Dylan DPC [Fri, 6 Jan 2023 06:08:58 +0000 (11:38 +0530)]
Rollup merge of #106502 - notriddle:notriddle/user-select, r=GuillaumeGomez

rustdoc: remove legacy user-select CSS

According to [caniuse], the only supported browser that requires the vendor prefix, as defined in [RFC 1985], is Safari.

* The last version of Chrome that required a vendor prefix was version 53. The current version is 108.
* Firefox 68 is the last version that required a vendor prefix. The [current Firefox ESR] is version 102.
* The current version of Safari for Mac and iOS still requires a prefix.
* The last version of Edge that required a vendor frefix was 18. The current version of Edge is 108.
* UCAndroid support is unknown, but if it still requires a vendor prefix, it's more likely to be `-webkit-` than `-moz-` or `-ms-`, since they would want to emulate iOS for compatibility.

[caniuse]: https://caniuse.com/?search=user-select
[RFC 1985]: https://rust-lang.github.io/rfcs/1985-tiered-browser-support.html
[current Firefox ESR]: https://wiki.mozilla.org/Releases

17 months agoRollup merge of #106499 - lyming2007:issue-105946-fix, r=estebank
Dylan DPC [Fri, 6 Jan 2023 06:08:57 +0000 (11:38 +0530)]
Rollup merge of #106499 - lyming2007:issue-105946-fix, r=estebank

fix [type error] for error E0029 and E0277

check explicitly for the type references error
if ty.references_error() is true change the error to be err.delay_as_bug() and prevent the error E0029 and E0277 from emitting out this fix #105946

17 months agoRollup merge of #106494 - JohnTitor:issue-58355, r=compiler-errors
Dylan DPC [Fri, 6 Jan 2023 06:08:57 +0000 (11:38 +0530)]
Rollup merge of #106494 - JohnTitor:issue-58355, r=compiler-errors

Add regression test for #58355

Closes #58355
r? `@compiler-errors`
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
17 months agoRollup merge of #106491 - ehuss:error-index-redirect, r=GuillaumeGomez,notriddle
Dylan DPC [Fri, 6 Jan 2023 06:08:56 +0000 (11:38 +0530)]
Rollup merge of #106491 - ehuss:error-index-redirect, r=GuillaumeGomez,notriddle

Fix error-index redirect to work with the back button.

This fixes the redirect page at https://doc.rust-lang.org/error-index.html so that it works with the browser's back-button. The solution is to use `window.location.replace()`, which avoids adding the page to the browser history stack.

This also cleans up the code a little bit, since it looks like it was written with different assumptions (maybe before f5857d5c5e1d2fde302f330d11c5cdea8005eb2a).  I don't think there is a need to have a redirect at https://doc.rust-lang.org/error_codes/error-index.html since I don't think fragment-based links were ever used there.

I have tested with Firefox, Chrome, and Safari. Going to `/error-index.html` redirects without adding to the stack, and can use the back button. Additionally, `/error-index.html#E0005` redirects correctly to the error page.

Finally, there is an unrelated commit to remove the 404 hack. There is an official way of avoiding the generation of the 404 page with setting input-404 to an empty value.

Fixes #106485

17 months agoRollup merge of #106400 - estebank:type-errs, r=compiler-errors
Dylan DPC [Fri, 6 Jan 2023 06:08:56 +0000 (11:38 +0530)]
Rollup merge of #106400 - estebank:type-errs, r=compiler-errors

Point at expressions where inference refines an unexpected type

Fix #106355. Fix #14007. (!)

```
error[E0308]: mismatched types
  --> src/test/ui/type/type-check/point-at-inference.rs:12:9
   |
9  |         foo.push(i);
   |                  - this is of type `&{integer}`, which makes `foo` to be inferred as `Vec<&{integer}>`
...
12 |     bar(foo);
   |     --- ^^^ expected `i32`, found `&{integer}`
   |     |
   |     arguments to this function are incorrect
   |
   = note: expected struct `Vec<i32>`
              found struct `Vec<&{integer}>`
note: function defined here
  --> src/test/ui/type/type-check/point-at-inference.rs:2:4
   |
2  | fn bar(_: Vec<i32>) {}
   |    ^^^ -----------
help: consider dereferencing the borrow
   |
9  |         foo.push(*i);
   |                  +
```

17 months agoAuto merge of #106429 - djkoloski:add_vendor_to_fuchsia_target_triple, r=nagisa
bors [Fri, 6 Jan 2023 06:05:40 +0000 (06:05 +0000)]
Auto merge of #106429 - djkoloski:add_vendor_to_fuchsia_target_triple, r=nagisa

Add vendor to Fuchsia's target triple

Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia and aarch64-fuchsia. However, they should technically contain vendor information. This CL changes Fuchsia's target triples to include the "unknown" vendor since Clang now does normalization and handles all triple spellings.

This was previously attempted in #90510, which was closed due to inactivity.

17 months agoTiny formatting fix
Esteban Küber [Fri, 6 Jan 2023 05:34:56 +0000 (05:34 +0000)]
Tiny formatting fix

17 months agofix [type error] for error E0029 and E0277
Yiming Lei [Thu, 5 Jan 2023 17:12:37 +0000 (09:12 -0800)]
fix [type error] for error E0029 and E0277
check explicitly for the type references error
if ty.references_error() is true change the error to be err.delay_as_bug()
and prevent the error E0029 and E0277 from emitting out
this fix #105946

17 months agoSuggests adding named lifetime when the return contains value borrowed from more...
yanchen4791 [Fri, 16 Dec 2022 22:47:24 +0000 (14:47 -0800)]
Suggests adding named lifetime when the return contains value borrowed from more than one lifetimes of the function's inputs

17 months agoTweak output
Esteban Küber [Fri, 6 Jan 2023 02:49:15 +0000 (02:49 +0000)]
Tweak output

17 months agoReport WF error for new solver too
Michael Goulet [Fri, 6 Jan 2023 00:28:39 +0000 (00:28 +0000)]
Report WF error for new solver too

17 months agoAuto merge of #105890 - Nilstrieb:inline-fmt-part-1, r=jackh726
bors [Fri, 6 Jan 2023 02:58:40 +0000 (02:58 +0000)]
Auto merge of #105890 - Nilstrieb:inline-fmt-part-1, r=jackh726

Fix `uninlined_format_args` in compiler crates with the diagnostic migration completed

Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).

Some of them have been reviewed by myself and they were all correct (though I still recommend going over all of them again for review).

17 months agoDetect bindings assigned blocks without tail expressions in trait errors
Esteban Küber [Fri, 6 Jan 2023 02:43:16 +0000 (02:43 +0000)]
Detect bindings assigned blocks without tail expressions in trait errors

Address  #44173 for trait errors.

17 months agoDetect bindings assigned blocks without tail expressions
Esteban Küber [Fri, 6 Jan 2023 00:45:10 +0000 (00:45 +0000)]
Detect bindings assigned blocks without tail expressions

Address  #44173 for type check errors.

17 months agoAuto merge of #106416 - Nilstrieb:better-failure, r=compiler-errors
bors [Thu, 5 Jan 2023 23:27:51 +0000 (23:27 +0000)]
Auto merge of #106416 - Nilstrieb:better-failure, r=compiler-errors

Shrink `ParseResult` in the hot path.

#105570 increased the size, which caused regressions. This uses the existing generic infrastructure to differentiate between the hot path and the diagnostics path.

17 months agoDetect closures assigned to binding in block
Esteban Küber [Thu, 5 Jan 2023 21:29:36 +0000 (21:29 +0000)]
Detect closures assigned to binding in block

Fix #58497.

17 months agoShrink `ParseResult` in the hot path.
Nilstrieb [Tue, 3 Jan 2023 18:28:28 +0000 (19:28 +0100)]
Shrink `ParseResult` in the hot path.

A recent PR increased the size, which caused regressions. This uses the
existing generic infrastructure to differentiate between the hot path
and the diagnostics path.

17 months agoerror-index: Don't generate 404 instead of removing it.
Eric Huss [Thu, 5 Jan 2023 14:44:11 +0000 (06:44 -0800)]
error-index: Don't generate 404 instead of removing it.

17 months agoFix error-index redirect to work with back button.
Eric Huss [Thu, 5 Jan 2023 19:07:11 +0000 (11:07 -0800)]
Fix error-index redirect to work with back button.

17 months agorustdoc: remove legacy user-select CSS
Michael Howell [Thu, 5 Jan 2023 17:59:21 +0000 (10:59 -0700)]
rustdoc: remove legacy user-select CSS

According to [caniuse], the only supported browser that requires the vendor prefix,
as defined in [RFC 1985], is Safari.

* The last version of Chrome that required a vendor prefix was version 53.
  The current version is 108.
* Firefox 68 is the last version that required a vendor prefix. The
  [current Firefox ESR] is version 102.
* The current version of Safari for Mac and iOS still requires a prefix.
* The last version of Edge that required a vendor frefix was 18. The current
  version of Edge is 108.
* UCAndroid support is unknown, but if it still requires a vendor prefix,
  it's more likely to be `-webkit-` than `-moz-` or `-ms-`, since they
  would want to emulate iOS for compatibility.

[caniuse]: https://caniuse.com/?search=user-select
[RFC 1985]: https://rust-lang.github.io/rfcs/1985-tiered-browser-support.html
[current Firefox ESR]: https://wiki.mozilla.org/Releases

17 months agoFix `uninlined_format_args` for some compiler crates
nils [Mon, 19 Dec 2022 09:31:55 +0000 (10:31 +0100)]
Fix `uninlined_format_args` for some compiler crates

Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).

17 months agoCorrect detection of elided lifetimes in impl-trait.
Camille GILLOT [Thu, 5 Jan 2023 17:57:55 +0000 (17:57 +0000)]
Correct detection of elided lifetimes in impl-trait.

17 months agofix rebase
Esteban Küber [Thu, 5 Jan 2023 17:06:34 +0000 (17:06 +0000)]
fix rebase

17 months agoreview comments: reword
Esteban Küber [Thu, 5 Jan 2023 01:26:44 +0000 (01:26 +0000)]
review comments: reword

17 months agoreview comment: potentially produce more suggestions for arg type mismatch
Esteban Küber [Thu, 5 Jan 2023 01:00:21 +0000 (01:00 +0000)]
review comment: potentially produce more suggestions for arg type mismatch

17 months agoSuggest changing argument on type error
Esteban Küber [Thu, 5 Jan 2023 00:37:53 +0000 (00:37 +0000)]
Suggest changing argument on type error

17 months agoAccount for type error on method arg caused by earlier inference
Esteban Küber [Thu, 5 Jan 2023 00:18:57 +0000 (00:18 +0000)]
Account for type error on method arg caused by earlier inference

```rust
fn main() {
    let v = Vec::new();
    v.push(0);
    v.push(0);
    v.push("");
}
```

now produces

```
error[E0308]: mismatched types
  --> $DIR/point-at-inference-3.rs:6:12
   |
LL |     v.push(0);
   |            - this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
...
LL |     v.push("");
   |       ---- ^^ expected integer, found `&str`
   |       |
   |       arguments to this function are incorrect
   |
note: associated function defined here
  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
```

17 months agoUse `BottomUpFolder`
Esteban Küber [Wed, 4 Jan 2023 04:49:47 +0000 (20:49 -0800)]
Use `BottomUpFolder`

17 months agoFormatting
Esteban Küber [Wed, 4 Jan 2023 04:32:15 +0000 (20:32 -0800)]
Formatting

17 months agoTweak output
Esteban Küber [Wed, 4 Jan 2023 04:20:31 +0000 (20:20 -0800)]
Tweak output

- Only point at a the single expression where the found type was first
  inferred.
- Find method call argument that might have caused the found type to be
  inferred.
- Provide structured suggestion.
- Apply some review comments.
- Tweak wording.

17 months agoreview comments: do not always point at init expr
Esteban Küber [Tue, 3 Jan 2023 07:34:26 +0000 (23:34 -0800)]
review comments: do not always point at init expr

17 months agoMore eagerly resolve expr `ty`s before writing them
Esteban Küber [Tue, 3 Jan 2023 06:25:50 +0000 (22:25 -0800)]
More eagerly resolve expr `ty`s before writing them

This allows the expressions to have more accurate types
when showing inference steps.

17 months agoSkip macros to avoid talking about bindings the user can't see
Esteban Küber [Tue, 3 Jan 2023 05:56:19 +0000 (21:56 -0800)]
Skip macros to avoid talking about bindings the user can't see

17 months agoPoint at expressions where inference refines an unexpected type
Esteban Küber [Tue, 3 Jan 2023 00:23:08 +0000 (16:23 -0800)]
Point at expressions where inference refines an unexpected type

Address #106355.

17 months agoBetter phrasing for hygiene of include macro
Gijs Burghoorn [Thu, 5 Jan 2023 16:09:05 +0000 (17:09 +0100)]
Better phrasing for hygiene of include macro

17 months agoAuto merge of #106487 - GuillaumeGomez:fix-kbd-var, r=notriddle
bors [Thu, 5 Jan 2023 15:47:39 +0000 (15:47 +0000)]
Auto merge of #106487 - GuillaumeGomez:fix-kbd-var, r=notriddle

Fix --kbd-color variable name in rustdoc.css

Interestingly enough, it only impacted the dark theme.

Before:

![Screenshot from 2023-01-05 11-03-17](https://user-images.githubusercontent.com/3050060/210754145-c3bb0f50-d35f-4543-bf73-010a4524a803.png)

After:

![Screenshot from 2023-01-05 11-03-05](https://user-images.githubusercontent.com/3050060/210754190-85c2f146-a774-4463-9cd3-9495b7c91bd7.png)

r? `@notriddle`

17 months agoAdd regression test for #58355
Yuki Okushi [Thu, 5 Jan 2023 15:24:42 +0000 (00:24 +0900)]
Add regression test for #58355

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
17 months agoAdd vendor to Fuchsia's target triple
David Koloski [Tue, 3 Jan 2023 20:59:21 +0000 (15:59 -0500)]
Add vendor to Fuchsia's target triple

Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia
and aarch64-fuchsia. However, they should technically contain vendor
information. This CL changes Fuchsia's target triples to include the
"unknown" vendor since Clang now does normalization and handles all
triple spellings.

This was previously attempted in #90510, which was closed due to
inactivity.

17 months agoAuto merge of #106406 - nikic:update-llvm-11, r=cuviper
bors [Thu, 5 Jan 2023 12:45:43 +0000 (12:45 +0000)]
Auto merge of #106406 - nikic:update-llvm-11, r=cuviper

Update LLVM submodule

Fixes #104099.

17 months agoUpdate kbd GUI test
Guillaume Gomez [Thu, 5 Jan 2023 10:03:45 +0000 (11:03 +0100)]
Update kbd GUI test

17 months agoFix --kbd-color variable name in rustdoc.css
Guillaume Gomez [Thu, 5 Jan 2023 10:03:35 +0000 (11:03 +0100)]
Fix --kbd-color variable name in rustdoc.css

17 months agoAuto merge of #106404 - tmiasko:dedup-box-derefs, r=wesleywiser
bors [Thu, 5 Jan 2023 09:50:05 +0000 (09:50 +0000)]
Auto merge of #106404 - tmiasko:dedup-box-derefs, r=wesleywiser

Remove duplicated elaborate box derefs pass

The pass runs earlier as a part of `run_runtime_lowering_passes`.

The duplicate was added in #99102.

17 months agoAuto merge of #106482 - compiler-errors:rollup-g7n1p39, r=compiler-errors
bors [Thu, 5 Jan 2023 06:47:02 +0000 (06:47 +0000)]
Auto merge of #106482 - compiler-errors:rollup-g7n1p39, r=compiler-errors

Rollup of 6 pull requests

Successful merges:

 - #105846 (Account for return-position `impl Trait` in trait in `opt_suggest_box_span`)
 - #106385 (Split `-Zchalk` flag into `-Ztrait-solver=(classic|chalk|next)` flag)
 - #106403 (Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`)
 - #106462 (rustdoc: remove unnecessary wrapper around sidebar and mobile logos)
 - #106464 (Update Fuchsia walkthrough with new configs)
 - #106478 (Tweak wording of fn call with wrong number of args)

Failed merges:

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

17 months agoRollup merge of #106478 - estebank:tweak-fn-mismatch, r=compiler-errors
Michael Goulet [Thu, 5 Jan 2023 04:36:29 +0000 (20:36 -0800)]
Rollup merge of #106478 - estebank:tweak-fn-mismatch, r=compiler-errors

Tweak wording of fn call with wrong number of args

17 months agoRollup merge of #106464 - djkoloski:update_fuchsia_platform_support_docs, r=tmandry
Michael Goulet [Thu, 5 Jan 2023 04:36:28 +0000 (20:36 -0800)]
Rollup merge of #106464 - djkoloski:update_fuchsia_platform_support_docs, r=tmandry

Update Fuchsia walkthrough with new configs

The new `download-ci-llvm` configuration option dosn't work with `lld = true` (see #100853). The Fuchsia walkthrough should recommend setting it to `false`.

r? `@tmandry`

17 months agoRollup merge of #106462 - notriddle:notriddle/logo-container-sidebar, r=GuillaumeGomez
Michael Goulet [Thu, 5 Jan 2023 04:36:28 +0000 (20:36 -0800)]
Rollup merge of #106462 - notriddle:notriddle/logo-container-sidebar, r=GuillaumeGomez

rustdoc: remove unnecessary wrapper around sidebar and mobile logos

This commit changes `.sidebar a:hover:not(.logo-container)` to add the `:not()` pseudo-class, retaining the old appearance of the logo when mousing over it.

This didn't used to be necessary because the `a.sidebar-logo` was `display:inline`, and was what got the `background` changed on hover, while the `div.logo-container` inside it was `display:block`. This resulted in the hover rule not having any effect, because the logo-container box was not actually nested inside the sidebar-logo box:

https://www.w3.org/TR/CSS2/visuren.html#anonymous-block-level

> When an inline box contains an in-flow block-level box, the inline box (and its inline ancestors within the same line box) are broken around the block-level box (and any block-level siblings that are consecutive or separated only by collapsible whitespace and/or out-of-flow elements), splitting the inline box into two boxes (even if either side is empty), one on each side of the block-level box(es). The line boxes before the break and after the break are enclosed in anonymous block boxes, and the block-level box becomes a sibling of those anonymous boxes. When such an inline box is affected by relative positioning, any resulting translation also affects the block-level box contained in the inline box.

17 months agoRollup merge of #106403 - compiler-errors:rename-hir-methods, r=cjgillot
Michael Goulet [Thu, 5 Jan 2023 04:36:28 +0000 (20:36 -0800)]
Rollup merge of #106403 - compiler-errors:rename-hir-methods, r=cjgillot

Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`

The `hir::Map::get_parent_node` function doesn't return a `Node`, and I think that's quite confusing. Let's rename it to something that sounds more like something that gets the parent hir id => `hir::Map::parent_id`. Same with `find_parent_node` => `opt_parent_id`.

Also, combine `hir.get(hir.parent_id(hir_id))` and similar `hir.find(hir.parent_id(hir_id))` function into new functions that actually retrieve the parent node in one call. This last commit is the only one that might need to be looked at closely.

17 months agoRollup merge of #106385 - compiler-errors:new-solver-flag, r=jackh726
Michael Goulet [Thu, 5 Jan 2023 04:36:27 +0000 (20:36 -0800)]
Rollup merge of #106385 - compiler-errors:new-solver-flag, r=jackh726

Split `-Zchalk` flag into `-Ztrait-solver=(classic|chalk|next)` flag

We'll eventually need a way to select more than chalk + not-chalk.

Does this need an MCP since it's touching a `-Z` flag? Or perhaps I should preserve `-Zchalk` for the time being... maybe I could make it a warning to use that flag? cc ``@rust-lang/types``

r? types

17 months agoRollup merge of #105846 - compiler-errors:issue-105838, r=jackh726
Michael Goulet [Thu, 5 Jan 2023 04:36:27 +0000 (20:36 -0800)]
Rollup merge of #105846 - compiler-errors:issue-105838, r=jackh726

Account for return-position `impl Trait` in trait in `opt_suggest_box_span`

RPITITs are the only types where their opaque bounds might normalize to some other self type than the opaque type itself. To avoid needing to do normalization, let's just match on either alias kind.

Ideally, we'd just get rid of `opt_suggest_box_span`. It's kind of a wart on type-checking `if`/`match`. I've recently refactored this expression for being confusing/wrong, but moving it into the error path is pretty hard.

Fixes #105838

17 months agoAuto merge of #105409 - compiler-errors:closure-infer-cycle, r=jackh726
bors [Thu, 5 Jan 2023 03:59:31 +0000 (03:59 +0000)]
Auto merge of #105409 - compiler-errors:closure-infer-cycle, r=jackh726

Don't deduce a signature that makes a closure cyclic

Sometimes when elaborating supertrait bounds for closure signature inference, we end up deducing a closure signature that is cyclical because either a parameter or the return type references a projection mentioning `Self` that also has escaping bound vars, which means that it's not eagerly replaced with an inference variable.

Interestingly, this is not *just* related to my PR that elaborates supertrait bounds for closure signature deduction. The committed test `supertrait-hint-cycle-3.rs` shows **stable** code that is fixed by this PR:

```rust
trait Foo<'a> {
    type Input;
}

impl<F: Fn(u32)> Foo<'_> for F {
    type Input = u32;
}

fn needs_super<F: for<'a> Fn(<F as Foo<'a>>::Input) + for<'a> Foo<'a>>(_: F) {}

fn main() {
    needs_super(|_: u32| {});
}
```

Fixes #105401
Fixes #105396

r? types

17 months agoTweak wording of fn call with wrong number of args
Esteban Küber [Thu, 5 Jan 2023 03:02:10 +0000 (03:02 +0000)]
Tweak wording of fn call with wrong number of args

17 months agoAuto merge of #106472 - matthiaskrgr:rollup-4w4v50e, r=matthiaskrgr
bors [Thu, 5 Jan 2023 01:06:05 +0000 (01:06 +0000)]
Auto merge of #106472 - matthiaskrgr:rollup-4w4v50e, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #106391 (rustdoc: allow popover child links to work)
 - #106398 (Fix a few clippy lints in libtest)
 - #106412 (Fix link generation for local primitive types in rustdoc JSON output)
 - #106437 (rustdoc: fix buggy JS check for absolute URL)
 - #106451 (Merge borrowck permission checks)
 - #106460 (Move tests)
 - #106461 (docs: fix broken link "search bar")

Failed merges:

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

17 months agocleanup: handle -Zmutable-noalias like -Zbox-noalias
Erik Desjardins [Thu, 5 Jan 2023 00:24:42 +0000 (19:24 -0500)]
cleanup: handle -Zmutable-noalias like -Zbox-noalias