]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRemove irrelevant FIXME
varkor [Wed, 28 Oct 2020 00:46:53 +0000 (00:46 +0000)]
Remove irrelevant FIXME

3 years agoAdjust turbofish help message for const generics
varkor [Wed, 28 Oct 2020 00:41:40 +0000 (00:41 +0000)]
Adjust turbofish help message for const generics

3 years agoSuggest expressions that look like const generic arguments should be enclosed in...
varkor [Sat, 3 Oct 2020 18:30:32 +0000 (19:30 +0100)]
Suggest expressions that look like const generic arguments should be enclosed in brackets

Co-Authored-By: Esteban Kuber <github@kuber.com.ar>
3 years agoAuto merge of #78195 - tmiasko:instcombine, r=jonas-schievink
bors [Wed, 21 Oct 2020 17:44:48 +0000 (17:44 +0000)]
Auto merge of #78195 - tmiasko:instcombine, r=jonas-schievink

Disable "optimization to avoid load of address" in InstCombine

The transformation is incorrect #78192. Disable it.

3 years agoAuto merge of #77250 - Aaron1011:feature/flat-token-collection, r=petrochenkov
bors [Wed, 21 Oct 2020 15:03:14 +0000 (15:03 +0000)]
Auto merge of #77250 - Aaron1011:feature/flat-token-collection, r=petrochenkov

Rewrite `collect_tokens` implementations to use a flattened buffer

Instead of trying to collect tokens at each depth, we 'flatten' the
stream as we go allong, pushing open/close delimiters to our buffer
just like regular tokens. One capturing is complete, we reconstruct a
nested `TokenTree::Delimited` structure, producing a normal
`TokenStream`.

The reconstructed `TokenStream` is not created immediately - instead, it is
produced on-demand by a closure (wrapped in a new `LazyTokenStream` type). This
closure stores a clone of the original `TokenCursor`, plus a record of the
number of calls to `next()/next_desugared()`. This is sufficient to reconstruct
the tokenstream seen by the callback without storing any additional state. If
the tokenstream is never used (e.g. when a captured `macro_rules!` argument is
never passed to a proc macro), we never actually create a `TokenStream`.

This implementation has a number of advantages over the previous one:

* It is significantly simpler, with no edge cases around capturing the
  start/end of a delimited group.

* It can be easily extended to allow replacing tokens an an arbitrary
  'depth' by just using `Vec::splice` at the proper position. This is
  important for PR #76130, which requires us to track information about
  attributes along with tokens.

* The lazy approach to `TokenStream` construction allows us to easily
  parse an AST struct, and then decide after the fact whether we need a
  `TokenStream`. This will be useful when we start collecting tokens for
  `Attribute` - we can discard the `LazyTokenStream` if the parsed
  attribute doesn't need tokens (e.g. is a builtin attribute).

