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
```
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.
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)
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.
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)
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.
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
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.
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);
| +
```
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.
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
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).
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.
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.
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.
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).
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
```
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.
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.
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)
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`.
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:
> 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.
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.
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``
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.
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;
}
Matthias Krüger [Wed, 4 Jan 2023 22:39:51 +0000 (23:39 +0100)]
Rollup merge of #106451 - Zeegomo:merge-borrowck-access, r=estebank
Merge borrowck permission checks
Merge `check_access_permission` and `check_if_reassignment_to_immutable_state`.
The goal of this commit is twofold:
* simplify the codebase by removing duplicate logic.
* avoid duplicate reporting of illegal reassignment errors by reusing the exiting de-duplicating logic of access_place.
As mentioned in the issue, I'm not super happy about this fix which is more a hack rather than a sound-proof solution. However I couldn't find a better way to fix it.
Matthias Krüger [Wed, 4 Jan 2023 22:39:49 +0000 (23:39 +0100)]
Rollup merge of #106398 - jyn514:fix-clippy, r=thomcc
Fix a few clippy lints in libtest
- Remove unnecessary references and dereferences
- Use `.contains` instead of `a <= x && x <= b`
- Use `mem::take` instead of `mem::replace` where possible
cc https://github.com/rust-lang/rust/pull/106394 :)
bors [Wed, 4 Jan 2023 21:35:15 +0000 (21:35 +0000)]
Auto merge of #106224 - bjorn3:staticlib_fixes, r=wesleywiser
Small fixes for --crate-type staticlib
The first commit doesn't have an effect until we start translating error messages. The second commit fixes potential linker errors when combining `--crate-type staticlib` with another crate type and I think `-Cprefer-dynamic`.
David Koloski [Wed, 4 Jan 2023 20:55:48 +0000 (15:55 -0500)]
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`.
Michael Howell [Wed, 4 Jan 2023 20:04:30 +0000 (13:04 -0700)]
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:
> 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.
bors [Wed, 4 Jan 2023 18:43:32 +0000 (18:43 +0000)]
Auto merge of #106330 - weihanglo:update-cargo, r=weihanglo
Update cargo
8 commits in 2381cbdb4e9b07090f552d34a44a529b6e620e44..8c460b2237a6359a7e3335890db8da049bdd62fc
2022-12-23 12:19:27 +0000 to 2023-01-04 14:30:01 +0000
- test: revive nightly plugin tests to work (rust-lang/cargo#11534)
- Add note to release notes about rejecting multiple registries. (rust-lang/cargo#11531)
- Fix a typo `fresheness` -> `freshness` (rust-lang/cargo#11529)
- Reasons for rebuilding (rust-lang/cargo#11407)
- Asymmetric tokens (rust-lang/cargo#10771)
- Use proper git URL for GitHub repos (rust-lang/cargo#11517)
- Add `registry.default` example (rust-lang/cargo#11516)
- Support vendoring with different revs from same git repo (rust-lang/cargo#10690)
Also update license exceptions and permitted dependencies
for new cargo dependency "pasetors".
A new dependency `getrandom` is added into `rustc-workspace-hacks`,
since it requires feature `js`.
Weihang Lo [Wed, 4 Jan 2023 15:33:59 +0000 (15:33 +0000)]
Update cargo
8 commits in 2381cbdb4e9b07090f552d34a44a529b6e620e44..8c460b2237a6359a7e3335890db8da049bdd62fc
2022-12-23 12:19:27 +0000 to 2023-01-04 14:30:01 +0000
- test: revive nightly plugin tests to work (rust-lang/cargo#11534)
- Add note to release notes about rejecting multiple registries. (rust-lang/cargo#11531)
- Fix a typo `fresheness` -> `freshness` (rust-lang/cargo#11529)
- Reasons for rebuilding (rust-lang/cargo#11407)
- Asymmetric tokens (rust-lang/cargo#10771)
- Use proper git URL for GitHub repos (rust-lang/cargo#11517)
- Add `registry.default` example (rust-lang/cargo#11516)
- Support vendoring with different revs from same git repo (rust-lang/cargo#10690)
Also update license exceptions and permitted dependencies
for new cargo dependency "pasetors".
A new dependency `getrandom` is added into `rustc-workspace-hacks`,
since it requires feature `js`.
Giacomo Pasini [Sat, 31 Dec 2022 12:45:22 +0000 (13:45 +0100)]
Merge borrowck permission checks
Merge `check_access_permission` and
`check_if_reassignment_to_immutable_state`.
The goal of this commit is twofold:
First, we simplify the codebase by removing duplicate logic.
Second, we avoid duplicate reporting of illegal reassignment
errors by reusing the exiting de-duplicating logic of
access_place.
bors [Wed, 4 Jan 2023 09:41:43 +0000 (09:41 +0000)]
Auto merge of #106442 - matthiaskrgr:rollup-wivf7gh, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #106200 (Suggest `impl Fn*` and `impl Future` in `-> _` return suggestions)
- #106274 (Add JSON output to -Zdump-mono-stats)
- #106292 (Add codegen test for `Box::new(uninit)` of big arrays)
- #106327 (Add tidy check for dbg)
- #106361 (Note maximum integer literal for `IntLiteralTooLarge`)
- #106396 (Allow passing a specific date to `bump-stage0`)
- #106436 (Enable doctests for rustc_query_impl)
Matthias Krüger [Wed, 4 Jan 2023 06:28:56 +0000 (07:28 +0100)]
Rollup merge of #106396 - jyn514:bump-stage-date, r=pietroalbini
Allow passing a specific date to `bump-stage0`
This allows regenerating `src/stage0.json` on changes to the tool, without needing to hard-code the date in the source. It was useful for https://github.com/rust-lang/rust/pull/106394, which added clippy to the list of required components.
Use the `<T as Pointee>::Metadata` associated type to calculate the layout of a pointee's metadata, instead of hard-coding rules about certain types.
Maybe this approach is overkill -- we could instead hard-code this approach as a fallback, with the matching on `Slice`/`Dynamic`/etc. happening first
Fixes this issue here https://github.com/rust-lang/rust/pull/104338#issuecomment-1312595844 .. But is also useful with transmutes, for example, given the UI test I added below.