Commit Graph

164235 Commits

Author SHA1 Message Date
Scott McMurray
705b8807d5 The Clone::clone call is now a ConstantKind::Val, not a ConstantKind::Ty 2022-03-10 01:50:47 -08:00
Scott McMurray
697464a487 Disable the test on wasm32
Since the expected output has unwind targets
2022-03-10 01:19:02 -08:00
Scott McMurray
54408f0963 short-circuit the easy cases in is_copy_modulo_regions
This change is somewhat extensive, since it affects MIR -- since this is called to determine Copy vs Move -- so any test that's `no_core` needs to actually have the normal `impl`s it uses.
2022-03-10 01:19:02 -08:00
Scott McMurray
b5a54d8777 Move is_trivially_pure_clone_copy onto Ty instead 2022-03-10 01:19:02 -08:00
Scott McMurray
0d4a3f11e2 mir-opt: Replace clone on primitives with copy
We can't do it for everything, but it would be nice to at least stop making calls to clone methods in debug from things like derived-clones.
2022-03-10 01:19:02 -08:00
bors
d7b282b886 Auto merge of #94059 - b-naber:constantkind-val-transformation, r=lcnr
Treat constant values as mir::ConstantKind::Val

Another step that is necessary for the introduction of Valtrees: we don't want to treat `ty::Const` instances of kind `ty::ConstKind::Value` as `mir::ConstantKind::Ty` anymore.

r? `@oli-obk`
2022-03-10 05:53:59 +00:00
bors
01ad0ad653 Auto merge of #94787 - matthiaskrgr:rollup-yyou15f, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #91804 (Make some `Clone` impls `const`)
 - #92541 (Mention intent of `From` trait in its docs)
 - #93057 (Add Iterator::collect_into)
 - #94739 (Suggest `if let`/`let_else` for refutable pat in `let`)
 - #94754 (Warn users about `||` in let chain expressions)
 - #94763 (Add documentation about lifetimes to thread::scope.)
 - #94768 (Ignore `close_read_wakes_up` test on SGX platform)
 - #94772 (Add miri to the well known conditional compilation names and values)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-10 02:38:43 +00:00
bors
85ce7fdfa2 Auto merge of #94737 - lcnr:pass-stuff-by-value, r=davidtwco
add `#[rustc_pass_by_value]` to more types

the only interesting changes here should be to `TransitiveRelation`, but I believe to be highly unlikely that we will ever use a non `Copy` type with this type.
2022-03-10 00:15:39 +00:00
Matthias Krüger
94f5f1f3bf
Rollup merge of #94772 - Urgau:check-cfg-miri, r=petrochenkov
Add miri to the well known conditional compilation names and values

This pull request adds `miri` to the list of well known names and values of the conditional compilation checking (`--check-cfg`).

This was brought up in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/RFC.203013.3A.20Checking.20conditional.20compilation.20at.20compile.20time/near/274513827) when discussing about the future of `--check-cfg`.

r? ``@petrochenkov``
2022-03-09 23:14:16 +01:00
Matthias Krüger
06944d9e49
Rollup merge of #94768 - fortanix:raoul/fix_close_read_wakes_up_test_sgx_platform, r=dtolnay
Ignore `close_read_wakes_up` test on SGX platform

PR #94714 enabled the `close_read_wakes_up` test for all platforms. This is incorrect. This test should be ignored at least for the SGX platform.

cc: ``@mzohreva`` ``@jethrogb``
2022-03-09 23:14:15 +01:00
Matthias Krüger
9e90f8d39b
Rollup merge of #94763 - m-ou-se:scoped-threads-lifetime-docs, r=Mark-Simulacrum
Add documentation about lifetimes to thread::scope.

This resolves the last unresolved question of https://github.com/rust-lang/rust/issues/93203

This was brought up in https://github.com/rust-lang/rust/pull/94559#discussion_r820872694

r? `````@Mark-Simulacrum`````
2022-03-09 23:14:14 +01:00
Matthias Krüger
99c6be1321
Rollup merge of #94754 - c410-f3r:nice-error, r=lcnr
Warn users about `||` in let chain expressions

