Commit Graph

167936 Commits

Author SHA1 Message Date
Joshua Nelson
b9eedea4b0 Panic if dist generates a symbolic link in a generated tarball
This avoids regressions in rustup-toolchain-install-master
2022-06-19 15:54:31 -05:00
bors
532be942dd Auto merge of #96375 - jyn514:bootstrap-submodules, r=Mark-Simulacrum
Fix running bootstrap tests on a fresh clone

In #96303, I changed the tests not to manage submodules, with the main
goal of avoiding a clone for llvm-project. Unfortunately, there are some tests
which depend on submodules - I didn't notice locally because they were already checked out for me,
and CI doesn't use submodule handling at all. Fresh clones, however, were impacted:
```
failures:

---- builder::tests::defaults::doc_default stdout ----
thread 'main' panicked at 'fs::read_dir(builder.src.join(&relative_path).join("redirects")) failed with No such file or directory (os error 2)', src/bootstrap/doc.rs:232:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- builder::tests::dist::dist_only_cross_host stdout ----
thread 'main' panicked at 'fs::read_to_string(&toml_file_name) failed with No such file or directory (os error 2)', src/bootstrap/lib.rs:1314:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Try and get the best of both worlds by only checking out the submodules actually used in tests.
2022-05-11 00:41:50 +00:00
Joshua Nelson
212fc2134d Fix running bootstrap tests on a fresh clone
In #96303, I changed the tests not to manage submodules, with the main
goal of avoiding a clone for llvm-project. Unfortunately, there are some tests
which depend on submodules - I didn't notice locally because they were already checked out for me,
and CI doesn't use submodule handling at all. Fresh clones, however, were impacted:
```
failures:

---- builder::tests::defaults::doc_default stdout ----
thread 'main' panicked at 'fs::read_dir(builder.src.join(&relative_path).join("redirects")) failed with No such file or directory (os error 2)', src/bootstrap/doc.rs:232:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- builder::tests::dist::dist_only_cross_host stdout ----
thread 'main' panicked at 'fs::read_to_string(&toml_file_name) failed with No such file or directory (os error 2)', src/bootstrap/lib.rs:1314:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Try and get the best of both worlds by only checking out the submodules actually used in tests.
2022-05-10 18:13:54 -05:00
bors
ecd44958e0 Auto merge of #96232 - sunfishcode:sunfishcode/io-safety-const-fns, r=joshtriplett
Make `BorrowedFd::borrow_raw` a const fn.

Making `BorrowedFd::borrow_raw` a const fn allows it to be used to
create a constant `BorrowedFd<'static>` holding constants such as
`AT_FDCWD`. This will allow [`rustix::fs::cwd`] to become a const fn.

For consistency, make similar changes to `BorrowedHandle::borrow_raw`
and `BorrowedSocket::borrow_raw`.

[`rustix::fs::cwd`]: https://docs.rs/rustix/latest/rustix/fs/fn.cwd.html

r? `@joshtriplett`
2022-05-10 21:19:19 +00:00
bors
fee75fbe11 Auto merge of #96905 - jyn514:revert-96803-faster-assemble, r=Mark-Simulacrum
Revert "Make "Assemble stage1 compiler" orders of magnitude faster"

Reverts rust-lang/rust#96803. This caused `llvm-tools-nightly` to fail when installing with `rustup-toolchain-install-master` because of the presence of symlinks. I'm not sure how the symlinks got in there, but revert the PR for now while I figure it out.

r? `@Mark-Simulacrum` cc `@RalfJung`
2022-05-10 18:26:31 +00:00
Joshua Nelson
89e0c29489
Revert "Make "Assemble stage1 compiler" orders of magnitude faster" 2022-05-10 10:58:52 -05:00
bors
d4c364347c Auto merge of #96904 - JohnTitor:rollup-f1sz5x0, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #96717 (Handle mismatched generic param kinds in trait impls betterly)
 - #96725 (Expose process windows_process_extensions_main_thread_handle on Windows)
 - #96849 (Move some tests to more reasonable places)
 - #96861 (Use Rust 2021 prelude in std itself.)
 - #96879 (rustdoc: search result ranking fix)
 - #96882 (Don't subst an AdtDef with its own substs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-10 15:58:17 +00:00
