]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #76858 - rcvalle:rust-lang-exploit-mitigations, r=steveklabnik
Jonas Schievink [Tue, 24 Nov 2020 12:17:28 +0000 (13:17 +0100)]
Rollup merge of #76858 - rcvalle:rust-lang-exploit-mitigations, r=steveklabnik

Add exploit mitigations chapter to the rustc book

This section documents the exploit mitigations applicable to the Rust compiler when building programs for the Linux operating system on the AMD64 architecture and equivalent. This was done for a project I'm currently working on, and I hope it'll also be helpful to others.

3 years agoAuto merge of #79294 - petrochenkov:determ, r=varkor
bors [Tue, 24 Nov 2020 09:17:33 +0000 (09:17 +0000)]
Auto merge of #79294 - petrochenkov:determ, r=varkor

resolve: Do not put macros into `module.unexpanded_invocations` unless necessary

Macro invocations in modules <sup>(*)</sup> need to be tracked because they can produce named items when expanded.
We cannot give definite answer to queries like "does this module declare name `n`?" until all macro calls in that module are expanded.

Previously we marked too many macros as potentially producing named items.
E.g. in this example
```rust
mod m {
    const C: u32 = line!();
}
```
`line!()` cannot emit any items into module `m`, but it was still marked.
This PR fixes that and marks macro calls as "unexpanded in module" only if they can actually emit named items into that module.

Diagnostics in UI test outputs have different order now because this change affects macro expansion order.

<sup>*</sup> Any containers for named items are called modules in resolve (that includes blocks, traits and enums in addition to `mod` items).

3 years agoAuto merge of #79228 - flip1995:clippyup, r=oli-obk
bors [Tue, 24 Nov 2020 06:56:02 +0000 (06:56 +0000)]
Auto merge of #79228 - flip1995:clippyup, r=oli-obk

Update Clippy

Biweekly Clippy update

r? `@Manishearth`

3 years agoAdd exploit mitigations chapter to the rustc book
Ramon de C Valle [Fri, 18 Sep 2020 00:47:56 +0000 (17:47 -0700)]
Add exploit mitigations chapter to the rustc book

This section documents the exploit mitigations applicable to the Rust
compiler when building programs for the Linux operating system on the
AMD64 architecture and equivalent.

3 years agoAuto merge of #78953 - mzohreva:mz/from_raw_fd, r=Mark-Simulacrum
bors [Tue, 24 Nov 2020 03:12:20 +0000 (03:12 +0000)]
Auto merge of #78953 - mzohreva:mz/from_raw_fd, r=Mark-Simulacrum

Add Metadata in std::os::fortanix_sgx::io::FromRawFd

Needed for https://github.com/fortanix/rust-sgx/pull/291

cc `@jethrogb`

3 years agoAuto merge of #78636 - dtolnay:puncteq, r=petrochenkov
bors [Tue, 24 Nov 2020 00:30:25 +0000 (00:30 +0000)]
Auto merge of #78636 - dtolnay:puncteq, r=petrochenkov

Add PartialEq<char> for proc_macro::Punct

`punct.as_char() == '░'` is pervasive when parsing anything involving punct. I think `punct == '░'` is sufficiently unambiguous that it makes sense to provide the impl.

https://github.com/rust-lang/rust/blob/1899c489d4c30b2640d30b77ac04f0a548834d81/library/proc_macro/src/quote.rs#L79
https://github.com/rust-lang/rust/blob/1899c489d4c30b2640d30b77ac04f0a548834d81/library/proc_macro/src/quote.rs#L83
https://github.com/rust-lang/rust/blob/1899c489d4c30b2640d30b77ac04f0a548834d81/src/test/ui/suggestions/auxiliary/issue-61963.rs#L26
https://github.com/rust-lang/rust/blob/1899c489d4c30b2640d30b77ac04f0a548834d81/src/test/ui/proc-macro/auxiliary/three-equals.rs#L23

3 years agoAuto merge of #78343 - camelid:macros-qualify-panic, r=m-ou-se
bors [Mon, 23 Nov 2020 22:05:28 +0000 (22:05 +0000)]
Auto merge of #78343 - camelid:macros-qualify-panic, r=m-ou-se

Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Fixes #78333.

-----

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.

3 years agoClean up `core` macros documentation
Camelid [Sun, 25 Oct 2020 01:38:25 +0000 (18:38 -0700)]
Clean up `core` macros documentation

* Switch a couple links over to intra-doc links
* Clean up some formatting/typography

3 years agoQualify `panic!` as `core::panic!` in non-built-in `core` macros
Camelid [Sun, 25 Oct 2020 01:35:46 +0000 (18:35 -0700)]
Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.

3 years agoAuto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum
bors [Mon, 23 Nov 2020 19:01:19 +0000 (19:01 +0000)]
Auto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum

Drop support for all cloudabi targets

`cloudabi` is a tier-3 target, and [it is no longer being maintained upstream][no].

This PR drops supports for cloudabi targets. Those targets are:
* aarch64-unknown-cloudabi
* armv7-unknown-cloudabi
* i686-unknown-cloudabi
* x86_64-unknown-cloudabi

Since this drops supports for a target, I'd like somebody to tag `relnotes` label to this PR.

Some other issues:
* The tidy exception for `cloudabi` crate is still remained because
  * `parking_lot v0.9.0` and `parking_lot v0.10.2` depends on `cloudabi v0.0.3`.
  * `parking_lot v0.11.0` depends on `cloudabi v0.1.0`.

