Commit Graph

158464 Commits

Author SHA1 Message Date
threadexception
5f6059d9a2 Fix float ICE
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-11-20 16:41:36 +01:00
bors
93542a8240 Auto merge of #91066 - camelid:externs, r=jyn514,GuillaumeGomez
rustdoc: Remove `Crate.externs` and compute on-demand instead

r? `@GuillaumeGomez`
cc `@jyn514`
2021-11-20 14:12:29 +00:00
Badel2
8c8914ecab Move parser tests to parser/issues subdirectory
Because the parser directory has already reached the 1000 file limit.
2021-11-20 14:52:21 +01:00
Badel2
77a105c91f Fix ICE #90993: add missing call to cancel 2021-11-20 14:32:25 +01:00
Ken Matsui
88787a33a7
Move scripts on the rustdoc template into head and apply the defer attribute 2021-11-20 21:40:41 +09:00
bors
3d789740b0 Auto merge of #91080 - matthiaskrgr:rollup-znh88cy, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #90575 (Improve suggestions for compatible variants on type mismatch.)
 - #90628 (Clarify error messages caused by re-exporting `pub(crate)` visibility to outside)
 - #90930 (Fix `non-constant value` ICE (#90878))
 - #90983 (Make scrollbar in the sidebar always visible for visual consistency)
 - #91021 (Elaborate `Future::Output` when printing opaque `impl Future` type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-20 10:28:05 +00:00
Matthias Krüger
3379721a30
Rollup merge of #91021 - compiler-errors:print_future_output, r=estebank
Elaborate `Future::Output` when printing opaque `impl Future` type

I would love to see the `Output =` type when printing type errors involving opaque `impl Future`.

[Test code](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a800b481edd31575fbcaf5771a9c3678)

Before (cut relevant part of output):
```
note: while checking the return type of the `async fn`
 --> /home/michael/test.rs:5:19
  |
5 | async fn bar() -> usize {
  |                   ^^^^^ checked the `Output` of this `async fn`, found opaque type
  = note:     expected type `usize`
          found opaque type `impl Future`
```

After:
```
note: while checking the return type of the `async fn`
 --> /home/michael/test.rs:5:19
  |
5 | async fn bar() -> usize {
  |                   ^^^^^ checked the `Output` of this `async fn`, found opaque type
  = note:     expected type `usize`
          found opaque type `impl Future<Output = usize>`
```

Note the "found opaque type `impl Future<Output = usize>`" in the new output.

----

Questions:
1. We skip printing the output type when it's a projection, since I have been seeing some types like `impl Future<Output = <[static generator@/home/michael/test.rs:2:11: 2:21] as Generator<ResumeTy>>::Return>` which are not particularly helpful and leak implementation detail.
    * Am I able to normalize this type within `rustc_middle::ty::print::pretty`? Alternatively, can we normalize it when creating the diagnostic? Otherwise, I'm fine with skipping it and falling back to the old output.
    * Should I suppress any other types? I didn't encounter anything other than this generator projection type.
2. Not sure what the formatting of this should be. Do I include spaces in `Output = `?
2021-11-20 10:21:16 +01:00
Matthias Krüger
59c9c66bc0
Rollup merge of #90983 - GuillaumeGomez:sidebar-scrollbar, r=jsha
Make scrollbar in the sidebar always visible for visual consistency

Fixes #90943.

I had to add a background in `dark` and `ayu` themes, otherwise it was looking strange (like an invisible margin). So it looks like this:

