Commit Graph

107279 Commits

Author SHA1 Message Date
Dylan MacKenzie
323ff193b8 Add tests for calling trait methods on concrete types 2020-02-18 21:03:28 -08:00
Dylan MacKenzie
7a019b1bd2 Check for trait methods on concrete types in const checking 2020-02-18 21:03:28 -08:00
Dylan MacKenzie
5e422efba1 Remove "not yet implemented" warning 2020-02-18 21:03:28 -08:00
bors
3a8108d8e5 Auto merge of #69113 - ecstatic-morse:unified-dataflow-borrowed, r=wesleywiser
Combine `HaveBeenBorrowedLocals` and `IndirectlyMutableLocals` into one dataflow analysis

This PR began as an attempt to port `HaveBeenBorrowedLocals` to the new dataflow framework (see #68241 for prior art). Along the way, I noticed that it could share most of its code with `IndirectlyMutableLocals` and then found a few bugs in the two analyses:
- Neither one marked locals as borrowed after an `Rvalue::AddressOf`.
- `IndirectlyMutableLocals` was missing a minor fix that `HaveBeenBorrowedLocals` got in #61069. This is not a problem today since it is only used during const-checking, where custom drop glue is forbidden. However, this may change some day.

I decided to combine the two analyses so that they wouldn't diverge in the future while ensuring that they remain distinct types (called `MaybeBorrowedLocals` and `MaybeMutBorrowedLocals` to be consistent with the `Maybe{Un,}InitializedPlaces` naming scheme). I fixed the bugs and switched to exhaustive matching where possible to make them less likely in the future. Finally, I added comments explaining some of the finer points of the transfer function for these analyses (see #61069 and #65006).
2020-02-19 04:57:10 +00:00
Dylan MacKenzie
3e0b0605a0 Const-check functions in a const impl 2020-02-18 19:27:58 -08:00
Dylan MacKenzie
62ff11f1a4 Add is_const_impl_raw query 2020-02-18 19:27:58 -08:00
Matthias Krüger
076cd9eabd submodules: update clippy from b91ae16e to 2855b214
Changes:
````
Rustup to rust-lang/rust#69194
Rustup to rust-lang/rust#69181
Add `LOG2_10` and `LOG10_2` to `approx_const` lint
Clean up imports
Use `Vec::with_capacity()` as possible
needless_doctest_main: False positive for async fn
Remove use of `TyKind`.
Use `if_chain`.
Fix ICE.
Add tests and improve checks.
Add `Future` detection for `missing_errors_doc`.
````

Fixes #69269
2020-02-19 03:46:10 +01:00
bors
a2fb0c28be Auto merge of #69241 - shahn:checked_add_revert, r=Mark-Simulacrum,lqd
Revert "Remove `checked_add` in `Layout::repeat`"

This fixes a a segfault in safe code, a stable regression. Reported in #69225.

This reverts commit a983e0590a.
2020-02-19 01:36:31 +00:00
Sebastian Hahn
3e17d191fa Revert "Remove checked_add in Layout::repeat"
This fixes a a segfault in safe code, a stable regression. Reported in
\#69225.

This reverts commit a983e0590a.

Also adds a test for the expected behaviour.
2020-02-18 23:57:48 +01:00
bors
e0e5d82e16 Auto merge of #69271 - Centril:rollup-iupsol6, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #69146 (Always const qualify literals by type)
 - #69159 (Select an appropriate unused lifetime name in suggestion)
 - #69194 (parse: fuse associated and extern items up to defaultness)
 - #69211 (parser: Simplify treatment of macro variables in `Parser::bump`)
 - #69217 (Do not emit note suggesting to implement operation trait to foreign type)
 - #69236 (parse: recover `mut (x @ y)` as `(mut x @ mut y)`.)

Failed merges:

r? @ghost
2020-02-18 22:29:06 +00:00
Ralf Jung
5e19350a4c better lint names 2020-02-18 22:49:47 +01:00
John Kåre Alsaker
437f56edf4 Fix race condition when allocating source files in SourceMap 2020-02-18 22:29:23 +01:00
Mazdak Farrokhzad
6c6d45c6e7
Rollup merge of #69236 - Centril:mut-parens-at-recovery, r=estebank
parse: recover `mut (x @ y)` as `(mut x @ mut y)`.

Follow up to https://github.com/rust-lang/rust/pull/68992#discussion_r376829749 and https://github.com/rust-lang/rust/pull/63945.

Specifically, when given `let mut (x @ y)` we recover with `let (mut x @ mut y)` as the suggestion:

```rust
error: `mut` must be attached to each individual binding
  --> $DIR/mut-patterns.rs:12:9
   |
LL |     let mut (x @ y) = 0;
   |         ^^^^^^^^^^^ help: add `mut` to each binding: `(mut x @ mut y)`
   |
   = note: `mut` may be followed by `variable` and `variable @ pattern`
```

r? @matthewjasper @estebank
2020-02-18 22:16:31 +01:00
Mazdak Farrokhzad
c499570b5d
Rollup merge of #69217 - LeSeulArtichaut:remove-lint-impl-op, r=estebank
Do not emit note suggesting to implement operation trait to foreign type

When a binary operation isn't valid, you will get a lint proposing to add a trait implementation to make the operation possible. However, this cannot be done for foreign types, such as types from `core` or `std`.

For example:
```
= note: an implementation of `std::ops::Add` might be missing for `std::option::Option<i8>`
```
As mentioned in https://github.com/rust-lang/rust/issues/60497#issuecomment-562665539:
> The note suggesting implementing Add<i8> should only be emitted if Option<i8> were local to the current crate, which it isn't, so in this case it shouldn't be emitted.

(I will use the CI to check tests for me, or my computer will just burn... and running IDEs is not possible on a pile of ashes)

r? @estebank
2020-02-18 22:16:29 +01:00
Mazdak Farrokhzad
1cf0194b46
Rollup merge of #69211 - petrochenkov:prevtok, r=Centril
parser: Simplify treatment of macro variables in `Parser::bump`

Follow-up to https://github.com/rust-lang/rust/pull/69006.

Token normalization for `$ident` and `$lifetime` is merged directly into `bump`.
Special "unknown macro variable" diagnostic for unexpected `$`s is removed as preventing legal code from compiling (as a result `bump` also doesn't call itself recursively anymore and can't make `prev_token` inconsistent).

r? @Centril
2020-02-18 22:16:28 +01:00
Mazdak Farrokhzad
b864d23f34
Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkov
parse: fuse associated and extern items up to defaultness

Language changes:

- The grammar of extern `type` aliases is unified with associated ones, and becomes:
  ```rust
  TypeItem = "type" ident generics {":" bounds}? where_clause {"=" type}? ";" ;
  ```

  Semantic restrictions (`ast_validation`) are added to forbid any parameters in `generics`, any bounds in `bounds`, and any predicates in `where_clause`, as well as the presence of a type expression (`= u8`).

  (Work still remains to fuse this with free `type` aliases, but this can be done later.)

- The grammar of constants and static items (free, associated, and extern) now permits the absence of an expression, and becomes:

  ```rust
  GlobalItem = {"const" {ident | "_"} | "static" "mut"? ident} {"=" expr}? ";" ;
  ```

  - A semantic restriction is added to enforce the presence of the expression (the body).
  - A semantic restriction is added to reject `const _` in associated contexts.

Together, these changes allow us to fuse the grammar of associated items and extern items up to `default`ness which is the main goal of the PR.

-----------------------

We are now very close to fully fusing the entirely of item parsing and their ASTs. To progress further, we must make a decision: should we parse e.g. `default use foo::bar;` and whatnot? Accepting that is likely easiest from a parsing perspective, as it does not require using look-ahead, but it is perhaps not too onerous to only accept it for `fn`s (and all their various qualifiers), `const`s, `static`s, and `type`s.

r? @petrochenkov
2020-02-18 22:16:26 +01:00
Mazdak Farrokhzad
981acd9035
Rollup merge of #69159 - estebank:use-appropriate-lt-name, r=ecstatic-morse
Select an appropriate unused lifetime name in suggestion

Follow up to #69048.
2020-02-18 22:16:24 +01:00
Mazdak Farrokhzad
5e2a095ba0
Rollup merge of #69146 - matthewjasper:literal-qualif, r=eddyb
Always const qualify literals by type

r? @eddyb
2020-02-18 22:16:23 +01:00
bors
e620d0f337 Auto merge of #69262 - Dylan-DPC:rollup-m6dt9cn, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #69181 (Change const eval to just return the value )
 - #69192 (Add more regression tests)
 - #69200 (Fix printing of `Yield` terminator)
 - #69205 (Allow whitespaces in revision flags)
 - #69233 (Clean up E0310 explanation)

Failed merges:

r? @ghost
2020-02-18 17:51:29 +00:00
Eric Huss
597b4f743e Update cargo 2020-02-18 09:21:34 -08:00
Dylan DPC
210b18118e
Rollup merge of #69233 - GuillaumeGomez:cleanup-e0310, r=Dylan-DPC
Clean up E0310 explanation

r? @Dylan-DPC
2020-02-18 16:07:29 +01:00
Dylan DPC
bea18c7673
Rollup merge of #69205 - JohnTitor:allow-whitespaces, r=Mark-Simulacrum
Allow whitespaces in revision flags

Allow whitespaces in revision flags, like `// [foo]`.

Fixes #69183
2020-02-18 16:07:27 +01:00
Dylan DPC
8b93e67c32
Rollup merge of #69200 - jonas-schievink:yield-print, r=eddyb,Zoxc
Fix printing of `Yield` terminator

Addresses the bug found in https://github.com/rust-lang/rust/issues/69039#issuecomment-586633495
2020-02-18 16:07:25 +01:00
Dylan DPC
d1f175b2ad
Rollup merge of #69192 - JohnTitor:add-tests, r=Centril
Add more regression tests

Closes #39618
Closes #51798
Closes #62894
Closes #63952
Closes #68653

r? @Centril
2020-02-18 16:07:24 +01:00
Dylan DPC
391e7e26ae
Rollup merge of #69181 - skinny121:const-eval-return, r=oli-obk
Change const eval to just return the value

As discussed in https://github.com/rust-lang/rust/pull/68505#discussion_r370956535, the type of consts shouldn't be returned from const eval queries.

r? @eddyb
cc @nikomatsakis
2020-02-18 16:07:22 +01:00
bors
b0d5813fd7 Auto merge of #69234 - JohnTitor:clippy-up, r=JohnTitor
Update Clippy

Fixes #69221

r? @ghost
2020-02-18 14:49:28 +00:00
Guillaume Gomez
73283f1b32 Clean up E0310 explanation 2020-02-18 13:07:49 +01:00
bors
6317721cd9 Auto merge of #69258 - JohnTitor:rollup-n2hljai, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #67272 (recursion_limit parsing handles overflows)
 - #68597 (Simplify `Skip::nth` and `Skip::last` implementations)
 - #68767 (macOS: avoid calling pthread_self() twice)
 - #69175 (Do not ICE when encountering `yield` inside `async` block)
 - #69223 (Ignore GDB versions with broken str printing.)
 - #69244 (configure: set LLVM flags with a value)
 - #69249 (Stabilize {f32, f64}::{LOG2_10, LOG10_2})
 - #69252 (Clean out unused directories for extra disk space)

Failed merges:

r? @ghost
2020-02-18 11:10:51 +00:00
Yuki Okushi
c1a05fbf00
Rollup merge of #69252 - Mark-Simulacrum:disk-try, r=pietroalbini
Clean out unused directories for extra disk space

This cleans out some of the unused (but large) directories on our linux builders to hopefully allow them to complete without running out of disk space.
2020-02-18 20:09:11 +09:00
Yuki Okushi
20c483506a
Rollup merge of #69249 - LeSeulArtichaut:stabilize-logs-consts, r=sfackler
Stabilize {f32, f64}::{LOG2_10, LOG10_2}

Following the decision to stabilize `LOG2_10` and `LOG10_2` in https://github.com/rust-lang/rust/issues/50540#issuecomment-536627588.

Closes #50540.
r? @sfackler
2020-02-18 20:09:09 +09:00
Yuki Okushi
6528b9f887
Rollup merge of #69244 - cuviper:llvm-flags, r=Mark-Simulacrum
configure: set LLVM flags with a value

Rather than a boolean `--enable-cflags` etc., these options should
reflect that they are for LLVM, and that they need a value. You would
now use `./configure --llvm-cflags="..."`.
2020-02-18 20:09:08 +09:00
Yuki Okushi
8b34f72b4f
Rollup merge of #69223 - spunit262:empty-string-gdb-version, r=Dylan-DPC
Ignore GDB versions with broken str printing.

https://sourceware.org/bugzilla/show_bug.cgi?id=22236
2020-02-18 20:09:06 +09:00
Yuki Okushi
35e7c783a2
Rollup merge of #69175 - estebank:shall-not-ice, r=petrochenkov
Do not ICE when encountering `yield` inside `async` block

Fix #67158.
2020-02-18 20:09:05 +09:00
Yuki Okushi
284acafe61
Rollup merge of #68767 - kubo39:patch-macos, r=shepmaster
macOS: avoid calling pthread_self() twice
2020-02-18 20:09:04 +09:00
Yuki Okushi
ae81241eae
Rollup merge of #68597 - ollie27:skip_nth_last, r=Amanieu
Simplify `Skip::nth` and `Skip::last` implementations

The main improvement is to make `last` no longer recursive.
2020-02-18 20:09:02 +09:00
Yuki Okushi
6c4f8598b9
Rollup merge of #67272 - fisherdarling:master, r=varkor,hellow554
recursion_limit parsing handles overflows

This PR adds overflow handling to `#![recursion_limit]` attribute parsing. If parsing the given value results in an `IntErrorKind::Overflow`, then the recursion_limit is set to `usize::max_value()`.

closes #67265
2020-02-18 20:08:59 +09:00
Mark Rousskov
c992ab23fa
Clean out some default-installed directories
This helps us have enough disk space for our builders to be able to complete
successfully. For now, the choices are ad-hoc and 'definitely not needed'. This
should never fail the build, as everything our build needs should be inside
Docker.
2020-02-18 11:34:59 +01:00
Nicholas Nethercote
e761f3af90 Inline various simple emit_* and read_* methods in Decoder.
Mostly, these are the ones whose body just contains `f(self)`.
2020-02-18 16:46:50 +11:00
Nicholas Nethercote
c02d689a62 Inline Symbol::decode and Interner::intern. 2020-02-18 16:07:25 +11:00
Nicholas Nethercote
ab906179cc Always inline run_utf8_validation.
It only has two call sites, and the one within `from_utf8` is hot within
rustc itself.
2020-02-18 15:42:11 +11:00
Jonas Schievink
27cfb2b9c2 Fix typo 2020-02-18 00:00:06 +01:00
Dylan MacKenzie
077a93c6a9 Fix typo in comment 2020-02-17 13:43:13 -08:00
Dylan MacKenzie
9d423950cc Use doc comment for explanation of shared_borrow_allows_mutation 2020-02-17 13:39:50 -08:00
Jonas Schievink
c9b87ac4b3 Don't eliminate frame pointers on thumb targets 2020-02-17 21:46:26 +01:00
Vadim Petrochenkov
950845c5b1 Add a test for proc macro generating $ IDENT 2020-02-17 22:47:59 +03:00
Vadim Petrochenkov
06fbb0b4fa parser: Remove Options from unnormalized tokens
They are always set synchronously with normalized tokens now
2020-02-17 22:12:39 +03:00
Vadim Petrochenkov
ed2fd28d38 parser: Set previous and unnormalized tokens in couple more places 2020-02-17 22:12:39 +03:00
Vadim Petrochenkov
d33b3562e5 parser: Do not call bump recursively
Token normalization is merged directly into `bump`.
Special "unknown macro variable" diagnostic for unexpected `$`s is removed as preventing legal code from compiling.
2020-02-17 22:12:39 +03:00
Josh Stone
3a55e8875e configure: set LLVM flags with a value
Rather than a boolean `--enable-cflags` etc., these options should
reflect that they are for LLVM, and that they need a value. You would
now use `./configure --llvm-cflags="..."`.
2020-02-17 11:01:52 -08:00
Camille GILLOT
6e15faf68a Querify object_safety_violations. 2020-02-17 19:48:36 +01:00