[no]: https://github.com/NuxiNL/cloudabi#note-this-project-is-unmaintained

3 years agoAuto merge of #79345 - jonas-schievink:rollup-1yhhzx9, r=jonas-schievink
bors [Mon, 23 Nov 2020 16:33:03 +0000 (16:33 +0000)]
Auto merge of #79345 - jonas-schievink:rollup-1yhhzx9, r=jonas-schievink

Rollup of 10 pull requests

Successful merges:

 - #76829 (stabilize const_int_pow)
 - #79080 (MIR visitor: Don't treat debuginfo field access as a use of the struct)
 - #79236 (const_generics: assert resolve hack causes an error)
 - #79287 (Allow using generic trait methods in `const fn`)
 - #79324 (Use Option::and_then instead of open-coding it)
 - #79325 (Reduce boilerplate with the `?` operator)
 - #79330 (Fix typo in comment)
 - #79333 (doc typo)
 - #79337 (Use Option::map instead of open coding it)
 - #79343 (Add my (`@flip1995)` work mail to the mailmap)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #79343 - flip1995:mailmap, r=Mark-Simulacrum
Jonas Schievink [Mon, 23 Nov 2020 14:25:55 +0000 (15:25 +0100)]
Rollup merge of #79343 - flip1995:mailmap, r=Mark-Simulacrum

Add my (@flip1995) work mail to the mailmap

3 years agoRollup merge of #79337 - LingMan:map, r=jyn514
Jonas Schievink [Mon, 23 Nov 2020 14:25:53 +0000 (15:25 +0100)]
Rollup merge of #79337 - LingMan:map, r=jyn514

Use Option::map instead of open coding it

r?  `@jonas-schievink` since you're frequently sniping these minor cleanups anyway.
`@rustbot` modify labels +C-cleanup  +T-compiler

3 years agoRollup merge of #79333 - o752d:patch-3, r=Mark-Simulacrum
Jonas Schievink [Mon, 23 Nov 2020 14:25:51 +0000 (15:25 +0100)]
Rollup merge of #79333 - o752d:patch-3, r=Mark-Simulacrum

doc typo

plus a small edit for clarity

3 years agoRollup merge of #79330 - jyn514:typo, r=jyn514
Jonas Schievink [Mon, 23 Nov 2020 14:25:49 +0000 (15:25 +0100)]
Rollup merge of #79330 - jyn514:typo, r=jyn514

Fix typo in comment

This is trivial enough I'm just going to merge without review.

r? `@ghost`

3 years agoRollup merge of #79325 - LingMan:try_op, r=jonas-schievink
Jonas Schievink [Mon, 23 Nov 2020 14:25:47 +0000 (15:25 +0100)]
Rollup merge of #79325 - LingMan:try_op, r=jonas-schievink

Reduce boilerplate with the `?` operator

`@rustbot` modify labels to +C-cleanup.

3 years agoRollup merge of #79324 - LingMan:and_then, r=jonas-schievink
Jonas Schievink [Mon, 23 Nov 2020 14:25:46 +0000 (15:25 +0100)]
Rollup merge of #79324 - LingMan:and_then, r=jonas-schievink

Use Option::and_then instead of open-coding it

`@rustbot` modify labels to +C-cleanup.

3 years agoRollup merge of #79287 - jonas-schievink:const-trait-impl, r=oli-obk
Jonas Schievink [Mon, 23 Nov 2020 14:25:44 +0000 (15:25 +0100)]
Rollup merge of #79287 - jonas-schievink:const-trait-impl, r=oli-obk

Allow using generic trait methods in `const fn`

Next step for https://github.com/rust-lang/rust/issues/67792, this now also allows code like the following:

```rust
struct S;

impl const PartialEq for S {
    fn eq(&self, _: &S) -> bool {
        true
    }
}

const fn equals_self<T: PartialEq>(t: &T) -> bool {
    *t == *t
}

pub const EQ: bool = equals_self(&S);
```

This works by threading const-ness of trait predicates through trait selection, in particular through `ParamCandidate`, and exposing it in the resulting `ImplSource`.

Since this change makes two bounds `T: Trait` and `T: ?const Trait` that only differ in their const-ness be treated like different bounds, candidate winnowing has been changed to drop the `?const` candidate in favor of the const candidate, to avoid ambiguities when both a const and a non-const bound is present.

3 years agoRollup merge of #79236 - lcnr:mcg-resolve-dsb, r=eddyb
Jonas Schievink [Mon, 23 Nov 2020 14:25:42 +0000 (15:25 +0100)]
Rollup merge of #79236 - lcnr:mcg-resolve-dsb, r=eddyb

const_generics: assert resolve hack causes an error

prevent the min_const_generics `HACK`s in resolve from triggering a fallback path which successfully compiles so that we don't have to worry about future compat issues when removing it

r? `@eddyb` cc `@varkor`

3 years agoRollup merge of #79080 - camelid:mir-visit-debuginfo-project, r=jonas-schievink
Jonas Schievink [Mon, 23 Nov 2020 14:25:40 +0000 (15:25 +0100)]
Rollup merge of #79080 - camelid:mir-visit-debuginfo-project, r=jonas-schievink

MIR visitor: Don't treat debuginfo field access as a use of the struct

Fixes #77454.

r? `@jonas-schievink`

3 years agoRollup merge of #76829 - tspiteri:const-int-pow, r=oli-obk
Jonas Schievink [Mon, 23 Nov 2020 14:25:38 +0000 (15:25 +0100)]
Rollup merge of #76829 - tspiteri:const-int-pow, r=oli-obk

