Commit Graph

1613 Commits

Author SHA1 Message Date
Joshua Nelson
bfecb18771 Fix some more clippy warnings 2020-10-30 10:12:56 -04:00
bors
388ef34904 Auto merge of #78562 - JohnTitor:rollup-otg906u, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #77334 (Reorder benches const variable)
 - #77888 (Simplify a nested bool match)
 - #77921 (f64: Refactor collapsible_if)
 - #78523 (Revert invalid `fn` return type parsing change)
 - #78524 (Avoid BorrowMutError with RUSTC_LOG=debug)
 - #78545 (Make anonymous binders start at 0)
 - #78554 (Improve wording of `core::ptr::drop_in_place` docs)
 - #78556 (Link to pass docs from NRVO module docs)

Failed merges:

 - #78424 (Fix some more clippy warnings)

r? `@ghost`
2020-10-30 10:01:49 +00:00
Yuki Okushi
2471a7cdaa
Rollup merge of #78556 - camelid:mir-opt-nrvo-docs, r=jyn514
Link to pass docs from NRVO module docs

It can be easy to miss that this is documented on the pass's struct if you are
looking at the module docs.

Cc https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/what.20is.20NRVO.3F
2020-10-30 18:00:58 +09:00
Yuki Okushi
05f80f03a9
Rollup merge of #78545 - jackh726:anonymous, r=oli-obk
Make anonymous binders start at 0

A few changes to some test outputs, but these actually look *more* correct to me.
2020-10-30 18:00:56 +09:00
Yuki Okushi
f8539221d0
Rollup merge of #78524 - tmiasko:source-files-borrow, r=Aaron1011
Avoid BorrowMutError with RUSTC_LOG=debug

```console
$ touch empty.rs
$ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs
```

Fails with a `BorrowMutError` because source map files are already
borrowed while `features_query` attempts to format a log message
containing a span.

Release the borrow before the query to avoid the issue.
2020-10-30 18:00:54 +09:00
Yuki Okushi
8111706c18
Rollup merge of #78523 - estebank:fix-return-type-parse-regression, r=dtolnay
Revert invalid `fn` return type parsing change

Revert one of the changes in #78379.

Fix #78507.
2020-10-30 18:00:53 +09:00
Yuki Okushi
439ea4b621
Rollup merge of #77888 - LingMan:ast_pretty_tt_prepend_space, r=jyn514
Simplify a nested bool match

Logically this first eliminates the innermost match by merging the patterns.
Then, in a second step, turns the newly innermost match into a `matches!` call.
2020-10-30 18:00:45 +09:00
bors
8df58ae03a Auto merge of #78393 - SNCPlay42:match-if-guard, r=tmandry
Always record reference to binding in match if guards

When encountering a binding from a `match` pattern in its `if` guard when computing a generator's interior types, we must always record the type of a reference to the binding because of how `if` guards are lowered to MIR. This was missed in #75213 because the binding in that test case was autorefed and we recorded that adjusted type anyway.

Fixes #78366
2020-10-30 07:05:57 +00:00
Camelid
f558d96253 Link to pass docs from NRVO module docs 2020-10-29 23:05:45 -07:00
bors
0d33ab7af4 Auto merge of #78432 - sexxi-goose:fix-77993-take3, r=nikomatsakis
Handle type errors in closure/generator upvar_tys

Fixes #77993
2020-10-30 03:00:13 +00:00
Jack Huey
41ce397990 Make anonymous binders start at 0 2020-10-29 18:50:23 -04:00
bors
a3d7a5e945 Auto merge of #78528 - jonas-schievink:rollup-e70g9zk, r=jonas-schievink
Rollup of 11 pull requests

Successful merges:

 - #75078 (Improve documentation for slice strip_* functions)
 - #76138 (Explain fully qualified syntax for `Rc` and `Arc`)
 - #78244 (Dogfood {exclusive,half-open} ranges in compiler (nfc))
 - #78422 (Do not ICE on invalid input)
 - #78423 (rustc_span: improve bounds checks in byte_pos_to_line_and_col)
 - #78431 (Prefer new associated numeric consts in float error messages)
 - #78462 (Use unwrapDIPtr because the Scope may be null.)
 - #78493 (Update cargo)
 - #78499 (Prevent String::retain from creating non-utf8 strings when abusing panic)
 - #78505 (Update Clippy - temporary_cstring_as_ptr deprecation)
 - #78527 (Fix some more typos)