Yuki Okushi
c5f2c4476e
Rollup merge of #96882 - jackh726:no-subst, r=oli-obk
Don't subst an AdtDef with its own substs
2022-05-11 00:09:36 +09:00
Yuki Okushi
d34915f691
Rollup merge of #96879 - notriddle:notriddle/search-ranking, r=GuillaumeGomez
rustdoc: search result ranking fix

# Before

![image](https://user-images.githubusercontent.com/1593513/167477286-91049761-67f9-4a73-8fb7-09dbb19ca76c.png)

# After

![image](https://user-images.githubusercontent.com/1593513/167477345-6733bc0f-4bb2-4625-9f7f-094031e36414.png)
2022-05-11 00:09:35 +09:00
Yuki Okushi
7274447c36
Rollup merge of #96861 - m-ou-se:std-use-prelude-2021, r=joshtriplett
Use Rust 2021 prelude in std itself.
2022-05-11 00:09:34 +09:00
Yuki Okushi
ac97727528
Rollup merge of #96849 - c410-f3r:z-errors, r=petrochenkov
Move some tests to more reasonable places

cc https://github.com/rust-lang/rust/issues/73494
r? `@petrochenkov`
2022-05-11 00:09:33 +09:00
Yuki Okushi
f689f6582c
Rollup merge of #96725 - nico-abram:win_tid, r=ChrisDenton
Expose process windows_process_extensions_main_thread_handle on Windows

~~I did not find any tests in 7d3e03666a/library/std/src/sys/windows/process/tests.rs that actually launch processes, so I haven't added tests for this.~~ I ran the following locally, to check that it works as expected:
```rs
#![feature(windows_process_extensions_main_thread_handle)]

fn main() {
    use std::os::windows::process::{ChildExt, CommandExt};
    const CREATE_SUSPENDED: u32 = 0x00000004;

    let proc = std::process::Command::new("cmd")
        .args(["/C", "echo hello"])
        .creation_flags(CREATE_SUSPENDED)
        .spawn()
        .unwrap();

    extern "system" {
        fn ResumeThread(_: *mut std::ffi::c_void) -> u32;
    }
    unsafe {
        ResumeThread(proc.main_thread_handle());
    }

    let output = proc.wait_with_output().unwrap();
    let str_output = std::str::from_utf8(&output.stdout[..]).unwrap();
    println!("{}", str_output);
}

```

Without the feature attribute it wouldn't compile, and commenting the `ResumeThread` line makes it hang forever, showing that it works.

Trakcing issue https://github.com/rust-lang/rust/issues/96723
2022-05-11 00:09:32 +09:00
Yuki Okushi
77030b7825
Rollup merge of #96717 - BoxyUwU:gats_const_param_types_mismatch_err, r=lcnr
Handle mismatched generic param kinds in trait impls betterly

- Check that generic params on a generic associated type are the same as in the trait definition
- Check that const generics are not used in place of type generics (and the other way round too)

r? `@lcnr`
2022-05-11 00:09:31 +09:00
bors
eead58e75b Auto merge of #96736 - oli-obk:tait_missing_wf_check, r=davidtwco
Check hidden types for well formedness at the definition site instead of only at the opaque type itself

work towards #90409 . We'll need to look into closure and generator bodies of closures and generators nested inside the hidden type in order to fix that. In hindsight this PR is not necessary for that, but it may be a bit easier with it and we'll get better diagnostics from it on its own.
2022-05-10 13:39:43 +00:00
bors
c51871c469 Auto merge of #94799 - lcnr:list-ty-perf, r=petrochenkov
update `hash_stable` for `List<Ty<'tcx>>`

cc https://github.com/rust-lang/rust/pull/93505#issuecomment-1047538798

this is the hottest part changed since the pre-merge perf run
2022-05-10 10:53:47 +00:00
bors
d53f1e8fbf Auto merge of #96891 - Dylan-DPC:rollup-echa4wg, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #93661 (Add missing rustc arg docs)
 - #96674 (docs: add link explaining variance to NonNull docs)
 - #96812 (Do not lint on explicit outlives requirements from external macros.)
 - #96823 (Properly fix #96638)
 - #96872 (make sure ScalarPair enums have ScalarPair variants; add some layout sanity checks)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-10 08:12:50 +00:00
Oli Scherer
f667e952f8 Check hidden types for well formedness at the definition site instead of only at the opaque type itself 2022-05-10 07:20:00 +00:00
Dylan DPC
ec53c379cc
Rollup merge of #96872 - RalfJung:layout-sanity, r=eddyb
make sure ScalarPair enums have ScalarPair variants; add some layout sanity checks

`@eddyb` suggested that it might be reasonable for `ScalarPair` enums to simply adjust the ABI of their variants accordingly, such that the layout invariant Miri expects actually holds. This PR implements that. I should note though that I don't know much about this layout computation code and what non-Miri consumers expect from it, so tread with caution!

I also added a function to sanity-check that computed layouts are internally consistent. This helped a lot in figuring out the final shape of this PR, though I am also not 100% sure that these sanity checks are the right ones.

Cc `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/96221
2022-05-10 08:24:05 +02:00
Dylan DPC
9a3f17b34d
Rollup merge of #96823 - jackh726:params-heuristics-fix, r=estebank
Properly fix #96638

Closes #96638

The main part of this change is `Error::Invalid` now returns both the input and arg indices. However, I realized the code here was kind of confusing and not internally consistent (and thus I was having trouble getting the right behavior). So I've also switched `input_indices` and `arg_indices` to more closely match some naming in `checks` (although I think a more thorough cleanup there could be beneficial). I've added comments, but essentially `input_indices` refers to *user provided* inputs and `arg_indices` refers to *expected* args.
2022-05-10 08:24:04 +02:00
Dylan DPC
7b32e9304b
Rollup merge of #96812 - cjgillot:no-lint-outllives-macro, r=petrochenkov
Do not lint on explicit outlives requirements from external macros.

The current implementation of the list rightfully skipped where predicates from external macros.
However, if the where predicate came from the current macro but the bounds were from an external macro, the lint still fired.

Closes https://github.com/rust-lang/rust/issues/96640
2022-05-10 08:24:03 +02:00
Dylan DPC
c5c273b30e
Rollup merge of #96674 - bstrie:vardoc, r=thomcc
docs: add link explaining variance to NonNull docs
2022-05-10 08:24:02 +02:00
Dylan DPC
dd83ae2cd6
Rollup merge of #93661 - ehuss:add-missing-rustc-arg-docs, r=estebank,Mark-Simulacrum
Add missing rustc arg docs

Add documentation for recently added rustc args

`-C symbol-mangling-version` was stabilized in #90128.
`--json=future-incompat` was stabilized in #91535.
2022-05-10 08:24:00 +02:00
unknown
5368ea7d2e Expose process main_thread_handle on Windows 2022-05-10 02:41:19 -03:00
bors
2226f19f70 Auto merge of #96808 - cjgillot:impossible-trait, r=compiler-errors
Detect trait fulfillment in `subst_and_check_impossible_predicates`

Split from https://github.com/rust-lang/rust/pull/91743
r? `@compiler-errors`
2022-05-10 05:27:54 +00:00
bors
87fd70c107 Auto merge of #96803 - jyn514:faster-assemble, r=Mark-Simulacrum
Make "Assemble stage1 compiler" orders of magnitude faster

This used to take upwards of 5 seconds for me locally. I found that the culprit was copying the downloaded LLVM shared object:
```
[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09]   c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }
```

It turned out that `install()` used full copies unconditionally. Change it to try using a hard-link before falling back to copying.
2022-05-10 03:11:05 +00:00
bors
362010d6be Auto merge of #96715 - cjgillot:trait-alias-loop, r=compiler-errors
Fortify handing of where bounds on trait & trait alias definitions

Closes https://github.com/rust-lang/rust/issues/96664
Closes https://github.com/rust-lang/rust/issues/96665

Since https://github.com/rust-lang/rust/pull/93803, when listing all bounds and predicates we now need to account for the possible presence of predicates on any of the generic parameters.  Both bugs were hidden by the special handling of bounds at  the generic parameter declaration position.

Trait alias expansion used to confuse predicates on `Self` and where predicates.
Exiting too late when listing all the bounds caused a cycle error.
2022-05-10 00:40:57 +00:00
bors
cb390735b0 Auto merge of #96838 - tmiasko:lazy-switch-sources, r=oli-obk
Optimize switch sources representation and usage

* Avoid constructing switch sources unless necessary - switch sources are used by backward analysis with a custom switch int edge effects, but are otherwise unnecessarily computed.
* Use sparse representation of switch sources to avoid quadratic space overhead.
2022-05-09 22:15:30 +00:00
Jack Huey
cb1c0c6516 Don't subst an adt def 2022-05-09 16:07:10 -04:00
bors
88860d5474 Auto merge of #96473 - lcnr:querify-codegen-fn-attrs, r=cjgillot
store `codegen_fn_attrs` in crate metadata

extracted from #95562 because the change isn't trivial.
2022-05-09 19:52:59 +00:00
Ralf Jung
02eca34534 also sanity-check Abi::Vector, and slight refactoring 2022-05-09 21:40:33 +02:00
Michael Howell
a9a90d450d Add test case for hashset::insert ranking 2022-05-09 12:24:09 -07:00
Michael Howell
360d6e4b7d rustdoc: search result ranking fix 2022-05-09 11:49:05 -07:00
Jack Huey
1d68e6d674 Properly fix issue 96638 2022-05-09 13:53:16 -04:00
bors
0dd7e10282 Auto merge of #96877 - matthiaskrgr:rollup-evlh6ot, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #95483 (Improve floating point documentation)
 - #96008 (Warn on unused `#[doc(hidden)]` attributes on trait impl items)
 - #96841 (Revert "Implement [OsStr]::join", which was merged without FCP.)
 - #96844 (Actually fix ICE from #96583)
 - #96854 (Some subst cleanup)
 - #96858 (Remove unused param from search.js::checkPath)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-09 17:23:34 +00:00
Camille GILLOT
e947fad68c Point to the empty trait alias. 2022-05-09 19:03:37 +02:00
Matthias Krüger
59722228b9
Rollup merge of #96858 - notriddle:notriddle/cleanup-search-js, r=GuillaumeGomez
Remove unused param from search.js::checkPath
2022-05-09 18:45:40 +02:00
Matthias Krüger
0e00ed5f48
Rollup merge of #96854 - jackh726:subst-cleanup, r=compiler-errors
Some subst cleanup

Two separate things here. Both changes are useful for some refactoring I'm doing to add an "EarlyBinder" newtype. (Part of chalkification).

1) Remove `subst_spanned` and just use `subst`. It wasn't used much anyways. In practice, I think we can probably get most of the info just from the actual error message. If not, outputting logs should do the trick. (The specific line probably wouldn't help much anyways).