stabilize const_int_pow

This also requires stabilizing constctlz for const ctlz_nonzero.

3 years agoAuto merge of #79186 - JulianKnodt:str_from, r=Mark-Simulacrum
bors [Mon, 23 Nov 2020 14:20:22 +0000 (14:20 +0000)]
Auto merge of #79186 - JulianKnodt:str_from, r=Mark-Simulacrum

Change slice::to_vec to not use extend_from_slice

I saw this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/String.3A.3Afrom%28.26str%29.20wonky.20codegen/near/216164455), and didn't see any update from it, so I thought I'd try to fix it. This converts `to_vec` to no longer use `extend_from_slice`, but relies on knowing that the allocated capacity is the same size as the input.

[Godbolt new v1](https://rust.godbolt.org/z/1bcWKG)
[Godbolt new v2 w/ drop guard](https://rust.godbolt.org/z/5jn76K)
[Godbolt old version](https://rust.godbolt.org/z/e4ePav)

After some amount of iteration, there are now two specializations for `to_vec`, one for `Copy` types that use memcpy, and one for clone types which is the original from this PR.

This is then used inside of `impl<T: Clone> FromIterator<Iter::Slice<T>> for Vec<T>` which is essentially equivalent to `&[T] -> Vec<T>`, instead of previous specialization of the `extend` function. This is because extend has to reason more about existing capacity by calling `reserve` on an existing vec, and thus produces worse asm.

Downsides: This allocates the exact capacity, so I think if many items are added to this `Vec` after, it might need to allocate whereas extending may not. I also noticed the number of faults went up in the benchmarks, but not sure where from exactly.

3 years agoAdd my (@flip1995) work mail to the mailmap
flip1995 [Mon, 23 Nov 2020 13:11:56 +0000 (14:11 +0100)]
Add my (@flip1995) work mail to the mailmap

3 years agoFix ICE in utils::implements_trait
flip1995 [Mon, 23 Nov 2020 12:52:27 +0000 (13:52 +0100)]
Fix ICE in utils::implements_trait

This only happend when debug_assertions were enabled in rustc

3 years agoMerge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
flip1995 [Mon, 23 Nov 2020 12:51:04 +0000 (13:51 +0100)]
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup

3 years agoAuto merge of #77893 - petertodd:2020-impl-default-for-phantompinned, r=dtolnay
bors [Mon, 23 Nov 2020 07:00:30 +0000 (07:00 +0000)]
Auto merge of #77893 - petertodd:2020-impl-default-for-phantompinned, r=dtolnay

Impl Default for PhantomPinned

`PhantomPinned` is just a marker type, with an obvious default value (the only value). So I can't think of a reason not to do this. Sure, it's used in exotic situations with unsafe code. But the people writing that code can decide for themselves if they can derive `Default`, and in many situations the derived impl will make sense:

```rust
#[derive(Default)]
struct NeedsPin {
   marker: PhantomPinned,
   buf: [u8; 1024],
   ptr_to_data: Option<*const u8>,
}
```

3 years agoAuto merge of #76226 - CDirkx:const-ipaddr, r=dtolnay
bors [Mon, 23 Nov 2020 04:47:25 +0000 (04:47 +0000)]
Auto merge of #76226 - CDirkx:const-ipaddr, r=dtolnay

Stabilize `IpAddr::is_ipv4` and `is_ipv6` as const

Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `std::net::IpAddr` as const, in the same way as [PR#76198](https://github.com/rust-lang/rust/pull/76198).

Possible because of the recent stabilization of const control flow.

Part of #76225 and #76205.

3 years agoUse Option::map instead of open coding it
LingMan [Mon, 23 Nov 2020 03:58:21 +0000 (04:58 +0100)]
Use Option::map instead of open coding it

3 years agodoc typo
oliver [Mon, 23 Nov 2020 02:47:45 +0000 (02:47 +0000)]
doc typo

plus a small edit for clarity

3 years agoAuto merge of #79172 - a1phyr:cold_abort, r=Mark-Simulacrum
bors [Mon, 23 Nov 2020 02:25:13 +0000 (02:25 +0000)]
Auto merge of #79172 - a1phyr:cold_abort, r=Mark-Simulacrum

Add #[cold] attribute to `std::process::abort` and `alloc::alloc::handle_alloc_error`

3 years agoAdd comment and remove obsolete special case
Camelid [Mon, 23 Nov 2020 01:33:06 +0000 (17:33 -0800)]
Add comment and remove obsolete special case

3 years agoFix typo in comment
Joshua Nelson [Mon, 23 Nov 2020 01:32:36 +0000 (20:32 -0500)]
Fix typo in comment

3 years agoconst_int_pow will be stabilized in 1.50.0, not in 1.49.0
Trevor Spiteri [Mon, 23 Nov 2020 01:04:37 +0000 (02:04 +0100)]
const_int_pow will be stabilized in 1.50.0, not in 1.49.0

Same for constctlz.

3 years agostabilize const_int_pow
Trevor Spiteri [Fri, 2 Oct 2020 17:30:16 +0000 (19:30 +0200)]
stabilize const_int_pow

Also stabilize constctlz for const ctlz_nonzero.

The public methods stabilized const by this commit are:

  * `{i*,u*}::checked_pow`
  * `{i*,u*}::saturating_pow`
  * `{i*,u*}::wrapping_pow`
  * `{i*,u*}::overflowing_pow`
  * `{i*,u*}::pow`
  * `u*::next_power_of_two`
  * `u*::checked_next_power_of_two`
  * `u*::wrapping_next_power_of_two` (the method itself is still unstable)

3 years agoBump version to 1.50.0
Christiaan Dirkx [Mon, 23 Nov 2020 00:40:26 +0000 (01:40 +0100)]
Bump version to 1.50.0

3 years agoStabilize `IpAddr::is_ipv4` and `is_ipv6` as const
Christiaan Dirkx [Wed, 2 Sep 2020 00:05:42 +0000 (02:05 +0200)]
Stabilize `IpAddr::is_ipv4` and `is_ipv6` as const

Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `IpAddr`.

Possible because of the recent stabilization of const control flow.

Also adds a test for these methods in a const context.

3 years agoAuto merge of #79319 - m-ou-se:rollup-d9n5viq, r=m-ou-se
bors [Sun, 22 Nov 2020 23:59:48 +0000 (23:59 +0000)]
Auto merge of #79319 - m-ou-se:rollup-d9n5viq, r=m-ou-se

Rollup of 10 pull requests

Successful merges:

 - #76941 (Add f{32,64}::is_subnormal)
 - #77697 (Split each iterator adapter and source into individual modules)
 - #78305 (Stabilize alloc::Layout const functions)
 - #78608 (Stabilize refcell_take)
 - #78793 (Clean up `StructuralEq` docs)
 - #79267 (BTreeMap: address namespace conflicts)
 - #79293 (Add test for eval order for a+=b)
 - #79295 (BTreeMap: fix minor testing mistakes in #78903)
 - #79297 (BTreeMap: swap the names of NodeRef::new and Root::new_leaf)
 - #79299 (Stabilise `then`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoReduce boilerplate with the `?` operator
LingMan [Sun, 11 Oct 2020 18:52:48 +0000 (20:52 +0200)]
Reduce boilerplate with the `?` operator

3 years agoUse Option::and_then instead of open-coding it
LingMan [Sun, 11 Oct 2020 06:32:19 +0000 (08:32 +0200)]
Use Option::and_then instead of open-coding it

3 years agoChange slice::to_vec to not use extend_from_slice
kadmin [Wed, 18 Nov 2020 22:59:47 +0000 (22:59 +0000)]
Change slice::to_vec to not use extend_from_slice

This also required adding a loop guard in case clone panics

Add specialization for copy

There is a better version for copy, so I've added specialization for that function
and hopefully that should speed it up even more.

Switch FromIter<slice::Iter> to use `to_vec`

Test different unrolling version for to_vec

Revert to impl

From benchmarking, it appears this version is faster

3 years agoDrop support for cloudabi targets
Lzu Tao [Tue, 27 Oct 2020 13:10:31 +0000 (13:10 +0000)]
Drop support for cloudabi targets

3 years agoRollup merge of #79299 - varkor:stabilise-then, r=m-ou-se
Mara Bos [Sun, 22 Nov 2020 22:01:08 +0000 (23:01 +0100)]
Rollup merge of #79299 - varkor:stabilise-then, r=m-ou-se

Stabilise `then`

Stabilises the lazy variant of https://github.com/rust-lang/rust/issues/64260 now that the FCP [has ended](https://github.com/rust-lang/rust/issues/64260#issuecomment-731636203).

I've kept the original feature gate `bool_to_option` for the strict variant (`then_some`), and created a new insta-stable feature gate `lazy_bool_to_option` for `then`.

3 years agoRollup merge of #79297 - ssomers:btree_post_redux, r=Mark-Simulacrum
Mara Bos [Sun, 22 Nov 2020 22:01:07 +0000 (23:01 +0100)]
Rollup merge of #79297 - ssomers:btree_post_redux, r=Mark-Simulacrum

BTreeMap: swap the names of NodeRef::new and Root::new_leaf

#78104 preserved the name of Root::new_leaf to minimize changes, but the resulting names are confusing.

r? `@Mark-Simulacrum`

3 years agoRollup merge of #79295 - ssomers:btree_fix_78903, r=Mark-Simulacrum
Mara Bos [Sun, 22 Nov 2020 22:01:05 +0000 (23:01 +0100)]
Rollup merge of #79295 - ssomers:btree_fix_78903, r=Mark-Simulacrum

BTreeMap: fix minor testing mistakes in #78903

Mostly a duplicate test case
r? `@Mark-Simulacrum`

3 years agoRollup merge of #79293 - Havvy:test-eval-order-compound-assign, r=Mark-Simulacrum
Mara Bos [Sun, 22 Nov 2020 22:01:03 +0000 (23:01 +0100)]
Rollup merge of #79293 - Havvy:test-eval-order-compound-assign, r=Mark-Simulacrum

Add test for eval order for a+=b

Yes, the order of evaluation *does* change depending on the types of
the operands. Cursed, I know.

I've elected to place this test into `expr/compound-assignment` creating
both the `expr` directory and the `compound-assignment` directory. I
plan in a future PR to also move the `if` directory and the loose `if`
tests into `expr/if` and other similar cleanups of the `test/ui`
directory.

Future work: Test more than just `+=`, but all operators. I don't know
if using a macro to generate these tests cases would be okay or not,
but it'd be boilerplatey without it. I'm also confident you cannot
change the evaluation order of one operator without changing all of
them.

Future work: Additionally, test more than just `i32 += i32` for the
primitive version. I don't actually know the full set of primitive
implementations, but I imagine there's enough to cause a combinatorial
explosion with the previous future work item. Somewhere on the order of
one to two hundred individual functions.

3 years agoRollup merge of #79267 - ssomers:btree_namespaces, r=Mark-Simulacrum
Mara Bos [Sun, 22 Nov 2020 22:01:02 +0000 (23:01 +0100)]
Rollup merge of #79267 - ssomers:btree_namespaces, r=Mark-Simulacrum

BTreeMap: address namespace conflicts

Fix an annoyance popping up whenever synchronizing the test cases with a version capable of miri-track-raw-pointers.

r? `@Mark-Simulacrum`

3 years agoRollup merge of #78793 - camelid:fixup-structuraleq, r=jyn514
Mara Bos [Sun, 22 Nov 2020 22:01:00 +0000 (23:01 +0100)]
Rollup merge of #78793 - camelid:fixup-structuraleq, r=jyn514

Clean up `StructuralEq` docs

3 years agoRollup merge of #78608 - ThinkChaos:stabilize_refcell_take, r=m-ou-se
Mara Bos [Sun, 22 Nov 2020 22:00:58 +0000 (23:00 +0100)]
Rollup merge of #78608 - ThinkChaos:stabilize_refcell_take, r=m-ou-se

Stabilize refcell_take

Tracking Issue: #71395

``@KodrAus`` nominated this for FCP, so here's a PR!
I've never made a stabilization PR, so please mention if there's anything I can improve, thanks.

3 years agoRollup merge of #78305 - ChrisDenton:const-layout, r=oli-obk
Mara Bos [Sun, 22 Nov 2020 22:00:56 +0000 (23:00 +0100)]
Rollup merge of #78305 - ChrisDenton:const-layout, r=oli-obk

Stabilize alloc::Layout const functions

Stabilizes #67521. In particular the following stable methods are stabilized as `const fn`:

* `size`
* `align`
* `from_size_align`

Stabilizing `size` and `align` should not be controversial as they are simple (usize and NonZeroUsize) fields and I don't think there's any reason to make them not const compatible in the future. That being true, the other methods are trivially `const`. The only other issue being returning a `Result` from a `const fn` but this has been made more usable by recent stabilizations.

3 years agoRollup merge of #77697 - WaffleLapkin:iter_split_adaptors, r=m-ou-se
Mara Bos [Sun, 22 Nov 2020 22:00:55 +0000 (23:00 +0100)]
Rollup merge of #77697 - WaffleLapkin:iter_split_adaptors, r=m-ou-se

Split each iterator adapter and source into individual modules

This PR creates individual modules for each iterator adapter and iterator source.

This is done to enhance the readability of corresponding modules (`adapters/mod.rs` and `sources.rs`) which were hard to navigate and read because of lots of repeated lines (e.g.: `adapters/mod.rs` was 3k lines long). This is also in line with some adapters which already had their own modules (`Flatten`, `FlatMap`, `Chain`, `Zip`, `Fuse`).

This PR also makes `Take`s adapter fields private (I have no idea why they were `pub(super)` before).

r? ``@LukasKalbertodt``

3 years agoRollup merge of #76941 - clarfonthey:is_subnormal, r=m-ou-se
Mara Bos [Sun, 22 Nov 2020 22:00:48 +0000 (23:00 +0100)]
Rollup merge of #76941 - clarfonthey:is_subnormal, r=m-ou-se

Add f{32,64}::is_subnormal

The docs recommend that you use dedicated methods instead of calling `classify` directly, although there isn't actually a way of checking if a number is subnormal without calling classify. There are dedicated methods for all other forms, excluding `is_zero` (which is just `== 0.0` anyway).

3 years agoStabilize `alloc::Layout const` functions
Chris Denton [Sun, 22 Nov 2020 21:21:46 +0000 (21:21 +0000)]
Stabilize `alloc::Layout const` functions

Stabilizes #67521. In particular the following stable methods are stabilized as const fn:

* size
* align
* from_size_align

3 years agoAuto merge of #79219 - shepmaster:beta-bump, r=Mark-Simulacrum
bors [Sun, 22 Nov 2020 21:38:03 +0000 (21:38 +0000)]
Auto merge of #79219 - shepmaster:beta-bump, r=Mark-Simulacrum

Bump bootstrap compiler version

r? `@Mark-Simulacrum`

/cc `@pietroalbini`

3 years agoAdd f{32,64}::is_subnormal
ltdk [Sat, 19 Sep 2020 20:31:47 +0000 (16:31 -0400)]
Add f{32,64}::is_subnormal

3 years agoStabilize refcell_take
ThinkChaos [Sat, 31 Oct 2020 18:06:25 +0000 (19:06 +0100)]
Stabilize refcell_take

3 years agoAuto merge of #79243 - Nadrieril:consolidate-tests, r=varkor
bors [Sun, 22 Nov 2020 18:29:38 +0000 (18:29 +0000)]
Auto merge of #79243 - Nadrieril:consolidate-tests, r=varkor

Consolidate exhaustiveness-related tests

I hunted for tests that only exercised the match exhaustiveness algorithm and regrouped them. I also improved integer-range tests since I had found them lacking while hacking around.
The interest is mainly so that one can pass `--test-args patterns` and catch most relevant tests.

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking

3 years agoAuto merge of #79306 - GuillaumeGomez:rollup-4cnudfj, r=GuillaumeGomez
bors [Sun, 22 Nov 2020 15:40:03 +0000 (15:40 +0000)]
Auto merge of #79306 - GuillaumeGomez:rollup-4cnudfj, r=GuillaumeGomez

Rollup of 4 pull requests

Successful merges:

 - #78670 (Remove FIXME comment in some incremental test suite)
 - #79292 (Fix typo in doc comment for report_too_many_hashes)
 - #79300 (Prevent feature information to be hidden if it's on the impl directly)
 - #79302 (Add regression test for issue 73899)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoAuto merge of #6361 - integer32llc:doc-style, r=carols10cents
bors [Sun, 22 Nov 2020 15:34:56 +0000 (15:34 +0000)]
Auto merge of #6361 - integer32llc:doc-style, r=carols10cents

Small grammar, punctuation, and code style improvements to docs

changelog: Made small grammar, punctuation, and code style improvements to docs

I recently found some places in rust-lang/rust that had lists without spaces after commas, which led me to look for more places, which led me over here to find:

- Some similar lists in code examples that could use spaces after commas to be idiomatic Rust style
- Some lists in documentation text that didn't have spaces after commas, needed an Oxford comma (fight me), or were otherwise misformatted
- Some other grammar improvements in the area of the other changes

These changes should only be in user-facing documentation or output.

3 years agoApply suggestions from code review to change "that" to "which"
Carol (Nichols || Goulding) [Sun, 22 Nov 2020 15:12:41 +0000 (10:12 -0500)]
Apply suggestions from code review to change "that" to "which"

Co-authored-by: oliver <16816606+o752d@users.noreply.github.com>
3 years agoSmall grammar, punctuation, and code style improvements to docs
Carol (Nichols || Goulding) [Sat, 21 Nov 2020 20:00:03 +0000 (15:00 -0500)]
Small grammar, punctuation, and code style improvements to docs

3 years agoRollup merge of #79302 - est31:issue_73899_test, r=lcnr
Guillaume Gomez [Sun, 22 Nov 2020 15:15:15 +0000 (16:15 +0100)]
Rollup merge of #79302 - est31:issue_73899_test, r=lcnr

Add regression test for issue 73899

Closes #73899

3 years agoRollup merge of #79300 - GuillaumeGomez:hidden-feature-info, r=jyn514
Guillaume Gomez [Sun, 22 Nov 2020 15:15:13 +0000 (16:15 +0100)]
Rollup merge of #79300 - GuillaumeGomez:hidden-feature-info, r=jyn514

Prevent feature information to be hidden if it's on the impl directly

Fixes #79279.

So when a `#[doc(cfg...)]` is used on a trait impl directly, it's not hidden by the toggle.

![Screenshot from 2020-11-22 14-40-11](https://user-images.githubusercontent.com/3050060/99905528-997fab00-2cd1-11eb-83be-ed06b0cb97df.png)

r? `@jyn514`

3 years agoRollup merge of #79292 - nico-abram:master, r=jonas-schievink
Guillaume Gomez [Sun, 22 Nov 2020 15:15:12 +0000 (16:15 +0100)]
Rollup merge of #79292 - nico-abram:master, r=jonas-schievink

Fix typo in doc comment for report_too_many_hashes

"to big" -> "too big"

3 years agoRollup merge of #78670 - sasurau4:test/check-pass-incremental, r=jyn514
Guillaume Gomez [Sun, 22 Nov 2020 15:15:10 +0000 (16:15 +0100)]
Rollup merge of #78670 - sasurau4:test/check-pass-incremental, r=jyn514

Remove FIXME comment in some incremental test suite

Helps with #62277

I removed FIXME comment in some incremental tests with [rustc_partition_codegened](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_incremental/assert_module_sources/index.html). This seems using codegen process. So it uses intentionally `build-pass`

3 years agoPrevent feature information to be hidden if it's on the impl directly
Guillaume Gomez [Sun, 22 Nov 2020 13:45:54 +0000 (14:45 +0100)]
Prevent feature information to be hidden if it's on the impl directly

3 years agoAdd some more tests
Jonas Schievink [Sun, 22 Nov 2020 14:51:05 +0000 (15:51 +0100)]
Add some more tests

3 years agoAdd regression test for issue 73899
est31 [Sun, 22 Nov 2020 13:53:31 +0000 (14:53 +0100)]
Add regression test for issue 73899

Adds regression test for https://github.com/rust-lang/rust/issues/73899

3 years agoAuto merge of #6363 - o752d:patch-2, r=flip1995
bors [Sun, 22 Nov 2020 14:08:01 +0000 (14:08 +0000)]
Auto merge of #6363 - o752d:patch-2, r=flip1995

a typo

typo

changelog: none

3 years agoAuto merge of #6364 - o752d:master, r=flip1995
bors [Sun, 22 Nov 2020 13:48:02 +0000 (13:48 +0000)]
Auto merge of #6364 - o752d:master, r=flip1995

revisiting a typo

changelog: none

3 years agoStabilise `then`
varkor [Sun, 22 Nov 2020 13:25:19 +0000 (13:25 +0000)]
Stabilise `then`

3 years agoAuto merge of #78816 - SkiFire13:fix-slice-pointer-provenance, r=RalfJung
bors [Sun, 22 Nov 2020 13:10:15 +0000 (13:10 +0000)]
Auto merge of #78816 - SkiFire13:fix-slice-pointer-provenance, r=RalfJung

<[T]>::reverse: Fix pointer provenance rules

Should fix #78749

3 years agoBTreeMap: swap the names of NodeRef::new and Root::new_leaf
Stein Somers [Sun, 22 Nov 2020 11:29:48 +0000 (12:29 +0100)]
BTreeMap: swap the names of NodeRef::new and Root::new_leaf

3 years agoBTreeMap: fix minor testing mistakes in #78903
Stein Somers [Sun, 22 Nov 2020 12:06:12 +0000 (13:06 +0100)]
BTreeMap: fix minor testing mistakes in #78903

3 years agoresolve: Do not put macros into `module.unexpanded_invocations` unless necessary
Vadim Petrochenkov [Sat, 21 Nov 2020 15:02:37 +0000 (18:02 +0300)]
resolve: Do not put macros into `module.unexpanded_invocations` unless necessary

3 years agoAdd test for an unmotivated "cannot determine resolution" error
Vadim Petrochenkov [Sun, 22 Nov 2020 11:20:16 +0000 (14:20 +0300)]
Add test for an unmotivated "cannot determine resolution" error

3 years agoAdd test for eval order for a+=b
Havvy (Ryan Scheel) [Sun, 22 Nov 2020 10:48:14 +0000 (02:48 -0800)]
Add test for eval order for a+=b

Yes, the order of evaluation *does* change depending on the types of
the operands. Cursed, I know.

I've elected to place this test into `expr/compound-assignment` creating
both the `expr` directory and the `compound-assignment` directory. I
plan in a future PR to also move the `if` directory and the loose `if`
tests into `expr/if` and other similar cleanups of the `test/ui`
directory.

Future work: Test more than just `+=`, but all operators. I don't know
if using a macro to generate these tests cases would be okay or not,
but it'd be boilerplatey without it. I'm also confident you cannot
change the evaluation order of one operator without changing all of
them.

Future work: Additionally, test more than just `i32 += i32` for the
primitive version. I don't actually know the full set of primitive
implementations, but I imagine there's enough to cause a combinatorial
explosion with the previous future work item. Somewhere on the order of
one to two hundred individual functions.

3 years agoAuto merge of #77872 - Xaeroxe:stabilize-clamp, r=scottmcm
bors [Sun, 22 Nov 2020 10:50:04 +0000 (10:50 +0000)]
Auto merge of #77872 - Xaeroxe:stabilize-clamp, r=scottmcm

Stabilize clamp

Tracking issue: https://github.com/rust-lang/rust/issues/44095

Clamp has been merged and unstable for about a year and a half now. How do we feel about stabilizing this?

3 years agoFix typo in doc comment for report_too_many_hashes
Nicolas [Sun, 22 Nov 2020 10:02:58 +0000 (07:02 -0300)]
Fix typo in doc comment for report_too_many_hashes

"to big" -> "too big"

3 years agoAuto merge of #79275 - integer32llc:doc-style, r=jonas-schievink
bors [Sun, 22 Nov 2020 08:30:23 +0000 (08:30 +0000)]
Auto merge of #79275 - integer32llc:doc-style, r=jonas-schievink

More consistently use spaces after commas in lists in docs

This PR changes instances of lists that didn't use spaces after commas, like `vec![1,2,3]`, to `vec![1, 2, 3]` to be more consistent with idiomatic Rust style (the way these were looks strange to me, especially because there are often lists that *do* use spaces after the commas later in the same code block 😬).

I noticed one of these in an example in the stdlib docs and went looking for more, but as far as I can see, I'm only changing those spots in user-facing documentation or rustc output, and the changes make no semantic difference.

3 years agoupdate
oliver [Sun, 22 Nov 2020 04:50:09 +0000 (00:50 -0400)]
update

3 years agoa typo
oliver [Sun, 22 Nov 2020 04:44:47 +0000 (04:44 +0000)]
a typo

typo

3 years agoAuto merge of #79229 - sdroege:slice-fill-memset, r=dtolnay
bors [Sun, 22 Nov 2020 04:27:03 +0000 (04:27 +0000)]
Auto merge of #79229 - sdroege:slice-fill-memset, r=dtolnay

Add "memset" as doc alias to slice::fill()

Similar to 53f969dfd1b5c128145c24653c668193e8c50f85 and should make it easier for people coming from C to find this function.

3 years agoconst fn: allow use of trait impls from bounds
Jonas Schievink [Sun, 22 Nov 2020 03:19:46 +0000 (04:19 +0100)]
const fn: allow use of trait impls from bounds

3 years agowinnow: drop non-const cand. in favor of const
Jonas Schievink [Sun, 22 Nov 2020 03:04:49 +0000 (04:04 +0100)]
winnow: drop non-const cand. in favor of const

3 years agoThread `Constness` through selection
Jonas Schievink [Sun, 22 Nov 2020 01:13:53 +0000 (02:13 +0100)]
Thread `Constness` through selection

3 years agoAuto merge of #78752 - jyn514:html-diff, r=GuillaumeGomez
bors [Sun, 22 Nov 2020 01:09:04 +0000 (01:09 +0000)]
Auto merge of #78752 - jyn514:html-diff, r=GuillaumeGomez

Give a better error when rustdoc tests fail

- Run the default rustdoc against the current rustdoc
- Diff output recursively
- Colorize diff output

Closes https://github.com/rust-lang/rust/issues/78750.

## Resolved questions

- Should this be opt-in instead of on by default?
  + No
- Should this call through to `delta`? That's not a very common program to have installed, but I'm not sure how to do diffs after the fact. Maybe `compiletest` can take a `--syntax-highlighter` parameter or something?
  + I decided to use `delta` if available and `diff --color` otherwise. It prints a warning if delta isn't installed so you know you can get nicer diffs

## Open questions.

- What version of rustdoc would this compare against? Ideally it would compare against `$(git merge-base HEAD origin/master)` - maybe that's feasible if we install those artifacts from CI?
- Does it always make sense to compare the tests? Especially for new tests, I'm not sure how useful it would be ... but then again, one of the questions I want to know most as a reviewer is 'did it break before?'.

r? `@GuillaumeGomez`
cc `@Mark-Simulacrum`

3 years agoRemove multiline `use`s
Waffle [Thu, 8 Oct 2020 17:08:40 +0000 (20:08 +0300)]
Remove multiline `use`s

3 years agoFix UI tests
Waffle [Thu, 8 Oct 2020 15:18:28 +0000 (18:18 +0300)]
Fix UI tests

Some UI tests started failing after moving iterator adapters to different modules.

3 years agoFix doc links in core::iter::sources
Waffle [Thu, 8 Oct 2020 11:02:28 +0000 (14:02 +0300)]
Fix doc links in core::iter::sources

3 years agoMerge `use`s in core::iter
Waffle [Wed, 7 Oct 2020 23:26:29 +0000 (02:26 +0300)]
Merge `use`s in core::iter

3 years agoSplit iterator sources into different modules
Waffle [Wed, 7 Oct 2020 22:08:01 +0000 (01:08 +0300)]
Split iterator sources into different modules

3 years agoSplit iterator adaptors into individual modules
Waffle [Wed, 7 Oct 2020 21:14:11 +0000 (00:14 +0300)]
Split iterator adaptors into individual modules

This commit also makes fields of `Take` private. I have no idea why they
were `pub(super)` before.

3 years agoAuto merge of #78461 - TimDiekmann:vec-alloc, r=Amanieu
bors [Sat, 21 Nov 2020 22:46:50 +0000 (22:46 +0000)]
Auto merge of #78461 - TimDiekmann:vec-alloc, r=Amanieu

Add support for custom allocators in `Vec`

This follows the [roadmap](https://github.com/rust-lang/wg-allocators/issues/7) of the allocator WG to add custom allocators to collections.

r? `@Amanieu`

This pull request requires a crater run.

### Prior work:
- #71873: Crater-test to solve rust-lang/wg-allocators#1
- [`alloc-wg`](https://github.com/TimDiekmann/alloc-wg)-crate

3 years agoAuto merge of #79273 - Dylan-DPC:rollup-zd10xlt, r=Dylan-DPC
bors [Sat, 21 Nov 2020 20:18:11 +0000 (20:18 +0000)]
Auto merge of #79273 - Dylan-DPC:rollup-zd10xlt, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #77844 (clarify rules for ZST Boxes)
 - #79067 (Refactor the abi handling code a bit)
 - #79182 (Fix links to extern types in rustdoc (fixes #78777))
 - #79231 (Exhaustively match in variant count instrinsic)
 - #79238 (Direct RUSTC_LOG (tracing/log) output to stderr instead of stdout.)
 - #79256 (Fix typos)
 - #79264 (Get rid of some doctree items)
 - #79272 (Support building clone shims for arrays with generic size)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoMore consistently use spaces after commas in lists in docs
Carol (Nichols || Goulding) [Sat, 21 Nov 2020 19:43:34 +0000 (14:43 -0500)]
More consistently use spaces after commas in lists in docs

3 years agoRollup merge of #79272 - tmiasko:array-clone, r=jonas-schievink
Dylan DPC [Sat, 21 Nov 2020 18:44:20 +0000 (19:44 +0100)]
Rollup merge of #79272 - tmiasko:array-clone, r=jonas-schievink

Support building clone shims for arrays with generic size

Fixes #79269.

3 years agoRollup merge of #79264 - jyn514:less-doctree, r=GuillaumeGomez
Dylan DPC [Sat, 21 Nov 2020 18:44:18 +0000 (19:44 +0100)]
Rollup merge of #79264 - jyn514:less-doctree, r=GuillaumeGomez

Get rid of some doctree items

They can be derived directly from the `hir::Item`, there's no special logic.

- TypeDef
- OpaqueTy
- Constant
- Static
- TraitAlias
- Enum
- Union
- Struct

Part of #78082 (the easiest part, I'm still debugging some other changes).
r? `@GuillaumeGomez`

3 years agoRollup merge of #79256 - bugadani:query-typo, r=jonas-schievink
Dylan DPC [Sat, 21 Nov 2020 18:44:16 +0000 (19:44 +0100)]
Rollup merge of #79256 - bugadani:query-typo, r=jonas-schievink

Fix typos

3 years agoRollup merge of #79238 - eddyb:rustc-log-stderr, r=jyn514
Dylan DPC [Sat, 21 Nov 2020 18:44:15 +0000 (19:44 +0100)]
Rollup merge of #79238 - eddyb:rustc-log-stderr, r=jyn514

Direct RUSTC_LOG (tracing/log) output to stderr instead of stdout.

Looks like this got missed in the initial implementation, AFAIK the old behavior was to output on stderr.
(Hit this while trying to debug `rustc` running inside a build script which was only letting stderr through)

r? ``@oli-obk`` cc ``@davidbarsky`` ``@hawkw``

3 years agoRollup merge of #79231 - wusyong:issue-79137, r=lcnr
Dylan DPC [Sat, 21 Nov 2020 18:44:13 +0000 (19:44 +0100)]
Rollup merge of #79231 - wusyong:issue-79137, r=lcnr

Exhaustively match in variant count instrinsic

Fix #79137