The performance impact seems to be neglibile (see
https://github.com/rust-lang/rust/pull/77250#issuecomment-703960604). There is a
small slowdown on a few benchmarks, but it only rises above 1% for incremental
builds, where it represents a larger fraction of the much smaller instruction
count. There a ~1% speedup on a few other incremental benchmarks - my guess is
that the speedups and slowdowns will usually cancel out in practice.

3 years agoAuto merge of #78178 - JohnTitor:rollup-dslazzj, r=JohnTitor
bors [Wed, 21 Oct 2020 11:22:17 +0000 (11:22 +0000)]
Auto merge of #78178 - JohnTitor:rollup-dslazzj, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #77726 (Add Pin::static_ref, static_mut.)
 - #78002 (Tweak "object unsafe" errors)
 - #78056 (BTreeMap: split off most code of remove and split_off)
 - #78063 (Improve wording of "cannot multiply" type error)
 - #78094 (rustdoc: Show the correct source filename in page titles, without `.html`)
 - #78101 (fix static_ptr_ty for foreign statics)
 - #78118 (Inline const followups)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78118 - spastorino:inline-const-followups, r=petrochenkov
Yuki Okushi [Wed, 21 Oct 2020 04:59:44 +0000 (13:59 +0900)]
Rollup merge of #78118 - spastorino:inline-const-followups, r=petrochenkov

Inline const followups

r? @petrochenkov

Follow ups of #77124

3 years agoRollup merge of #78101 - RalfJung:foreign-static, r=oli-obk
Yuki Okushi [Wed, 21 Oct 2020 04:59:43 +0000 (13:59 +0900)]
Rollup merge of #78101 - RalfJung:foreign-static, r=oli-obk

fix static_ptr_ty for foreign statics

Cc https://github.com/rust-lang/rust/issues/74840

This does not fix that issue but fixes a problem in `static_ptr_ty` that we noticed while discussing that issue. I also added and updated a few comments. The one about `internal` locals being ignored does not seem to have been true [even in the commit that introduced it](https://github.com/rust-lang/rust/pull/44700/files#diff-ae2f3c7e2f9744f7ef43e96072b10e98d4e3fe74a3a399a3ad8a810fbe56c520R139).

r? @oli-obk

3 years agoRollup merge of #78094 - camelid:rustdoc-fix-source-title, r=jyn514
Yuki Okushi [Wed, 21 Oct 2020 04:59:41 +0000 (13:59 +0900)]
Rollup merge of #78094 - camelid:rustdoc-fix-source-title, r=jyn514

rustdoc: Show the correct source filename in page titles, without `.html`

Previously the title would be

    lib.rs.html -- source

if `lib.rs` was the actual source filename. Now the title is

    lib.rs - source

3 years agoRollup merge of #78063 - camelid:improve-cannot-multiply-error, r=estebank
Yuki Okushi [Wed, 21 Oct 2020 04:59:39 +0000 (13:59 +0900)]
Rollup merge of #78063 - camelid:improve-cannot-multiply-error, r=estebank

Improve wording of "cannot multiply" type error

For example, if you had this code:

    fn foo(x: i32, y: f32) -> f32 {
        x * y
    }

You would get this error:

    error[E0277]: cannot multiply `f32` to `i32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`

However, that's not usually how people describe multiplication. People
usually describe multiplication like how the division error words it:

    error[E0277]: cannot divide `i32` by `f32`
     --> src/lib.rs:2:7
      |
    2 |     x / y
      |       ^ no implementation for `i32 / f32`
      |
      = help: the trait `Div<f32>` is not implemented for `i32`

So that's what this change does. It changes this:

    error[E0277]: cannot multiply `f32` to `i32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`

To this:

    error[E0277]: cannot multiply `i32` by `f32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`

3 years agoRollup merge of #78056 - ssomers:btree_chop_up_1, r=dtolnay
Yuki Okushi [Wed, 21 Oct 2020 04:59:37 +0000 (13:59 +0900)]
Rollup merge of #78056 - ssomers:btree_chop_up_1, r=dtolnay

BTreeMap: split off most code of remove and split_off

Putting map.rs on a diet, in addition to #77851.
r? @dtolnay

3 years agoRollup merge of #78002 - estebank:issue-77598, r=oli-obk
Yuki Okushi [Wed, 21 Oct 2020 04:59:35 +0000 (13:59 +0900)]
Rollup merge of #78002 - estebank:issue-77598, r=oli-obk

Tweak "object unsafe" errors

CC #77598.

3 years agoRollup merge of #77726 - fusion-engineering-forks:static-pin, r=dtolnay
Yuki Okushi [Wed, 21 Oct 2020 04:59:29 +0000 (13:59 +0900)]
Rollup merge of #77726 - fusion-engineering-forks:static-pin, r=dtolnay

Add Pin::static_ref, static_mut.

This adds `Pin::static_ref` and `Pin::static_mut`, which convert a static reference to a pinned static reference.

Static references are effectively already pinned, as what they refer to has to live forever and can never be moved.

---

Context: I want to update the `sys` and `sys_common` mutexes/rwlocks/condvars to use `Pin<&self>` in their functions, instead of only warning in the unsafety comments that they may not be moved. That should make them a little bit less dangerous to use. Putting such an object in a `static` (e.g. through `sys_common::StaticMutex`) fulfills the requirements about never moving it, but right now there's no safe way to get a `Pin<&T>` to a `static`. This solves that.

3 years agoDisable "optimization to avoid load of address" in InstCombine
Tomasz Miąsko [Wed, 21 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Disable "optimization to avoid load of address" in InstCombine

3 years agoAuto merge of #77244 - ssomers:btree_love_the_leaf_edge, r=Mark-Simulacrum
bors [Tue, 20 Oct 2020 23:33:56 +0000 (23:33 +0000)]
Auto merge of #77244 - ssomers:btree_love_the_leaf_edge, r=Mark-Simulacrum

BTreeMap: more refactoring around edges

Continuation of #77005.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #78162 - GuillaumeGomez:rollup-6a4qiqu, r=GuillaumeGomez
bors [Tue, 20 Oct 2020 21:27:47 +0000 (21:27 +0000)]
Auto merge of #78162 - GuillaumeGomez:rollup-6a4qiqu, r=GuillaumeGomez

Rollup of 9 pull requests

Successful merges:

 - #78046 (Add codegen test for issue #73827)
 - #78061 (Optimize const value interning for ZST types)
 - #78070 (we can test std and core panic macros together)
 - #78076 (Move orphan module-name/mod.rs files into module-name.rs files)
 - #78129 (Wrapping intrinsics doc links update.)
 - #78133 (Add some MIR-related regression tests)
 - #78144 (Don't update `entries` in `TypedArena` if T does not need drop)
 - #78145 (Drop unneeded `mut`)
 - #78157 (Remove unused type from librustdoc)

Failed merges:

r? `@ghost`

3 years agoApply some review suggestions
Camelid [Tue, 20 Oct 2020 20:23:11 +0000 (13:23 -0700)]
Apply some review suggestions

3 years agoRollup merge of #78157 - GuillaumeGomez:remove-unused-type, r=jyn514
Guillaume Gomez [Tue, 20 Oct 2020 19:46:43 +0000 (21:46 +0200)]
Rollup merge of #78157 - GuillaumeGomez:remove-unused-type, r=jyn514

Remove unused type from librustdoc

r? @jyn514

3 years agoRollup merge of #78145 - LingMan:ast_pretty_mut, r=jonas-schievink
Guillaume Gomez [Tue, 20 Oct 2020 19:46:42 +0000 (21:46 +0200)]
Rollup merge of #78145 - LingMan:ast_pretty_mut, r=jonas-schievink

Drop unneeded `mut`

These parameters don't get modified.

Note that `trailing_comment` is pub and gets exported from `rustc_ast_pretty`. Is that considered to be a stable API? If yes, and you want to reserve the right to modify `self` in `trailing_comment` in the future, that hunk would need to be dropped.

3 years agoRollup merge of #78144 - bugadani:elements-nodrop, r=oli-obk
Guillaume Gomez [Tue, 20 Oct 2020 19:46:40 +0000 (21:46 +0200)]
Rollup merge of #78144 - bugadani:elements-nodrop, r=oli-obk

Don't update `entries` in `TypedArena` if T does not need drop

As far as I can tell, `entries` is only used when dropping `TypedArenaChunk`s and their contents. It is already ignored there, if T is not `mem::needs_drop`, this PR just skips updating it's value.

You can see `TypedArenaChunk` ignoring the entry count in L71. The reasoning is similar to what you can find in `DroplessArena`.

r? @oli-obk

3 years agoRollup merge of #78133 - JohnTitor:mir-tests, r=lcnr
Guillaume Gomez [Tue, 20 Oct 2020 19:46:38 +0000 (21:46 +0200)]
Rollup merge of #78133 - JohnTitor:mir-tests, r=lcnr

Add some MIR-related regression tests

Closes #68841
Closes #75053
Closes #76375
Closes #77911

I think they're fixed by #77306.

3 years agoRollup merge of #78129 - mbartlett21:patch-1, r=kennytm
Guillaume Gomez [Tue, 20 Oct 2020 19:46:37 +0000 (21:46 +0200)]
Rollup merge of #78129 - mbartlett21:patch-1, r=kennytm

Wrapping intrinsics doc links update.

The links in the wrapping intrinsics docs now refer to the `wrapping_*` functions, not the `checked_*` functions.

3 years agoRollup merge of #78076 - est31:orphan_mod, r=Mark-Simulacrum
Guillaume Gomez [Tue, 20 Oct 2020 19:46:35 +0000 (21:46 +0200)]
Rollup merge of #78076 - est31:orphan_mod, r=Mark-Simulacrum

Move orphan module-name/mod.rs files into module-name.rs files

3 years agoRollup merge of #78070 - RalfJung:const-panic-test, r=oli-obk
Guillaume Gomez [Tue, 20 Oct 2020 19:46:33 +0000 (21:46 +0200)]
Rollup merge of #78070 - RalfJung:const-panic-test, r=oli-obk

we can test std and core panic macros together

r? @oli-obk

3 years agoRollup merge of #78061 - wesleywiser:opt_zst_const_interning, r=oli-obk
Guillaume Gomez [Tue, 20 Oct 2020 19:46:32 +0000 (21:46 +0200)]
Rollup merge of #78061 - wesleywiser:opt_zst_const_interning, r=oli-obk

Optimize const value interning for ZST types

Interning can skip any inhabited ZST type in general.

Fixes #68010

r? @oli-obk

3 years agoRollup merge of #78046 - bugadani:issue-73827, r=nikic
Guillaume Gomez [Tue, 20 Oct 2020 19:46:30 +0000 (21:46 +0200)]
Rollup merge of #78046 - bugadani:issue-73827, r=nikic

Add codegen test for issue #73827

Closes #73827

3 years agoRemove unused type from librustdoc
Guillaume Gomez [Tue, 20 Oct 2020 17:49:08 +0000 (19:49 +0200)]
Remove unused type from librustdoc

3 years agoAuto merge of #78151 - tmiasko:disable-match-branch-simplification, r=wesleywiser
bors [Tue, 20 Oct 2020 16:59:23 +0000 (16:59 +0000)]
Auto merge of #78151 - tmiasko:disable-match-branch-simplification, r=wesleywiser

Disable MatchBranchSimplification

This optimization can result in unsoundness, because it introduces
additional uses of a place holding the discriminant value without
ensuring that it is valid to do so.

Found by validation from #77369 / #78147.

3 years agoreview comments
Esteban Küber [Tue, 20 Oct 2020 00:57:18 +0000 (17:57 -0700)]
review comments

3 years agoTweak "object unsafe" errors
Esteban Küber [Fri, 16 Oct 2020 00:23:45 +0000 (17:23 -0700)]
Tweak "object unsafe" errors

Fix #77598.

3 years agoTrack element count only for types that need drop
Dániel Buga [Tue, 20 Oct 2020 09:32:10 +0000 (11:32 +0200)]
Track element count only for types that need drop

3 years agoDrop unneeded `mut`
LingMan [Mon, 12 Oct 2020 23:39:47 +0000 (01:39 +0200)]
Drop unneeded `mut`

These parameters don't get modified.

3 years agoBTreeMap: less sharing, more similarity between leaf and internal nodes
Stein Somers [Sat, 26 Sep 2020 18:46:44 +0000 (20:46 +0200)]
BTreeMap: less sharing, more similarity between leaf and internal nodes

3 years agoBTreeMap: reuse BoxedNode instances directly instead of their contents
Stein Somers [Thu, 1 Oct 2020 13:02:40 +0000 (15:02 +0200)]
BTreeMap: reuse BoxedNode instances directly instead of their contents

3 years agoAuto merge of #76893 - lcnr:existential-proj, r=estebank
bors [Tue, 20 Oct 2020 08:59:12 +0000 (08:59 +0000)]
Auto merge of #76893 - lcnr:existential-proj, r=estebank

Improve `skip_binder` usage during FlagComputation

It looks like there was previously a bug around `ExistentialPredicate::Projection` here, don't know how to best trigger that one to add a regression test though.

3 years agoAdd test for issue-77911
Yuki Okushi [Tue, 20 Oct 2020 08:07:56 +0000 (17:07 +0900)]
Add test for issue-77911

3 years agoAdd test for issue-76375
Yuki Okushi [Tue, 20 Oct 2020 08:07:41 +0000 (17:07 +0900)]
Add test for issue-76375

3 years agoAdd test for issue-75053
Yuki Okushi [Tue, 20 Oct 2020 08:07:27 +0000 (17:07 +0900)]
Add test for issue-75053

3 years agoAdd test for issue-68841
Yuki Okushi [Tue, 20 Oct 2020 08:07:11 +0000 (17:07 +0900)]
Add test for issue-68841

3 years agoAuto merge of #76696 - Aaron1011:tokenstream-avoid-clone, r=petrochenkov
bors [Tue, 20 Oct 2020 05:45:08 +0000 (05:45 +0000)]
Auto merge of #76696 - Aaron1011:tokenstream-avoid-clone, r=petrochenkov

Avoid cloning the contents of a `TokenStream` in a few places

3 years agoWrapping intrinsics update link
mbartlett21 [Tue, 20 Oct 2020 04:09:01 +0000 (14:09 +1000)]
Wrapping intrinsics update link

Now refers to `wrapping_*`, not `checked_*` for wrapping intrinsics.

3 years agoAuto merge of #78127 - JohnTitor:rollup-p1bxtqq, r=JohnTitor
bors [Tue, 20 Oct 2020 03:13:30 +0000 (03:13 +0000)]
Auto merge of #78127 - JohnTitor:rollup-p1bxtqq, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #77612 (BTreeMap: test invariants more thoroughly and more readably)
 - #77761 (Assert that pthread mutex initialization succeeded)
 - #77778 ([x.py setup] Allow setting up git hooks from other worktrees)
 - #77838 (const keyword: brief paragraph on 'const fn')
 - #77923 ([net] apply clippy lints)
 - #77931 (Fix false positive for `unused_parens` lint)
 - #77959 (Tweak ui-tests structure)
 - #78105 (change name in .mailmap)
 - #78111 (Trait predicate ambiguities are not always in `Self`)
 - #78121 (Do not ICE on pattern that uses a binding multiple times in generator)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78121 - LeSeulArtichaut:issue-78115, r=tmandry
Yuki Okushi [Tue, 20 Oct 2020 03:11:13 +0000 (12:11 +0900)]
Rollup merge of #78121 - LeSeulArtichaut:issue-78115, r=tmandry

Do not ICE on pattern that uses a binding multiple times in generator

Fixes #78115.
r? @tmandry

3 years agoRollup merge of #78111 - SNCPlay42:not-always-self, r=lcnr
Yuki Okushi [Tue, 20 Oct 2020 03:11:11 +0000 (12:11 +0900)]
Rollup merge of #78111 - SNCPlay42:not-always-self, r=lcnr

Trait predicate ambiguities are not always in `Self`

When reporting ambiguities in trait predicates, the compiler incorrectly assumed the ambiguity was always in the type the trait should be implemented on, and never the generic parameters of the trait. This caused silly suggestions for predicates like `<KnownType as Trait<_>>`, such as giving explicit types to completely unrelated variables that happened to be of type `KnownType`.

This also reverts #73027, which worked around this issue in some cases and does not appear to be necessary any more.

fixes #77982
fixes #78055

3 years agoRollup merge of #78105 - lcnr:namesNstuff, r=Mark-Simulacrum
Yuki Okushi [Tue, 20 Oct 2020 03:11:10 +0000 (12:11 +0900)]
Rollup merge of #78105 - lcnr:namesNstuff, r=Mark-Simulacrum

change name in .mailmap

3 years agoRollup merge of #77959 - JohnTitor:tweak-test-structure, r=petrochenkov
Yuki Okushi [Tue, 20 Oct 2020 03:11:08 +0000 (12:11 +0900)]
Rollup merge of #77959 - JohnTitor:tweak-test-structure, r=petrochenkov

Tweak ui-tests structure

We have some similar name dirs in ui tests, e.g. `associated-type` and `associated-types` and it can be an issue when we add a test, "which is the right place?". At a glance, it seems they can be merged into one directory so let's merge them to avoid some confusion :)

3 years agoRollup merge of #77931 - aticu:fix_60336, r=petrochenkov
Yuki Okushi [Tue, 20 Oct 2020 03:11:06 +0000 (12:11 +0900)]
Rollup merge of #77931 - aticu:fix_60336, r=petrochenkov

Fix false positive for `unused_parens` lint

Fixes #60336

3 years agoRollup merge of #77923 - wcampbell0x2a:cleanup-net-module, r=scottmcm
Yuki Okushi [Tue, 20 Oct 2020 03:11:04 +0000 (12:11 +0900)]
Rollup merge of #77923 - wcampbell0x2a:cleanup-net-module, r=scottmcm

[net] apply clippy lints

Applied helpful clippy lints to the network std library module.

3 years agoRollup merge of #77838 - RalfJung:const-fn, r=kennytm
Yuki Okushi [Tue, 20 Oct 2020 03:11:02 +0000 (12:11 +0900)]
Rollup merge of #77838 - RalfJung:const-fn, r=kennytm

const keyword: brief paragraph on 'const fn'

`const fn` were mentioned in the title, but called "deterministic functions" which is not their main property (though at least currently it is a consequence of being const-evaluable). This adds a brief paragraph discussing them, also in the hopes of clarifying that they do *not* have any effect on run-time uses.

3 years agoRollup merge of #77778 - jyn514:git-hook, r=mark-simulacrum
Yuki Okushi [Tue, 20 Oct 2020 03:11:00 +0000 (12:11 +0900)]
Rollup merge of #77778 - jyn514:git-hook, r=mark-simulacrum

[x.py setup] Allow setting up git hooks from other worktrees

Closes https://github.com/rust-lang/rust/issues/77684
r? @caass

3 years agoRollup merge of #77761 - tmiasko:pthread-mutex, r=cuviper
Yuki Okushi [Tue, 20 Oct 2020 03:10:58 +0000 (12:10 +0900)]
Rollup merge of #77761 - tmiasko:pthread-mutex, r=cuviper

Assert that pthread mutex initialization succeeded

If pthread mutex initialization fails, the failure will go unnoticed unless
debug assertions are enabled. Any subsequent use of mutex will also silently
fail, since return values from lock & unlock operations are similarly checked
only through debug assertions.

In some implementations the mutex initialization requires a memory
allocation and so it does fail in practice.

Assert that initialization succeeds to ensure that mutex guarantees
mutual exclusion.

Fixes #34966.

3 years agoRollup merge of #77612 - ssomers:btree_cleanup_2, r=Mark-Simulacrum
Yuki Okushi [Tue, 20 Oct 2020 03:10:52 +0000 (12:10 +0900)]
Rollup merge of #77612 - ssomers:btree_cleanup_2, r=Mark-Simulacrum

BTreeMap: test invariants more thoroughly and more readably

r? @Mark-Simulacrum

3 years agoDisable MatchBranchSimplification
Tomasz Miąsko [Tue, 20 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Disable MatchBranchSimplification

This optimization can result in unsoundness, because it introduces
additional uses of a place holding the discriminant value without
ensuring that it is valid to do so.

3 years agoCheck that pthread mutex initialization succeeded
Tomasz Miąsko [Tue, 20 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Check that pthread mutex initialization succeeded

If pthread mutex initialization fails, the failure will go unnoticed unless
debug assertions are enabled. Any subsequent use of mutex will also silently
fail, since return values from lock & unlock operations are similarly checked
only through debug assertions.

In some implementations the mutex initialization requires a memory
allocation and so it does fail in practice.

Check that initialization succeeds to ensure that mutex guarantees
mutual exclusion.

3 years agoAdd inline const macro test
Santiago Pastorino [Mon, 19 Oct 2020 21:55:43 +0000 (18:55 -0300)]
Add inline const macro test

3 years agoAllow NtBlock to parse on check inline const next token
Santiago Pastorino [Mon, 19 Oct 2020 19:57:04 +0000 (16:57 -0300)]
Allow NtBlock to parse on check inline const next token

3 years agoAdd regression test
LeSeulArtichaut [Mon, 19 Oct 2020 21:32:07 +0000 (23:32 +0200)]
Add regression test

3 years agoDo not ICE on pattern that uses a binding multiple times in generator
LeSeulArtichaut [Mon, 19 Oct 2020 21:14:28 +0000 (23:14 +0200)]
Do not ICE on pattern that uses a binding multiple times in generator

3 years agorevert workaround #73027
SNCPlay42 [Mon, 19 Oct 2020 16:58:44 +0000 (17:58 +0100)]
revert workaround #73027

3 years agodon't assume trait ambiguity happens in `Self`
SNCPlay42 [Mon, 19 Oct 2020 16:42:57 +0000 (17:42 +0100)]
don't assume trait ambiguity happens in `Self`

3 years agoDo not print braces again print_anon_const already does it
Santiago Pastorino [Mon, 19 Oct 2020 19:26:13 +0000 (16:26 -0300)]
Do not print braces again print_anon_const already does it

3 years agoRewrite `collect_tokens` implementations to use a flattened buffer
Aaron Hill [Sun, 27 Sep 2020 01:56:29 +0000 (21:56 -0400)]
Rewrite `collect_tokens` implementations to use a flattened buffer

Instead of trying to collect tokens at each depth, we 'flatten' the
stream as we go allong, pushing open/close delimiters to our buffer
just like regular tokens. One capturing is complete, we reconstruct a
nested `TokenTree::Delimited` structure, producing a normal
`TokenStream`.

The reconstructed `TokenStream` is not created immediately - instead, it is
produced on-demand by a closure (wrapped in a new `LazyTokenStream` type). This
closure stores a clone of the original `TokenCursor`, plus a record of the
number of calls to `next()/next_desugared()`. This is sufficient to reconstruct
the tokenstream seen by the callback without storing any additional state. If
the tokenstream is never used (e.g. when a captured `macro_rules!` argument is
never passed to a proc macro), we never actually create a `TokenStream`.

This implementation has a number of advantages over the previous one:

* It is significantly simpler, with no edge cases around capturing the
  start/end of a delimited group.

* It can be easily extended to allow replacing tokens an an arbitrary
  'depth' by just using `Vec::splice` at the proper position. This is
  important for PR #76130, which requires us to track information about
  attributes along with tokens.

* The lazy approach to `TokenStream` construction allows us to easily
  parse an AST struct, and then decide after the fact whether we need a
  `TokenStream`. This will be useful when we start collecting tokens for
  `Attribute` - we can discard the `LazyTokenStream` if the parsed
  attribute doesn't need tokens (e.g. is a builtin attribute).

The performance impact seems to be neglibile (see
https://github.com/rust-lang/rust/pull/77250#issuecomment-703960604). There is a
small slowdown on a few benchmarks, but it only rises above 1% for incremental
builds, where it represents a larger fraction of the much smaller instruction
count. There a ~1% speedup on a few other incremental benchmarks - my guess is
that the speedups and slowdowns will usually cancel out in practice.

3 years agoAuto merge of #78106 - GuillaumeGomez:rollup-06vwk7p, r=GuillaumeGomez
bors [Mon, 19 Oct 2020 17:53:17 +0000 (17:53 +0000)]
Auto merge of #78106 - GuillaumeGomez:rollup-06vwk7p, r=GuillaumeGomez

Rollup of 4 pull requests

Successful merges:

 - #77877 (Use `try{}` in `try_fold` to decouple iterators in the library from `Try` details)
 - #78089 (Fix issue with specifying generic arguments for primitive types)
 - #78099 (Add missing punctuation)
 - #78103 (Add link to rustdoc book in rustdoc help popup)

Failed merges:

r? `@ghost`

3 years agoAvoid cloning the contents of a `TokenStream` in a few places
Aaron Hill [Mon, 14 Sep 2020 05:45:10 +0000 (01:45 -0400)]
Avoid cloning the contents of a `TokenStream` in a few places

3 years agoRollup merge of #78103 - GuillaumeGomez:rustdoc-book, r=jyn514
Guillaume Gomez [Mon, 19 Oct 2020 16:20:26 +0000 (18:20 +0200)]
Rollup merge of #78103 - GuillaumeGomez:rustdoc-book, r=jyn514

Add link to rustdoc book in rustdoc help popup

Part of #75520.

It looks like this:

![Screenshot from 2020-10-19 13-46-02](https://user-images.githubusercontent.com/3050060/96446334-934d6900-1211-11eb-8fdc-133fecc8c30d.png)
![Screenshot from 2020-10-19 13-43-46](https://user-images.githubusercontent.com/3050060/96446335-947e9600-1211-11eb-955c-68af5292aecc.png)
![Screenshot from 2020-10-19 13-37-26](https://user-images.githubusercontent.com/3050060/96446337-947e9600-1211-11eb-9a2e-399b99178a65.png)

r? @jyn514

3 years agoRollup merge of #78099 - pierwill:patch-5, r=jonas-schievink
Guillaume Gomez [Mon, 19 Oct 2020 16:20:24 +0000 (18:20 +0200)]
Rollup merge of #78099 - pierwill:patch-5, r=jonas-schievink

Add missing punctuation

3 years agoRollup merge of #78089 - varkor:opt_const_param_of-error, r=lcnr
Guillaume Gomez [Mon, 19 Oct 2020 16:20:23 +0000 (18:20 +0200)]
Rollup merge of #78089 - varkor:opt_const_param_of-error, r=lcnr

Fix issue with specifying generic arguments for primitive types

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

r? @lcnr

3 years agoRollup merge of #77877 - scottmcm:fewer-try-trait-method-references, r=shepmaster
Guillaume Gomez [Mon, 19 Oct 2020 16:20:20 +0000 (18:20 +0200)]
Rollup merge of #77877 - scottmcm:fewer-try-trait-method-references, r=shepmaster

Use `try{}` in `try_fold` to decouple iterators in the library from `Try` details

I'd like to experiment with changing the `?`/`try` desugaring and correspondingly the `Try` trait (see #42327 for discussions about the suboptimalities of the current one) and this change would keep from needing any `cfg(bootstrap)` in iterator things.

This will be lowered to the same thing, so shouldn't cause any perf issues:
https://github.com/rust-lang/rust/blob/08e2d4616613716362b4b49980ff303f2b9ae654/compiler/rustc_ast_lowering/src/expr.rs#L428-L429

But ~~I'll trigger~~ I've triggered [a perf run](https://perf.rust-lang.org/compare.html?start=d65c08e9cc164b7b44de53503fae859a4fafd976&end=2c067c5235e779cd75e9f0cdfe572c64f1a12b9b) just in case.

~~EDIT: changed to a draft because of the rustfmt-only syntax error.  zulip thread about it: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/New.20bootstrap.20rustfmt.20doesn't.20support.20syntax.20from.20sept.3F/near/213098097~~

EDIT: This now includes a rustfmt version bump to get through tidy.

3 years agoAuto merge of #77908 - bugadani:obl-forest, r=nnethercote
bors [Mon, 19 Oct 2020 15:14:15 +0000 (15:14 +0000)]
Auto merge of #77908 - bugadani:obl-forest, r=nnethercote

Try to make ObligationForest more efficient

This PR tries to decrease the number of allocations in ObligationForest, as well as moves some cold path code to an uninlined function.

3 years agoAdd link to rustdoc book in rustdoc help popup
Guillaume Gomez [Mon, 19 Oct 2020 11:44:27 +0000 (13:44 +0200)]
Add link to rustdoc book in rustdoc help popup

3 years agochange name in mailmap
Bastian Kauschke [Mon, 19 Oct 2020 13:23:32 +0000 (15:23 +0200)]
change name in mailmap

3 years agoRevert "[net] clippy: needless_update"
wcampbell [Mon, 19 Oct 2020 11:22:45 +0000 (07:22 -0400)]
Revert "[net] clippy: needless_update"

This reverts commit 058699d0a2fca02127761f014d0ecfce1c5541ec.

3 years agofix Rvalue::ty for ThreadLocalRef
Ralf Jung [Mon, 19 Oct 2020 08:53:20 +0000 (10:53 +0200)]
fix Rvalue::ty for ThreadLocalRef

3 years agoBTreeMap: test invariants more thoroughly and more readably
Stein Somers [Mon, 5 Oct 2020 23:50:35 +0000 (01:50 +0200)]
BTreeMap: test invariants more thoroughly and more readably

3 years agofix static_ptr_ty for foreign statics, and more comments in check_unsafety
Ralf Jung [Mon, 19 Oct 2020 07:47:18 +0000 (09:47 +0200)]
fix static_ptr_ty for foreign statics, and more comments in check_unsafety

3 years agoremove what seems to be an outdated comment
Ralf Jung [Mon, 19 Oct 2020 07:46:18 +0000 (09:46 +0200)]
remove what seems to be an outdated comment

Even in the PR that introduced this comment, it does not seem like these locals are actually ignored -- just their `source_info` is adjusted:
https://github.com/rust-lang/rust/pull/44700/files#diff-ae2f3c7e2f9744f7ef43e96072b10e98d4e3fe74a3a399a3ad8a810fbe56c520R139

3 years agoAdd missing punctuation
pierwill [Mon, 19 Oct 2020 06:03:16 +0000 (23:03 -0700)]
Add missing punctuation

3 years agoAuto merge of #78087 - camelid:bootstrap-print-units, r=jyn514
bors [Mon, 19 Oct 2020 04:34:34 +0000 (04:34 +0000)]
Auto merge of #78087 - camelid:bootstrap-print-units, r=jyn514

bootstrap: Print units for "finished in xxx" message

It now says "finished in xxx seconds".

Also slightly improved some wording in the README.

3 years agorustdoc: Show the correct source filename, without `.html`
Camelid [Mon, 19 Oct 2020 02:38:47 +0000 (19:38 -0700)]
rustdoc: Show the correct source filename, without `.html`

Previously the title would be

    lib.rs.html -- source

if `lib.rs` was the actual source filename. Now the title is

    lib.rs – source

(note the en dash).

3 years agoAuto merge of #77278 - camelid:use-correct-article, r=estebank
bors [Mon, 19 Oct 2020 02:19:21 +0000 (02:19 +0000)]
Auto merge of #77278 - camelid:use-correct-article, r=estebank

Use correct article in help message for conversion or cast

Before it always used `an`; now it uses the correct article for the type.

3 years agoDon't ICE if called with a `TyKind::Error`
Camelid [Mon, 19 Oct 2020 00:37:26 +0000 (17:37 -0700)]
Don't ICE if called with a `TyKind::Error`

It felt too harsh to estebank and others to ICE even though it's
technically a mistake to show a `TyKind::Error`.

3 years agoAuto merge of #77874 - camelid:range-docs-readability, r=scottmcm
bors [Mon, 19 Oct 2020 00:11:08 +0000 (00:11 +0000)]
Auto merge of #77874 - camelid:range-docs-readability, r=scottmcm

Improve range docs

* Improve code formatting and legibility
* Various other readability improvements

3 years agoImprove range docs
Camelid [Mon, 12 Oct 2020 21:53:41 +0000 (14:53 -0700)]
Improve range docs

* Mention that `RangeFull` is a ZST and thus a singleton
* Improve code formatting and legibility
* Various other readability improvements

3 years agoFix issue with specifying generic arguments for primitive types
varkor [Sun, 18 Oct 2020 21:40:50 +0000 (22:40 +0100)]
Fix issue with specifying generic arguments for primitive types

3 years agoAuto merge of #78075 - est31:remove_redundant_static, r=jonas-schievink
bors [Sun, 18 Oct 2020 21:02:05 +0000 (21:02 +0000)]
Auto merge of #78075 - est31:remove_redundant_static, r=jonas-schievink

Remove redundant 'static

3 years agobootstrap: Print units for "finished in xxx" message
Camelid [Sun, 18 Oct 2020 20:54:51 +0000 (13:54 -0700)]
bootstrap: Print units for "finished in xxx" message

It now says "finished in xxx seconds".

Also slightly improved some wording in the README.

3 years agoMove orphan module-name/mod.rs files into module-name.rs files
est31 [Sun, 18 Oct 2020 15:52:01 +0000 (17:52 +0200)]
Move orphan module-name/mod.rs files into module-name.rs files

3 years agoAuto merge of #76885 - dylni:move-slice-check-range-to-range-bounds, r=KodrAus
bors [Sun, 18 Oct 2020 18:50:43 +0000 (18:50 +0000)]
Auto merge of #76885 - dylni:move-slice-check-range-to-range-bounds, r=KodrAus

Move `slice::check_range` to `RangeBounds`

Since this method doesn't take a slice anymore (#76662), it makes more sense to define it on `RangeBounds`.

Questions:
- Should the new method be `assert_len` or `assert_length`?

3 years agoAuto merge of #77306 - lcnr:inline-ok, r=eddyb
bors [Sun, 18 Oct 2020 16:10:00 +0000 (16:10 +0000)]
Auto merge of #77306 - lcnr:inline-ok, r=eddyb

normalize substs while inlining

fixes #68347 or more precisely, this fixes the same ICE in rust analyser as veloren is pinned to a specific nightly
and had an error with the current one.

I didn't look into creating an MVCE here as that seems fairly annoying, will spend a few minutes doing so rn. (failed)

r? `@eddyb` cc `@bjorn3`

3 years agoRemove redundant 'static in the compiler
est31 [Sun, 18 Oct 2020 15:28:00 +0000 (17:28 +0200)]
Remove redundant 'static in the compiler

3 years agoRemove redundant 'static from library crates
est31 [Sun, 18 Oct 2020 15:14:25 +0000 (17:14 +0200)]
Remove redundant 'static from library crates

3 years agoAuto merge of #78066 - bugadani:wat, r=jonas-schievink
bors [Sun, 18 Oct 2020 13:50:31 +0000 (13:50 +0000)]
Auto merge of #78066 - bugadani:wat, r=jonas-schievink

Clean up small, surprising bits of code

This PR clean up a small number of unrelated, small things I found while browsing the code base.

3 years agowe can test std and core panic macros together
Ralf Jung [Sun, 18 Oct 2020 12:34:30 +0000 (14:34 +0200)]
we can test std and core panic macros together

3 years agoAuto merge of #78058 - bugadani:arena2, r=lcnr
bors [Sun, 18 Oct 2020 11:19:14 +0000 (11:19 +0000)]
Auto merge of #78058 - bugadani:arena2, r=lcnr

Make sure arenas don't allocate bigger than HUGE_PAGE

Right now, arenas allocate based on the size of the last chunk. It is possible for a `grow` call to allocate a chunk that is not a multiple of `PAGE`, and this size is doubled for each subsequent allocation. This means, instead of `HUGE_PAGE`, the biggest page possible is actually unknown.

This change fixes this, and also removes an unnecessary checked multiplication. It is still possible to allocate bigger than `HUGE_PAGE` pages, but this will only happen as many times as absolutely necessary.

3 years agoBTreeMap: split off most code of remove and split_off
Stein Somers [Sat, 17 Oct 2020 15:00:59 +0000 (17:00 +0200)]
BTreeMap: split off most code of remove and split_off

3 years agoAuto merge of #78035 - camelid:basic-block-pointer-note, r=RalfJung
bors [Sun, 18 Oct 2020 09:08:00 +0000 (09:08 +0000)]
Auto merge of #78035 - camelid:basic-block-pointer-note, r=RalfJung

Note that `BasicBlock` is just an index

r? `@RalfJung`

3 years agoReplace unnecessary map_or_else with map_or
Dániel Buga [Sun, 18 Oct 2020 08:59:03 +0000 (10:59 +0200)]
Replace unnecessary map_or_else with map_or

3 years agoZip -> Enumerate
Dániel Buga [Sun, 18 Oct 2020 08:43:01 +0000 (10:43 +0200)]
Zip -> Enumerate

3 years agoNo need to map the max_distance
Dániel Buga [Fri, 16 Oct 2020 10:49:25 +0000 (12:49 +0200)]
No need to map the max_distance

3 years agoEarly return to decrease indentation
Dániel Buga [Wed, 14 Oct 2020 08:58:12 +0000 (10:58 +0200)]
Early return to decrease indentation