]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agochange the order of type arguments on ControlFlow
Leonora Tindall [Fri, 11 Sep 2020 21:36:58 +0000 (16:36 -0500)]
change the order of type arguments on ControlFlow

This allows ControlFlow<BreakType> which is much more ergonomic for
common iterator combinator use cases.

3 years agoAuto merge of #77720 - matthewjasper:fix-trait-ices, r=nikomatsakis
bors [Thu, 22 Oct 2020 14:40:20 +0000 (14:40 +0000)]
Auto merge of #77720 - matthewjasper:fix-trait-ices, r=nikomatsakis

Fix trait solving ICEs

- Selection candidates that are known to be applicable are preferred
  over candidates that are not.
- Don't ICE if a projection/object candidate is no longer applicable
  (this can happen due to cycles in normalization)
- Normalize supertraits when finding trait object candidates

Closes #77653
Closes #77656

r? `@nikomatsakis`

3 years agoAuto merge of #77871 - Julian-Wollersberger:less-query-context, r=oli-obk
bors [Thu, 22 Oct 2020 12:24:55 +0000 (12:24 +0000)]
Auto merge of #77871 - Julian-Wollersberger:less-query-context, r=oli-obk

Make fewer types generic over QueryContext

While trying to refactor `rustc_query_system::query::QueryContext` to make it dyn-safe, I noticed some smaller things:
* QueryConfig doesn't need to be generic over QueryContext
* ~~The `kind` field on QueryJobId is unused~~
* Some unnecessary where clauses
* Many types in `job.rs` where generic over `QueryContext` but only needed `QueryContext::Query`.
  If handle_cycle_error() could be refactored to not take `error: CycleError<CTX::Query>`, all those bounds could be removed as well.

Changing `find_cycle_in_stack()` in job.rs to not take a `tcx` argument is the only functional change here. Everything else is just updating type signatures. (aka compile-error driven development ^^)

~~Currently there is a weird bug where memory usage suddenly skyrockets when running UI tests. I'll investigate that tomorrow.
A perf run probably won't make sense before that is fixed.~~

EDIT: `kind` actually is used by `Eq`, and re-adding it fixed the memory issue.

3 years agoNormalize when finding trait object candidates
Matthew Jasper [Thu, 8 Oct 2020 20:52:40 +0000 (21:52 +0100)]
Normalize when finding trait object candidates

3 years agoAuto merge of #78134 - bugadani:arena-nodrop, r=lcnr
bors [Thu, 22 Oct 2020 07:05:21 +0000 (07:05 +0000)]
Auto merge of #78134 - bugadani:arena-nodrop, r=lcnr

Use `DroplessArena` where we know the type doesn't need drop

This PR uses a single `DroplessArena` in resolve instead of three separate `TypedArena`s.

`DroplessArena` checks that the type indeed doesn't need drop, so in case the types change, this will result in visible failures.

3 years agoAuto merge of #78131 - SimonSapin:ar, r=Mark-Simulacrum
bors [Thu, 22 Oct 2020 04:40:06 +0000 (04:40 +0000)]
Auto merge of #78131 - SimonSapin:ar, r=Mark-Simulacrum

Package more llvm-* tools in the rust-dev component, for run-make-fulldeps tests

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

3 years agoAuto merge of #78212 - JohnTitor:rollup-j5r6xuy, r=JohnTitor
bors [Thu, 22 Oct 2020 01:35:05 +0000 (01:35 +0000)]
Auto merge of #78212 - JohnTitor:rollup-j5r6xuy, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #77420 (Unify const-checking structured errors for `&mut` and `&raw mut`)
 - #77554 (Support signed integers and `char` in v0 mangling)
 - #77976 (Mark inout asm! operands as used in liveness pass)
 - #78009 (Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling)
 - #78084 (Greatly improve display for small mobile devices screens)
 - #78155 (Fix two small issues in compiler/rustc_lint/src/types.rs)
 - #78156 (Fixed build failure of `rustfmt`)
 - #78172 (Add test case for #77062)
 - #78188 (Add tracking issue number for pin_static_ref)
 - #78200 (Add `ControlFlow::is_{break,continue}` methods)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78200 - LeSeulArtichaut:controlflow-is-meth, r=scottmcm
Yuki Okushi [Thu, 22 Oct 2020 00:45:45 +0000 (09:45 +0900)]
Rollup merge of #78200 - LeSeulArtichaut:controlflow-is-meth, r=scottmcm

Add `ControlFlow::is_{break,continue}` methods

r? @scottmcm cc #75744

3 years agoRollup merge of #78188 - fusion-engineering-forks:static-ref-tracking-issue, r=withou...
Yuki Okushi [Thu, 22 Oct 2020 00:45:43 +0000 (09:45 +0900)]
Rollup merge of #78188 - fusion-engineering-forks:static-ref-tracking-issue, r=withoutboats

Add tracking issue number for pin_static_ref

Forgot to add a tracking issue in #77726. Opened #78186 as tracking issue.