Failed merges:

r? `@ghost`
2020-10-29 20:56:25 +00:00
bors
6bdae9edd0 Auto merge of #78508 - wesleywiser:optimize_visit_scopes, r=petrochenkov
[resolve] Use `unwrap_or_else` instead of `unwrap_or` in a hot path

This improves the performance of the `resolve_crate` function by 30% for
a very large single file crate with auto-generated C bindings.

cc `@rylev`
2020-10-29 18:34:59 +00:00
Jonas Schievink
e656e609ba
Rollup merge of #78527 - bugadani:typo3, r=jonas-schievink
Fix some more typos
2020-10-29 17:05:31 +01:00
Jonas Schievink
38c34098b1
Rollup merge of #78462 - danielframpton:fixnullisa, r=nagisa
Use unwrapDIPtr because the Scope may be null.

I ran into an assertion when using debug information on Windows with LLVM assertions enabled.

It seems like we are using unwrap here (which in turn calls isa and requires the pointer to be non-null) but we expect the value to be null because that is what we are passing from rustc.

This change uses unwrapDIPtr which explicitly allows nullptr.

The FFI prototype for this method on the rust side has the `LLVMMetadataRef` parameter as `Scope: Option<&'a DIScope>`, and we always pass `None` when `msvc_like_names` is true.
2020-10-29 17:05:23 +01:00
Jonas Schievink
31cfe63fb9
Rollup merge of #78431 - Rustin-Liu:rustin-patch-lint, r=estebank
Prefer new associated numeric consts in float error messages

Fix https://github.com/rust-lang/rust/issues/78382
2020-10-29 17:05:21 +01:00
Jonas Schievink
151db25599
Rollup merge of #78423 - tgnottingham:caching_source_map_bounds_check, r=oli-obk
rustc_span: improve bounds checks in byte_pos_to_line_and_col

The effect of this change is to consider edge-case spans that start or
end at the position one past the end of a file to be valid during span
hashing and encoding. This change means that these spans will be
preserved across incremental compilation sessions when they are part of
a serialized query result, instead of causing the dummy span to be used.
2020-10-29 17:05:17 +01:00
Jonas Schievink
7fa9e39682
Rollup merge of #78422 - estebank:fix-78372, r=pnkfelix
Do not ICE on invalid input

Fix #78372.
2020-10-29 17:05:14 +01:00
Jonas Schievink
9867e54bea
Rollup merge of #78244 - workingjubilee:dogfood-fancy-ranges, r=varkor
Dogfood {exclusive,half-open} ranges in compiler (nfc)

In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.

No functional changes.
2020-10-29 17:05:11 +01:00
Dániel Buga
3fba948510 Fix typos 2020-10-29 16:51:46 +01:00
Esteban Küber
f9a26643ec Revert invalid fn return type parsing change
Fix #78507.
2020-10-29 08:26:42 -07:00
bors
49720d2b9a Auto merge of #78512 - JohnTitor:rollup-a7qwjah, r=JohnTitor
Rollup of 11 pull requests

Successful merges:

 - #77213 (rustdoc options to set default theme (and other settings))
 - #78224 (min_const_generics: allow ty param in repeat expr)
 - #78428 (MinConstGenerics UI test for invalid values for bool & char)
 - #78460 (Adjust turbofish help message for const generics)
 - #78470 (Clean up intra-doc links in `std::path`)
 - #78475 (fix a comment in validity check)
 - #78478 (Add const generics tests for supertraits + dyn traits.)
 - #78487 (Fix typo "compiltest")
 - #78491 (Inline NonZeroN::from(n))
 - #78492 (Update books)
 - #78494 (Fix typos)

Failed merges:

r? `@ghost`
2020-10-29 03:57:54 +00:00
Jubilee Young
0e88db7db4 Dogfood {exclusive,half-open} ranges in compiler (nfc)
In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.

No functional changes.
2020-10-28 20:09:20 -07:00
Yuki Okushi
30d1d8f5da
Rollup merge of #78494 - bugadani:typo2, r=jonas-schievink
Fix typos
2020-10-29 12:09:03 +09:00
Yuki Okushi
5e3cc6e913
Rollup merge of #78475 - RalfJung:validity-comment, r=oli-obk
fix a comment in validity check

A few things changed since that comment was written; update it to the current reality.

r? @oli-obk
2020-10-29 12:08:55 +09:00
Yuki Okushi
a7a0538802
Rollup merge of #78460 - varkor:turbofish-string-generic, r=lcnr
Adjust turbofish help message for const generics

