Commit graph

153982 commits

Author SHA1 Message Date
Mara Bos
8fd53e3085
Rollup merge of #88053 - bjorn3:fix_flock_fallback_impl, r=cjgillot
Fix the flock fallback implementation
2021-09-01 09:23:25 +02:00
Mara Bos
5878780e64
Rollup merge of #88040 - nbdd0121:btreemap, r=m-ou-se
BTree: remove Ord bound from new

`K: Ord` bound is unnecessary on `BTree{Map,Set}::new` and their `Default` impl. No elements exist so there are nothing to compare anyway, so I don't think "future proof" would be a blocker here. This is analogous to `HashMap::new` not having a `K: Eq + Hash` bound.

#79245 originally does this and for some reason drops the change to `new` and `Default`. I can see why changes to other methods like `entry` or `symmetric_difference` need to be careful but I couldn't find out any reason not to do it on `new`.

Removing the bound also makes the stabilisation of `const fn new` not depending on const trait bounds.

cc `@steffahn` who suggests me to make this PR.

r? `@dtolnay`
2021-09-01 09:23:23 +02:00
Mara Bos
dcefd6871d
Rollup merge of #86376 - asquared31415:extern-no-mangle-84204, r=Mark-Simulacrum
Emit specific warning to clarify that `#[no_mangle]` should not be applied on foreign statics or functions

Foreign statics and foreign functions should not have `#[no_mangle]` applied, as it does nothing to the name and has some extra hidden behavior that is normally unwanted.  There was an existing warning for this, but it says the attribute is only allowed on "statics or functions", which to the user can be confusing.

This PR adds a specific version of the unused `#[no_mangle]` warning that explains that the target is a *foreign* static or function and that they do not need the attribute.

Fixes #78989
2021-09-01 09:23:22 +02:00
bors
608b5e1c20 Auto merge of #88272 - willcrichton:mutable-sparse-matrix, r=ecstatic-morse
Add bit removal methods to SparseBitMatrix and factor *BitSet relational methods into more extensible trait

I need the ability to clear the bits out of a row from `SparseBitMatrix`. Currently, all the mutating methods only allow insertion of bits, and there is no way to get access to the underlying data.

One approach is simply to make `ensure_row` public, since it grants `&mut` access to the underlying `HybridBitSet`. This PR adds the `pub` modifier. However, presumably this method was private for a reason, so I'm open to other designs. I would prefer general mutable access to the rows, because that way I can add many mutating operations (`clear`, `intersect`, etc.) without filing a PR each time :-)

r? `@ecstatic-morse`
2021-09-01 06:13:15 +00:00
bors
c4f26b15e3 Auto merge of #88121 - camelid:better-recursive-alias-error, r=estebank
Improve errors for recursive type aliases

Fixes #17539.
2021-09-01 03:43:37 +00:00
Noah Lev
280e16787e Remove unhelpful expect() message 2021-08-31 20:32:19 -07:00
Noah Lev
2d1240e6f7 Box GenericArgs::Parenthesized.output
This reduces the size of `GenericArgs` from 104 bytes to 56 bytes,
essentially reducing it by half.

`GenericArgs` is one of the fields of `PathSegment`, so this should
reduce the amount of memory allocated for `PathSegment`s in the cases
where the generics are not for a `Fn`, `FnMut`, or `FnOnce` trait.

I also added `static_assert_size!`s to `GenericArgs` and `PathSegment`
to ensure they don't increase in size unexpectedly.
2021-08-31 20:32:17 -07:00
bors
c2a408840a Auto merge of #87688 - camsteffen:let-else, r=cjgillot
Introduce `let...else`

Tracking issue: #87335

The trickiest part for me was enforcing the diverging else block with clear diagnostics. Perhaps the obvious solution is to expand to `let _: ! = ..`, but I decided against this because, when a "mismatched type" error is found in typeck, there is no way to trace where in the HIR the expected type originated, AFAICT. In order to pass down this information, I believe we should introduce `Expectation::LetElseNever(HirId)` or maybe add `HirId` to `Expectation::HasType`, but I left that as a future enhancement. For now, I simply assert that the block is `!` with a custom `ObligationCauseCode`, and I think this is clear enough, at least to start. The downside here is that the error points at the entire block rather than the specific expression with the wrong type. I left a todo to this effect.

Overall, I believe this PR is feature-complete with regard to the RFC.
2021-09-01 01:02:42 +00:00
inquisitivecrystal
227e004d3f Add a few tests for UnsafeCell 2021-08-31 16:32:01 -07:00
bors
a3956106d1 Auto merge of #88533 - oli-obk:tait_🧊, r=spastorino
Concrete regions can show up in mir borrowck if the originated from there

