Commit graph

151775 commits

Author SHA1 Message Date
Mark Rousskov
a44abe58ea Add missing winapi feature to workspace hack 2021-07-23 08:15:40 -04:00
Igor Matuszewski
5fcb726f6c Fix formatting in tidy exception list 2021-07-21 21:08:39 +02:00
Igor Matuszewski
bf12f340ee Clean up now unused deps from the exceptions list 2021-07-21 20:37:50 +02:00
Igor Matuszewski
af53b0d9d4 Update RLS 2021-07-21 15:17:31 +02:00
bors
cf932aa584 Auto merge of #86847 - tlyu:stdin-forwarders, r=joshtriplett
add `Stdin::lines`, `Stdin::split` forwarder methods

Add forwarder methods `Stdin::lines` and `Stdin::split`, which consume
and lock a `Stdin` handle, and forward on to the corresponding `BufRead`
methods. This should make it easier for beginners to use those iterator
constructors without explicitly dealing with locks or lifetimes.

Replaces #86412.
~~Based on #86846 to get the tracking issue number for the `stdio_locked` feature.~~ Rebased after merge, so it's only one commit now.

r? `@joshtriplett`
`@rustbot` label +A-io +C-enhancement +D-newcomer-roadblock +T-libs-api
2021-07-21 06:06:37 +00:00
bors
ac575b64ed Auto merge of #82653 - jyn514:submodules-on-demand, r=Mark-Simulacrum
Update all submodules that rustbuild doesn't depend on lazily

This only updates the submodules the first time they're needed, instead
of unconditionally the first time you run x.py.

Ideally, this would move *all* submodules to rustbuild and not exclude some tools and
backtrace. Unfortunately, cargo requires all `Cargo.toml` files in the
whole workspace to be present to build any crate.

On my machine, this takes the time for an initial submodule clone (for
`x.py --help`) from 55.70 to 15.87 seconds.

Helps with https://github.com/rust-lang/rust/issues/76653. Builds on https://github.com/rust-lang/rust/pull/86015 and should not be merged before (only the last commit is relevant).
2021-07-21 03:36:21 +00:00
Joshua Nelson
2ac0e9b694 Update all submodules that rustbuild doesn't depend on lazily
This only updates the submodules the first time they're needed, instead
of unconditionally the first time you run x.py.

Ideally, this would move *all* submodules and not exclude some tools and
backtrace. Unfortunately, cargo requires all `Cargo.toml` files in the
whole workspace to be present to build any crate.

On my machine, this takes the time for an initial submodule clone (for
`x.py --help`) from 55.70 to 15.87 seconds.

This uses exactly the same logic as the LLVM update used, modulo some
minor cleanups:
- Use a local variable for `src.join(relative_path)`
- Remove unnecessary arrays for `book!` macro and make the macro simpler to use
- Add more comments
2021-07-20 23:07:12 -04:00
bors
fabf502a7a Auto merge of #87168 - the8472:flatten-len, r=scottmcm
implement TrustedLen for Flatten/FlatMap if the U: IntoIterator == [T; N]

This only works if arrays are passed directly instead of array iterators
because we need to be sure that they have not been advanced before
Flatten does its size calculation.

resolves #87094
2021-07-20 23:47:48 +00:00
bors
b41936b92c Auto merge of #87312 - ehuss:update-books, r=ehuss
Update books

## reference