Types are no longer special. (This message arguably only makes sense with `min_const_generics` or more, but we'll be there soon.)

r? @lcnr
2020-10-29 12:08:50 +09:00
Yuki Okushi
270d2e0c2e
Rollup merge of #78224 - lcnr:repeat-expr, r=varkor
min_const_generics: allow ty param in repeat expr

implements https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/repeat.20expressions

Even with `min_const_generics` active, now keeps resulting in future compat warnings instead of hard errors.
Const parameters, for example `[0; N + 1]`, still result in hard errors during resolve.
```rust
#![allow(dead_code)]

fn foo<T>() {
    [0; std::mem::size_of::<*mut T>()];
}

struct Foo<T>(T);

impl<T> Foo<T> {
    const ASSOC: usize = 4;

    fn test() {
        [0; Self::ASSOC];
    }
}
```

r? @varkor cc @petrochenkov
2020-10-29 12:08:40 +09:00
Wesley Wiser
1c1c591c81 [resolve] Use unwrap_or_else instead of unwrap_or in a hot path
This improves the performance of the `resolve_crate` function by 30% for
a very large single file crate with auto-generated C bindings.
2020-10-28 21:53:25 -04:00
bors
f9187adaef Auto merge of #78430 - Nadrieril:taking-constructors-seriously2, r=varkor
Clarify main code paths in exhaustiveness checking

This PR massively clarifies the main code paths of exhaustiveness checking, by using the `Constructor` enum to a fuller extent. I've been itching to write it for more than a year, but the complexity of matching consts had prevented me. Behold a massive simplification :D.
This in particular removes a fair amount of duplication between various parts, localizes code into methods of relevant types when applicable, makes some implicit assumptions explicit, and overall improves legibility a lot (or so I hope). Additionally, after my changes undoing #76918 turned out to be a noticeable perf gain.

As usual I tried my best to make the commits self-contained and easy to follow. I've also tried to keep the code well-commented, but I tend to forget how complex this file is; I'm happy to clarify things as needed.
My measurements show good perf improvements on the two match-heavy benchmarks (-18.0% on `unicode_normalization-check`! :D); I'd like a perf run to check the overall impact.

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking
2020-10-29 01:37:49 +00:00
Tomasz Miąsko
79cc5099b1 Use RwLock instead of Lock for SourceMap::files 2020-10-29 18:09:53 +01:00
Tomasz Miąsko
2661a4edb9 Avoid BorrowMutError with RUSTC_LOG=debug
$ touch empty.rs
$ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs

Fails with a `BorrowMutError` because source map files are already
borrowed while `features_query` attempts to format a log message
containing a span.

Release the borrow before the query to avoid the issue.
2020-10-29 18:09:53 +01:00
bors
31ee872db5 Auto merge of #78415 - tgnottingham:expn_id_tag_hash, r=Aaron1011
rustc_span: avoid hashing ExpnId tag when using cached hash
2020-10-28 20:03:55 +00:00
Nadrieril
41a74ace4a Apply suggestions from code review
Co-authored-by: Who? Me?! <mark-i-m@users.noreply.github.com>
Co-authored-by: varkor <github@varkor.com>
2020-10-28 19:08:01 +00:00
Dániel Buga
0fabbf9713 Fix typos 2020-10-28 19:32:28 +01:00
bors
3dddf6ac1e Auto merge of #78414 - nox:function-sections, r=nagisa,bjorn3
Implement -Z function-sections=yes|no

This lets rustc users tweak whether all functions should be put in their own TEXT section, using whatever default value the target defines if the flag is missing.

I'm having fun experimenting with musl libc and trying to implement the start symbol in Rust, that means avoiding code that requires relocations, and AFAIK putting everything in its own section makes the toolchain generate `GOTPCREL` relocations for symbols that could use plain old PC-relative addressing (at least on `x86_64`) if they were all in the same section.
2020-10-28 17:47:36 +00:00
varkor
a6d01da716 Remove irrelevant FIXME 2020-10-28 10:47:27 +00:00
varkor
6c73adf324 Adjust turbofish help message for const generics 2020-10-28 10:47:27 +00:00
Ralf Jung
c90ef979de fix a comment in validity check 2020-10-28 10:39:21 +01:00
bors
2eb4fc800a Auto merge of #78323 - est31:smaller_list_overlap, r=varkor
Iterate over the smaller list

If there are two lists of different sizes,
iterating over the smaller list and then
looking up in the larger list is cheaper
than vice versa, because lookups scale
sublinearly.
2020-10-28 03:58:32 +00:00
bors
db241bb0c8 Auto merge of #78458 - Dylan-DPC:rollup-tan044s, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #78152 (Separate unsized locals)
 - #78297 (Suggest calling await on method call and field access)
 - #78351 (Move "mutable thing in const" check from interning to validity)
 - #78365 (check object safety of generic constants)
 - #78379 (Tweak invalid `fn` header and body parsing)
 - #78391 (Add const_fn in generics test)
 - #78401 (resolve: private fields in tuple struct ctor diag)
 - #78408 (Remove tokens from foreign items in `TokenStripper`)
 - #78447 (Fix typo in  comment)
 - #78453 (Fix typo in comments)

Failed merges:

r? `@ghost`
2020-10-28 01:40:06 +00:00
Daniel Frampton
a3bff69134 Use unwrapDIPtr because the Scope may be passed as None 2020-10-27 18:05:16 -07:00
Dylan DPC
6967005e6e
Rollup merge of #78453 - Storyyeller:patch-1, r=jonas-schievink
Fix typo in comments
2020-10-28 01:21:39 +01:00
Dylan DPC
3349b6847f
Rollup merge of #78447 - bugadani:typo, r=matthewjasper
Fix typo in  comment

I hope I got all the typos in that word. :)
2020-10-28 01:21:37 +01:00
Dylan DPC
14b4ed20c7
Rollup merge of #78408 - Aaron1011:fix/remove-foreign-tokens, r=oli-obk
Remove tokens from foreign items in `TokenStripper`