We used to not encounter them here, because we took regions from typeck's opaque type resolution by renumbering them. We don't do that anymore. Instead mir borrock does all the logic, and it can handle concrete regions just fine, as long as it created them itself.

fixes #83190 which was introduced by #87287

r? `@spastorino`
2021-08-31 22:15:26 +00:00
Patrick Conrad
cfe2d30bb4 Move test to run-make-fulldeps to avoid compiler flag bug 2021-08-31 18:06:18 -04:00
inquisitivecrystal
06dd4c03a0 Stabilize Iterator::intersperse() 2021-08-31 14:50:18 -07:00
inquisitivecrystal
753dac16ab Stabilize UnsafeCell::raw_get() 2021-08-31 14:44:13 -07:00
Mara Bos
7d18052b1b Add test for closure migration where body is a block fragment. 2021-08-31 22:18:10 +02:00
Mara Bos
7189c85413 Improve closure dummy capture suggestion in macros. 2021-08-31 22:17:51 +02:00
bors
29ef6cf163 Auto merge of #88506 - Mark-Simulacrum:fix-rlibs, r=ehuss
Fix loading large rlibs

Bumps object crate to permit parsing archives with 64-bit table entries. These
are primarily encountered when there's more than 4GB of archive data.

cc https://github.com/gimli-rs/object/issues/365

Helps with https://github.com/rust-lang/rust/issues/88351, but will also need a beta backport

r? `@ehuss` (mostly for the test)
2021-08-31 19:33:06 +00:00
Camille GILLOT
8d7d488d3b Lint Abi in ast validation. 2021-08-31 20:30:17 +02:00
Matthias Krüger
7f2df9ad65 some low hanging clippy::perf fixes 2021-08-31 20:29:04 +02:00
Tavian Barnes
0e0c8aef87 Use the return value of readdir_r() instead of errno
POSIX says:

> If successful, the readdir_r() function shall return zero; otherwise,
> an error number shall be returned to indicate the error.

But we were previously using errno instead of the return value.  This
led to issue #86649.
2021-08-31 14:11:42 -04:00
Noah Lev
87e39ac1ec Remove bolding on associated constants
Associated types don't get bolded, so it looks off to have one kind
bolded and one not.
2021-08-31 09:53:21 -07:00
bors
0a84708edc Auto merge of #88535 - m-ou-se:rollup-jeusxbo, r=m-ou-se
Rollup of 10 pull requests

Successful merges:

 - #85017 (Add carrying_add, borrowing_sub, widening_mul, carrying_mul methods to integers)
 - #86362 (Avoid cloning LocalDecls)
 - #88391 (Fix json tuple struct enum variant )
 - #88399 (Disallow the aapcs CC on Aarch64)
 - #88418 (Allow `~const` bounds on trait assoc functions)
 - #88445 (Clean up the lowering of AST items)
 - #88495 (Add `TcpStream::set_linger` and `TcpStream::linger`)
 - #88501 (Use right span in prelude collision suggestions with macros. )
 - #88504 (Keep turbofish in prelude collision lint.)
 - #88524 (Remove unnecessary `mut` from udp doctests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-31 16:47:06 +00:00
Mara Bos
f5cf9678c2
Rollup merge of #88524 - soenkehahn:master, r=jyn514
Remove unnecessary `mut` from udp doctests

I don't think this `mut` is necessary, since both `recv_from` and `send_to` take `&self`.
2021-08-31 17:55:02 +02:00
Mara Bos
13f6d7e4cc
Rollup merge of #88504 - m-ou-se:turbofish-please-stay, r=oli-obk
Keep turbofish in prelude collision lint.

Fixes https://github.com/rust-lang/rust/issues/88442
2021-08-31 17:55:00 +02:00
Mara Bos
91c4fee9fc
Rollup merge of #88501 - m-ou-se:prelude-collusion-oh-no-macros-help, r=estebank
Use right span in prelude collision suggestions with macros.

Fixes https://github.com/rust-lang/rust/issues/88347

r? `@estebank`
2021-08-31 17:54:59 +02:00
Mara Bos
c5a34d802d
Rollup merge of #88495 - ibraheemdev:tcp-linger, r=joshtriplett
Add `TcpStream::set_linger` and `TcpStream::linger`

Adds methods for getting/setting the `SO_LINGER` option on TCP sockets. Behavior is consistent across Unix and Windows.

