Commit graph

165746 commits

Author SHA1 Message Date
bors
fe5b13d681 Auto merge of #97128 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum
[stable] 1.61 stable rebuild

* New version of release notes (from as-yet unmerged https://github.com/rust-lang/rust/pull/96539)
* Manual patch to drop clippy's needless_match lint to nursery, per [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/release.201.2E61.2E0/near/282717457)

r? `@Mark-Simulacrum`
2022-05-18 01:29:06 +00:00
Mark Rousskov
f9567f1b0f Drop needless match to clippy's nursery
This lint has a false positive and there's not an easy backport available,
particularly given how late in the cycle we are at this point.
2022-05-17 19:07:06 -04:00
Mark Rousskov
2775176349 Adjust release notes per upstream 2022-05-17 18:52:18 -04:00
bors
66a356df85 Auto merge of #97084 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum
[stable] Rust 1.61

* Cherry-picking release notes from not yet landed #96539.

r? `@Mark-Simulacrum`
2022-05-16 19:54:00 +00:00
Mark Rousskov
6a51206394 Switch to stable channel 2022-05-16 12:57:38 -04:00
Mark Rousskov
e48839d840 Add release notes
Cherry-picking from not yet landed PR#96539.
2022-05-16 12:56:18 -04:00
bors
30a51465e2 Auto merge of #97040 - cjgillot:no-rpit-hrtb-beta, r=jackh726
Forbid nested opaque types to reference HRTB from opaque types.

Backport version of https://github.com/rust-lang/rust/pull/97039 if useful.

r? `@Mark-Simulacrum`
2022-05-14 18:28:15 +00:00
Camille GILLOT
7d0f04a218 Add a test with both passing and erroneous cases. 2022-05-14 17:03:56 +02:00
Camille GILLOT
c98eae6b8f Forbid nested opaque types to reference HRTB from opaque types. 2022-05-14 11:37:40 +02:00
bors
eb1e588e1d Auto merge of #97014 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backports

This backports/rolls up:

*  Quick fix for #96223. #96679
*  [beta] Revert #92519 on beta #96556
*  [beta] Clippy backport ICE/infinite loop fix #96740
*  Revert "Prefer projection candidates instead of param_env candidates for Sized predicates" #96593
2022-05-14 00:35:33 +00:00
Jack Huey
97f0d7fdbb Revert #92191 Prefer projection candidates instead of param_env candidates for Sized predicates 2022-05-13 15:14:32 -04:00
Mark Rousskov
169374fdf3 Fix UI test 2022-05-13 10:29:41 -04:00
flip1995
7d3bb1dd2d Move only_used_in_recursion to nursery 2022-05-13 10:04:30 -04:00
flip1995
096a7ca120 Prevent infinite (exponential) recursion in only_used_in_recursion
This simplifies the visitor code a bit and prevents checking expressions
multiple times. I still think this lint should be removed for now,
because its code isn't really tested.
2022-05-13 10:04:21 -04:00
ricked-twice
6db7d1bc83 Taking review hints into account. 2022-05-13 10:03:08 -04:00
ricked-twice
5046d91e54 Quick fix for #96223. 2022-05-13 10:03:07 -04:00
Chris Denton
2a5c4e998c Revert "Rollup merge of #92519 - ChrisDenton:command-maybe-verbatim, r=dtolnay"
This reverts commit ba2d5ede70, reversing
changes made to 9b701e7eaa.
2022-05-13 10:02:52 -04:00
bors
cf5fd89474 Auto merge of #96692 - ehuss:beta-backports, r=ehuss
[beta] Beta backports

* Revert diagnostic duplication and accidental stabilization #96516
* Revert "Re-export core::ffi types from std::ffi" #96492
* Make [e]println macros eagerly drop temporaries (for backport) #96490
* Revert "impl From<&[T; N]> and From<&mut [T; N]> for Vec<T>" #96489
* Cargo:
    * move workspace inheritance unstable docs to the correct place (rust-lang/cargo#10616)
2022-05-04 17:49:52 +00:00
Dylan DPC
1c78743574 Rollup merge of #96516 - oli-obk:impl_trait_inference_accidental_permitted, r=jackh726
Revert diagnostic duplication and accidental stabilization

fixes #96460

this is an accidental stabilization that we should put into the beta. I believe it is low-risk, because it was literally what we had before #94081

The effect on tests is massive, but mostly deduplication of diagnostics and some minor span changes.
2022-05-03 22:09:49 -07:00
Dylan DPC
d5ae8b5d70 Rollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahc
Revert "Re-export core::ffi types from std::ffi"

This reverts commit 9aed829fe6.

Fixes https://github.com/rust-lang/rust/issues/96435 , a regression
in crates doing `use std::ffi::*;` and `use std::os::raw::*;`.

We can re-add this re-export once the `core::ffi` types
are stable, and thus the `std::os::raw` types can become re-exports as
well, which will avoid the conflict. (Type aliases to the same type
still conflict, but re-exports of the same type don't.)
2022-05-03 21:30:44 -07:00
bors
be781f28a5 Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrum
Make [e]println macros eagerly drop temporaries (for backport)

This PR extracts the subset of #96455 which is only the parts necessary for fixing the 1.61-beta regressions in #96434.

My larger PR #96455 contains a few other changes relative to the pre-#94868 behavior; those are not necessary to backport into 1.61.

argument position | before #94868 | after #94868 | after this PR
--- |:---:|:---:|:---:
`write!($tmp, "…", …)` | 😡 | 😡 | 😡
`write!(…, "…", $tmp)` | 😡 | 😡 | 😡
`writeln!($tmp, "…", …)` | 😡 | 😡 | 😡
`writeln!(…, "…", $tmp)` | 😡 | 😡 | 😡
`print!("…", $tmp)` | 😡 | 😡 | 😡
`println!("…", $tmp)` | 😺 | 😡 | 😺
`eprint!("…", $tmp)` | 😡 | 😡 | 😡
`eprintln!("…", $tmp)` | 😺 | 😡 | 😺
`panic!("…", $tmp)` | 😺 | 😺 | 😺
2022-05-03 21:23:15 -07:00
bors
d55330c151 Auto merge of #96489 - shepmaster:revert-vec-from-array-ref, r=yaahc
Revert "impl From<&[T; N]> and From<&mut [T; N]> for Vec<T>"

This reverts commit 5dd702763a.
2022-05-03 21:22:56 -07:00
Eric Huss
b802d2da44 [beta] Update cargo 2022-05-03 21:21:45 -07:00
bors
69a6d12e9f Auto merge of #96367 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backports rollup

*  Remove NodeIdHashingMode. #95656
*  Check that all hidden types are the same and then deduplicate them. #95731

r? `@Mark-Simulacrum`
2022-04-25 00:40:51 +00:00
Mark Rousskov
d76101d8d8 Backport fixes -- drop uses of NodeIdHashingMode 2022-04-24 17:36:51 -04:00
Camille GILLOT
7ce8e0ef2a Bless tests. 2022-04-24 17:26:44 -04:00
Camille GILLOT
20a451e72d Remove NodeIdHashingMode. 2022-04-24 17:26:43 -04:00
Oli Scherer
6a5f43d6e9 Check that all hidden types are the same and then deduplicate them. 2022-04-24 17:25:46 -04:00
bors
2431a974c2 Auto merge of #96138 - erikdesjardins:revertinl, r=Mark-Simulacrum
[beta] Revert: Make TLS __getit #[inline(always)] on non-Windows

Fixes #96132

r? `@Mark-Simulacrum`
2022-04-17 15:58:32 +00:00
Erik Desjardins
6a8a8f58c1 Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum"
This reverts commit 035a717ee8, reversing
changes made to 761e888485.
2022-04-17 02:10:40 -04:00
bors
7c13df8537 Auto merge of #95806 - pietroalbini:pa-1.61.0-beta-stage0, r=Mark-Simulacrum
[beta] Bump stage0 to 1.60.0

r? `@Mark-Simulacrum`
2022-04-09 18:01:08 +00:00
Pietro Albini
08f54d2029
bump stage0 to 1.60.0 2022-04-08 15:55:11 +02:00
bors
0f231250ba Auto merge of #95641 - pietroalbini:pa-1.61.0-beta, r=pietroalbini
Prepare 1.61.0 beta release

Just a channel and RLS bump this time.

r? `@ghost`
2022-04-05 07:23:45 +00:00
Pietro Albini
a7bf4677ea
bump rls 2022-04-05 09:16:26 +02:00
Pietro Albini
2729fd8216
bump channel to beta 2022-04-04 11:45:28 +02:00
bors
ec667fbcfc Auto merge of #95031 - compiler-errors:param-env-cache, r=Aaron1011
Do not use `ParamEnv::and` when building a cache key from a param-env and trait eval candidate

Do not use `ParamEnv::and` to cache a param-env with a selection/evaluation candidate.

This is because if the param-env is `RevealAll` mode, and the candidate looks global (i.e. it has erased regions, which can show up when we normalize a projection type under a binder<sup>1</sup>), then when we use `ParamEnv::and` to pair the candidate and the param-env for use as a cache key, we will throw away the param-env's caller bounds, and we'll end up caching a candidate that we inferred from the param-env with a empty param-env, which may cause cache-hit later when we have an empty param-env, and possibly mess with normalization like we see in the referenced issue during codegen.

Not sure how to trigger this with a more structured test, but changing `check-pass` to `build-pass` triggers the case that https://github.com/rust-lang/rust/issues/94903 detected.

<sup>1.</sup> That is, we will replace the late-bound region with a placeholder, which gets canonicalized and turned into an infererence variable, which gets erased during region freshening right before we cache the result. Sorry, it's quite a few steps.

Fixes #94903
r? `@Aaron1011` (or reassign as you see fit)
2022-04-04 04:48:36 +00:00
bors
ac4b3450ed Auto merge of #95606 - petrochenkov:linkregr, r=wesleywiser
linker: Implicitly link native libs as whole-archive in some more cases

Partially revert changes from https://github.com/rust-lang/rust/pull/93901 to address regressions like https://github.com/rust-lang/rust/issues/95561.

Fixes https://github.com/rust-lang/rust/issues/95561
r? `@wesleywiser`
2022-04-04 02:23:15 +00:00
bors
596deceaac Auto merge of #95619 - bjorn3:inline_location_caller, r=scottmcm
Mark Location::caller() as #[inline]

This function gets compiled to a single register move as it actually gets it's return value passed in as argument.
2022-04-03 23:42:31 +00:00
bors
6af09d2505 Auto merge of #95624 - Dylan-DPC:rollup-r8w7ui3, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #95202 (Reduce the cost of loading all built-ins targets)
 - #95553 (Don't emit non-asm contents error for naked function composed of errors)
 - #95613 (Fix rustdoc attribute display)
 - #95617 (Fix &mut invalidation in ptr::swap doctest)
 - #95618 (core: document that the align_of* functions return the alignment in bytes)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-03 21:22:50 +00:00
Dylan DPC
1ea6e93610
Rollup merge of #95618 - adamse:master, r=dtolnay
core: document that the align_of* functions return the alignment in bytes
2022-04-03 23:21:45 +02:00
Dylan DPC
f7f2d83eda
Rollup merge of #95617 - saethlin:swap-test-invalidation, r=Dylan-DPC
Fix &mut invalidation in ptr::swap doctest

Under Stacked Borrows with raw pointer tagging, the previous code was UB
because the code which creates the the second pointer borrows the array
through a tag in the borrow stacks below the Unique tag that our first
pointer is based on, thus invalidating the first pointer.

This is not definitely a bug and may never be real UB, but I desperately
want people to write code that conforms to SB with raw pointer tagging
so that I can write good diagnostics. The alternative aliasing models
aren't possible to diagnose well due to state space explosion.
Therefore, it would be super cool if the standard library nudged people
towards writing code that is valid with respect to SB with raw pointer
tagging.

The diagnostics that I want to write are implemented in a branch of Miri and the one for this case is below:
```
error: Undefined Behavior: attempting a read access using <2170> at alloc1068[0x0], but that tag does not exist in the borrow stack for this location
    --> /home/ben/rust/library/core/src/intrinsics.rs:2103:14
     |
2103 |     unsafe { copy_nonoverlapping(src, dst, count) }
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |              |
     |              attempting a read access using <2170> at alloc1068[0x0], but that tag does not exist in the borrow stack for this location
     |              this error occurs as part of an access at alloc1068[0x0..0x8]
     |
     = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
     = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <2170> was created due to a retag at offsets [0x0..0x10]
    --> ../libcore/src/ptr/mod.rs:640:9
     |
8    | let x = array[0..].as_mut_ptr() as *mut [u32; 2]; // this is `array[0..2]`
     |         ^^^^^^^^^^^^^^^^^^^^^^^
help: <2170> was later invalidated due to a retag at offsets [0x0..0x10]
    --> ../libcore/src/ptr/mod.rs:641:9
     |
9    | let y = array[2..].as_mut_ptr() as *mut [u32; 2]; // this is `array[2..4]`
     |         ^^^^^
     = note: inside `std::intrinsics::copy_nonoverlapping::<[u32; 2]>` at /home/ben/rust/library/core/src/intrinsics.rs:2103:14
     = note: inside `std::ptr::swap::<[u32; 2]>` at /home/ben/rust/library/core/src/ptr/mod.rs:685:9
note: inside `main::_doctest_main____libcore_src_ptr_mod_rs_635_0` at ../libcore/src/ptr/mod.rs:12:5
    --> ../libcore/src/ptr/mod.rs:644:5
     |
12   |     ptr::swap(x, y);
     |     ^^^^^^^^^^^^^^^
note: inside `main` at ../libcore/src/ptr/mod.rs:15:3
    --> ../libcore/src/ptr/mod.rs:647:3
     |
15   | } _doctest_main____libcore_src_ptr_mod_rs_635_0() }
     |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error
```
2022-04-03 23:21:43 +02:00
Dylan DPC
5925c8ee79
Rollup merge of #95613 - GuillaumeGomez:fix-rustdoc-attr-display, r=notriddle
Fix rustdoc attribute display

Fixes #81482.

r? `@notriddle`
2022-04-03 23:21:43 +02:00
Dylan DPC
19a90c7018
Rollup merge of #95553 - jam1garner:naked-function-compile-error, r=tmiasko
Don't emit non-asm contents error for naked function composed of errors

## Motivation

For naked functions an error is emitted when they are composed of anything other than a single asm!() block. However, this error triggers in a couple situations in which it adds no additional information or is actively misleading.

One example is if you do have an asm!() block but simply one with a syntax error:
```rust
#[naked]
unsafe extern "C" fn compiler_errors() {
    asm!(invalid_syntax)
}
```

This results in two errors, one for the syntax error itself and another telling you that you need an asm block in your function:

```rust
error[E0787]: naked functions must contain a single asm block
 --> src/main.rs:6:1
  |
6 | / unsafe extern "C" fn naked_compile_error() {
7 | |     asm!(blah)
8 | | }
  | |_^
```

This issue also comes up when [utilizing `compile_error!()` for improving your diagnostics](https://twitter.com/steveklabnik/status/1509538243020218372), such as raising a compiler error when compiling for an unsupported target.

## Implementation

The rules this PR implements are as follows:

1. If any non-erroneous  non-asm statement is included, an error will still occur
2. If multiple asm statements are included, an error will still occur
3. If 0 or 1 asm statements are present, as well as any non-zero number of erroneous statements, then this error will *not* be raised as it is likely either redundant or incorrect

The rule of thumb is effectively "if an error is present and its correction could change things, don't raise an error".
2022-04-03 23:21:42 +02:00
Dylan DPC
796bc7e9aa
Rollup merge of #95202 - Urgau:check-cfg-perf-well-known-values, r=petrochenkov
Reduce the cost of loading all built-ins targets

This PR started by measuring the exact slowdown of checking of well known conditional values.
Than this PR implemented some technics to reduce the cost of loading all built-ins targets.

cf. https://github.com/rust-lang/rust/issues/82450#issuecomment-1073992323
2022-04-03 23:21:41 +02:00
Ben Kimock
f4a7ed4338 Fix &mut invalidation in ptr::swap doctest
Under Stacked Borrows with raw pointer tagging, the previous code was UB
because the code which creates the the second pointer borrows the array
through a tag in the borrow stacks below the Unique tag that our first
pointer is based on, thus invalidating the first pointer.

This is not definitely a bug and may never be real UB, but I desperately
want people to write code that conforms to SB with raw pointer tagging
so that I can write good diagnostics. The alternative aliasing models
aren't possible to diagnose well due to state space explosion.
Therefore, it would be super cool if the standard library nudged people
towards writing code that is valid with respect to SB with raw pointer
tagging.
2022-04-03 16:16:33 -04:00
Loïc BRANSTETT
1a1f5b89a4 Cleanup after some refactoring in rustc_target 2022-04-03 21:29:57 +02:00
Loïc BRANSTETT
c16a558f24 Replace LinkArgs with Cow<'static, str> 2022-04-03 21:29:57 +02:00
Loïc BRANSTETT
ce61d4044d Replace every Vec in Target(Options) with it's Cow equivalent 2022-04-03 21:29:57 +02:00
Loïc BRANSTETT
ccff48f97b Replace every String in Target(Options) with Cow<'static, str> 2022-04-03 21:29:57 +02:00
bors
2ad4eb207b Auto merge of #95610 - createyourpersonalaccount:derefmut-docfix, r=Dylan-DPC
Improve doc example of DerefMut

It is more illustrative, after using `*x` to modify the field, to show
in the assertion that the field has indeed been modified.
2022-04-03 19:06:20 +00:00