Or more specifically, warn that `||` operators are forbidden.

This PR is simple so I guess anyone can review 🤷

cc #53667
cc ``@matthewjasper``
2022-03-09 23:14:13 +01:00
Matthias Krüger
ec09e70ee1
Rollup merge of #94739 - estebank:suggest-let-else, r=oli-obk
Suggest `if let`/`let_else` for refutable pat in `let`

r? `````@oli-obk`````
2022-03-09 23:14:11 +01:00
Matthias Krüger
d5c05fcc8a
Rollup merge of #93057 - frengor:iter_collect_into, r=m-ou-se
Add Iterator::collect_into

This PR adds `Iterator::collect_into` as proposed by ``@cormacrelf`` in #48597 (see https://github.com/rust-lang/rust/pull/48597#issuecomment-842083688).
Followup of #92982.

This adds the following method to the Iterator trait:

```rust
fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E
```
2022-03-09 23:14:11 +01:00
Matthias Krüger
2567d0f883
Rollup merge of #92541 - asquared31415:from-docs, r=m-ou-se
Mention intent of `From` trait in its docs

This pr is a docs modification to add to the documentation of the `From` trait a note about its intent as a perfect conversion.  This is already stated in the `TryFrom` docs so this is simply adding that information in a more visible way.
2022-03-09 23:14:10 +01:00
Matthias Krüger
c0259626b6
Rollup merge of #91804 - woppopo:const_clone, r=oli-obk
Make some `Clone` impls `const`

Tracking issue: #91805
`Clone::clone_from` and some impls (Option, Result) bounded on `~const Drop`.

```rust
// core::clone
impl const Clone for INTEGER
impl const Clone for FLOAT
impl const Clone for bool
impl const Clone for char
impl const Clone for !
impl<T: ?Sized> const Clone for *const T
impl<T: ?Sized> const Clone for *mut T
impl<T: ?Sized> const Clone for &T

// core::option
impl<T> const Clone for Option<T>
where
    T: ~const Clone + ~const Drop

// core::result
impl<T, E> const Clone for Result<T, E>
where
    T: ~const Clone + ~const Drop,
    E: ~const Clone + ~const Drop,

// core::convert
impl const Clone for Infallible

// core::ptr
impl<T: ?Sized> const Clone for NonNull<T>
impl<T: ?Sized> const Clone for Unique<T>
```
2022-03-09 23:14:09 +01:00
bors
458262b131 Auto merge of #94779 - GuillaumeGomez:ci-spurious-failures, r=Dylan-DPC
Fix spurious CI failures

This should fix the CI error encountered in https://github.com/rust-lang/rust/pull/94774 (and multiple others).

cc `@nikic`
2022-03-09 20:29:12 +00:00
Guillaume Gomez
18006a60d0 Fix spurious CI failures 2022-03-09 21:28:23 +01:00
fren_gor
63eddb3e68
Add tracking issue 2022-03-09 21:12:07 +01:00
Caio
915f9a599c Warn users about || in let chain expressions 2022-03-09 15:04:09 -03:00
Loïc BRANSTETT
6781016421 Add miri to the well known conditional compilation names and values 2022-03-09 16:58:07 +01:00
Mara Bos
4d56c1563c Add documentation about lifetimes to thread::scope. 2022-03-09 15:20:00 +01:00
b-naber
021c3b011a keep ERROR in message 2022-03-09 14:16:41 +01:00
b-naber
18bb2dd7f1 manually bless 32-bit stderr 2022-03-09 13:39:25 +01:00
Raoul Strackx
491350ce75 Ignore close_read_wakes_up test on SGX platform 2022-03-09 12:28:16 +01:00
b-naber
26fe550670 normalization change and rebase 2022-03-09 11:33:11 +01:00
b-naber
8a811a1213 bless tests 2022-03-09 10:52:04 +01:00
b-naber
40e4bd2d02 treat all mir::Constant values as ConstantKind::Val 2022-03-09 10:52:04 +01:00
bors
10dccdc7fc Auto merge of #94515 - estebank:tweak-move-error, r=davidtwco
Tweak move error