2) Call `.subst()` before `replace_bound_vars_with_fresh_vars` and `erase_late_bound_regions` in three places that do the opposite. I think there might have been some time in the past that the order here matter for something, but this shouldn't be the case anymore. Conceptually, it makes more sense to the of the *early bound* vars on `fn`s as "outside" the late bound vars.
2022-05-09 18:45:39 +02:00
Matthias Krüger
84a8f8dedf
Rollup merge of #96844 - Badel2:actually-fix-96583, r=compiler-errors
Actually fix ICE from #96583

PR #96746 fixed a very similar bug, so the same logic is used in a different place.

I originally concluded that the two issues (#96583 and #96738) were identical by comparing the backtrace, but I didn't look close enough.
2022-05-09 18:45:38 +02:00
Matthias Krüger
f4bef2e41c
Rollup merge of #96841 - thomcc:revert-osstr-join, r=m-ou-se
Revert "Implement [OsStr]::join", which was merged without FCP.

This reverts commit 4fcbc53820, see https://github.com/rust-lang/rust/pull/96744. (I'm terribly sorry, and truly don't remember r+ing it, or even having seen it before yesterday, which is... genuinely very worrisome for me).

r? `@m-ou-se`
2022-05-09 18:45:37 +02:00
Matthias Krüger
6c8001b85c
Rollup merge of #96008 - fmease:warn-on-useless-doc-hidden-on-assoc-impl-items, r=lcnr
Warn on unused `#[doc(hidden)]` attributes on trait impl items

[Zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.E2.9C.94.20Validy.20checks.20for.20.60.23.5Bdoc.28hidden.29.5D.60).

Whether an associated item in a trait impl is shown or hidden in the documentation entirely depends on the corresponding item in the trait declaration. Rustdoc completely ignores `#[doc(hidden)]` attributes on impl items. No error or warning is emitted:

```rust
pub trait Tr { fn f(); }
pub struct Ty;
impl Tr for Ty { #[doc(hidden)] fn f() {} }
//               ^^^^^^^^^^^^^^ ignored by rustdoc and currently
//                              no error or warning issued
```

This may lead users to the wrong belief that the attribute has an effect. In fact, several such cases are found in the standard library (I've removed all of them in this PR).
There does not seem to exist any incentive to allow this in the future either: Impl'ing a trait for a type means the type *fully* conforms to its API. Users can add `#[doc(hidden)]` to the whole impl if they want to hide the implementation or add the attribute to the corresponding associated item in the trait declaration to hide the specific item. Hiding an implementation of an associated item does not make much sense: The associated item can still be found on the trait page.

This PR emits the warn-by-default lint `unused_attribute` for this case with a future-incompat warning.

`@rustbot` label T-compiler T-rustdoc A-lint
2022-05-09 18:45:36 +02:00
Matthias Krüger
28d800ce1c
Rollup merge of #95483 - golddranks:improve_float_docs, r=joshtriplett
Improve floating point documentation

This is my attempt to improve/solve https://github.com/rust-lang/rust/issues/95468 and https://github.com/rust-lang/rust/issues/73328 .

Added/refined explanations:
- Refine the "NaN as a special value" top level explanation of f32
- Refine `const NAN` docstring: add an explanation about there being multitude of NaN bitpatterns and disclaimer about the portability/stability guarantees.
- Refine `fn is_sign_positive` and `fn is_sign_negative` docstrings: add disclaimer about the sign bit of NaNs.
- Refine `fn min` and `fn max` docstrings: explain the semantics and their relationship to the standard and libm better.
- Refine `fn trunc` docstrings: explain the semantics slightly more.
- Refine `fn powi` docstrings: add disclaimer that the rounding behaviour might be different from `powf`.
- Refine `fn copysign` docstrings: add disclaimer about payloads of NaNs.
- Refine `minimum` and `maximum`: add disclaimer that "propagating NaN" doesn't mean that propagating the NaN bit patterns is guaranteed.
- Refine `max` and `min` docstrings: add "ignoring NaN" to bring the one-row explanation to parity with `minimum` and `maximum`.

Cosmetic changes:
- Reword `NaN` and `NAN` as plain "NaN", unless they refer to the specific `const NAN`.
- Reword "a number" to `self` in function docstrings to clarify.
- Remove "Returns NAN if the number is NAN" from `abs`, as this is told to be the default behavior in the top explanation.
2022-05-09 18:45:35 +02:00
lcnr
32b13ac928 review 2022-05-09 18:40:18 +02:00
lcnr
d371ebe117 only compute codegen_fn_attrs where needed 2022-05-09 18:40:18 +02:00
Ralf Jung
04fb9222f8 fix codegen test failure 2022-05-09 18:10:21 +02:00
Ralf Jung
2c11c3d86c make sure ScalarPair enums have ScalarPair variants; add some layout sanity checks 2022-05-09 17:46:35 +02:00
bors
0e345b76a5 Auto merge of #96845 - Patryk27:upgrade-llvm, r=nikic
Upgrade llvm-project (rustc + avr = lovelove back again!)

See:
https://github.com/rust-lang/llvm-project/pull/139

tl;dr:
- closes https://github.com/rust-lang/rust/issues/83633,
- closes https://github.com/rust-lang/rust/issues/82104,
- closes https://github.com/rust-lang/rust/issues/79889,
- closes https://github.com/rust-lang/compiler-builtins/issues/400.

🙂
2022-05-09 14:58:22 +00:00
lcnr
66ff6c32e5 only cache codegen_fn_attrs on disk if its local 2022-05-09 16:48:30 +02:00
lcnr
501067cb05 move panic-in-drop=abort check for drop_in_place
Whether `drop_in_place` can abort does depend on the
`panic-in-drop` option while compiling the current crate,
not `core`
2022-05-09 16:48:30 +02:00
lcnr
bd1d18660b store codegen_fn_attrs in crate metadata 2022-05-09 16:48:30 +02:00
bors
e013f9e0ca Auto merge of #96815 - SparrowLii:promote_const, r=oli-obk
optimize `promote_consts` by caching the results of `validate_local`

From the FIXME in the impl of `promote_consts`. Early return the `validate_local` should save some compile time.

`qualif_local` is similar to this, but requires futher changing because there are different types of qualif checks. If this PR is effective, I will do it as well.
2022-05-09 11:49:09 +00:00