3 years agoRollup merge of #78172 - wesleywiser:close_77062, r=oli-obk
Yuki Okushi [Thu, 22 Oct 2020 00:45:42 +0000 (09:45 +0900)]
Rollup merge of #78172 - wesleywiser:close_77062, r=oli-obk

Add test case for #77062

Closes #77062

3 years agoRollup merge of #78156 - bishtpawan:bugfix/rustfmt-no-longer-builds, r=lcnr
Yuki Okushi [Thu, 22 Oct 2020 00:45:40 +0000 (09:45 +0900)]
Rollup merge of #78156 - bishtpawan:bugfix/rustfmt-no-longer-builds, r=lcnr

Fixed build failure of `rustfmt`

Fixes #78079
r? @eddyb cc @bjorn3

3 years agoRollup merge of #78155 - est31:rustc_lint_types_refactor, r=davidtwco
Yuki Okushi [Thu, 22 Oct 2020 00:45:38 +0000 (09:45 +0900)]
Rollup merge of #78155 - est31:rustc_lint_types_refactor, r=davidtwco

Fix two small issues in compiler/rustc_lint/src/types.rs

Two small improvements of `compiler/rustc_lint/src/types.rs`

3 years agoRollup merge of #78084 - GuillaumeGomez:improve-mobile-display, r=jyn514,Nemo157
Yuki Okushi [Thu, 22 Oct 2020 00:45:37 +0000 (09:45 +0900)]
Rollup merge of #78084 - GuillaumeGomez:improve-mobile-display, r=jyn514,Nemo157

Greatly improve display for small mobile devices screens

Fixes #78014.

The biggest change being the "search bar". Instead of having everything on one line, I decided to move the search input on its own:

