Commit Graph

133928 Commits

Author SHA1 Message Date
bors
25a691003c Auto merge of #79335 - jyn514:doctree-crate, r=GuillaumeGomez
Get rid of doctree::{ExternalCrate, ForeignItem, Trait, Function}

Closes #79314, closes #79331, closes #79332. Follow-up to #79264 and #79312, continues breaking up #78082.

r? `@GuillaumeGomez`
2020-11-24 16:08:23 +00:00
Joshua Nelson
66e30ec712 Get rid of doctree::ExternCrate 2020-11-24 09:54:53 -05:00
Joshua Nelson
2a58fa0682 Get rid of doctree::Trait 2020-11-24 09:54:53 -05:00
Joshua Nelson
a3a5d2cd13 Get rid of doctree::Function 2020-11-24 09:54:53 -05:00
Joshua Nelson
35e7beed0e Get rid of doctree::ForeignItem 2020-11-24 09:54:53 -05:00
bors
53d19b37c5 Auto merge of #79377 - jonas-schievink:rollup-ye81i66, r=jonas-schievink
Rollup of 10 pull requests

Successful merges:

 - #76858 (Add exploit mitigations chapter to the rustc book)
 - #79310 (Make `fold_item_recur` non-nullable)
 - #79312 (Get rid of `doctree::Impl`)
 - #79321 (Accept '!' in intra-doc links)
 - #79346 (Allow using `-Z fewer-names=no` to retain value names)
 - #79351 (Fix typo in `keyword` docs for traits)
 - #79354 (BTreeMap: cut out the ceremony around BoxedNode)
 - #79358 (BTreeMap/BTreeSet: make public doc more consistent)
 - #79367 (Allow disabling TrapUnreachable via -Ztrap-unreachable=no)
 - #79374 (Add note to use nightly when using expr in const generics)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-24 12:27:30 +00:00
Jonas Schievink
f049b0be96
Rollup merge of #79374 - mendess:const-param-expr-diagnostic, r=lcnr
Add note to use nightly when using expr in const generics

As recommended by `@Icnr` in #73899 and in zulip, I've added a note saying that const expressions can be used in nightly.

```
error: generic parameters may not be used in const operations
  --> $DIR/issue-61935.rs:10:23
   |
 6 |         Self:FooImpl<{N==0}>
   |                       ^ cannot perform const operation using `N`
   |
   = help: const parameters may only be used as standalone arguments, i.e. `N`
   = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this

error: aborting due to previous error
```

I hope the note is well written 😅
2020-11-24 13:17:51 +01:00
Jonas Schievink
95e7af353f
Rollup merge of #79367 - Dirbaio:trap-unreachable, r=jonas-schievink
Allow disabling TrapUnreachable via -Ztrap-unreachable=no

Currently this is only possible by defining a custom target, which is quite unwieldy.

This is useful for embedded targets where small code size is desired. For example, on my project (thumbv7em-none-eabi) this yields a 0.6% code size reduction: 132892 bytes -> 132122 bytes (770 bytes down).
2020-11-24 13:17:49 +01:00
Jonas Schievink
ce197961ac
Rollup merge of #79358 - ssomers:btree_public_comments, r=Mark-Simulacrum
BTreeMap/BTreeSet: make public doc more consistent

Tweaks #72876 and #73667 and propagate them to `BTreeSet`.
2020-11-24 13:17:47 +01:00
Jonas Schievink
012d5fd8d7
Rollup merge of #79354 - ssomers:btree_bereave_BoxedNode, r=Mark-Simulacrum
BTreeMap: cut out the ceremony around BoxedNode

The opposite direction of #79093.

r? ``@Mark-Simulacrum``
2020-11-24 13:17:45 +01:00
Jonas Schievink
ed5d539c62
Rollup merge of #79351 - Takashiidobe:keyword-docs-typo, r=m-ou-se
Fix typo in `keyword` docs for traits

This PR fixes a small typo in the `keyword_docs.rs` file, describing the differences between the 2015 and 2018 editions of traits.
2020-11-24 13:17:43 +01:00
Jonas Schievink
3a728bd129
Rollup merge of #79346 - tmiasko:more-names, r=jonas-schievink
Allow using `-Z fewer-names=no` to retain value names

Change `-Z fewer-names` into an optional boolean flag and allow using it
to either discard value names when true or retain them when false,
regardless of other settings.
2020-11-24 13:17:41 +01:00
Jonas Schievink
3f36f92a96
Rollup merge of #79321 - camelid:intra-doc-bang, r=Manishearth
Accept '!' in intra-doc links

This will allow linking to things like `Result<T, !>`.

*See <https://github.com/rust-lang/rust/pull/77832#discussion_r528409079>.*

r? ``@jyn514``
2020-11-24 13:17:39 +01:00
Jonas Schievink
5a66a73282
Rollup merge of #79312 - jyn514:doctree-impl, r=GuillaumeGomez
Get rid of `doctree::Impl`

Follow-up to https://github.com/rust-lang/rust/pull/79264, continues breaking up https://github.com/rust-lang/rust/pull/78082. At some point I want to introduce `MaybeInlined`, but I think I'll wait until I need `MaybeInlined::InlinedWithOriginal` because it's not very useful in other situations.