![Screenshot from 2021-11-17 14-45-49](https://user-images.githubusercontent.com/3050060/142212476-18892ae0-ba4b-48e3-8c0f-4ca1dd2f851d.png)
![Screenshot from 2021-11-17 14-45-53](https://user-images.githubusercontent.com/3050060/142212482-e97b2fad-68d2-439a-b62e-b56e6ded5345.png)

Sadly, I wasn't able to add a GUI test to ensure that the scrollbar was always displayed because it seems not possible in puppeteer for whatever reason... I used this method: on small pages (like `lib2/sub_mod/index.html`), comparing `.navbar`'s `clientWidth` with `offsetWidth` (the first doesn't include the sidebar in the computed amount). When checking in the browser, it works fine but in puppeteer it almost never works...

In case anyone want to try to solve the bug, here is the puppeteer code:

<details>
More information about this: I tried another approach which was to get the element in `evaluate` directly (by calling it from `page.evaluate(() => { .. });` directly instead of `parseAssertElemProp.evaluate(e => {...});`.

```js
const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto("file:///path/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/lib2/sub_mod/index.html");
    await page.waitFor(".sidebar");
    let parseAssertElemProp = await page.$(".sidebar");
    if (parseAssertElemProp === null) { throw '".sidebar" not found'; }
    await parseAssertElemProp.evaluate(e => {
        const parseAssertElemPropDict = {"clientWidth": "192", "offsetWidth":"200"};
        for (const [parseAssertElemPropKey, parseAssertElemPropValue] of Object.entries(parseAssertElemPropDict)) {
            if (e[parseAssertElemPropKey] === undefined || String(e[parseAssertElemPropKey]) != parseAssertElemPropValue) {
                throw 'expected `' + parseAssertElemPropValue + '` for property `' + parseAssertElemPropKey + '` for selector `.sidebar`, found `' + e[parseAssertElemPropKey] + '`';
            }
        }
    }).catch(e => console.error(e));
    await browser.close();
})();
```

</details>

r? ``@jsha``
2021-11-20 10:21:15 +01:00
Matthias Krüger
79935714f3
Rollup merge of #90930 - Nilstrieb:fix-non-const-value-ice, r=estebank
Fix `non-constant value` ICE (#90878)

This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const.

I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong.

Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE.

Asking Esteban to review since he was the last one to change the relevant code.

r? ``@estebank``

Fixes #90878
2021-11-20 10:21:14 +01:00
Matthias Krüger
81f3ae8997
Rollup merge of #90628 - ken-matsui:clarify-error-messages-caused-by-reexporting-pub-crate-visibility-to-outside, r=oli-obk
Clarify error messages caused by re-exporting `pub(crate)` visibility to outside

This PR clarifies error messages and suggestions caused by re-exporting pub(crate) visibility outside the crate.

Here is a small example ([Rust Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e2cd0bd4422d4f20e6522dcbad167d3b)):

```rust
mod m {
    pub(crate) enum E {}
}
pub use m::E;

fn main() {}
```

This code is compiled to:

```
error[E0365]: `E` is private, and cannot be re-exported
 --> prog.rs:4:9
  |
4 | pub use m::E;
  |         ^^^^ re-export of private `E`
  |
  = note: consider declaring type or module `E` with `pub`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0365`.
```

However, enum `E` is actually public to the crate, not private totally—nevertheless, rustc treats `pub(crate)` and private visibility as the same on the error messages. They are not clear and should be segmented distinctly.

By applying changes in this PR, the error message below will be the following message that would be clearer:

```
error[E0365]: `E` is only public to inside of the crate, and cannot be re-exported outside
 --> prog.rs:4:9
  |
4 | pub use m::E;
  |         ^^^^ re-export of crate public `E`
  |
  = note: consider declaring type or module `E` with `pub`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0365`.
```
2021-11-20 10:21:13 +01:00
Matthias Krüger
7354bb331e
Rollup merge of #90575 - m-ou-se:compatible-variant-improvements, r=estebank
Improve suggestions for compatible variants on type mismatch.

Fixes #90553.

Before:
![image](https://user-images.githubusercontent.com/783247/140385675-6ff41090-eca2-41bc-b161-99c5dabfec61.png)

After:
![image](https://user-images.githubusercontent.com/783247/140385748-20cf26b5-ea96-4e56-8af2-5fe1ab16fd3b.png)

r? `````@estebank`````
2021-11-20 10:21:12 +01:00
Loïc BRANSTETT
2bad893900 Add similar note as LLVM does for minNum and maxNum functions 2021-11-20 10:14:03 +01:00
Loïc BRANSTETT
a8ee0e9c2c Implement IEEE 754-2019 minimun and maximum functions for f32/f64 2021-11-20 10:14:03 +01:00
Jacob Hoffman-Andrews
e6ab982d46 Reduce prominence of item-infos
- Remove border.
 - Reduce size of emoji slightly.
 - Remove details disclosure for unstable reason. This was inconsistent
   with our other details disclosures, and the detail revealed was
   usually better explained by clicking on the issue link.
2021-11-20 00:10:22 -08:00
bors
6d48ee90f5 Auto merge of #91052 - ehuss:update-stdarch, r=Amanieu
Update stdarch

5 commits in 815d55c610dab39e92e7c83bf5fd4b7a020b4d46..cfba59fccd90b3b52a614120834320f764ab08d1
2021-11-08 00:58:47 +0000 to 2021-11-19 01:29:04 +0000
- Work-around buggy Intel chips erroneously reporting BMI1/BMI2 support (rust-lang/stdarch#1249)
- complete armv8 instructions (rust-lang/stdarch#1256)
- Fix i8mm feature with bootstrap compiler. (rust-lang/stdarch#1252)
- Fix unused link_name attribute. (rust-lang/stdarch#1251)
- Add remaining insturctions (rust-lang/stdarch#1250)
2021-11-20 07:20:43 +00:00
bors
50f2c29200 Auto merge of #90535 - tmiasko:clone-from, r=oli-obk
Implement `clone_from` for `State`

Data flow engine uses `clone_from` for domain values.  Providing an
implementation of `clone_from` will avoid some intermediate memory
allocations.

Extracted from #90413.

r? `@oli-obk`
2021-11-20 04:12:03 +00:00
Josh Stone
023cc968e1 Make LLVMRustGetOrInsertGlobal always return a GlobalVariable
`Module::getOrInsertGlobal` returns a `Constant*`, which is a super
class of `GlobalVariable`, but if the given type doesn't match an
existing declaration, it returns a bitcast of that global instead.
This causes UB when we pass that to `LLVMGetVisibility` which
unconditionally casts the opaque argument to a `GlobalValue*`.

Instead, we can do our own get-or-insert without worrying whether
existing types match exactly. It's not relevant when we're just trying
to get/set the linkage and visibility, and if types are needed we can
bitcast or error nicely from `rustc_codegen_llvm` instead.
2021-11-19 19:33:29 -08:00
Noah Lev
bbc3825d26 rustdoc: Move doc-reachability visiting back to cleaning
It populates `cx.cache.access_levels`, which seems to be needed during
cleaning since a bunch of tests are failing.
2021-11-19 22:00:37 -05:00
Noah Lev
a65421651a rustdoc: Record aliases as Symbols 2021-11-19 21:58:25 -05:00
Noah Lev
8b8f1e069f rustdoc: Add static size assertion for DocFragment
Tons of them are constructed, so the size has a big impact on max-rss.
2021-11-19 21:41:23 -05:00
Noah Lev
6c017f071d rustdoc: Merge visits of extern crates into one loop 2021-11-19 21:28:52 -05:00
Noah Lev
f41beab5cd rustdoc: Remove Crate.externs and compute on-demand instead 2021-11-19 21:28:52 -05:00
Ken Matsui
33ab5123e2
Clarify error messages caused by re-exporting pub(crate) visibility to outside 2021-11-20 10:47:33 +09:00
bors
3b65165ab7 Auto merge of #91064 - matthiaskrgr:rollup-2ijidpt, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #88361 (Makes docs for references a little less confusing)
 - #90089 (Improve display of enum variants)
 - #90956 (Add a regression test for #87573)
 - #90999 (fix CTFE/Miri simd_insert/extract on array-style repr(simd) types)
 - #91026 (rustdoc doctest: detect `fn main` after an unexpected semicolon)
 - #91035 (Put back removed empty line)
 - #91044 (Turn all 0x1b_u8 into '\x1b' or b'\x1b')
 - #91054 (rustdoc: Fix some unescaped HTML tags in docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-20 01:06:27 +00:00
Matthias Krüger
54bc33367c
Rollup merge of #91054 - camelid:fix-tags, r=GuillaumeGomez
rustdoc: Fix some unescaped HTML tags in docs

They were being interpreted literally.
2021-11-20 01:09:45 +01:00
Matthias Krüger
62b259cd88
Rollup merge of #91044 - r00ster91:x1b, r=joshtriplett
Turn all 0x1b_u8 into '\x1b' or b'\x1b'

Supersedes #91040
2021-11-20 01:09:44 +01:00
Matthias Krüger
98540c6805
Rollup merge of #91035 - GuillaumeGomez:put-back-removed-empty-line, r=camelid
Put back removed empty line

Fixes comment from https://github.com/rust-lang/rust/pull/90438#r752813630.

r? ````@camelid````
2021-11-20 01:09:43 +01:00
Matthias Krüger
a9858ce78f
Rollup merge of #91026 - notriddle:notriddle/rustdoc-doctest-semicolon, r=jyn514
rustdoc doctest: detect `fn main` after an unexpected semicolon

Fixes #91014

The basic problem with this is that rustdoc, when hunting for `fn main`, will stop parsing after it reaches a fatal error. This unexpected semicolon was a fatal error, so in `src/test/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs`, it would wrap the doctest in an implied main function, turning it into this:

    fn main() {
        struct S {};
        fn main() {
            assert_eq!(0, 1);
        }
    }

This, as it turns out, is totally valid, and it executes no assertions, so *it passes,* even though the user wanted it to execute the assertion.

The Rust parser already has the ability to recover from these unexpected semicolons, but to do so, it needs to use the `parse_mod` function, so this PR changes it to do that.
2021-11-20 01:09:42 +01:00
Matthias Krüger
cf69f9e220
Rollup merge of #90999 - RalfJung:miri_simd, r=oli-obk
fix CTFE/Miri simd_insert/extract on array-style repr(simd) types

The changed test would previously fail since `place_index` would just return the only field of `f32x4`, i.e., the array -- rather than *indexing into* the array which is what we have to do.

The new helper methods will also be needed for https://github.com/rust-lang/miri/issues/1912.

r? ``````@oli-obk``````
2021-11-20 01:09:41 +01:00
Matthias Krüger
5c98cf145d
Rollup merge of #90956 - JohnTitor:issue-87573, r=Mark-Simulacrum
Add a regression test for #87573

Closes #87573
2021-11-20 01:09:40 +01:00
Matthias Krüger
c0695bbf60
Rollup merge of #90089 - jsha:enum-fields-headings, r=camelid,GuillaumeGomez
Improve display of enum variants

Use h3 and h4 for the variant name and the "Fields" subheading.
Remove the "of T" part of the "Fields" subheading.
Remove border-bottom from "Fields" subheading.
Move docblock below "Fields" listing.

Fixes #90061

Demo:

https://jacob.hoffman-andrews.com/rust/xmlparser-updated/xmlparser/enum.Token.html#variants
https://jacob.hoffman-andrews.com/rust/fix-enum-variants/std/io/enum.ErrorKind.html#variants
https://jacob.hoffman-andrews.com/rust/fix-enum-variants/std/result/enum.Result.html#variants

r? ``@camelid``
2021-11-20 01:09:38 +01:00
Matthias Krüger
97bd45b373
Rollup merge of #88361 - WaffleLapkin:patch-2, r=jyn514
Makes docs for references a little less confusing

- Make clear that the `Pointer` trait is related to formatting
- Make clear that the `Pointer` trait is implemented for references (previously it was confusing to first see that it's implemented and then see it in "expect")
- Make clear that `&T` (shared reference) implements `Send` (if `T: Send + Sync`)
2021-11-20 01:09:37 +01:00
Noah Lev
331465a867 rustdoc: Pass DocContext to Cache::populate
This will allow removing `Crate.externs`.
2021-11-19 17:55:40 -05:00
Noah Lev
0ae053a481 rustdoc: Fix some unescaped HTML tags in docs
They were being interpreted literally.
2021-11-19 15:54:05 -05:00
Eric Huss
458ed5a0c4 Update stdarch 2021-11-19 11:20:42 -08:00
bors
a77da2d454 Auto merge of #91034 - camelid:docfragment, r=jyn514
rustdoc: Cleanup `DocFragment`

- Remove unused `DocFragment.line` field
- Avoid using `Iterator::count()` where possible
2021-11-19 18:04:14 +00:00
r00ster91
a2d78573d3 Turn all 0x1b_u8 into '\x1b' or b'\x1b' 2021-11-19 18:14:18 +01:00
Noah Lev
7a4e2ceb92 Use fast comparison against kw::Empty
We think `.as_str().lines().next().is_none()` should be equivalent to
`== kw::Empty`.

Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-11-19 11:34:41 -05:00
Maybe Waffle
cdb0c29a9c Remove unnecessary doc links 2021-11-19 19:13:53 +03:00
bors
18fa4342fc Auto merge of #90996 - the8472:obligation-hashes2, r=matthewjasper
Optimize `impl Hash for ObligationCauseData` by not hashing `ObligationCauseCode` variant fields

Split out from #90913 since it's a [clear performance win](https://perf.rust-lang.org/compare.html?start=ad442399756573dccacb314b6bf8079964bcc72a&end=223f5e877fe93b5f437c2d703f883797913cd2b7) and should be easier to review.

It speeds up hashing for `Obligation` [deduplication](c9c4b5d727/compiler/rustc_trait_selection/src/traits/select/mod.rs (L2355-L2356)) by only hashing the discriminant of the `ObligationCauseCode` enum instead of its contents. That shouldn't affect hash quality much since there are several other fields in `Obligation` which should be unique enough, especially the predicate itself which is hashed as an interned pointer.
2021-11-19 11:50:51 +00:00
Guillaume Gomez
592178cfcf Put back removed empty line 2021-11-19 10:20:49 +01:00
bors
e8423e6c44 Auto merge of #91033 - JohnTitor:rollup-sr9zg6o, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #89258 (Make char conversion functions unstably const)
 - #90578 (add const generics test)
 - #90633 (Refactor single variant `Candidate` enum into a struct)
 - #90800 (bootstap: create .cargo/config only if not present)
 - #90942 (windows: Return the "Not Found" error when a path is empty)
 - #90947 (Move some tests to more reasonable directories - 9.5)
 - #90961 (Suggest removal of arguments for unit variant, not replacement)
 - #90990 (Arenas cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-19 06:13:29 +00:00
Yuki Okushi
1576a7cc81
Rollup merge of #90990 - nnethercote:arenas-cleanup, r=oli-obk
Arenas cleanup

I was looking closely at the arenas code and here are some small improvement to readability.
2021-11-19 13:06:38 +09:00
Yuki Okushi
c74ff8b563
Rollup merge of #90961 - estebank:suggest-removal-of-call, r=nagisa
Suggest removal of arguments for unit variant, not replacement
2021-11-19 13:06:37 +09:00
Yuki Okushi
022709f479
Rollup merge of #90947 - c410-f3r:testsssssss, r=petrochenkov
Move some tests to more reasonable directories - 9.5

cc #73494
r? `@petrochenkov`
2021-11-19 13:06:36 +09:00
Yuki Okushi
f62984fca9
Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se
windows: Return the "Not Found" error when a path is empty

Fixes #90940
2021-11-19 13:06:35 +09:00
Yuki Okushi
b542224fa5
Rollup merge of #90800 - aplanas:fix_cargo_config, r=Mark-Simulacrum
bootstap: create .cargo/config only if not present

In some situations we should want on influence into the .cargo/config
when we use vendored source.  One example is #90764, when we want to
workaround some references to crates forked and living in git, that are
missing in the vendor/ directory.

This commit will create the .cargo/config file only when the .cargo/
directory needs to be created.
2021-11-19 13:06:35 +09:00
Yuki Okushi
48947eafda
Rollup merge of #90633 - tmiasko:candidate-struct, r=nagisa
Refactor single variant `Candidate` enum into a struct

`Candidate` enum has only a single `Ref` variant.  Refactor it into a
struct and reduce overall indentation of the code by two levels.

No functional changes.
2021-11-19 13:06:34 +09:00
Yuki Okushi
81fd016848
Rollup merge of #90578 - lcnr:add-test, r=Mark-Simulacrum
add const generics test

cc https://github.com/rust-lang/rust/pull/89829#issuecomment-948921310

r? rust-lang/project-const-generics
2021-11-19 13:06:32 +09:00
Yuki Okushi
7432588e5d
Rollup merge of #89258 - est31:const_char_convert, r=oli-obk
Make char conversion functions unstably const

The char conversion functions like `char::from_u32` do trivial computations and can easily be converted into const fns. Only smaller tricks are needed to avoid non-const standard library functions like `Result::ok` or `bool::then_some`.

Tracking issue: https://github.com/rust-lang/rust/issues/89259
2021-11-19 13:06:31 +09:00