]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoDon't try to add nested predicate to Rustdoc auto-trait `ParamEnv`
Aaron Hill [Mon, 21 Dec 2020 02:07:13 +0000 (21:07 -0500)]
Don't try to add nested predicate to Rustdoc auto-trait `ParamEnv`

Fixes #80233

We already have logic in `evaluate_predicates` that tries to add
unimplemented predicates to our `ParamEnv`. Trying to add a predicate
that already holds can lead to errors later on, since projection
will prefer trait candidates from the `ParamEnv` to predicates from an
impl.

3 years agoAuto merge of #74699 - notriddle:fd-non-negative, r=m-ou-se
bors [Sun, 20 Dec 2020 16:36:23 +0000 (16:36 +0000)]
Auto merge of #74699 - notriddle:fd-non-negative, r=m-ou-se

Mark `-1` as an available niche for file descriptors

Based on discussion from <https://internals.rust-lang.org/t/can-the-standard-library-shrink-option-file/12768>, the file descriptor `-1` is chosen based on the POSIX API designs that use it as a sentinel to report errors. A bigger niche could've been chosen, particularly on Linux, but would not necessarily be portable.

This PR also adds a test case to ensure that the -1 niche (which is kind of hacky and has no obvious test case) works correctly. It requires the "upper" bound, which is actually -1, to be expressed in two's complement.

3 years agoAuto merge of #80213 - jryans:bootstrap-skip-dsymutil, r=nagisa
bors [Sun, 20 Dec 2020 13:47:23 +0000 (13:47 +0000)]
Auto merge of #80213 - jryans:bootstrap-skip-dsymutil, r=nagisa

Skip `dsymutil` by default for compiler bootstrap

`dsymutil` adds time to builds on Apple platforms for no clear benefit, and also makes it more difficult for debuggers to find debug info (which `@pnkfelix` highlighted on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/does.20lldb.20%28or.20gdb%29.20work.20on.20rustc.20on.20Mac.3F/near/220482092)). The compiler currently defaults to running `dsymutil` to preserve its historical default, but when compiling the compiler itself, we skip it by default since we know it's safe to do so in that case.

r? `@nagisa`

3 years agoCheck that c_int is i32 in FileDesc::new.
Mara Bos [Sun, 20 Dec 2020 11:56:51 +0000 (11:56 +0000)]
Check that c_int is i32 in FileDesc::new.

3 years agoAuto merge of #80123 - DrMeepster:maybe_uninit_write_slice, r=RalfJung
bors [Sun, 20 Dec 2020 10:08:56 +0000 (10:08 +0000)]
Auto merge of #80123 - DrMeepster:maybe_uninit_write_slice, r=RalfJung

Fix memory leak in test "mem::uninit_write_slice_cloned_no_drop"

This fixes #80116. I replaced the `Rc` based method I was using with a type that panics when dropped.

3 years agoAuto merge of #80163 - jackh726:binder-refactor-part-3, r=lcnr
bors [Sun, 20 Dec 2020 07:01:00 +0000 (07:01 +0000)]
Auto merge of #80163 - jackh726:binder-refactor-part-3, r=lcnr

Make BoundRegion have a kind of BoungRegionKind

Split from #76814

Also includes making `replace_escaping_bound_vars` only return `T`

Going to r? `@lcnr`
Feel free to reassign

3 years agoAuto merge of #80100 - mark-i-m:pattORns-2, r=petrochenkov
bors [Sun, 20 Dec 2020 04:10:44 +0000 (04:10 +0000)]
Auto merge of #80100 - mark-i-m:pattORns-2, r=petrochenkov

or_patterns: implement :pat edition-specific behavior

cc #54883 `@joshtriplett`

This PR implements the edition-specific behavior of `:pat` wrt or-patterns, as determined by the crater runs and T-lang consensus in https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090.

I believe this can unblock stabilization of or_patterns.

r? `@petrochenkov`

3 years agoSkip `dsymutil` by default for compiler bootstrap
J. Ryan Stinnett [Sun, 20 Dec 2020 02:49:18 +0000 (02:49 +0000)]
Skip `dsymutil` by default for compiler bootstrap

`dsymutil` adds time to builds on Apple platforms for no clear benefit, and also
makes it more difficult for debuggers to find debug info. The compiler currently
defaults to running `dsymutil` to preserve its historical default, but when
compiling the compiler itself, we skip it by default since we know it's safe to
do so in that case.

3 years agoAuto merge of #79635 - lcnr:const-eval-idk, r=oli-obk
bors [Sun, 20 Dec 2020 00:50:46 +0000 (00:50 +0000)]
Auto merge of #79635 - lcnr:const-eval-idk, r=oli-obk

const_evaluatable_checked: fix occurs check

fixes #79615

this is kind of a hack because we use `TypeRelation` for both the `Generalizer` and the `ConstInferUnifier` but i am not sure if there is a useful way to disentangle this without unnecessarily duplicating some code.

The error in the added test is kind of unavoidable until we erase the unused substs of `ConstKind::Unevaluated`. We talked a bit about this in the cg lazy norm meeting (https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/lazy_normalization_consts)

3 years agoAuto merge of #79473 - m-ou-se:clamp-in-core, r=m-ou-se
bors [Sat, 19 Dec 2020 21:57:38 +0000 (21:57 +0000)]
Auto merge of #79473 - m-ou-se:clamp-in-core, r=m-ou-se

Move {f32,f64}::clamp to core.