Fixes #78398

I forgot to handle this case in #77255
2020-10-28 01:21:34 +01:00
Dylan DPC
c9279c845d
Rollup merge of #78401 - davidtwco:issue-75906-tuple-construct-private-field, r=estebank
resolve: private fields in tuple struct ctor diag

Fixes #75906.

This PR improves the diagnostic emitted when a tuple struct is being constructed which has private fields so that private fields are labelled and the message is improved.

r? @estebank
2020-10-28 01:21:31 +01:00
Dylan DPC
892ebe9afe
Rollup merge of #78379 - estebank:fn-signature-parse, r=varkor
Tweak invalid `fn` header and body parsing

* Rely on regular "expected"/"found" parser error for `fn`, fix #77115
* Recover empty `fn` bodies when encountering `}`
* Recover trailing `>` in return types
* Recover from non-type in array type `[<BAD TOKEN>; LEN]`
2020-10-28 01:21:24 +01:00
Dylan DPC
1a64e570c6
Rollup merge of #78365 - lcnr:const-eval-obj-safety, r=oli-obk
check object safety of generic constants

As `Self` can only be effectively used in constants with `const_evaluatable_checked` this should not matter outside of it.

Implements the first item of #72219

> Object safety interactions with constants

r? @oli-obk for now cc @nikomatsakis
2020-10-28 01:21:21 +01:00
Dylan DPC
54ea0f9ccd
Rollup merge of #78351 - RalfJung:validity-unsafe-cell, r=oli-obk
Move "mutable thing in const" check from interning to validity

This moves the check for mutable things (such as `UnsafeCell` or `&mut`) in a`const` from interning to validity. That means we can give more targeted error messages (pointing out *where* the problem lies), and we can simplify interning a bit.

Also fix the interning mode used for promoteds in statics.

r? @oli-obk
2020-10-28 01:21:18 +01:00
Dylan DPC
86a4a38177
Rollup merge of #78297 - estebank:match-semicolon-2, r=oli-obk
Suggest calling await on method call and field access

When encountering a failing method or field resolution on a `Future`,
look at the `Output` and try the same operation on it. If successful,
suggest calling `.await` on the `Future`.

This had already been introduced in #72784, but at some point they
stopped working.

Built on top of #78214, only last commit is relevant.

r? @oli-obk
2020-10-28 01:21:10 +01:00
Dylan DPC
346aeef496
Rollup merge of #78152 - spastorino:separate-unsized-locals, r=oli-obk
Separate unsized locals

Closes #71694

Takes over again #72029 and #74971

cc @RalfJung @oli-obk @pnkfelix @eddyb as they've participated in previous reviews of this PR.
2020-10-28 01:21:08 +01:00