Commit graph

164273 commits

Author SHA1 Message Date
Nicholas Nethercote ca5525d564 Improve AdtDef interning.
This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.
2022-03-11 13:31:24 +11:00
bors 5f4e067719 Auto merge of #94814 - matthiaskrgr:rollup-a5sk366, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #94440 (Better error for normalization errors from parent crates that use `#![feature(generic_const_exprs)]`)
 - #94587 (Document new recommended use of `FromIterator::from_iter`)
 - #94644 (Fix soundness issue in scoped threads.)
 - #94740 (Unify impl blocks by wrapping them into a div)
 - #94753 (Improve rustdoc book)
 - #94796 (Allow `cargo run` instead of `cargo run -p bootstrap`)
 - #94805 (Revert accidental stabilization)
 - #94809 (RustWrapper: add missing include)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-10 18:28:45 +00:00
Matthias Krüger 07e4fbde5a
Rollup merge of #94809 - durin42:llvm-15-modulepass, r=nikic
RustWrapper: add missing include

This is required after LLVM change 3c4410dfcaaf (aka
https://reviews.llvm.org/D121168) did some includes cleanup.

r? nikic
2022-03-10 19:00:12 +01:00
Matthias Krüger af35dc2a95
Rollup merge of #94805 - oli-obk:drop_box, r=pnkfelix
Revert accidental stabilization

fixes #94804
2022-03-10 19:00:11 +01:00
Matthias Krüger fa685a5499
Rollup merge of #94796 - jyn514:cargo-run-bootstrap, r=Mark-Simulacrum
Allow `cargo run` instead of `cargo run -p bootstrap`

This was part of `@Mark-Simulacrum` 's original PR in ecb424f129,
but I missed it when writing #92260.

This also has the side effect of allowing `cargo build --bins` instead of `cargo build -p bootstrap --bins`. I'm not sure when you would want to run cargo build/check/test without going through bootstrap, but this still allows you to do so as long as you pass `-p` for all the crates you want to build.
2022-03-10 19:00:10 +01:00
Matthias Krüger ec99104414
Rollup merge of #94753 - Urgau:rustdoc-book-improvements, r=GuillaumeGomez
Improve rustdoc book

This pull-request improves the `rustdoc` book by doing some (light) cleanup, by merging some stuff, by adding some missing stuff (like tracking issues links, for those who had one) and also by moving some chapter's into sub-chapter's to improve the flow of the book.

~~Note that I locally tested with `mdbook-lintcheck` that no links became accidentally broken.~~ (Not enough, ;-))

r? `````@GuillaumeGomez`````
2022-03-10 19:00:09 +01:00
Matthias Krüger 82215ce646
Rollup merge of #94740 - GuillaumeGomez:unify-impl-blocks, r=notriddle
Unify impl blocks by wrapping them into a div

The blanket and "auto traits" sections are wrapped into a `div` with an ID. This PR fixes this incoherence by wrapping each impl section (the "deref impl" and the "inherent impl" sections were missing it). It'll also make some tests simpler to write.

r? `````@notriddle`````
2022-03-10 19:00:08 +01:00
Matthias Krüger f1a677789a
Rollup merge of #94644 - m-ou-se:scoped-threads-drop-soundness, r=joshtriplett
Fix soundness issue in scoped threads.

This was discovered in https://github.com/rust-lang/rust/pull/94559#discussion_r820116323

The `scope()` function returns when all threads are finished, but I accidentally considered a thread 'finished' before dropping their panic payload or ignored return value.

So if a thread returned (or panics with) something that in its `Drop` implementation still uses borrowed stuff, it goes wrong.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=2a1f19ac4676cdabe43e24e536ff9358
2022-03-10 19:00:07 +01:00
Matthias Krüger b5127202b2
Rollup merge of #94587 - JKAnderson409:issue-90107-fix, r=scottmcm
Document new recommended use of `FromIterator::from_iter`

#90107
Most of the added prose was paraphrased from the links provided in the issue. The suggested `VecDeque` example seemed to make the point well enough so I just used that.
2022-03-10 19:00:06 +01:00
Matthias Krüger b41374598f
Rollup merge of #94440 - compiler-errors:issue-94282, r=lcnr
Better error for normalization errors from parent crates that use `#![feature(generic_const_exprs)]`

This PR implements a somewhat rudimentary heuristic to suggest using `#![feature(generic_const_exprs)]` in a child crate when a function from a foreign crate (that may have used `#![feature(generic_const_exprs)]`) fails to normalize during codegen.