r? `@joshtriplett` (I noticed you've been reviewing net related PRs)
2021-08-31 17:54:58 +02:00
Mara Bos
41249cad91
Rollup merge of #88445 - inquisitivecrystal:ast-lowering, r=cjgillot
Clean up the lowering of AST items

This PR simplifies and improves `rustc_ast_lowering::item` in various minor ways. The reasons for the changes should mostly be self evident, though I'm happy to specifically explain anything if needed.

These changes used to be part of #88019, but I removed them after it was pointed out that some of my other changes to `rustc_ast_lowering` were unnecessary. It felt like a bad idea to clean up code which I didn't even need to touch anymore.

r? `@cjgillot`
2021-08-31 17:54:57 +02:00
Mara Bos
ab37e49611
Rollup merge of #88418 - fee1-dead:trait-assoc-tilde-const, r=oli-obk
Allow `~const` bounds on trait assoc functions

r? `@oli-obk`
2021-08-31 17:54:56 +02:00
Mara Bos
4d089088f6
Rollup merge of #88399 - nagisa:nagisa/aapcs-on-aarch, r=petrochenkov
Disallow the aapcs CC on Aarch64

This never really worked and makes LLVM assert.
2021-08-31 17:54:55 +02:00
Mara Bos
f4f5dd5186
Rollup merge of #88391 - GuillaumeGomez:fix-json-enum-variant, r=camelid,notriddle
Fix json tuple struct enum variant

Fixes #87887.

cc `@dsherret` `@camelid`

r? `@notriddle`
2021-08-31 17:54:54 +02:00
Mara Bos
175c8cb851
Rollup merge of #86362 - ptrojahn:insert_vars_and_temps, r=jackh726
Avoid cloning LocalDecls
2021-08-31 17:54:53 +02:00
Mara Bos
e7a247dba4
Rollup merge of #85017 - clarfonthey:carrying_widening, r=m-ou-se
Add carrying_add, borrowing_sub, widening_mul, carrying_mul methods to integers

This comes in part from my own attempts to make (crude) big integer implementations, and also due to the stalled discussion in [RFC 2417](https://github.com/rust-lang/rfcs/pull/2417). My understanding is that changes like these are best offered directly as code and then an RFC can be opened if there needs to be more discussion before stabilisation. Since all of these methods are unstable from the start, I figured I might as well offer them now.

I tried looking into intrinsics, messed around with a few different implementations, and ultimately concluded that these are "good enough" implementations for now to at least put up some code and maybe start bikeshedding on a proper API for these.

For the `carrying_add` and `borrowing_sub`, I tried looking into potential architecture-specific code and realised that even using the LLVM intrinsics for `addcarry` and `subborrow` on x86 specifically, I was getting exactly the same assembly as the naive implementation using `overflowing_add` and `overflowing_sub`, although the LLVM IR did differ because of the architecture-specific code. Longer-term I think that they would be best suited to specific intrinsics as that would make optimisations easier (instructions like add-carry tend to use implicit flags, and thus can only be optimised if they're done one-after-another, and thus it would make the most sense to have compact intrinsics that can be merged together easily).

For `widening_mul` and `carrying_mul`, for now at least, I simply cast to the larger type and perform arithmetic that way, since we currently have no intrinsic that would work better for 128-bit integers. In the future, I also think that some form of intrinsic would work best to cover that case, but for now at least, I think that they're "good enough" for now.

The main reasoning for offering these directly to the standard library even though they're relatively niche optimisations is to help ensure that the code generated for them is optimal. Plus, these operations alone aren't enough to create big integer implementations, although they could help simplify the code required to do so and make it a bit more accessible for the average implementor.

That said, I 100% understand if any or all of these methods are not desired simply because of how niche they are. Up to you. 🤷🏻
2021-08-31 17:54:52 +02:00
Michael Howell
6e70678f7d Change wording to less jaron-y "non-auto trait"
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-08-31 08:53:23 -07:00
Ibraheem Ahmed
072e8c977a
disable tcp_linger feature in std
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-08-31 11:19:39 -04:00
Ibraheem Ahmed
ffc43b8468
add safety annotation to LinkedList::detach_all_nodes
Co-authored-by: kennytm <kennytm@gmail.com>
2021-08-31 11:18:30 -04:00
Oli Scherer
43738c6787 Concrete regions can show up in mir borrowck if the originated from there.
We used to not encounter them here, because we took regions from typeck's opaque type resolution by renumbering them. We don't do that anymore.
2021-08-31 14:38:21 +00:00
Mara Bos
7c0479bd8c Use and_then instead of unwrap_or_default. 2021-08-31 16:26:27 +02:00
Mara Bos
fc0fb38b19 Add macro test for prelude collision suggestions. 2021-08-31 16:25:51 +02:00
Mara Bos
a15dab9ce2 Use right span in prelude collision suggestions with macros. 2021-08-31 16:25:51 +02:00
Mara Bos
2a06daa863 Pull Span::find_ancestor_inside loop into its own function. 2021-08-31 16:25:51 +02:00
Mark Rousskov
84df1edad3 Delete long-running large rlibs test
This is kept to a separate commit so that the test itself is preserved in the
commit history.
2021-08-31 10:20:49 -04:00
Paul Trojahn
99a3d64673 Remove single use variables 2021-08-31 15:54:41 +02:00
Paul Trojahn
7bcc9ae422 Avoid cloning LocalDecls 2021-08-31 14:51:16 +02:00
bors
76d18cfb89 Auto merge of #88527 - m-ou-se:rollup-az6xtc5, r=m-ou-se
Rollup of 14 pull requests

Successful merges:

 - #88394 (Document `std::env::current_exe` possible rename behaviour)
 - #88406 (Tait nest infer test)
 - #88408 (Add inference cycle TAIT test)
 - #88409 (Add auto trait leakage TAIT test)
 - #88413 (Add weird return types TAIT test)
 - #88450 (fix(rustc_parse): correct span in `maybe_whole_expr!`)
 - #88462 (rustdoc: Stop using resolver for macro loading)
 - #88465 (Adding examples to docs of `std::time` module)
 - #88486 (Remove unused arena macro args)
 - #88492 (Use MaybeUninit::write in functor.rs)
 - #88496 (Fix prelude collision lint suggestion for generics with lifetimes)
 - #88497 (Fix prelude collision suggestions for glob imported traits. )
 - #88503 (Warn when [T; N].into_iter() is ambiguous in the new edition. )
 - #88509 (Don't suggest extra <> in dyn suggestion.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-31 11:20:32 +00:00
Mara Bos
feafda8cd3
Rollup merge of #88509 - m-ou-se:dyn-no-left-shift-right-shift-just-single-angle-brackets-please-thanks, r=petrochenkov
Don't suggest extra <> in dyn suggestion.

Fixes https://github.com/rust-lang/rust/issues/88508
2021-08-31 10:41:30 +02:00
Mara Bos
caca256b52
Rollup merge of #88503 - m-ou-se:array-into-inter-ambiguous, r=cjgillot
Warn when [T; N].into_iter() is ambiguous in the new edition.

Fixes https://github.com/rust-lang/rust/issues/88475

In https://github.com/rust-lang/rust/issues/88475, a situation was found where `[T; N].into_iter()` becomes *ambiguous* in the new edition. This is different than the case where `(&[T; N]).into_iter()` resolves differently, which was the only case handled by the `array_into_iter` lint. This is almost identical to the new-traits-in-the-prelude problem. Effectively, due to the array-into-iter hack disappearing in Rust 2021, we effectively added `IntoIterator` to the 'prelude' in Rust 2021 specifically for arrays.

This modifies the prelude collisions lint to detect that case and emit a `array_into_iter` lint in that case.
2021-08-31 10:41:29 +02:00
Mara Bos
db44069482
Rollup merge of #88497 - m-ou-se:prelude-collision-glob, r=nikomatsakis
Fix prelude collision suggestions for glob imported traits.

Fixes https://github.com/rust-lang/rust/issues/88471

cc `@nikomatsakis`
2021-08-31 10:41:28 +02:00
Mara Bos
fdf9c09c50
Rollup merge of #88496 - m-ou-se:prelude-collision-lifetime-generics, r=petrochenkov
Fix prelude collision lint suggestion for generics with lifetimes

Fixes https://github.com/rust-lang/rust/issues/88470

cc `@nikomatsakis`
2021-08-31 10:41:27 +02:00
Mara Bos
4adacfd43e
Rollup merge of #88492 - est31:maybe_uninit_write, r=wesleywiser
Use MaybeUninit::write in functor.rs

MaybeUninit::write is stable as of 1.55.0.
2021-08-31 10:41:26 +02:00
Mara Bos
e094380025
Rollup merge of #88486 - bjorn3:better_arena_macro, r=jackh726
Remove unused arena macro args
2021-08-31 10:41:25 +02:00
Mara Bos
497267a961
Rollup merge of #88465 - marcospb19:master, r=joshtriplett
Adding examples to docs of `std::time` module

And adding missing link to `Duration` from `Instant`.
2021-08-31 10:41:24 +02:00