`clamp` was recently stabilized (tracking issue: https://github.com/rust-lang/rust/issues/44095). But although `Ord::clamp` was added in `core` (because `Ord` is in `core`), the versions for the `f32` and `f64` primitives were added in `std` (together with `floor`, `sin`, etc.), not in `core` (together with `min`, `max`, `from_bits`, etc.).

This change moves them to `core`, such that `clamp` on floats is available in `no_std` programs as well.

3 years agoAuto merge of #80104 - Nadrieril:usefulness-merging, r=varkor
bors [Sat, 19 Dec 2020 19:14:04 +0000 (19:14 +0000)]
Auto merge of #80104 - Nadrieril:usefulness-merging, r=varkor

Improve and fix diagnostics of exhaustiveness checking

Primarily, this fixes https://github.com/rust-lang/rust/issues/56379. This also fixes incorrect interactions between or-patterns and slice patterns that I discovered while working on #56379. Those two examples show the incorrect diagnostics:

```rust
match &[][..] {
    [true] => {}
    [true // detected as unreachable but that's not true
        | false, ..] => {}
    _ => {}
}
match (true, None) {
    (true, Some(_)) => {}
    (false, Some(true)) => {}
    (true | false, None | Some(true // should be detected as unreachable
                               | false)) => {}
}
```

I did not measure any perf impact. However, I suspect that [`616ba9f`](https://github.com/rust-lang/rust/pull/80104/commits/616ba9f9f7f5845777a36e1a41a515e6c33a8776) should have a negative impact on large or-patterns. I'll see what the perf run says; I have optimization ideas up my sleeve if needed.

EDIT: I initially had a noticeable perf impact that I thought unavoidable. I then proceeded to avoid it x)

r? `@varkor`
`@rustbot` label +A-exhaustiveness-checking

3 years agoAuto merge of #80132 - matthewjasper:revert-eval-order, r=nikomatsakis
bors [Sat, 19 Dec 2020 16:20:22 +0000 (16:20 +0000)]
Auto merge of #80132 - matthewjasper:revert-eval-order, r=nikomatsakis

Revert change to trait evaluation order

This change breaks some code and doesn't appear to enable any new code.

closes #79902

r? `@nikomatsakis`

3 years agoAuto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk
bors [Sat, 19 Dec 2020 13:13:41 +0000 (13:13 +0000)]
Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk

Stabilize all stable methods of `Ipv4Addr`, `Ipv6Addr` and `IpAddr` as const

This PR stabilizes all currently stable methods of `Ipv4Addr`, `Ipv6Addr` and `IpAddr` as const.
Tracking issue: #76205

`Ipv4Addr` (`const_ipv4`):
 - `octets`
 - `is_loopback`
 - `is_private`
 - `is_link_local`
 - `is_multicast`
 - `is_broadcast`
 - `is_docmentation`
 - `to_ipv6_compatible`
 - `to_ipv6_mapped`

`Ipv6Addr` (`const_ipv6`):
 - `segments`
 - `is_unspecified`
 - `is_loopback`
 - `is_multicast`
 - `to_ipv4`

`IpAddr` (`const_ip`):
 - `is_unspecified`
 - `is_loopback`
 - `is_multicast`

## Motivation
The ip methods seem like prime candidates to be made const: their behavior is defined by an external spec, and based solely on the byte contents of an address. These methods have been made unstable const in the beginning of September, after the necessary const integer arithmetic was stabilized.

There is currently a PR open (#78802) to change the internal representation of `IpAddr{4,6}` from `libc` types to a byte array. This does not have any impact on the constness of the methods.

## Implementation
Most of the stabilizations are straightforward, with the exception of `Ipv6Addr::segments`, which uses the unstable feature `const_fn_transmute`. The code could be rewritten to equivalent stable code, but this leads to worse code generation (#75085).
This is why `segments` gets marked with `#[rustc_allow_const_fn_unstable(const_fn_transmute)]`, like the already const-stable `Ipv6Addr::new`, the justification being that a const-stable alternative implementation exists https://github.com/rust-lang/rust/pull/76206#issuecomment-685044184.

## Future posibilities
This PR const-stabilizes all currently stable ip methods, however there are also a number of unstable methods under the `ip` feature (#27709). These methods are already unstable const. There is a PR open (#76098) to stabilize those methods, which could include const-stabilization. However, stabilizing those methods as const is dependent on `Ipv4Addr::octets` and `Ipv6Addr::segments` (covered by this PR).

3 years agoimplement edition-specific :pat behavior for 2015/18
mark [Wed, 11 Nov 2020 00:00:53 +0000 (18:00 -0600)]
implement edition-specific :pat behavior for 2015/18

3 years agoAuto merge of #80106 - jackh726:binder-refactor-part-2, r=lcnr
bors [Sat, 19 Dec 2020 10:13:52 +0000 (10:13 +0000)]
Auto merge of #80106 - jackh726:binder-refactor-part-2, r=lcnr

A lot of refactoring to remove more `Binder::bind`s

Split out from #76814

3 years agoMore rebinds
Jack Huey [Thu, 17 Dec 2020 03:36:14 +0000 (22:36 -0500)]
More rebinds

3 years agoAuto merge of #80180 - JohnTitor:rollup-a31s996, r=JohnTitor
bors [Sat, 19 Dec 2020 07:23:41 +0000 (07:23 +0000)]
Auto merge of #80180 - JohnTitor:rollup-a31s996, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #78083 (Stabilize or_insert_with_key)
 - #79211 (Add the "async" and "promise" doc aliases to `core::future::Future`)
 - #79612 (Switch some links in compiler/ to intra-doc links)
 - #80068 (Add `&mut` as an alias for 'reference' primitive)
 - #80129 (docs: Edit rustc_ast::token::Token)
 - #80133 (Suppress `CONST_ITEM_MUTATION` lint if a dereference occurs anywhere)
 - #80155 (Fix typo)

Failed merges:

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

3 years agoRollup merge of #80155 - matsujika:matsujika-patch-1, r=jonas-schievink
Yuki Okushi [Sat, 19 Dec 2020 06:16:10 +0000 (15:16 +0900)]
Rollup merge of #80155 - matsujika:matsujika-patch-1, r=jonas-schievink

Fix typo

3 years agoRollup merge of #80133 - Aaron1011:fix/const-mut-deref, r=estebank
Yuki Okushi [Sat, 19 Dec 2020 06:16:08 +0000 (15:16 +0900)]
Rollup merge of #80133 - Aaron1011:fix/const-mut-deref, r=estebank

Suppress `CONST_ITEM_MUTATION` lint if a dereference occurs anywhere

Fixes #79971

3 years agoRollup merge of #80129 - pierwill:patch-6, r=estebank
Yuki Okushi [Sat, 19 Dec 2020 06:16:07 +0000 (15:16 +0900)]
Rollup merge of #80129 - pierwill:patch-6, r=estebank

docs: Edit rustc_ast::token::Token

Add missing punctuation.

3 years agoRollup merge of #80068 - jyn514:mut-reference, r=m-ou-se
Yuki Okushi [Sat, 19 Dec 2020 06:16:05 +0000 (15:16 +0900)]
Rollup merge of #80068 - jyn514:mut-reference, r=m-ou-se

Add `&mut` as an alias for 'reference' primitive

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

3 years agoRollup merge of #79612 - jyn514:compiler-links, r=Aaron1011
Yuki Okushi [Sat, 19 Dec 2020 06:16:03 +0000 (15:16 +0900)]
Rollup merge of #79612 - jyn514:compiler-links, r=Aaron1011

Switch some links in compiler/ to intra-doc links

3 years agoRollup merge of #79211 - yoshuawuyts:future-doc-alias, r=Mark-Simulacrum
Yuki Okushi [Sat, 19 Dec 2020 06:16:01 +0000 (15:16 +0900)]
Rollup merge of #79211 - yoshuawuyts:future-doc-alias, r=Mark-Simulacrum

Add the "async" and "promise" doc aliases to `core::future::Future`

Adds the "async" and "promise" doc aliases to `core::future::Future`. This enables people who search for "async" or "promise" to find `Future`, which is Rust's core primitive for async programming. Thanks!

3 years agoRollup merge of #78083 - ChaiTRex:master, r=m-ou-se
Yuki Okushi [Sat, 19 Dec 2020 06:15:57 +0000 (15:15 +0900)]
Rollup merge of #78083 - ChaiTRex:master, r=m-ou-se

Stabilize or_insert_with_key

Stabilizes the `or_insert_with_key` feature from https://github.com/rust-lang/rust/issues/71024. This allows inserting key-derived values when a `HashMap`/`BTreeMap` entry is vacant.

The difference between this and  `.or_insert_with(|| ... )` is that this provides a reference to the key to the closure after it is moved with `.entry(key_being_moved)`, avoiding the need to copy or clone the key.

3 years agoAuto merge of #79073 - davidtwco:issue-78957-const-param-attrs, r=lcnr
bors [Sat, 19 Dec 2020 04:32:50 +0000 (04:32 +0000)]
Auto merge of #79073 - davidtwco:issue-78957-const-param-attrs, r=lcnr

passes: prohibit invalid attrs on generic params

Fixes #78957.

This PR modifies the `check_attr` pass so that attribute placement on generic parameters is checked for validity.

r? `@lcnr`

3 years agoAuto merge of #77035 - mibac138:fn-fat-arrow-return, r=davidtwco
bors [Sat, 19 Dec 2020 01:47:05 +0000 (01:47 +0000)]
Auto merge of #77035 - mibac138:fn-fat-arrow-return, r=davidtwco

Gracefully handle mistyping -> as => in function return type

Fixes #77019

3 years agoAuto merge of #80154 - GuillaumeGomez:str-to-symbol, r=jyn514
bors [Fri, 18 Dec 2020 22:54:47 +0000 (22:54 +0000)]
Auto merge of #80154 - GuillaumeGomez:str-to-symbol, r=jyn514

Continue String to Symbol conversion in rustdoc (2)

Follow-up of #80119.

This is the last one (and I actually expected more conversions but seems like it was the last one remaining...).

r? `@jyn514`

3 years agoFix unused import error on wasm
DrMeepster [Fri, 18 Dec 2020 22:53:55 +0000 (14:53 -0800)]
Fix unused import error on wasm

3 years agoChange potentially_qualified to be defined on Binder<PredicateAtom>
Jack Huey [Thu, 17 Dec 2020 02:13:29 +0000 (21:13 -0500)]
Change potentially_qualified to be defined on Binder<PredicateAtom>

3 years agoMake BoundRegion have a kind of BoungRegionKind
Jack Huey [Fri, 18 Dec 2020 18:24:55 +0000 (13:24 -0500)]
Make BoundRegion have a kind of BoungRegionKind

3 years agoSwitch compiler/ to intra-doc links
Joshua Nelson [Tue, 1 Dec 2020 22:41:09 +0000 (17:41 -0500)]
Switch compiler/ to intra-doc links

rustc_lint and rustc_lint_defs weren't switched because they're included
in the compiler book and so can't use intra-doc links.

3 years agoAuto merge of #80081 - ehuss:update-cargo, r=Mark-Simulacrum
bors [Fri, 18 Dec 2020 19:09:17 +0000 (19:09 +0000)]
Auto merge of #80081 - ehuss:update-cargo, r=Mark-Simulacrum

Update cargo

4 commits in d274fcf862b89264fa2c6b917b15230705257317..a3c2627fbc2f5391c65ba45ab53b81bf71fa323c
2020-12-07 23:08:44 +0000 to 2020-12-14 17:21:26 +0000
- Check if rerun-if-changed points to a directory. (rust-lang/cargo#8973)
- Implement external credential process. (RFC 2730) (rust-lang/cargo#8934)
- Revert recent build-std vendoring changes (rust-lang/cargo#8968)
- Fix the unit dependency graph with dev-dependency `links` (rust-lang/cargo#8969)

3 years agoUnify the two kinds of usefulness merging
Nadrieril [Thu, 17 Dec 2020 01:56:22 +0000 (01:56 +0000)]
Unify the two kinds of usefulness merging

This is elegant but a bit of a perf gamble. That said, or-patterns
rarely have many branches and it's easy to optimize or revert if we ever
need to. In the meantime simpler code is worth it.

3 years agoMerge unreachable subpatterns correctly
Nadrieril [Thu, 17 Dec 2020 01:25:53 +0000 (01:25 +0000)]
Merge unreachable subpatterns correctly

3 years agoKeep all witnesses of non-exhaustiveness
Nadrieril [Thu, 17 Dec 2020 01:18:01 +0000 (01:18 +0000)]
Keep all witnesses of non-exhaustiveness

3 years agoRewrite usefulness merging using `SpanSet`
Nadrieril [Thu, 17 Dec 2020 01:07:49 +0000 (01:07 +0000)]
Rewrite usefulness merging using `SpanSet`

`SpanSet` is heavily inspired from `DefIdForest`.

3 years agoLog the output of `is_useful` in the or-pattern case too
Nadrieril [Thu, 17 Dec 2020 00:47:31 +0000 (00:47 +0000)]
Log the output of `is_useful` in the or-pattern case too

3 years agoFactor out or-pattern usefulness merging
Nadrieril [Wed, 16 Dec 2020 06:24:31 +0000 (06:24 +0000)]
Factor out or-pattern usefulness merging

3 years agoAdd tests
Nadrieril [Thu, 17 Dec 2020 00:42:49 +0000 (00:42 +0000)]
Add tests

3 years agoAuto merge of #80156 - RalfJung:rollup-m3poz8z, r=RalfJung
bors [Fri, 18 Dec 2020 16:17:23 +0000 (16:17 +0000)]
Auto merge of #80156 - RalfJung:rollup-m3poz8z, r=RalfJung

Rollup of 6 pull requests

Successful merges:

 - #80121 (Change the message for `if_let_guard` feature gate)
 - #80130 (docs: Edit rustc_span::symbol::Symbol method)
 - #80135 (Don't allow `const` to begin a nonterminal)
 - #80145 (Fix typo in rustc_typeck docs)
 - #80146 (Edit formatting in Rust Prelude docs)
 - #80147 (Add missing punctuation to std::alloc docs)

Failed merges:

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

3 years agoUpdate cargo
Eric Huss [Wed, 16 Dec 2020 17:03:33 +0000 (09:03 -0800)]
Update cargo

3 years agoAdd the "promise" aliases to the `async` lang feature
Yoshua Wuyts [Thu, 19 Nov 2020 20:22:32 +0000 (21:22 +0100)]
Add the "promise" aliases to the `async` lang feature

3 years agoRollup merge of #80147 - pierwill:patch-9, r=lcnr
Ralf Jung [Fri, 18 Dec 2020 15:22:14 +0000 (16:22 +0100)]
Rollup merge of #80147 - pierwill:patch-9, r=lcnr

Add missing punctuation to std::alloc docs

Add a period to first line of module docs to match other modules in std.

3 years agoRollup merge of #80146 - pierwill:pierwill-prelude-mod-docs, r=lcnr
Ralf Jung [Fri, 18 Dec 2020 15:22:13 +0000 (16:22 +0100)]
Rollup merge of #80146 - pierwill:pierwill-prelude-mod-docs, r=lcnr

Edit formatting in Rust Prelude docs

Use consistent punctuation and capitalization in the list of things re-exported in the prelude.

Also adds a (possibly missing) word.

3 years agoRollup merge of #80145 - pierwill:patch-8, r=lcnr
Ralf Jung [Fri, 18 Dec 2020 15:22:11 +0000 (16:22 +0100)]
Rollup merge of #80145 - pierwill:patch-8, r=lcnr

Fix typo in rustc_typeck docs

3 years agoRollup merge of #80135 - camelid:const-macro-nt, r=petrochenkov
Ralf Jung [Fri, 18 Dec 2020 15:22:09 +0000 (16:22 +0100)]
Rollup merge of #80135 - camelid:const-macro-nt, r=petrochenkov

Don't allow `const` to begin a nonterminal

Fixes #79908.

Thanks to Vadim Petrochenkov who [told me what the fix was][z]!

[z]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/finding.20which.20macro.20rule.20to.20use/near/220240422

r? ``@petrochenkov``

3 years agoRollup merge of #80130 - pierwill:patch-7, r=oli-obk
Ralf Jung [Fri, 18 Dec 2020 15:22:07 +0000 (16:22 +0100)]
Rollup merge of #80130 - pierwill:patch-7, r=oli-obk

docs: Edit rustc_span::symbol::Symbol method

Edit wording of the doc comment for [rustc_span::symbol::Symbol::can_be_raw](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/symbol/struct.Symbol.html#method.can_be_raw) to match related methods.

3 years agoRollup merge of #80121 - LeSeulArtichaut:if-let-experimental, r=davidtwco
Ralf Jung [Fri, 18 Dec 2020 15:22:06 +0000 (16:22 +0100)]
Rollup merge of #80121 - LeSeulArtichaut:if-let-experimental, r=davidtwco

Change the message for `if_let_guard` feature gate

`if-let` guards are now implemented by #79051 🎉
Thanks ``@camelid`` for pointing this out 🙂

3 years agoFix typo
Hirochika Matsumoto [Fri, 18 Dec 2020 13:13:25 +0000 (22:13 +0900)]
Fix typo

3 years agoAuto merge of #79485 - EllenNyan:stabilize_unsafe_cell_get_mut, r=m-ou-se
bors [Fri, 18 Dec 2020 11:39:26 +0000 (11:39 +0000)]
Auto merge of #79485 - EllenNyan:stabilize_unsafe_cell_get_mut, r=m-ou-se

Stabilize `unsafe_cell_get_mut`

Tracking issue: #76943

r? `@m-ou-se`

3 years agoContinue String to Symbol conversion in rustdoc
Guillaume Gomez [Fri, 18 Dec 2020 11:05:51 +0000 (12:05 +0100)]
Continue String to Symbol conversion in rustdoc

3 years agoAuto merge of #80090 - jyn514:tcx-in-render, r=GuillaumeGomez
bors [Fri, 18 Dec 2020 08:44:50 +0000 (08:44 +0000)]
Auto merge of #80090 - jyn514:tcx-in-render, r=GuillaumeGomez

Pass a `TyCtxt` through to `FormatRender`

This is the next step after https://github.com/rust-lang/rust/pull/79957 for https://github.com/rust-lang/rust/issues/76382. Eventually I plan to use this to remove `stability`, `const_stability`, and `deprecation` from `Item`, but that needs more extensive changes (in particular, https://github.com/rust-lang/rust/pull/75355 or something like it).

This has no actual changes to behavior, it's just moving types around.

ccc https://github.com/rust-lang/rust/pull/80014#issuecomment-746810284

3 years agoAuto merge of #80119 - GuillaumeGomez:str-to-symbol, r=jyn514
bors [Fri, 18 Dec 2020 05:55:24 +0000 (05:55 +0000)]
Auto merge of #80119 - GuillaumeGomez:str-to-symbol, r=jyn514

Continue String to Symbol conversion in rustdoc

Follow-up of https://github.com/rust-lang/rust/pull/80091.

This PR is already big enough so I'll stop here before the next one.

r? `@jyn514`

3 years agoAdd missing punctuation to std::alloc docs
pierwill [Fri, 18 Dec 2020 05:49:32 +0000 (21:49 -0800)]
Add missing punctuation to std::alloc docs

Add a period to first line of module docs to match other modules in std.

3 years agoEdit formatting in Rust Prelude docs
pierwill [Fri, 18 Dec 2020 05:17:43 +0000 (21:17 -0800)]
Edit formatting in Rust Prelude docs

Use consistent punctuation and capitalization in the list
of things re-exported in the prelude.

Also adds a (possibly missing) word.

3 years agoFix typo in rustc_typeck docs
pierwill [Fri, 18 Dec 2020 04:47:05 +0000 (20:47 -0800)]
Fix typo in rustc_typeck docs

3 years agoAuto merge of #80036 - sivadeilra:syms_no_macro, r=petrochenkov
bors [Fri, 18 Dec 2020 03:01:14 +0000 (03:01 +0000)]
Auto merge of #80036 - sivadeilra:syms_no_macro, r=petrochenkov

Stop using intermediate macros in definition of symbols

Currently, the rustc_macros::symbols macro generates two
`macro_rules!` macros as its output. These two macros are
used in rustc_span/src/symbol.rs.

This means that each Symbol that we define is represented
in the AST of rustc_symbols twice: once in the definition
of the `define_symbols!` macro (similarly for the
`keywords! macro), and once in the rustc_span::symbols
definition.

That would be OK if there were only a handful of symbols,
but currently we define over 1100 symbols. The definition
of the `define_symbols!` macro contains the expanded definition
of each symbol, so that's a lot of AST storage wasted on a
macro that is used exactly once.

This commit removes the `define_symbols` macro, and simply
allows the proc macro to directly generate the
`rustc_symbols::symbol::sym` module.

The benefit is mainly in reducing memory wasted during
compilation of rustc itself. It should also reduce memory used
by Rust Analyzer.

This commit also reduces the size of the AST for symbol
definitions, by moving two `#[allow(...)]` attributes from
the symbol constants to the `sym` module. This eliminates 2200+
attribute nodes.

This commit also eliminates the need for the `digits_array`
constant. There's no need to store an array of Symbol values
for digits. We can simply define a constant of the base value,
and add to that base value.

I left the `sym::integer` function in rustc_span/src/symbol.rs
instead of moving it into rustc_macros/src/symbols.rs for two
reasons. First, because it's human-written code; it doesn't need
to be generated by the proc-macro. Second, because I didn't want
the `#[allow(...)]` attributes that I moved to the `sym` module
scope to apply to this function. The `sym` module re-exports the
`integer` function from its parent module.

3 years agoAuto merge of #80138 - Dylan-DPC:rollup-qamsfyh, r=Dylan-DPC
bors [Fri, 18 Dec 2020 00:08:30 +0000 (00:08 +0000)]
Auto merge of #80138 - Dylan-DPC:rollup-qamsfyh, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #78164 (Prefer regions with an `external_name` in `approx_universal_upper_bound`)
 - #80003 (Fix overflow when converting ZST Vec to VecDeque)
 - #80023 (Enhance error message when misspelled label to value in break expression)
 - #80046 (Add more documentation to `Diagnostic` and `DiagnosticBuilder`)
 - #80109 (Remove redundant and unreliable coverage test results)

Failed merges:

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

3 years agoRollup merge of #80109 - richkadel:llvm-coverage-counters-2.3.0, r=tmandry
Dylan DPC [Thu, 17 Dec 2020 23:30:21 +0000 (00:30 +0100)]
Rollup merge of #80109 - richkadel:llvm-coverage-counters-2.3.0, r=tmandry

Remove redundant and unreliable coverage test results

The `coverage-reports` tests still generate counters and JSON reports
for inspection, but these files are no longer used in Makefile diffs, to
reduce complexity and confusion from unreliable or unexpected test
results, especially when maintaining them (i.e., generating `--bless`ed
results).

The associated `expected_` files for counters and JSON reports have been
removed, leaving only the files actually used for testing: the `llvm-cov
show` reports.

r? `@tmandry`

Tyler - as we discussed offline...

FYI: `@wesleywiser` `@Swatinem`

Arpad, depending on the timing of this PR, it may not affect you, but I'm removing some of the files that produce slightly different results on Windows as they really aren't necessary to validate coverage results.

3 years agoRollup merge of #80046 - camelid:diag-docs, r=lcnr
Dylan DPC [Thu, 17 Dec 2020 23:30:20 +0000 (00:30 +0100)]
Rollup merge of #80046 - camelid:diag-docs, r=lcnr

Add more documentation to `Diagnostic` and `DiagnosticBuilder`

cc `@estebank`

3 years agoRollup merge of #80023 - sasurau4:feature/enhance-error-message-when-wrongly-written...
Dylan DPC [Thu, 17 Dec 2020 23:30:18 +0000 (00:30 +0100)]
Rollup merge of #80023 - sasurau4:feature/enhance-error-message-when-wrongly-written-broken-label, r=lcnr

Enhance error message when misspelled label to value in break expression

Fix #79424

3 years agoRollup merge of #80003 - Stupremee:fix-zst-vecdeque-conversion-panic, r=dtolnay
Dylan DPC [Thu, 17 Dec 2020 23:30:11 +0000 (00:30 +0100)]
Rollup merge of #80003 - Stupremee:fix-zst-vecdeque-conversion-panic, r=dtolnay

Fix overflow when converting ZST Vec to VecDeque

```rust
let v = vec![(); 100];
let queue = VecDeque::from(v);
println!("{:?}", queue);
```
This code will currently panic with a capacity overflow.
This PR resolves this issue and makes the code run fine.

Resolves #78532

3 years agoRollup merge of #78164 - Aaron1011:fix/async-region-name, r=tmandry
Dylan DPC [Thu, 17 Dec 2020 23:30:09 +0000 (00:30 +0100)]
Rollup merge of #78164 - Aaron1011:fix/async-region-name, r=tmandry

Prefer regions with an `external_name` in `approx_universal_upper_bound`

Fixes #75785

When displaying a MIR borrowcheck error, we may need to find an upper
bound for a region, which gives us a region to point to in the error
message. However, a region might outlive multiple distinct universal
regions, in which case the only upper bound is 'static

To try to display a meaningful error message, we compute an
'approximate' upper bound by picking one of the universal regions.
Currently, we pick the region with the lowest index - however, this
caused us to produce a suboptimal error message in issue #75785

This PR `approx_universal_upper_bound` to prefer regions with an
`external_name`. This causes us to prefer regions from function
arguments/upvars, which seems to lead to a nicer error message in some
cases.

3 years agoStop using intermediate macros in definition of symbols
Arlie Davis [Mon, 14 Dec 2020 19:34:55 +0000 (11:34 -0800)]
Stop using intermediate macros in definition of symbols

Currently, the rustc_macros::symbols macro generates two
`macro_rules!` macros as its output. These two macros are
used in rustc_span/src/symbol.rs.

This means that each Symbol that we define is represented
in the AST of rustc_symbols twice: once in the definition
of the `define_symbols!` macro (similarly for the
`keywords! macro), and once in the rustc_span::symbols
definition.

That would be OK if there were only a handful of symbols,
but currently we define over 1100 symbols. The definition
of the `define_symbols!` macro contains the expanded definition
of each symbol, so that's a lot of AST storage wasted on a
macro that is used exactly once.

This commit removes the `define_symbols` macro, and simply
allows the proc macro to directly generate the
`rustc_symbols::symbol::sym` module.

The benefit is mainly in reducing memory wasted during
compilation of rustc itself. It should also reduce memory used
by Rust Analyzer.

This commit also reduces the size of the AST for symbol
definitions, by moving two `#[allow(...)]` attributes from
the symbol constants to the `sym` module. This eliminates 2200+
attribute nodes.

This commit also eliminates the need for the `digits_array`
constant. There's no need to store an array of Symbol values
for digits. We can simply define a constant of the base value,
and add to that base value.

3 years agoDon't allow `const` to begin a nonterminal
Camelid [Thu, 17 Dec 2020 21:51:20 +0000 (13:51 -0800)]
Don't allow `const` to begin a nonterminal

Thanks to Vadim Petrochenkov who [told me what the fix was][z]!

[z]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/finding.20which.20macro.20rule.20to.20use/near/220240422

3 years agoAuto merge of #80122 - davidtwco:revert-76030, r=oli-obk
bors [Thu, 17 Dec 2020 21:13:51 +0000 (21:13 +0000)]
Auto merge of #80122 - davidtwco:revert-76030, r=oli-obk

Revert "cg_llvm: `fewer_names` in `uncached_llvm_type`"

Fixes #76213 and fixes #79564.

This PR temporarily reverts commit fa01ce802f1b403a2140fd945b43af86ec3998a1 from #76030 to until the root issue can be resolved. Requested [in t-compiler meeting](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.20meeting.5D.202020-12-17.20.2354818/near/220261541).

*Note*: I was seeing some failing debuginfo-gdb tests locally but I wasn't sure if they were spurious.

3 years agoSuppress `CONST_ITEM_MUTATION` lint if a dereference occurs anywhere
Aaron Hill [Thu, 17 Dec 2020 20:25:55 +0000 (15:25 -0500)]
Suppress `CONST_ITEM_MUTATION` lint if a dereference occurs anywhere

Fixes #79971

3 years agoRevert change to evaluation order
Matthew Jasper [Thu, 17 Dec 2020 20:16:10 +0000 (20:16 +0000)]
Revert change to evaluation order

This change breaks some code and doesn't appear to enable any new code.

3 years agodocs: Edit rustc_span::symbol::Symbol method
pierwill [Thu, 17 Dec 2020 20:02:34 +0000 (12:02 -0800)]
docs: Edit rustc_span::symbol::Symbol method

Edit wording of the doc comment for rustc_span::symbol::Symbol::can_be_raw
to match related methods.

3 years agodocs: Edit rustc_ast::token::Token
pierwill [Thu, 17 Dec 2020 19:55:49 +0000 (11:55 -0800)]
docs: Edit rustc_ast::token::Token

Add missing punctuation.

3 years agoPrefer regions with an `external_name` in `approx_universal_upper_bound`
Aaron Hill [Tue, 20 Oct 2020 20:31:54 +0000 (16:31 -0400)]
Prefer regions with an `external_name` in `approx_universal_upper_bound`

Fixes #75785

When displaying a MIR borrowcheck error, we may need to find an upper
bound for a region, which gives us a region to point to in the error
message. However, a region might outlive multiple distinct universal
regions, in which case the only upper bound is 'static

To try to display a meaningful error message, we compute an
'approximate' upper bound by picking one of the universal regions.
Currently, we pick the region with the lowest index - however, this
caused us to produce a suboptimal error message in issue #75785

This PR `approx_universal_upper_bound` to prefer regions with an
`external_name`. This causes us to prefer regions from function
arguments/upvars, which seems to lead to a nicer error message in some
cases.

3 years agoAuto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakis
bors [Thu, 17 Dec 2020 18:21:20 +0000 (18:21 +0000)]
Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakis

Move binder for dyn to each list item

This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`.

This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.`

r? `@nikomatsakis`

3 years agoContinue String to Symbol conversion in rustdoc
Guillaume Gomez [Thu, 17 Dec 2020 13:02:09 +0000 (14:02 +0100)]
Continue String to Symbol conversion in rustdoc

3 years agofix memory leak in test
DrMeepster [Thu, 17 Dec 2020 17:18:06 +0000 (09:18 -0800)]
fix memory leak in test

3 years agoRevert "cg_llvm: `fewer_names` in `uncached_llvm_type`"
David Wood [Thu, 17 Dec 2020 16:06:24 +0000 (16:06 +0000)]
Revert "cg_llvm: `fewer_names` in `uncached_llvm_type`"

This reverts commit fa01ce802f1b403a2140fd945b43af86ec3998a1.

3 years agoFix rebase conflict
Joshua Nelson [Thu, 17 Dec 2020 16:40:02 +0000 (11:40 -0500)]
Fix rebase conflict

3 years agoTODO -> FIXME
Joshua Nelson [Wed, 16 Dec 2020 21:22:11 +0000 (16:22 -0500)]
TODO -> FIXME

3 years agoFix error with `--cfg parallel_compiler`
Joshua Nelson [Wed, 16 Dec 2020 21:02:15 +0000 (16:02 -0500)]
Fix error with `--cfg parallel_compiler`

Apparently expansion() really does return Rc, not Lrc

3 years agoMake it compile
Joshua Nelson [Wed, 16 Dec 2020 19:34:08 +0000 (14:34 -0500)]
Make it compile

3 years ago[tmp] Pass `TyCtxt` through to the render backend
Joshua Nelson [Wed, 16 Dec 2020 19:23:14 +0000 (14:23 -0500)]
[tmp] Pass `TyCtxt` through to the render backend

First actually useful step in https://github.com/rust-lang/rust/issues/76382

This doesn't yet compile because there's no way to get a `Lrc<Session>`
from a TyCtxt, only a `&Session`.

3 years agoMove `run_renderer` into the main `global_ctxt` closure
Joshua Nelson [Sat, 12 Dec 2020 02:57:48 +0000 (21:57 -0500)]
Move `run_renderer` into the main `global_ctxt` closure

3 years agoSeparate `create_resolver` into a new function
Joshua Nelson [Sat, 12 Dec 2020 02:46:58 +0000 (21:46 -0500)]
Separate `create_resolver` into a new function

3 years agoSplit apart create_config and run_core
Joshua Nelson [Sat, 12 Dec 2020 02:37:14 +0000 (21:37 -0500)]
Split apart create_config and run_core

3 years agoChange the message for `if_let_guard` feature gate
LeSeulArtichaut [Thu, 17 Dec 2020 15:56:59 +0000 (16:56 +0100)]
Change the message for `if_let_guard` feature gate

3 years agoAuto merge of #80113 - davidtwco:issue-80086-ci-llvm-stamp, r=Mark-Simulacrum
bors [Thu, 17 Dec 2020 14:52:50 +0000 (14:52 +0000)]
Auto merge of #80113 - davidtwco:issue-80086-ci-llvm-stamp, r=Mark-Simulacrum

bootstrap: update ci-llvm stamp after #80087

Fixes #80086.

Unfortunately, #80087 forgot to update the ci-llvm stamp, so the updated ci-llvm tarball with `llvm-dwp` wasn't downloaded by users. This PR updates the ci-llvm stamp to resolve that problem.

r? `@Mark-Simulacrum`

3 years agoAddress review comments
mibac138 [Thu, 17 Dec 2020 12:44:08 +0000 (13:44 +0100)]
Address review comments

3 years agoAuto merge of #80114 - GuillaumeGomez:rollup-gszr5kn, r=GuillaumeGomez
bors [Thu, 17 Dec 2020 12:02:29 +0000 (12:02 +0000)]
Auto merge of #80114 - GuillaumeGomez:rollup-gszr5kn, r=GuillaumeGomez

Rollup of 5 pull requests

Successful merges:

 - #80006 (BTreeMap: more expressive local variables in merge)
 - #80022 (BTreeSet: simplify implementation of pop_first/pop_last)
 - #80035 (Optimization for bool's PartialOrd impl)
 - #80040 (Always run intrinsics lowering pass)
 - #80047 (Use more symbols in rustdoc)

Failed merges:

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

3 years agoAdd test case for break expr with misspelled value
Daiki Ihara [Mon, 14 Dec 2020 12:14:17 +0000 (21:14 +0900)]
Add test case for break expr with misspelled value

Update src/test/ui/loops/loop-break-value.rs

Co-authored-by: Ivan Tham <pickfire@riseup.net>
3 years agoEnhance error message when misspelled label to value in break expression
Daiki Ihara [Mon, 14 Dec 2020 12:13:40 +0000 (21:13 +0900)]
Enhance error message when misspelled label to value in break expression

Apply suggestions from code review

Co-authored-by: lcnr <bastian_kauschke@hotmail.de>
3 years agoRollup merge of #80047 - jyn514:more-symbols, r=GuillaumeGomez
Guillaume Gomez [Thu, 17 Dec 2020 10:36:54 +0000 (11:36 +0100)]
Rollup merge of #80047 - jyn514:more-symbols, r=GuillaumeGomez

Use more symbols in rustdoc

Builds on https://github.com/rust-lang/rust/pull/80044 and should not be merged before.

I want to test if this is actually faster before merging it, there was a lot of `to_string()` calls so I'm not sure it will actually help. That means I have to wait for 80044 to get merged before running perf.

r? `@ghost`

3 years agoRollup merge of #80040 - tmiasko:always-lower-intrinsics, r=Dylan-DPC
Guillaume Gomez [Thu, 17 Dec 2020 10:36:52 +0000 (11:36 +0100)]
Rollup merge of #80040 - tmiasko:always-lower-intrinsics, r=Dylan-DPC

Always run intrinsics lowering pass

Move intrinsics lowering pass from the optimization phase (where it
would not run if -Zmir-opt-level=0), to the drop lowering phase where it
runs unconditionally.

The implementation of those intrinsics in code generation and
interpreter is unnecessary. Remove it.

3 years agoRollup merge of #80035 - ChayimFriedman2:patch-1, r=nagisa
Guillaume Gomez [Thu, 17 Dec 2020 10:36:51 +0000 (11:36 +0100)]
Rollup merge of #80035 - ChayimFriedman2:patch-1, r=nagisa

Optimization for bool's PartialOrd impl

Fix #80034.

3 years agoRollup merge of #80022 - ssomers:btree_cleanup_8, r=Mark-Simulacrum
Guillaume Gomez [Thu, 17 Dec 2020 10:36:49 +0000 (11:36 +0100)]
Rollup merge of #80022 - ssomers:btree_cleanup_8, r=Mark-Simulacrum

BTreeSet: simplify implementation of pop_first/pop_last

…and stop it interfering in #79245.
r? ```````@Mark-Simulacrum```````

3 years agoRollup merge of #80006 - ssomers:btree_cleanup_6, r=Mark-Simulacrum
Guillaume Gomez [Thu, 17 Dec 2020 10:36:47 +0000 (11:36 +0100)]
Rollup merge of #80006 - ssomers:btree_cleanup_6, r=Mark-Simulacrum

BTreeMap: more expressive local variables in merge

r? ```````@Mark-Simulacrum```````

3 years agobootstrap: update ci-llvm stamp after #80087
David Wood [Thu, 17 Dec 2020 10:29:58 +0000 (10:29 +0000)]
bootstrap: update ci-llvm stamp after #80087

Unfortunately, #80087 forgot to update the ci-llvm stamp, so the updated
ci-llvm tarball with `llvm-dwp` wasn't downloaded by users. This commit
updates the ci-llvm stamp to resolve that problem.

Signed-off-by: David Wood <david@davidtw.co>
3 years agoAuto merge of #79840 - dvtkrlbs:issue-79667, r=oli-obk
bors [Thu, 17 Dec 2020 09:11:28 +0000 (09:11 +0000)]
Auto merge of #79840 - dvtkrlbs:issue-79667, r=oli-obk

Remove memoization leftovers from constant evaluation machine

Closes #79667

3 years agoRemove redundant and unreliable coverage test results
Rich Kadel [Thu, 17 Dec 2020 06:07:40 +0000 (22:07 -0800)]
Remove redundant and unreliable coverage test results

The `coverage-reports` tests still generate counters and JSON reports
for inspection, but these files are no longer used in Makefile diffs, to
reduce complexity and confusion from unreliable or unexpected test
results, especially when maintaining them (i.e., generating `--bless`ed
results).

The associated `expected_` files for counters and JSON reports have been
removed, leaving only the files actually used for testing: the `llvm-cov
show` reports.

3 years agoAuto merge of #80091 - GuillaumeGomez:str-to-symbol, r=jyn514
bors [Thu, 17 Dec 2020 06:00:12 +0000 (06:00 +0000)]
Auto merge of #80091 - GuillaumeGomez:str-to-symbol, r=jyn514

Replace String with Symbol where possible

The same as #80047 but on different types. Might be interesting to run some perf comparison.

r? `@jyn514`

3 years agoAuto merge of #80105 - JohnTitor:rollup-8c030u5, r=JohnTitor
bors [Thu, 17 Dec 2020 03:07:09 +0000 (03:07 +0000)]
Auto merge of #80105 - JohnTitor:rollup-8c030u5, r=JohnTitor

Rollup of 11 pull requests

Successful merges:

 - #79051 (Implement if-let match guards)
 - #79877 (Allow `since="TBD"` for rustc_deprecated)
 - #79882 (Fix issue #78496)
 - #80026 (expand-yaml-anchors: Make the output directory separator-insensitive)
 - #80039 (Remove unused `TyEncoder::tcx` required method)
 - #80069 (Test that `core::assert!` is valid)
 - #80072 (Fixed conflict with drop elaboration and coverage)
 - #80073 (Add support for target aliases)
 - #80082 (Revert #78790 - rust-src vendoring)
 - #80097 (Add `popcount` and `popcnt` as doc aliases for `count_ones` methods.)
 - #80103 (Remove docs for non-existent parameters in `rustc_expand`)

Failed merges:

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

3 years agoRollup merge of #80103 - camelid:remove-docs-old-params-rustc_expand, r=jyn514
Yuki Okushi [Thu, 17 Dec 2020 02:44:13 +0000 (11:44 +0900)]
Rollup merge of #80103 - camelid:remove-docs-old-params-rustc_expand, r=jyn514

Remove docs for non-existent parameters in `rustc_expand`