Point at method definition that causes type to be consumed.

Fix #94056.
2022-03-09 08:58:47 +00:00
bors
6045c34f15 Auto merge of #94761 - Dylan-DPC:rollup-v4emqsy, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #94312 (Edit `rustc_trait_selection::infer::lattice` docs)
 - #94583 (Add a team for '`@rustbot` ping fuchsia')
 - #94686 (Do not allow `#[rustc_legacy_const_generics]` on methods)
 - #94699 (BTree: remove dead data needlessly complicating insert)
 - #94756 (Use `unreachable!` for an unreachable code path)
 - #94759 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-09 06:30:19 +00:00
Dylan DPC
822c4b6a92
Rollup merge of #94759 - ehuss:update-cargo, r=ehuss
Update cargo

11 commits in 3d6970d50e30e797b8e26b2b9b1bdf92dc381f34..65c82664263feddc5fe2d424be0993c28d46377a
2022-02-28 19:29:07 +0000 to 2022-03-09 02:32:56 +0000
- Remove remaining 2 warn(clippy::*) instances (rust-lang/cargo#10438)
- Use `available_parallelism` instead of `num_cpus` (rust-lang/cargo#10427)
- Wait up to one second while waiting for curl (rust-lang/cargo#10456)
- Improve code coverage (rust-lang/cargo#10460)
- Don't recommend leaking tokens into the console history (rust-lang/cargo#10458)
- fix some typos (rust-lang/cargo#10454)
- Use `extend` instead of `push`ing in a loop (rust-lang/cargo#10453)
- Use locked_version more (rust-lang/cargo#10449)
- Disable dependabot (rust-lang/cargo#10443)
- Update git2 dependencies (rust-lang/cargo#10442)
- Stop gating stable features (rust-lang/cargo#10434)
2022-03-09 06:38:53 +01:00
Dylan DPC
28d06bdec9
Rollup merge of #94756 - ChrisDenton:unreachable, r=yaahc
Use `unreachable!` for an unreachable code path

Closes #73212
2022-03-09 06:38:53 +01:00
Dylan DPC
4de06d459f
Rollup merge of #94699 - ssomers:btree_prune_insert, r=Dylan-DPC
BTree: remove dead data needlessly complicating insert

Possibly needless instructions generated

r? rust-lang/libs
r? ``@Amanieu``
cc ``@frank-king``
2022-03-09 06:38:52 +01:00
Dylan DPC
3ce01f71ba
Rollup merge of #94686 - ChayimFriedman2:issue-94629, r=jackh726
Do not allow `#[rustc_legacy_const_generics]` on methods

It caused an ICE since `item` was `None`.

Fixes #94629.
2022-03-09 06:38:51 +01:00
Dylan DPC
d365d5eeaf
Rollup merge of #94583 - dtolnay:fuchsia, r=Mark-Simulacrum
Add a team for '@rustbot ping fuchsia'

I was looking for this in response to https://github.com/rust-lang/rust/pull/93858#issuecomment-1041367498.

Depends on https://github.com/rust-lang/team/pull/710.
2022-03-09 06:38:50 +01:00
Dylan DPC
2b17c27626
Rollup merge of #94312 - pierwill:fix-94311-lattice-docs, r=jackh726
Edit `rustc_trait_selection::infer::lattice` docs

Closes #94311.

Removes mentions of outdated/missing type and filename (`infer.rs` and `LatticeValue`).
2022-03-09 06:38:50 +01:00
Eric Huss
6fee0b0b71 Update cargo 2022-03-08 20:28:22 -08:00
bors
163c207fc2 Auto merge of #94750 - cuviper:dirent64_min, r=joshtriplett
unix: reduce the size of DirEntry

On platforms where we call `readdir` instead of `readdir_r`, we store
the name as an allocated `CString` for variable length. There's no point
carrying around a full `dirent64` with its fixed-length `d_name` too.
2022-03-09 02:17:58 +00:00
Chris Denton
57442beb18
Use unreachable! for an unreachable code path 2022-03-09 01:05:47 +00:00
bors
803a759304 Auto merge of #94751 - Dylan-DPC:rollup-zr7viw0, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #94689 (Use impl substs in `#[rustc_on_unimplemented]`)
 - #94714 (Enable `close_read_wakes_up` test on Windows)
 - #94723 (Add core::hint::must_use)
 - #94724 (unix: Avoid name conversions in `remove_dir_all_recursive`)
 - #94730 (Reverted atomic_mut_ptr feature removal causing compilation break)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-08 22:06:07 +00:00
Dylan DPC
5629026e90
Rollup merge of #94730 - msabansal:sabansal/b-atomic-mut-ptr, r=Dylan-DPC
Reverted atomic_mut_ptr feature removal causing compilation break

Fixes a regression introduced as part of https://github.com/rust-lang/rust/pull/94546

Std no longer compiles on nightly while using the following commnd:

export RUSTFLAGS='-C target-feature=+atomics,+bulk-memory'
cargo build --target wasm32-unknown-unknown -Z build-std=panic_abort,std

I can help add tests to avoid future breaks but i couldn't understand the test framework
2022-03-08 22:44:01 +01:00
Dylan DPC
a67b6299b4
Rollup merge of #94724 - cuviper:rmdirall-cstr, r=Dylan-DPC
unix: Avoid name conversions in `remove_dir_all_recursive`

Each recursive call was creating an `OsString` for a `&Path`, only for
it to be turned into a `CString` right away. Instead we can directly
pass `.name_cstr()`, saving two allocations each time.
2022-03-08 22:44:00 +01:00
Dylan DPC
ff54e34463
Rollup merge of #94723 - dtolnay:mustuse, r=Mark-Simulacrum
Add core::hint::must_use

The example code in this documentation is minimized from a real-world situation in the `anyhow` crate where this function would have been valuable.

Having this provided by the standard library is especially useful for proc macros, even more than for macro_rules. That's because proc macro crates aren't allowed to export anything other than macros, so they couldn't make their own `must_use` function for their macro-generated code to call.

<br>

## Rendered documentation

> An identity function that causes an `unused_must_use` warning to be triggered if the given value is not used (returned, stored in a variable, etc) by the caller.
>
> This is primarily intended for use in macro-generated code, in which a [`#[must_use]` attribute][must_use] either on a type or a function would not be convenient.
>
> [must_use]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute
>
> ### Example
>
> ```rust
> #![feature(hint_must_use)]
>
> use core::fmt;
>
> pub struct Error(/* ... */);
>
> #[macro_export]
> macro_rules! make_error {
>     ($($args:expr),*) => {
>         core::hint::must_use({
>             let error = $crate::make_error(core::format_args!($($args),*));
>             error
>         })
>     };
> }
>
> // Implementation detail of make_error! macro.
> #[doc(hidden)]
> pub fn make_error(args: fmt::Arguments<'_>) -> Error {
>     Error(/* ... */)
> }
>
> fn demo() -> Option<Error> {
>     if true {
>         // Oops, meant to write `return Some(make_error!("..."));`
>         Some(make_error!("..."));
>     }
>     None
> }
> ```
>
> In the above example, we'd like an `unused_must_use` lint to apply to the value created by `make_error!`. However, neither `#[must_use]` on a struct nor `#[must_use]` on a function is appropriate here, so the macro expands using `core::hint::must_use` instead.
>
> - We wouldn't want `#[must_use]` on the `struct Error` because that would make the following unproblematic code trigger a warning:
>
>   ```rust
>   fn f(arg: &str) -> Result<(), Error>
>
>   #[test]
>   fn t() {
>       // Assert that `f` returns error if passed an empty string.
>       // A value of type `Error` is unused here but that's not a problem.
>       f("").unwrap_err();
>   }
>   ```
>
> - Using `#[must_use]` on `fn make_error` can't help because the return value *is* used, as the right-hand side of a `let` statement. The `let` statement looks useless but is in fact necessary for ensuring that temporaries within the `format_args` expansion are not kept alive past the creation of the `Error`, as keeping them alive past that point can cause autotrait issues in async code:
>
>   ```rust
>   async fn f() {
>       // Using `let` inside the make_error expansion causes temporaries like
>       // `unsync()` to drop at the semicolon of that `let` statement, which
>       // is prior to the await point. They would otherwise stay around until
>       // the semicolon on *this* statement, which is after the await point,
>       // and the enclosing Future would not implement Send.
>       log(make_error!("look: {:p}", unsync())).await;
>   }
>
>   async fn log(error: Error) {/* ... */}
>
>   // Returns something without a Sync impl.
>   fn unsync() -> *const () {
>       0 as *const ()
>   }
>   ```
2022-03-08 22:43:59 +01:00
Dylan DPC
ee8109d12d
Rollup merge of #94714 - ChrisDenton:win-close_read_wakes_up, r=Mark-Simulacrum
Enable `close_read_wakes_up` test on Windows

I wonder if we could/should try enabling this again? It was closed by #38867 due to #31657. I've tried running this test (along with other tests) on my machine a number of times and haven't seen this fail yet,

Caveat: the worst that can happen is this succeeds initially but then causes random hangs in CI. This is not a great failure mode and would be a reason not to do this.

If this does work out, closes #39006

r? `@Mark-Simulacrum`
2022-03-08 22:43:57 +01:00
Dylan DPC
568736b98f
Rollup merge of #94689 - compiler-errors:on-unimplemented-substs, r=petrochenkov
Use impl substs in `#[rustc_on_unimplemented]`

We were using the trait-ref substs instead of impl substs in `rustc_on_unimplemented`, even when computing the `rustc_on_unimplemented` attached to an impl block. Let's not do that.

This PR also untangles impl and trait def-ids in the logic in `on_unimplemented` a bit.

Fixes #94675
2022-03-08 22:43:56 +01:00
Josh Stone
e8b9ba84be unix: reduce the size of DirEntry
On platforms where we call `readdir` instead of `readdir_r`, we store
the name as an allocated `CString` for variable length. There's no point
carrying around a full `dirent64` with its fixed-length `d_name` too.
2022-03-08 13:36:01 -08:00
bors
1eb72580d0 Auto merge of #94702 - b-naber:static-refs-mir, r=lcnr
Reinstate #93800

https://github.com/rust-lang/rust/pull/93800 caused a regression in an alt builder with parallel enabled. https://github.com/rust-lang/rust/pull/94205 reverted that PR because of the regression. For an unknown reason the regression has disappeared, so we reinstate the changes in https://github.com/rust-lang/rust/pull/93800 here.

r? `@Mark-Simulacrum`
2022-03-08 19:25:19 +00:00
David Tolnay
b2473e988f
Add core::hint::must_use 2022-03-08 10:58:03 -08:00
Esteban Kuber
c3a998e82a Do not suggest let_else if no bindings would be introduced 2022-03-08 17:20:05 +00:00
bors
64187b8374 Auto merge of #92260 - jyn514:less-python-logic, r=Mark-Simulacrum
Move some more bootstrap logic from python to rust

Same rationale as https://github.com/rust-lang/rust/pull/76544; it would be nice to make python entirely optional at some point.

This also removes $ROOT as an option for the build directory; I haven't been using it, and like Alex
said in https://github.com/rust-lang/rust/pull/76544#discussion_r488248930 it seems like a misfeature.

This allows running `cargo run` from src/bootstrap, although that still gives
lots of compile errors if you don't use the beta toolchain. It's not exactly the same as using `x.py`, since it won't have `BOOTSTRAP_DOWNLOAD_RUSTC` set, but it's pretty close. Doing this from the top-level directory requires https://github.com/rust-lang/cargo/issues/7290 to be fixed, or using `cargo run -p bootstrap`.

The next steps for making python optional are to move download-ci-llvm and download-rustc support into rustbuild, likely be shelling out as the python scripts do today.

It would also be nice (although not required) to move submodule support there, but that would require taking bootstrap out of the workspace to avoid errors from crates that haven't been cloned yet.

r? `@Mark-Simulacrum`
2022-03-08 17:04:45 +00:00