r? ``@GuillaumeGomez``
2020-11-24 13:17:37 +01:00
Jonas Schievink
f74b223e19
Rollup merge of #79310 - jyn514:fold-item-cleanup, r=GuillaumeGomez
Make `fold_item_recur` non-nullable

This gets rid of a bunch of `unwrap()`s and makes it a little more clear
what's going on.

Originally I wanted to make `fold_item` non-nullable too, which would
have been a lot nicer to work with, but unfortunately `stripper` does
actually return `None` in some places. I might make a follow-up moving
stripper to be special and not a pass so that passes can be
non-nullable.

Found while working on https://github.com/rust-lang/rust/issues/76998.
2020-11-24 13:17:35 +01:00
Jonas Schievink
8fde4be7d0
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.
2020-11-24 13:17:28 +01:00
mendess
888055eb4c Swap note for help 2020-11-24 11:05:55 +00:00
mendess
af978e3b63 Requested changes 2020-11-24 10:28:18 +00:00
mendess
b7593e5070 Add note to use nightly when using expr in const generics 2020-11-24 09:35:08 +00:00
bors
6331023708 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).
2020-11-24 09:17:33 +00:00
bors
238994f3b1 Auto merge of #79228 - flip1995:clippyup, r=oli-obk
Update Clippy

Biweekly Clippy update

r? `@Manishearth`
2020-11-24 06:56:02 +00:00
Ramon de C Valle
5b1cb0eb8a 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.
2020-11-23 19:25:59 -08:00
bors
4167d731dc 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`
2020-11-24 03:12:20 +00:00
bors
cb5b87133a 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.

1899c489d4/library/proc_macro/src/quote.rs (L79)
1899c489d4/library/proc_macro/src/quote.rs (L83)
1899c489d4/src/test/ui/suggestions/auxiliary/issue-61963.rs (L26)
1899c489d4/src/test/ui/proc-macro/auxiliary/three-equals.rs (L23)
2020-11-24 00:30:25 +00:00
Dario Nieuwenhuis
7b62e09b03 Allow disabling TrapUnreachable via -Ztrap-unreachable=no
This is useful for embedded targets where small code size is desired.
For example, on my project (thumbv7em-none-eabi) this yields a 0.6% code size reduction.
2020-11-24 01:08:27 +01:00
bors
f32a0cce2f 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.
2020-11-23 22:05:28 +00:00
Camelid
d8b1d51b95 Clean up core macros documentation
* Switch a couple links over to intra-doc links
* Clean up some formatting/typography
2020-11-23 11:28:25 -08:00
Camelid
d37e1e186e 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.
2020-11-23 11:28:25 -08:00
bors
d9a105fdd4 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
2020-11-23 19:01:19 +00:00
Stein Somers
9c8db454af BTreeMap/BTreeSet: make public doc more consistent 2020-11-23 19:10:02 +01:00
bors
40624dde6c 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
2020-11-23 16:33:03 +00:00
Stein Somers
8526c313c1 BTreeMap: cut out the ceremony around BoxedNode 2020-11-23 17:02:08 +01:00
takashiidobe
c5c3d7bdf4 Fix typo in keyword docs for traits 2020-11-23 10:51:30 -05:00
Jonas Schievink
ea3c269b70
Rollup merge of #79343 - flip1995:mailmap, r=Mark-Simulacrum
Add my (@flip1995) work mail to the mailmap
2020-11-23 15:25:55 +01:00
Jonas Schievink
064c3c146a
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
2020-11-23 15:25:53 +01:00
Jonas Schievink
a0cf162329
Rollup merge of #79333 - o752d:patch-3, r=Mark-Simulacrum
doc typo

plus a small edit for clarity
2020-11-23 15:25:51 +01:00
Jonas Schievink
b48ebc6b15
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`
2020-11-23 15:25:49 +01:00
Jonas Schievink
b4db342f51
Rollup merge of #79325 - LingMan:try_op, r=jonas-schievink
Reduce boilerplate with the `?` operator

`@rustbot` modify labels to +C-cleanup.
2020-11-23 15:25:47 +01:00
Jonas Schievink
32be3ae06a
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.
2020-11-23 15:25:46 +01:00
Jonas Schievink
c7a67209c8
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.
2020-11-23 15:25:44 +01:00
Jonas Schievink
c58c245e2c
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`
2020-11-23 15:25:42 +01:00
Jonas Schievink
d4a05696d9
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`
2020-11-23 15:25:40 +01:00
Jonas Schievink
703f176d57
Rollup merge of #76829 - tspiteri:const-int-pow, r=oli-obk
stabilize const_int_pow

This also requires stabilizing constctlz for const ctlz_nonzero.
2020-11-23 15:25:38 +01:00
bors
40cf72108e 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.
2020-11-23 14:20:22 +00:00
flip1995
c7d1189738
Add my (@flip1995) work mail to the mailmap 2020-11-23 14:11:56 +01:00
flip1995
99b9459a77
Fix ICE in utils::implements_trait
This only happend when debug_assertions were enabled in rustc
2020-11-23 13:52:27 +01:00
flip1995
dfac9be082
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup 2020-11-23 13:51:04 +01:00
bors
068320b39e 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>,
}
```
2020-11-23 07:00:30 +00:00
bors
1823a87986 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.
2020-11-23 04:47:25 +00:00
LingMan
cd8973250d Use Option::map instead of open coding it 2020-11-23 04:58:21 +01:00