cc: #79018
cc: #94287
2022-03-10 19:00:05 +01:00
Augie Fackler 185e3b95ca RustWrapper: add missing include
This is required after LLVM change 3c4410dfcaaf (aka
https://reviews.llvm.org/D121168) did some includes cleanup.
2022-03-10 11:16:33 -05:00
Oli Scherer 5f7ca55df6 Revert accidental stabilization 2022-03-10 14:36:51 +00:00
bors ba14a836c7 Auto merge of #94802 - matthiaskrgr:rollup-4plu0fi, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #92150 (Improve suggestion when casting usize to (possibly) wide pointer)
 - #94635 (Merge `#[deprecated]` and `#[rustc_deprecated]`)
 - #94657 (Constify `Index{,Mut}` for `[T]`, `str`, and `[T; N]`)
 - #94746 (diagnostics: use rustc_on_unimplemented to recommend `[].iter()`)
 - #94788 (Account for suggestions for complete removal of lines)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-10 12:32:01 +00:00
Matthias Krüger 6bbaca7d03
Rollup merge of #94788 - estebank:removal-suggestion, r=petrochenkov
Account for suggestions for complete removal of lines

Fix  #94192.
2022-03-10 12:20:54 +01:00
Matthias Krüger e7281d08de
Rollup merge of #94746 - notriddle:notriddle/method-rustc-on-unimplemented, r=davidtwco
diagnostics: use rustc_on_unimplemented to recommend `[].iter()`

To make this work, the `#[rustc_on_unimplemented]` data needs to be used to
report method resolution errors, which is most of what this commit does.

Fixes #94581
2022-03-10 12:20:53 +01:00
Matthias Krüger fe034cb43b
Rollup merge of #94657 - fee1-dead:const_slice_index, r=oli-obk
Constify `Index{,Mut}` for `[T]`, `str`, and `[T; N]`

Several panic functions were rewired (via `const_eval_select`) to simpler implementations that do not require formatting for compile-time usage.

r? ```@oli-obk```
2022-03-10 12:20:52 +01:00
Matthias Krüger 313a668234
Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwco
Merge `#[deprecated]` and `#[rustc_deprecated]`

The first commit makes "reason" an alias for "note" in `#[rustc_deprecated]`, while still prohibiting it in `#[deprecated]`.

The second commit changes "suggestion" to not just be a feature of `#[rustc_deprecated]`. This is placed behind the new `deprecated_suggestion` feature. This needs a tracking issue; let me know if this PR will be approved and I can create one.

The third commit is what permits `#[deprecated]` to be used when `#![feature(staged_api)]` is enabled. This isn't yet used in stdlib (only tests), as it would require duplicating all deprecation attributes until a bootstrap occurs. I intend to submit a follow-up PR that replaces all uses and removes the remaining `#[rustc_deprecated]` code after the next bootstrap.

`@rustbot` label +T-libs-api +C-feature-request +A-attributes +S-waiting-on-review
2022-03-10 12:20:51 +01:00
Matthias Krüger 7473750b13
Rollup merge of #92150 - compiler-errors:better_usize_to_wide_ptr_cast, r=petrochenkov
Improve suggestion when casting usize to (possibly) wide pointer

I thought #92125 was a wonderful idea, so I went ahead and took a stab at it. Not sure if my approach is the best going forward, but I'm happy with the improvement in the error message.

Iwill definitely address any changes if people are more opinionated with the wordings or want more features.

Also, do I need to add a new error code?

(Fixes #92125)
2022-03-10 12:20:50 +01:00
bors 282778aee2 Auto merge of #94764 - nikic:update-llvm-3, r=nagisa
Update LLVM submodule

This merges upstream changes from the 14.x release branch.

Fixes #89609.
Fixes #93923.
Fixes #94032.
2022-03-10 08:56:02 +00: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
Joshua Nelson 687e53ebfe Allow cargo run instead of cargo run -p bootstrap
This was part of Mark's original PR in ecb424f129,
but I missed it when writing #92260.
2022-03-09 22:37:44 -06: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
Esteban Kuber ac2afa0334 Account for suggestions for complete removal of lines
Fix  #94192.
2022-03-09 23:51:10 +00:00
Michael Goulet 814c18a6dc better suggestion for int to wide ptr cast 2022-03-09 15:34:39 -08:00
Michael Goulet 109cdc754e suggest enabling generic_const_exprs feature if const is unevaluatable 2022-03-09 14:47:50 -08: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
Jacob Pratt 38478ea0cd
Permit #[deprecated] in stdlib 2022-03-09 16:32:47 -05:00
Jacob Pratt 5636655d0f
New deprecated_suggestion feature, use in tests 2022-03-09 16:32:47 -05: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
Michael Howell 32d7f8145a diagnostics: use rustc_on_unimplemented to recommend [].iter()
To make this work, the `#[rustc_on_unimplemented]` data needs to be used to
report method resolution errors, which is most of what this commit does.

Fixes #94581
2022-03-09 09:52:55 -07: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
Loïc BRANSTETT e346920907 Also take in account mdbook redirect in linkchecker 2022-03-09 13:45:50 +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
Mara Bos b97d87518d Add soundness test for dropping scoped thread results before joining. 2022-03-09 11:47:53 +01:00
Mara Bos 1c06eb7c1f Remove outdated comment. 2022-03-09 11:47:46 +01:00
Mara Bos 7a481ff8a4 Properly abort when thread result panics on drop. 2022-03-09 11:44:24 +01:00