Commit Graph

225099 Commits

Author SHA1 Message Date
Michael Howell
1a77d9a54d rustdoc: get unnormalized link destination for suggestions
Fixes #110111

This bug, and the workaround in this commit, is closely linked to
[raphlinus/pulldown-cmark#441], getting offsets of link
components. In particular, pulldown-cmark doesn't provide the
offsets of the contents of a link.

To work around this, rustdoc parser parts of a link definition
itself.

[raphlinus/pulldown-cmark#441]: https://github.com/raphlinus/pulldown-cmark/issues/441
2023-05-26 18:38:46 -07:00
bors
23040c4a5f Auto merge of #111245 - fee1-dead-contrib:temp-fix-tuple-struct-field, r=lcnr
fix for `Self` not respecting tuple Ctor privacy

This PR fixes #111220 by checking the privacy of tuple constructors using `Self`, so the following code now errors
```rust
mod my {
    pub struct Foo(&'static str);
}

impl AsRef<str> for my::Foo {
    fn as_ref(&self) -> &str {
        let Self(s) = self; // previously compiled, now errors correctly
        s
    }
}
```
2023-05-27 01:27:01 +00:00
bors
19ed0aade6 Auto merge of #112013 - matthiaskrgr:rollup-a4pg2p8, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #111714 (Stop confusing specification levels when computing expectations.)
 - #111927 (Migrate `item_static` to Askama)
 - #111954 (improve error message for calling a method on a raw pointer with an unknown pointee)
 - #111973 (Update current implementation comments for `select_nth_unstable`)
 - #111976 (Generate docs for bootstrap itself)
 - #111977 (Make errors from `x doc` less verbose)
 - #111987 (do not prefer substs relate during coherence)
 - #111991 (Change ty and const error's pretty printing to be in braces)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-26 22:45:58 +00:00
Guillaume Gomez
898dfc680f Correctly handle multiple re-exports of bang macros at the same level 2023-05-27 00:25:37 +02:00
Matthias Krüger
a99209738e
Rollup merge of #111991 - BoxyUwU:change_error_term_display, r=compiler-errors
Change ty and const error's pretty printing to be in braces

`[const error]` and `[type error]` are slightly confusing since they look like either a slice with an error type for the element ty or a slice with a const argument as the type ???. This PR changes them to display as `{const error}` and `{type error}`  similar to `{integer}`.

This does not update the `Debug` impls for them which is done in #111988.

I updated some error logic to avoid printing the substs of trait refs when unable to resolve an assoc item for them, this avoids emitting errors with `{type error}` in them. The substs are not relevant for these errors since we don't take into account the substs when resolving the assoc item.

r? ``@compiler-errors``
2023-05-27 00:24:01 +02:00
Matthias Krüger
dfdbf1b133
Rollup merge of #111987 - lcnr:alias-relate-coherence, r=BoxyUwU
do not prefer substs relate during coherence

r? ```@compiler-errors```
2023-05-27 00:24:00 +02:00
Matthias Krüger
a81ef8aa08
Rollup merge of #111977 - jyn514:doc-errors, r=est31
Make errors from `x doc` less verbose

before:
```
error: could not document `bootstrap`

Caused by:
  process didn't exit successfully: `/home/jyn/src/rust/build/bootstrap/debug/rustdoc ... --crate-version '1.71.0
  (eb9da7bfa
  2023-05-25)
  (a
  long
  description
  goes
  here)' --document-private-items --enable-index-page --show-type-layout --generate-link-to-definition -Zunstable-options` (exit status: 1)
```

after:
```
error: could not document `bootstrap`

Caused by:
  process didn't exit successfully: `/home/jyn/src/rust/build/bootstrap/debug/rustdoc ... --crate-version '1.71.0        (eb9da7bfa      2023-05-25)     (a     long     description    goes     here)' --document-private-items --enable-index-page --show-type-layout --generate-link-to-definition -Zunstable-options` (exit status: 1)
```
2023-05-27 00:24:00 +02:00
Matthias Krüger
76bb98c76e
Rollup merge of #111976 - jyn514:doc-bootstrap, r=ozkanonur
Generate docs for bootstrap itself

This verifies the intra-doc links are correct, and hopefully makes things easier for new contributors.

Note that this will conflict with https://github.com/rust-lang/rust/pull/111955, i'm pretty sure i typo-ed some of the intra-doc links lol
2023-05-27 00:23:59 +02:00
Matthias Krüger
18398ad337
Rollup merge of #111973 - Sp00ph:update_current_impl, r=Amanieu
Update current implementation comments for `select_nth_unstable`

This more accurately reflects the actual implementation, as it hasn't been a simple quickselect since #106997. While it does say that the current implementation always runs in O(n), I don't think it should require an FCP as it doesn't guarantee linearity in general and only points out that the current implementation is in fact linear.

r? `@Amanieu`
2023-05-27 00:23:59 +02:00
Matthias Krüger
e7068ff819
Rollup merge of #111954 - asquared31415:unknown_ptr_type_error, r=compiler-errors
improve error message for calling a method on a raw pointer with an unknown pointee

The old error message had very confusing wording.
Also added some more test cases besides the single edition test.

r? `@compiler-errors`
2023-05-27 00:23:58 +02:00
Matthias Krüger
1e766bfd2a
Rollup merge of #111927 - sladyn98:item-static, r=GuillaumeGomez
Migrate `item_static` to Askama

This pull request addresses the type signature of the item_static function in our codebase. Previously, this function accepted a mutable reference to a Buffer for writing output. The current changes modify this to instead accept a mutable reference to any type that implements the Write trait.

Referes https://github.com/rust-lang/rust/issues/108868
2023-05-27 00:23:58 +02:00
Matthias Krüger
51cf1b62bc
Rollup merge of #111714 - cjgillot:lint-expect-confusion, r=wesleywiser
Stop confusing specification levels when computing expectations.

Fixes https://github.com/rust-lang/rust/issues/111682
2023-05-27 00:23:57 +02:00
Urgau
b84c190b9a Allow newly uplifted invalid_from_utf8 lint 2023-05-27 00:18:28 +02:00
Urgau
7f99c7d3e6 Add invalid_from_utf8 analogous to invalid_from_utf8_unchecked 2023-05-27 00:18:28 +02:00
Urgau
a0612d90b0 Drop uplifted clippy::invalid_utf8_in_unchecked 2023-05-27 00:16:47 +02:00
Urgau
7f8846a9ef Uplift clippy::invalid_utf8_in_unchecked as invalid_from_utf8_unchecked 2023-05-27 00:16:47 +02:00
Wesley Wiser
019d75b44e Add SafeStack support to rustc
Adds support for LLVM [SafeStack] which provides backward edge control
flow protection by separating the stack into two parts: data which is
only accessed in provable safe ways is allocated on the normal stack
(the "safe stack") and all other data is placed in a separate allocation
(the "unsafe stack").

SafeStack support is enabled by passing `-Zsanitizer=safestack`.

[SafeStack]: https://clang.llvm.org/docs/SafeStack.html
2023-05-26 15:18:54 -04:00
Wesley Wiser
d22314e0f5 Convert html table to markdown 2023-05-26 13:58:11 -04:00
Boxy
976adf3d6d better TyKind::Debug 2023-05-26 18:55:02 +01:00
bors
1a5f8bce74 Auto merge of #103291 - ink-feather-org:typeid_no_struct_match, r=dtolnay
Remove structural match from `TypeId`

As per https://github.com/rust-lang/rust/pull/99189#issuecomment-1203720442.

> Removing the structural equality might make sense, but is a breaking change that'd require a libs-api FCP.

https://github.com/rust-lang/rust/pull/99189#issuecomment-1197545482

> Landing this PR now (well, mainly the "remove structural equality" part) would unblock `const fn` `TypeId::of`, since we only postponed that because we were guaranteeing too much.

See also #99189, #101698
2023-05-26 17:29:03 +00:00
asquared31415
b19466abc2 improve error message for calling a method on a raw pointer with an unknown pointee, and add some tests 2023-05-26 13:15:15 -04:00
jyn
60e95e76d0 Update proc-macro-api for the new rustc metadata format 2023-05-26 11:59:25 -05:00
bohan
f78369b3af fix: dedup static_candidates before report 2023-05-27 00:52:07 +08:00
Guillaume Gomez
c908d1e4de Update tests for re-exports of doc hidden macros 2023-05-26 17:31:54 +02:00
Guillaume Gomez
3802ba0f6a Fix re-export of doc hidden macro not showing up 2023-05-26 17:31:11 +02:00
Oli Scherer
164d041e30 Stop creating intermediate places just to immediate convert them to operands 2023-05-26 15:01:29 +00:00
Boxy
ad77bc8427 print const and type errors in braces not square brackets 2023-05-26 16:01:29 +01:00
Oli Scherer
5f66c41921 Add regression test 2023-05-26 15:00:31 +00:00
ozkanonur
c7cec29215 add rustdoc-gui-test tool in triagebot.toml 2023-05-26 17:00:31 +03:00
Pietro Albini
c5139b9136
add reasoning for introducing a metrics format version 2023-05-26 15:25:21 +02:00
Pietro Albini
7040d4102f
rename metadata_version to format_version
The new name is more accurate.
2023-05-26 15:21:21 +02:00
jyn
62314be705 Load only the header for crate_matches
Previously, we used the following info to determine whether to load the crate:
1. The METADATA_HEADER, which includes a METADATA_VERSION constant
2. The embedded rustc version
3. Various metadata in the `CrateRoot`, including the SVH

This worked ok most of the time. Unfortunately, when building locally the rustc version is always
the same because `omit-git-hash` is on by default. That meant that we depended only on 1 and 3, and
we are not very good about bumping METADATA_VERSION (it's currently at 7) so in practice we were
only depending on 3. `CrateRoot` is a very large struct and changes somewhat regularly, so this led
to a steady stream of crashes from trying to load it.

Change the logic to add an intermediate step between 2 and 3: introduce a new `CrateHeader` struct
that contains only the minimum info needed to decide whether the crate should be loaded or not. That
avoids having to load all of `CrateRoot`, which in practice means we should crash much less often.

Note that this works because the SVH should be different between any two dependencies, even if the
compiler has changed, because we use `-Zbinary-dep-depinfo` in bootstrap. See
https://github.com/rust-lang/rust/pull/111329#issuecomment-1538303474 for more details about how the
original crash happened.
2023-05-26 07:44:37 -05:00
jyn
39f337ab95 Make errors from x doc less verbose
before:
```
error: could not document `bootstrap`

Caused by:
  process didn't exit successfully: `/home/jyn/src/rust/build/bootstrap/debug/rustdoc ... --crate-version '1.71.0
  (eb9da7bfa
  2023-05-25)
  (a
  long
  description
  goes
  here)' --document-private-items --enable-index-page --show-type-layout --generate-link-to-definition -Zunstable-options` (exit status: 1)
```

after:
```
error: could not document `bootstrap`

Caused by:
  process didn't exit successfully: `/home/jyn/src/rust/build/bootstrap/debug/rustdoc ... --crate-version '1.71.0        (eb9da7bfa      2023-05-25)     (a     long     description    goes     here)' --document-private-items --enable-index-page --show-type-layout --generate-link-to-definition -Zunstable-options` (exit status: 1)
```
2023-05-26 07:40:57 -05:00
bors
917b0b6c70 Auto merge of #111562 - clubby789:speedup-bootstrap-py, r=jyn514
Improve startup time of bootstrap

~~If the user has a `build/host` symlink set up, we can determine the target triple by reading it rather than invoking rustc. This significantly reduces startup time of bootstrap once any kind of build has been done~~
New approach explained below
```
➜  hyperfine -p 'git checkout -q master' -N './x.py -h' -r 50
Benchmark 1: ./x.py -h
  Time (mean ± σ):     140.7 ms ±   2.6 ms    [User: 99.9 ms, System: 39.3 ms]
  Range (min … max):   136.8 ms … 149.6 ms    50 runs

➜  rust git:(master) hyperfine -p 'git checkout -q speedup-bootstrap-py' -N './x.py -h' -r 50
Benchmark 1: ./x.py -h
  Time (mean ± σ):      95.2 ms ±   1.5 ms    [User: 67.7 ms, System: 26.7 ms]
  Range (min … max):    92.9 ms …  99.6 ms    50 runs
```

Also a small microoptimisation in using string splitting rather than regex when reading toml, which saves a few more milliseconds (2-5 testing locally), but less important.

Profiling shows the remaining runtime is around half setting up the Python runtime, and the vast majority of the remaining time is spent in subprocess building and running bootstrap itself, so probably can't be improved much further.
2023-05-26 11:52:25 +00:00
clubby789
9a86ceb049 Improve startup time for bootstrap.py 2023-05-26 10:40:55 +00:00
klensy
9b6a6b13c5 deps: bump crates
update iana-time-zone-haiku to drop bumch of cxx* deps
cargo update -p iana-time-zone-haiku
    Updating crates.io index
    Updating cc v1.0.77 -> v1.0.79
    Removing codespan-reporting v0.11.1
    Removing cxx v1.0.94
    Removing cxx-build v1.0.94
    Removing cxxbridge-flags v1.0.94
    Removing cxxbridge-macro v1.0.94
    Updating iana-time-zone-haiku v0.1.1 -> v0.1.2
    Removing link-cplusplus v1.0.8
    Removing scratch v1.0.5

fixes known issue https://github.com/crossbeam-rs/crossbeam/pull/972
cargo update -p crossbeam-channel
    Updating crates.io index
    Updating crossbeam-channel v0.5.6 -> v0.5.8

dedupes memoffset versions
cargo update -p crossbeam-epoch
    Updating crates.io index
    Updating crossbeam-epoch v0.9.13 -> v0.9.14
    Removing memoffset v0.7.1

dedupes bstr versions
cargo update -p ignore -p opener
    Updating crates.io index
    Removing bstr v0.2.17
    Updating globset v0.4.9 -> v0.4.10
    Updating ignore v0.4.18 -> v0.4.20
    Updating opener v0.5.0 -> v0.5.2
2023-05-26 13:03:47 +03:00
sladynnunes
aa67ae2d9d Formatted file correctly 2023-05-26 02:28:20 -07:00
sladynnunes
df98e3e6ec Fixed tests 2023-05-26 02:22:00 -07:00
lcnr
b6b9611190 remove unnecessary .ok() calls 2023-05-26 11:07:20 +02:00
lcnr
e7fa993d89 do not prefer substs relate during coherence 2023-05-26 11:00:06 +02:00
bors
1221e43bdf Auto merge of #111984 - matthiaskrgr:rollup-6u7ynyv, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #111384 (Fix linking Mac Catalyst by including LC_BUILD_VERSION in object files)
 - #111899 (CGU cleanups)
 - #111940 (Clarify safety concern of `io::Read::read` is only relevant in unsafe code)
 - #111947 (Add test for RPIT defined with different hidden types with different substs)
 - #111951 (Correct comment on privately uninhabited pattern.)

Failed merges:

 - #111954 (improve error message for calling a method on a raw pointer with an unknown pointee)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-26 08:58:40 +00:00
sladynnunes
9078fd51d6 Fix failing CI 2023-05-26 01:19:34 -07:00
onestacked
6827a413c8 Blesses UI tests, add known bug to typeid-equality-by-subtyping 2023-05-26 09:53:05 +02:00
Pietro Albini
cb68c05151
address review feedback 2023-05-26 09:47:21 +02:00
Matthias Krüger
dd74ae0929
Rollup merge of #111951 - cjgillot:uninh-comment, r=Nadrieril
Correct comment on privately uninhabited pattern.

Follow-up to https://github.com/rust-lang/rust/pull/111624#discussion_r1204767933

r? `@Nadrieril`
2023-05-26 08:24:09 +02:00
Matthias Krüger
39b633ece4
Rollup merge of #111947 - obeis:issue-111943, r=compiler-errors
Add test for RPIT defined with different hidden types with different substs

Close #111943
2023-05-26 08:24:08 +02:00
Matthias Krüger
2daecf7c45
Rollup merge of #111940 - zirconium-n:io-read-doc-change, r=thomcc
Clarify safety concern of `io::Read::read` is only relevant in unsafe code

We have this clarification note in other similar place like [Iterator::size_hint](https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#method.size_hint).

The lack of clarification might lead to confusion to Rust beginners. [Relevant URLO post](https://users.rust-lang.org/t/can-read-overflow-a-buffer/94347).
2023-05-26 08:24:08 +02:00
Matthias Krüger
78cc117f7b
Rollup merge of #111899 - nnethercote:cgu-cleanups, r=wesleywiser
CGU cleanups

Some code clarity improvements I found when reading this code closely.

r? ``@wesleywiser``
2023-05-26 08:24:07 +02:00
Matthias Krüger
42c7b8a7de
Rollup merge of #111384 - bmisiak:issue-106021-fix, r=petrochenkov
Fix linking Mac Catalyst by including LC_BUILD_VERSION in object files

Hello. My first rustc PR!

Issue #106021 prevents Rust code from being linked into Mac Catalyst applications. Apple's LD has started requiring object files to contain version information about the platform they were built for, such as:
* the "deployment target" (minimum supported OS version),
* the SDK version
* the type of the platform (macOS/iOS/catalyst/tvOS/watchOS all have a different number).

This is currently only enforced when building for Mac Catalyst.

Rust uses the `object` crate which added support for including this information starting with `0.31.0`. ~~I upgraded it along with `thorin-dwp` so that everything depends on 0.31.
Apparently 0.31 [pulls in](https://github.com/gimli-rs/object/issues/463) `ruzstd` due to a [new ELF standard](https://maskray.me/blog/2022-09-09-zstd-compressed-debug-sections) because its `compression` feature is enabled by thorin. If you find this objectionable, let me know what the best way to avoid pulling in those dependencies might be.~~

**(`object` upgraded in https://github.com/rust-lang/rust/pull/111413)**

I then added two commits:
* The first one adds very basic, hard-coded support for calling `set_macho_build_version` for `-macabi` (Catalyst) targets, where it claims deployment target of Catalyst 14.0 and SDK of 16.2.
* The second weaves the versioning through `rust_target::spec::TargetOptions`, so that we can stick to specifying all target-related info in one place.

Kudos to ``@ara4n`` for writing [this gist](https://gist.github.com/ara4n/320a53ea768aba51afad4c9ed2168536).
2023-05-26 08:24:07 +02:00
Deadbeef
be44860ab9 fix for Self not respecting tuple Ctor privacy
This fixes #111220 by checking the privacy of tuple constructors using `Self`, so the following code now errors

```rust
mod my {
    pub struct Foo(&'static str);
}

impl AsRef<str> for my::Foo {
    fn as_ref(&self) -> &str {
        let Self(s) = self; // previously compiled, now errors correctly
        s
    }
}
```
2023-05-26 06:23:03 +00:00