6 commits in ab60513a3a5a0591e237fddff5d027a982648392..82d75cf423e4a7824fb36e73ccb18519d6900610
2021-07-05 08:27:31 -0700 to 2021-07-15 06:49:08 -0700
- fix wording/punctuation in "Lifetime bounds" (rust-lang/reference#1062)
- mention implicit `Sized` bound in more places (rust-lang/reference#1053)
-  (rust-lang/reference#1060)
- Remove inner attributes from non-block expressions. (rust-lang/reference#1051)
- Add note about the sign of the remainder (rust-lang/reference#1073)
- Clarify closure capture modes slightly (rust-lang/reference#1064)

## book

21 commits in a90f07f1e9a7fc75dc9105a6c6f16d5c13edceb0..eac55314210519238652f12b30fec9daea61f7fe
2021-07-05 14:43:12 -0400 to 2021-07-19 11:08:01 -0400
-  (rust-lang/book#2791)
- Add Deref trait to overload the deref operator in appendix table
- Revise linker installation instructions. Fixes rust-lang/book#2151.
- Clarify number literal type suffixes. Fixes rust-lang/book#1979.
- Add a note that lifetimes are coming up but aren't required
- Zip creates an iterator, not a vector. Fixes rust-lang/book#2762.
- Add Thai translation to the appendix. Connects to rust-lang/book#2636
- Derive Copy and Clone for Point to match stdlib docs example; fixes rust-lang/book#2657
- Make the definition of Option match the stdlib's, fixes rust-lang/book#2634
- Explain double quote backslash; closes rust-lang/book#2597
- Don't use the term 'anonymous struct' to fix rust-lang/book#2584
- Reword a sentence to fix rust-lang/book#2525
- Add Hindi translation. Connects to rust-lang/book#2496
- Remove unsafe Ferris designations from code. Fixes rust-lang/book#2555
- Add Traditional Chinese translation. Connects to rust-lang/book#2470
- Remove some more references to the authors field
- Make Appendix E be a link
- fix line wrapping
- remove description about the authors field
- remove the authors field
- remove the authors field

## rust-by-example

6 commits in 028f93a61500fe8f746ee7cc6b204ea6c9f42935..1db6bb483cc87ad3b424d9aba764fe622960a1be
2021-07-06 06:28:53 -0300 to 2021-07-15 06:17:42 -0300
- Updated the file destructure_tuple.md (rust-lang/rust-by-example#1452)
- Fix nomenclature around methods (rust-lang/rust-by-example#1450)
- std_misc/path.md: update `Show` to `Display` (rust-lang/rust-by-example#1449)
- Fix up github action (rust-lang/rust-by-example#1451)
- Remove github pages
- Support GitHub Actions (rust-lang/rust-by-example#1330)

## rustc-dev-guide

2 commits in 60e282559104035985331645907c3d9f842312c5..93422c21baca585dc88357ec886a48f6ddc7d665
2021-07-05 11:21:03 -0400 to 2021-07-13 12:45:58 -0400
- Update for merge of CrateDisambiguator into StableCrateId
- Minor capitalization fix (rust-lang/rustc-dev-guide#1170)

## edition-guide

8 commits in 5d57b3832f8d308a9f478ce0a69799548f27ad4d..af696ce8ea526445590ae0ca66a8128d2a95a69a
2021-07-05 10:33:32 +0200 to 2021-07-20 11:38:03 -0400
- Add migration section for panic-macro-consistency (rust-lang/edition-guide#258)
- Update transitioning chapter. (rust-lang/edition-guide#255)
- Add details on migrating the Cargo feature resolver. (rust-lang/edition-guide#259)
- Improve panic macro consistency summary (rust-lang/edition-guide#256)
- Add migration details to or-patterns guide (rust-lang/edition-guide#252)
- Add migration section to into-iterator (rust-lang/edition-guide#253)
- Add Rust 2021 prelude migration details (rust-lang/edition-guide#251)
- Provide more information about disjoint capture in closures and migration instructions (rust-lang/edition-guide#246)

## embedded-book

1 commits in 506840eb73b0749336e1d5274e16d6393892ee82..09986cd352404eb4659db44613b27cac9aa652fc
2021-06-24 00:01:32 +0000 to 2021-07-18 19:26:46 +0000
- Stop referring to the alloc crate as unstable  (rust-embedded/book#297)
2021-07-20 18:44:35 +00:00
Eric Huss
e74d3c708b Update books 2021-07-20 09:10:17 -07:00
bors
39d8d3ab6a Auto merge of #87247 - crlf0710:merge-libterm-into-libtest, r=nagisa
Merge libterm into libtest

I think it's quite clear at this point that rust won't stablize the current libterm APIs to the outside world. And its only user is libtest. The compiler doesn't use this api at all. So I'm merging the crate into libtest as a module.

This also allows me to remove 15% of the libterm code, since these APIs are dead-code now.
2021-07-20 16:03:47 +00:00
bors
5c0ca08c66 Auto merge of #87310 - spastorino:update_miri, r=RalfJung
Update MIRI

Fixes #87306

r? `@RalfJung`
2021-07-20 13:37:02 +00:00
Santiago Pastorino
70891af43f
Update MIRI 2021-07-20 09:52:19 -03:00
bors
da7d405357 Auto merge of #87244 - jackh726:issue-71883, r=estebank
Better diagnostics with mismatched types due to implicit static lifetime

Fixes #78113

I think this is my first diagnostics PR...definitely happy to hear thoughts on the direction/implementation here.

I was originally just trying to solve the error above, where the lifetime on a GAT was causing a cryptic "mismatched types" error. But as I was writing this, I realized that this (unintentionally) also applied to a different case: `wf-in-foreign-fn-decls-issue-80468.rs`. I'm not sure if this diagnostic should get a new error code, or even reuse an existing one. And, there might be some ways to make this even more generalized. Also, the error is a bit more lengthy and verbose than probably needed. So thoughts there are welcome too.

This PR essentially ended up adding a new nice region error pass that triggers if a type doesn't match the self type of an impl which is selected because of a predicate because of an implicit static bound on that self type.

r? `@estebank`
2021-07-20 10:56:08 +00:00
bors
718d53b0cb Auto merge of #87224 - RalfJung:miri-ptr-oob, r=oli-obk
miri: better ptr-out-of-bounds errors

For offsets larger than `isize::MAX`, display them as negative offsets.

r? `@oli-obk`
2021-07-20 08:15:15 +00:00
bors
a72c360a30 Auto merge of #87141 - spastorino:remove_impl_trait_in_bindings, r=oli-obk
Remove impl trait in bindings

Closes #86729

r? `@oli-obk`
2021-07-20 05:34:22 +00:00
jackh726
ae02491984 Better errors when we don't have implicit statics in trait objects 2021-07-19 23:46:11 -04:00
bors
c9aa2595d9 Auto merge of #84959 - camsteffen:lint-suggest-group, r=estebank
Suggest lint groups

Fixes rust-lang/rust-clippy#6986
2021-07-20 02:11:55 +00:00
bors
6535449a00 Auto merge of #87284 - Aaron1011:remove-paren-special, r=petrochenkov
Remove special case for `ExprKind::Paren` in `MutVisitor`

The special case breaks several useful invariants (`ExpnId`s are
globally unique, and never change). This special case
was added back in 2016 in https://github.com/rust-lang/rust/pull/34355

r? `@petrochenkov`
2021-07-19 23:50:23 +00:00
Aaron Hill
f9f238e6b8
Remove special case for ExprKind::Paren in MutVisitor
The special case breaks several useful invariants (`ExpnId`s are
globally unique, and never change). This special case
was added back in 2016 in https://github.com/rust-lang/rust/pull/34355
2021-07-19 17:23:10 -05:00
jackh726
3cd5ad5cd7 Better diagnostics when mismatched types due to implict static lifetime 2021-07-19 18:20:21 -04:00
bors
014026d1a7 Auto merge of #87153 - michaelwoerister:debuginfo-names-dyn-trait-projection-bounds, r=wesleywiser
[debuginfo] Emit associated type bindings in trait object type names.

This PR updates debuginfo type name generation for trait objects to include associated type bindings and auto trait bounds -- so that, for example, the debuginfo type name of `&dyn Iterator<Item=Foo>` and `&dyn Iterator<Item=Bar>` don't both map to just `&dyn Iterator` anymore.

The following table shows examples of debuginfo type names before and after the PR:
| type | before |  after |
|------|---------|-------|
| `&dyn Iterator<Item=u32>>` | `&dyn Iterator` | `&dyn Iterator<Item=u32>` |
| `&(dyn Iterator<Item=u32>> + Sync)` | `&dyn Iterator` | `&(dyn Iterator<Item=u32> + Sync)` |
| `&(dyn SomeTrait<bool, i8, Bar=u32>> + Send)` | `&dyn SomeTrait<bool, i8>` | `&(dyn SomeTrait<bool, i8, Bar=u32>> + Send)`  |

For targets that need C++-like type names, we use `assoc$<Item,u32>` instead of `Item=u32`:
| type | before |  after |
|------|---------|-------|
| `&dyn Iterator<Item=u32>>` | `ref$<dyn$<Iterator> >` | `ref$<dyn$<Iterator<assoc$<Item,u32> > > >` |
| `&(dyn Iterator<Item=u32>> + Sync)` | `ref$<dyn$<Iterator> >` | `ref$<dyn$<Iterator<assoc$<Item,u32> >,Sync> >` |
| `&(dyn SomeTrait<bool, i8, Bar=u32>> + Send)` | `ref$<dyn$<SomeTrait<bool, i8> > >` | `ref$<dyn$<SomeTrait<bool,i8,assoc$<Bar,u32> > >,Send> >`  |

The PR also adds self-profiling measurements for debuginfo type name generation (re. https://github.com/rust-lang/rust/issues/86431). It looks like the compiler spends up to 0.5% of its time in that task, so the potential for optimizing it via caching seems limited.

However, the perf run also shows [the biggest regression](https://perf.rust-lang.org/detailed-query.html?commit=585e91c718b0b2c5319e1fffd0ff1e62aaf7ccc2&base_commit=b9197978a90be6f7570741eabe2da175fec75375&benchmark=tokio-webpush-simple-debug&run_name=incr-unchanged) in a test case that does not even invoke the code in question. This suggests that the length of the names we generate here can affect performance by influencing how much data the linker has to copy around.

Fixes https://github.com/rust-lang/rust/issues/86134.
2021-07-19 21:25:43 +00:00
bors
d5af63480f Auto merge of #87225 - estebank:cleanup, r=oli-obk
Various diagnostics clean ups/tweaks

* Always point at macros, including derive macros
* Point at non-local items that introduce a trait requirement
* On private associated item, point at definition
2021-07-19 18:44:27 +00:00
The8472
c3ac8d8b86 replace Option combinators with try block 2021-07-19 20:22:26 +02:00
bors
fad295b299 Auto merge of #87271 - flip1995:clippyup, r=Manishearth
Update Clippy

This is an out-of-cycle Clippy update, to fix 3 ICEs before the release (This should be merged before beta is branched):

rust-lang/rust-clippy#7470
rust-lang/rust-clippy#7471
rust-lang/rust-clippy#7473

cc `@jackh726` `@JohnTitor` rust-lang/rust-clippy#7470 was caused by #86867. I saw the same ICE in the last rustup for Clippy though, so this might be a more general problem. Is there something we should check before calling `layout_of`? Should we always check for `ty.has_escaping_bound_vars()` before calling `layout_of`? Or is this overkill?

r? `@Manishearth`
2021-07-19 16:03:35 +00:00
Esteban Küber
ba052bd8de Various diagnostics clean ups/tweaks
* Always point at macros, including derive macros
* Point at non-local items that introduce a trait requirement
* On private associated item, point at definition
2021-07-19 08:43:35 -07:00
Michael Woerister
5b1bfaed8c [debuginfo] Adapt CDB tests after changes to whitespace usage in debuginfo type names. 2021-07-19 16:00:04 +02:00
Santiago Pastorino
3e857f5743
Improve impl trait disallowed context error text 2021-07-19 10:19:58 -03:00
bors
b543e0dc03 Auto merge of #86970 - inquisitivecrystal:force-warn, r=davidtwco
Make `--force-warns` a normal lint level option

Now that `ForceWarn` is a lint level, there's no reason `--force-warns` should be treated differently from other options that set lint levels. This merges the `ForceWarn` handling in with the other lint level command line options. It also unifies all of the relevant selection logic in `compiler/rustc_lint/src/levels.rs`, rather than having some of it weirdly elsewhere.

Fixes #86958, which arose from the special-cased handling of `ForceWarn` having had an error in it.
2021-07-19 13:18:04 +00:00
Santiago Pastorino
e0745e8f5d
Improve impl_trait_in_bindings removed feature text 2021-07-19 09:20:15 -03:00
bors
8df945c471 Auto merge of #87269 - GuillaumeGomez:rollup-qukedv0, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #86230 (Add --nocapture option to rustdoc)
 - #87210 (Rustdoc accessibility: make the sidebar headers actual headers)
 - #87227 (Move asm! and global_asm! to core::arch)
 - #87236 (Simplify command-line argument initialization on unix)
 - #87251 (Fix "item info" width)
 - #87256 (Extend HIR-based WF checking to associated type defaults)
 - #87259 (triagebot shortcut config)
 - #87268 (Don't create references to uninitialized data in `List::from_arena`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-19 10:10:08 +00:00
flip1995
b10966be75
Merge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyup 2021-07-19 11:52:05 +02:00
bors
4c41a222ca Auto merge of #7476 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

Out of cycle sync for 2 ICE fixes #7470 #7471 #7473

changelog: none
2021-07-19 09:49:57 +00:00
flip1995
21abb5de27
Bump nightly version -> 2021-07-19 2021-07-19 11:49:03 +02:00
flip1995
26321b35c8
Merge remote-tracking branch 'upstream/master' into rustup 2021-07-19 11:48:49 +02:00
Guillaume Gomez
6cb69ea790
Rollup merge of #87268 - SkiFire13:fix-uninit-ref-list, r=nagisa
Don't create references to uninitialized data in `List::from_arena`

Previously `result` and `arena_slice` were references pointing to uninitialized data, which is technically UB. They may have been fine because the pointed data is `Copy` and and they were only written to, but the semantics of this aren't clearly defined yet, and since we have a sound way to do the same thing I don't think we should keep the possibly-unsound way.
2021-07-19 11:37:49 +02:00
Guillaume Gomez
5ef6439c8d
Rollup merge of #87259 - Llandy3d:triagebot_shortcuts, r=nikomatsakis
triagebot shortcut config

Enable the new triagebot shortcuts as per [#1381/triagebot](https://github.com/rust-lang/triagebot/pull/1381)
2021-07-19 11:37:48 +02:00
Guillaume Gomez
4dd32a1cac
Rollup merge of #87256 - Aaron1011:hir-wf-assoc-default, r=oli-obk
Extend HIR-based WF checking to associated type defaults

Previously, we would only look at associated types in `impl` blocks.
2021-07-19 11:37:47 +02:00
Guillaume Gomez
8cf995f6ac
Rollup merge of #87251 - GuillaumeGomez:item-info-width, r=notriddle
Fix "item info" width

Fixes #87202.

It now looks again like this:

![Screenshot from 2021-07-18 12-33-27](https://user-images.githubusercontent.com/3050060/126064005-013acabc-7f17-4436-8dfc-cb6b9bc24413.png)

cc `@jyn514`

r? `@notriddle`
2021-07-19 11:37:46 +02:00
Guillaume Gomez
6df9df7e36
Rollup merge of #87236 - sunfishcode:avoid-locking-args, r=joshtriplett
Simplify command-line argument initialization on unix

Simplify Rust's command-line argument initialization code on unix:
 - The cleanup code isn't needed, because it was just zeroing out non-owning variables at runtime cleanup time. After 91c3eee173, Rust's command-line initialization code on unix no longer allocates `CString`s and a `Vec` at startup time.
 - The `Mutex` isn't needed; if there's somehow a call to `args()` before argument initialization has happened, the code returns return an empty list, which we can do with a null check.

With these changes, a simple cdylib that doesn't use threads avoids getting `pthread_mutex_lock`/`pthread_mutex_unlock` in its symbol table.
2021-07-19 11:37:45 +02:00
Guillaume Gomez
65b7aa98c7
Rollup merge of #87227 - bstrie:asm2arch, r=Amanieu
Move asm! and global_asm! to core::arch

Follow-up to https://github.com/rust-lang/stdarch/pull/1183 .

Implements the libs-api team decision from rust-lang/rust#84019 (comment) .

In order to not break nightly users, this PR also adds the newly-moved items to the prelude. However, a decision will need to be made before stabilization as to whether these items should remain in the prelude. I will file an issue for this separately.

Fixes #84019 .

r? `@Amanieu`
2021-07-19 11:37:44 +02:00
Guillaume Gomez
456ebd30d5
Rollup merge of #87210 - notriddle:notriddle/rustdoc-sidebar-headers, r=GuillaumeGomez
Rustdoc accessibility: make the sidebar headers actual headers

Part of #87059

Preview it at: https://notriddle.com/notriddle-rustdoc-test/rustdoc-sidebar-header/std/index.html
2021-07-19 11:37:42 +02:00
Guillaume Gomez
0fce468fe8
Rollup merge of #86230 - GuillaumeGomez:nocapture, r=camelid
Add --nocapture option to rustdoc

Fixes https://github.com/rust-lang/rust/issues/26309.
Fixes #45724.

Once this PR is merged, I'll send a PR to cargo to also pass `--nocapture` to rustdoc.

cc `@jyn514`
r? `@camelid`
2021-07-19 11:37:41 +02:00
bors
f467750680 Auto merge of #7470 - DevinR528:fix-ice7447, r=flip1995
Add check if ty has_escaping_bound_vars in zero_sized_map_values lint

Fixes: #7447

changelog: fix ICE in [`zero_sized_map_values`]
2021-07-19 09:22:34 +00:00
Giacomo Stevanato
98e9d16d25 Don't create references to uninitialized data in List::from_arena 2021-07-19 10:47:45 +02:00
bors
83f08223a9 Auto merge of #87196 - oxalica:option-insert-must-use, r=joshtriplett
Mark `Option::insert` as must_use

Some people seems misled by the function name and use it in case where a simple assignment just works.
If the return value is not used, `option = Some(value);` should be preferred instead of `option.insert(value);`
2021-07-19 07:03:36 +00:00
bors
f70a07454b Auto merge of #7403 - Anthuang:redundant-method-names, r=Manishearth
New lint: [`self_named_constructor`]

Adds the `self_named_constructor` lint for detecting when an implemented method has the same name as the type it is implemented for.

changelog: [`self_named_constructor`]

closes: #7142
2021-07-19 06:49:51 +00:00
Anthony Huang
e9e10d209e Run bless 2021-07-19 01:21:06 -04:00
bors
0ecff8c623 Auto merge of #87146 - Aaron1011:better-macro-lint, r=petrochenkov
Compute a better `lint_node_id` during expansion

When we need to emit a lint at a macro invocation, we currently use the
`NodeId` of its parent definition (e.g. the enclosing function). This
means that any `#[allow]` / `#[deny]` attributes placed 'closer' to the
macro (e.g. on an enclosing block or statement) will have no effect.

This commit computes a better `lint_node_id` in `InvocationCollector`.
When we visit/flat_map an AST node, we assign it a `NodeId` (earlier
than we normally would), and store than `NodeId` in current
`ExpansionData`. When we collect a macro invocation, the current
`lint_node_id` gets cloned along with our `ExpansionData`, allowing it
to be used if we need to emit a lint later on.

This improves the handling of `#[allow]` / `#[deny]` for
`SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` and some `asm!`-related lints.
The 'legacy derive helpers' lint retains its current behavior
(I've inlined the now-removed `lint_node_id` function), since
there isn't an `ExpansionData` readily available.
2021-07-19 04:22:51 +00:00
bors
10c0b003db Auto merge of #86848 - notriddle:notriddle/drop-dyn, r=varkor
feat(rustc_lint): add `dyn_drop`

Based on the conversation in #86747.

Explanation
-----------

A trait object bound of the form `dyn Drop` is most likely misleading and not what the programmer intended.

`Drop` bounds do not actually indicate whether a type can be trivially dropped or not, because a composite type containing `Drop` types does not necessarily implement `Drop` itself. Naïvely, one might be tempted to write a deferred drop system, to pull cleaning up memory out of a latency-sensitive code path, using `dyn Drop` trait objects. However, this breaks down e.g. when `T` is `String`, which does not implement `Drop`, but should probably be accepted.

To write a trait object bound that accepts anything, use a placeholder trait with a blanket implementation.

```rust
trait Placeholder {}
impl<T> Placeholder for T {}
fn foo(_x: Box<dyn Placeholder>) {}
```
2021-07-19 01:41:54 +00:00