![Screenshot from 2020-10-18 21-54-26](https://user-images.githubusercontent.com/3050060/96378530-c863a800-118c-11eb-8e82-a43fce312b5b.png)

Another change is that now, we "break words" in the listing so that they don't grow too big:

![Screenshot from 2020-10-18 21-57-17](https://user-images.githubusercontent.com/3050060/96378555-ffd25480-118c-11eb-8a71-8f116c7edd93.png)

r? @jyn514

3 years agoRollup merge of #78009 - nielx:fix/CMAKE_SYSTEM_NAME, r=Mark-Simulacrum
Yuki Okushi [Thu, 22 Oct 2020 00:45:35 +0000 (09:45 +0900)]
Rollup merge of #78009 - nielx:fix/CMAKE_SYSTEM_NAME, r=Mark-Simulacrum

Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling

This resolves issues where the cross-build of LLVM fails because it tries to
link to the host's system libraries instead of the target's system libraries.

3 years agoRollup merge of #77976 - oliviacrain:issue-77915-fix, r=matthewjasper
Yuki Okushi [Thu, 22 Oct 2020 00:45:33 +0000 (09:45 +0900)]
Rollup merge of #77976 - oliviacrain:issue-77915-fix, r=matthewjasper

Mark inout asm! operands as used in liveness pass

Variables used in `inout` operands in inline assembly (that is, they're used as both input and output to some arbitrary assembly instruction) are being marked as read and written, but are not marked as being used in the RWU table during the liveness pass. This can result in such expressions triggering an unused variable lint warning. This is incorrect behavior- reads without uses are currently only used for compound assignments. We conservatively assume that an `inout` operand is being read and used in the context of the assembly instruction.

Closes #77915

3 years agoRollup merge of #77554 - varkor:mangle-int-char, r=eddyb
Yuki Okushi [Thu, 22 Oct 2020 00:45:31 +0000 (09:45 +0900)]
Rollup merge of #77554 - varkor:mangle-int-char, r=eddyb

Support signed integers and `char` in v0 mangling

Likely we want more tests, to check the output is correct too: however, I wasn't sure what kind of test we needed, so I just added one similar to that added in https://github.com/rust-lang/rust/pull/77452 for now.

r? @eddyb

3 years agoRollup merge of #77420 - ecstatic-morse:const-checking-raw-mut-ref, r=davidtwco
Yuki Okushi [Thu, 22 Oct 2020 00:45:25 +0000 (09:45 +0900)]
Rollup merge of #77420 - ecstatic-morse:const-checking-raw-mut-ref, r=davidtwco

Unify const-checking structured errors for `&mut` and `&raw mut`

Resolves #77414 as well as a FIXME.

3 years agoAuto merge of #78027 - lcnr:lift-by-value, r=varkor
bors [Wed, 21 Oct 2020 23:09:38 +0000 (23:09 +0000)]
Auto merge of #78027 - lcnr:lift-by-value, r=varkor

Lift: take self by value

seems small enough to not warrant an MCP :shrug:

3 years agoreview
Bastian Kauschke [Wed, 21 Oct 2020 21:52:41 +0000 (23:52 +0200)]
review

3 years agoLift: take self by value
Bastian Kauschke [Fri, 16 Oct 2020 19:59:49 +0000 (21:59 +0200)]
Lift: take self by value

3 years agoAuto merge of #78077 - petrochenkov:qvis, r=davidtwco
bors [Wed, 21 Oct 2020 20:23:26 +0000 (20:23 +0000)]
Auto merge of #78077 - petrochenkov:qvis, r=davidtwco

Calculate visibilities once in resolve

Then use them through a query based on resolver outputs.

Item visibilities were previously calculated in three places - initially in `rustc_resolve`, then in `rustc_privacy` during type privacy checkin, and then in `rustc_metadata` during metadata encoding.
The visibility logic is not entirely trivial, especially for things like constructors or enum variants, and all of it was duplicated.

This PR deduplicates all the visibility calculations, visibilities are determined once during early name resolution and then stored in `ResolverOutputs` and are later available through `tcx` as a query `tcx.visibility(def_id)`.
(This query existed previously, but only worked for other crates.)

Some special cases (e.g. visibilities for closure types, which are needed for type privacy checking) are not processed in resolve, but deferred and performed directly in the query instead.

3 years agoUpdate to rustc-demangle 0.1.18
varkor [Wed, 21 Oct 2020 20:11:11 +0000 (21:11 +0100)]
Update to rustc-demangle 0.1.18

3 years agoAdd test for const generics demangling
varkor [Wed, 7 Oct 2020 20:17:07 +0000 (21:17 +0100)]
Add test for const generics demangling

3 years agoUpdate rustc-demangle
varkor [Wed, 7 Oct 2020 19:52:02 +0000 (20:52 +0100)]
Update rustc-demangle

3 years agoDo not print type for placeholder values
varkor [Wed, 7 Oct 2020 18:31:23 +0000 (19:31 +0100)]
Do not print type for placeholder values

3 years agoSupport signed integers and `char` in v0 mangling
varkor [Sun, 4 Oct 2020 23:28:05 +0000 (00:28 +0100)]
Support signed integers and `char` in v0 mangling

3 years agoAdd `ControlFlow::is_{break,continue}` methods
LeSeulArtichaut [Wed, 21 Oct 2020 19:50:08 +0000 (21:50 +0200)]
Add `ControlFlow::is_{break,continue}` methods

3 years agoFix ICE from projection cycle
Matthew Jasper [Thu, 8 Oct 2020 20:49:36 +0000 (21:49 +0100)]
Fix ICE from projection cycle

Cycles in normalization can cause evaluations to change from Unknown to
Err. This means that some selection that were applicable no longer are.

To avoid this:
* Selection candidates that are known to be applicable are prefered
  over candidates that are not.
* We don't ICE if a candidate is no longer applicable.

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 agoAdd tracking issue number for pin_static_ref.
Mara Bos [Wed, 21 Oct 2020 14:30:41 +0000 (16:30 +0200)]
Add tracking issue number for pin_static_ref.

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 agoFix formatting
bishtpawan [Wed, 21 Oct 2020 06:12:52 +0000 (11:42 +0530)]
Fix formatting

3 years agoBless liveness-asm output
Olivia Crain [Wed, 21 Oct 2020 05:56:22 +0000 (00:56 -0500)]
Bless liveness-asm output

3 years agoLimit liveness-asm tests to x86_64
Olivia Crain [Wed, 21 Oct 2020 05:34:01 +0000 (00:34 -0500)]
Limit liveness-asm tests to x86_64

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 agoAdd test case for #77062
Wesley Wiser [Wed, 21 Oct 2020 00:55:37 +0000 (20:55 -0400)]
Add test case for #77062

Closes #77062

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 agoMake users of `download-ci-llvm` download a new version
Simon Sapin [Tue, 20 Oct 2020 18:04:53 +0000 (20:04 +0200)]
Make users of `download-ci-llvm` download a new version

3 years agoFix build failure of rustfmt
bishtpawan [Tue, 20 Oct 2020 17:43:21 +0000 (23:13 +0530)]
Fix build failure of rustfmt

3 years agoMake {u,}int_range functions a bit nicer
est31 [Tue, 20 Oct 2020 17:36:44 +0000 (19:36 +0200)]
Make {u,}int_range functions a bit nicer

.into() guarantees safety of the conversion.
Furthermore, the minimum value of all uints is known to be 0.

3 years agorustc_lint: remove unused to_string
est31 [Tue, 20 Oct 2020 17:09:50 +0000 (19:09 +0200)]
rustc_lint: remove unused to_string

In this instance, we can just pass a &str slice
and save an allocation.

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 agoPackage more llvm-* tools in the rust-dev component, for run-make-fulldeps tests
Simon Sapin [Tue, 20 Oct 2020 07:14:27 +0000 (09:14 +0200)]
Package more llvm-* tools in the rust-dev component, for run-make-fulldeps tests

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

3 years agoUse DroplessArena for variance inference
Dániel Buga [Tue, 20 Oct 2020 09:05:00 +0000 (11:05 +0200)]
Use DroplessArena for variance inference

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 agoResolve: Use dropless arena for types that don't need drop
Dániel Buga [Tue, 20 Oct 2020 08:37:56 +0000 (10:37 +0200)]
Resolve: Use dropless arena for types that don't need drop

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`