Commit Graph

101660 Commits

Author SHA1 Message Date
Matthew Jasper
170718c93f Stabilize const_constructor 2019-10-27 21:25:35 +00:00
Nadrieril
09f9947ebc Gather together usefulness tests
I took most tests that were testing only for match exhaustiveness,
pattern refutability or match arm reachability, and put them in
the same test folder.
2019-10-27 21:20:26 +00:00
Adam Perry
86e55b1882 Always use consteval to codegen caller_location. 2019-10-27 12:51:55 -07:00
Adam Perry
017877cbbe Implementation of const caller_location. 2019-10-27 12:51:34 -07:00
Adam Perry
aec97e050e Panicking infra uses &core::panic::Location.
This allows us to remove `static_panic_msg` from the SSA<->LLVM
boundary, along with its fat pointer representation for &str.

Also changes the signature of PanicInfo::internal_contructor to
avoid copying.

Closes #65856.
2019-10-27 12:50:58 -07:00
Adam Perry
743964ad3f Implement core::intrinsics::caller_location.
Returns a `&core::panic::Location` corresponding to where it was
called, also making `Location` a lang item.
2019-10-27 12:50:52 -07:00
Esteban Küber
b26ddb8af3 Point at local similarly named element and tweak references to variants
Point at the span for the definition of ADTs internal to the current
crate.

Look at the leading char of the ident to determine whether we're
expecting a likely fn or any of a fn, a tuple struct or a tuple variant.

Turn fn `add_typo_suggestion` into a `Resolver` method.
2019-10-27 11:50:43 -07:00
Nadrieril
2665b6434e Clarify and fix the explanation of the algorithm
There was a bit of confusion between individual patterns and lists of
patterns, and index mismatches linked to that. This introduces a
vocabulary of "pattern-stacks" to provide a clearer mental model of what
is happening. This also adds examples.
2019-10-27 17:34:21 +00:00
Nadrieril
7986599417 Remove mention of old slice pattern syntax 2019-10-27 17:34:21 +00:00
Nadrieril
af35934fa5 tidy 2019-10-27 17:34:21 +00:00
Nadrieril
a5de5a604e Run rustfmt 2019-10-27 17:34:21 +00:00
Lzu Tao
3f980785fb doc: explain why it is unsafe to construct Vec<u8> from Vec<u16>
Co-authored-by: Steve Klabnik <steve@steveklabnik.com>
2019-10-27 17:31:01 +00:00
Igor Aleksanov
993b920032 librustc_lexer: Enhance documentation
Apply review suggestions

Apply review suggestions
2019-10-27 20:08:08 +03:00
bors
95f437b3cf Auto merge of #65869 - Centril:rollup-bzlo74f, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #65566 (Use heuristics to suggest assignment)
 - #65738 (Coherence should allow fundamental types to impl traits when they are local)
 - #65777 (Don't ICE for completely unexpandable `impl Trait` types)
 - #65834 (Remove lint callback from driver)
 - #65839 (Clean up `check_consts` now that new promotion pass is implemented)
 - #65855 (Add long error explaination for E0666)

Failed merges:

r? @ghost
2019-10-27 16:15:40 +00:00
Mazdak Farrokhzad
fb12c70852 rustc, rustc_passes: don't depend on syntax_expand.
This is done by moving some data definitions to syntax::expand.
2019-10-27 17:05:57 +01:00
Mazdak Farrokhzad
16329402bf syntax/attr: reduce reliance on parser 2019-10-27 16:54:12 +01:00
Mazdak Farrokhzad
b5b4f9b304
Rollup merge of #65855 - ObsidianMinor:extended_error/E0666, r=varkor
Add long error explaination for E0666

In the spirit of the month of spooks, here's a long explanation for E0666 for #61137.
2019-10-27 16:46:58 +01:00
Mazdak Farrokhzad
dae8ded9f5
Rollup merge of #65839 - ecstatic-morse:promo-sanity-fixes, r=eddyb
Clean up `check_consts` now that new promotion pass is implemented

`check_consts::resolver` contained a layer of abstraction (`QualifResolver`) to allow the existing, eager style of qualif propagation to work with either a dataflow results cursor or by applying the transfer function directly (if dataflow was not needed e.g. for promotion). However, #63812 uses a different, lazy paradigm for checking promotability, which makes this unnecessary. This PR cleans up `check_consts::validation` to use `FlowSensitiveResolver` directly, instead of through the now obselete `QualifResolver` API.

Also, this contains a few commits (the first four) that address some FIXMEs in #63812 regarding code duplication. They could be split out, but I think they will be relatively noncontroversial? Notably, `validation::Mode` is renamed to `ConstKind` and used in `promote_consts` to denote what kind of item we are in.

This is best reviewed commit-by-commit and is low priority.

r? @eddyb
2019-10-27 16:46:56 +01:00
Mazdak Farrokhzad
0982060a69
Rollup merge of #65834 - Mark-Simulacrum:driver-clean, r=nikomatsakis
Remove lint callback from driver

This is leftover from a restructuring of lint registration for drivers; it should now happen via the register_lints field on Config rather than this function.

This is not used by anyone to my knowledge (including the compiler itself); it was introduced in an abandoned refactor in #65193.
2019-10-27 16:46:55 +01:00
Mazdak Farrokhzad
5406f7ad49
Rollup merge of #65777 - matthewjasper:allow-impl-trait-expansion, r=davidtwco
Don't ICE for completely unexpandable `impl Trait` types

Save the resolution of these types (to themselves) to the typeck tables so that they will eventually reach E0720.

closes #65561
2019-10-27 16:46:54 +01:00
Mazdak Farrokhzad
53568f3fb3
Rollup merge of #65738 - ohadravid:re-rebalance-coherence-allow-fundamental-local, r=nikomatsakis
Coherence should allow fundamental types to impl traits when they are local

After #64414, `impl<T> Remote for Box<T> { }` is disallowed, but it is also disallowed in liballoc, where `Box` is a local type!

Enabling `#![feature(re_rebalance_coherence)]` in `liballoc` results in:
```
error[E0210]: type parameter `F` must be used as the type parameter for some local type (e.g., `MyStruct<F>`)
    --> src\liballoc\boxed.rs:1098:1
     |
1098 | impl<F: ?Sized + Future + Unpin> Future for Box<F> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `F` must be used as the type parameter for some local type
```

This PR relaxes `uncover_fundamental_ty` to skip local fundamental types.
I didn't add a test since `liballoc` already fails to compile, but I can add one if needed.

r? @nikomatsakis

cc #63599
2019-10-27 16:46:52 +01:00
Mazdak Farrokhzad
a466f014b5
Rollup merge of #65566 - estebank:let-expr-as-ty, r=Centril
Use heuristics to suggest assignment

When detecting a possible `=` -> `:` typo in a `let` binding, suggest
assigning instead of setting the type.

Partially address #57828.
2019-10-27 16:46:51 +01:00
bors
0f677c65e8 Auto merge of #65541 - eddyb:spanned-inferred-outlives, r=nikomatsakis
rustc: add `Span`s to `inferred_outlives_of` predicates.

This would simplify #59789, and I suspect it has some potential in diagnostics (although we don't seem to use the predicate `Span`s much atm).
2019-10-27 12:58:10 +00:00
Guillaume Gomez
91ef9600db reduce size of generated HTML files by moving the popup helper code to the JS 2019-10-27 11:42:38 +01:00
Guillaume Gomez
1d2808341a Cleanup search element getter 2019-10-27 11:40:47 +01:00
bors
b7176b44a2 Auto merge of #65519 - pnkfelix:issue-63438-trait-based-structural-match, r=matthewjasper
trait-based structural match implementation

Moves from using a `#[structural_match]` attribute to using a marker trait (or pair of such traits, really) instead.

Fix #63438.

(This however does not remove the hacks that I believe were put into place to support the previous approach of injecting the attribute based on the presence of both derives... I have left that for follow-on work.)
2019-10-27 09:35:12 +00:00
AnthonyMikh
159d8a4154 Remove a loop which runs exactly once 2019-10-27 12:02:34 +03:00
bors
cf148a717a Auto merge of #65288 - estebank:point-at-assoc-type, r=nikomatsakis
Point at associated type for some obligations

Partially address #57663.
2019-10-27 03:34:54 +00:00
ObsidianMinor
16547f5025
Update with word change suggestion
Co-Authored-By: varkor <github@varkor.com>
2019-10-26 18:42:31 -05:00
bors
fcf516d827 Auto merge of #65852 - flip1995:clippyup, r=Manishearth
Update Clippy

Fixes https://github.com/rust-lang/rust/pull/65845#issuecomment-546633123

r? @Manishearth
2019-10-26 23:37:08 +00:00
Sydney Acksman
4b2b23cc07 Add detailed explaination for E0666 2019-10-26 17:44:23 -05:00
Esteban Küber
b579c5a2d6 Fix rebase 2019-10-26 15:34:28 -07:00
Esteban Küber
7ea28e761f review comment: use Default 2019-10-26 15:26:08 -07:00
Esteban Küber
93bb780e38 review comments and tweaks 2019-10-26 15:26:08 -07:00
Esteban Küber
55e4e2d52e Remove unnecessary error in test 2019-10-26 15:26:08 -07:00
Esteban Küber
6206a5a1b4 Use heuristics to suggest assignment
When detecting a possible `=` -> `:` typo in a `let` binding, suggest
assigning instead of setting the type.
2019-10-26 15:26:08 -07:00
roblabla
1099826efa Only run efiapi test on llvm 9.0+ 2019-10-26 21:05:13 +00:00
flip1995
e85980ddfa
Update Clippy 2019-10-26 23:02:23 +02:00
Michael Hewson
fb4095df94
Update comments re type parameter hack in object safety
To check if a method's receiver type is object safe, we create a new receiver type by substituting in a bogus type parameter (let's call it `U`) for `Self`, and checking that the unmodified receiver type implements `DispatchFromDyn<receiver type with Self = U>`. It would be better to use `dyn Trait` directly, and the only reason we don't is because it triggers another check that `Trait` is object safe, resulting in a query cycle. Once the feature `object_safe_for_dispatch` (tracking issue https://github.com/rust-lang/rust/issues/43561) is stabilized, this will no longer be the case, and we'll be able to use `dyn Trait` as the unsized `Self` type. I've updated the comments in object_safety.rs accordingly.
2019-10-26 16:44:06 -04:00
bors
fae75cd216 Auto merge of #65167 - hermitcore:rusty-hermit, r=alexcrichton
Redesign the interface to the unikernel HermitCore

We are developing the unikernel HermitCore, where the kernel is written in Rust and is already part of the Rust Standard Library. The interface between the standard library and the kernel based on a small C library. With this pull request, we remove completely the dependency to C and use lld as linker. Currently, the kernel will be linked to the application as static library, which is published at https://github.com/hermitcore/libhermit-rs.

We don’t longer support the C interface to the kernel. Consequently, we remove this part from the Rust Standard Library.
2019-10-26 19:35:59 +00:00
bors
46e6c533d0 Auto merge of #65845 - Centril:rollup-28jtjfc, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #65743 (rustc_typeck: don't record direct callees in generator_interior.)
 - #65761 (libsyntax: Enhance documentation of the AST module)
 - #65772 (Remove the last remaining READMEs)
 - #65773 (Increase spacing for suggestions in diagnostics)
 - #65791 (Adding doc on keyword continue)
 - #65824 (rustc: make DefPathData (and friends) Copy (now that it uses Symbol).)
 - #65828 (Derive Eq and Hash for SourceInfo again)
 - #65842 (Add more information on rustdoc search)

Failed merges:

 - #65825 (rustc: use IndexVec<DefIndex, T> instead of Vec<T>.)

r? @ghost
2019-10-26 16:14:16 +00:00
Mazdak Farrokhzad
d319ba2ccc
Rollup merge of #65842 - GuillaumeGomez:more-search-information, r=Dylan-DPC
Add more information on rustdoc search

Fixes #65735.

r? @kinnison
2019-10-26 14:17:51 +02:00
Mazdak Farrokhzad
d0d284eb39
Rollup merge of #65828 - bjorn3:add_source_info_eq_hash, r=petrochenkov
Derive Eq and Hash for SourceInfo again

In 75c24b9c96/src/common.rs (L368) I store it in a `indexmap::IndexSet`, which requires `Eq` and `Hash`. Unfortunately they were removed in https://github.com/rust-lang/rust/pull/65647, so I can't update to latest nightly.
2019-10-26 14:17:50 +02:00
Mazdak Farrokhzad
84b62a08b9
Rollup merge of #65824 - eddyb:def-key-copy, r=varkor
rustc: make DefPathData (and friends) Copy (now that it uses Symbol).

Spotted this while working on something else.
2019-10-26 14:17:48 +02:00
Mazdak Farrokhzad
7325a886e2
Rollup merge of #65791 - dorfsmay:doc_keyword_continue, r=Mark-Simulacrum
Adding doc on keyword continue

Partial solution of issue #34601.
2019-10-26 14:17:46 +02:00
Mazdak Farrokhzad
0aa7c6f96b
Rollup merge of #65773 - estebank:sugg-whitespace, r=Centril
Increase spacing for suggestions in diagnostics

Make the spacing between the code snippet and verbose structured
suggestions consistent with note and help messages.

r? @Centril
2019-10-26 14:17:45 +02:00
Mazdak Farrokhzad
78a4f8c8ce
Rollup merge of #65772 - mark-i-m:final-readmes, r=nikomatsakis
Remove the last remaining READMEs

cc https://github.com/rust-lang/rustc-guide/pull/481

closes #48478

r? @nikomatsakis
2019-10-26 14:17:43 +02:00
Mazdak Farrokhzad
d51a84259e
Rollup merge of #65761 - popzxc:document-ast, r=petrochenkov
libsyntax: Enhance documentation of the AST module

This PR enhances documentation state to the `libsyntax/ast.rs` (as initiative caused by [rustc-guide#474](https://github.com/rust-lang/rustc-guide/issues/474)), by adding:
- Module documentation.
- Doc-comments (and a bit of usual comments) in non-obvious (as for me) places.
- Minor style fixes to improve module readability.
2019-10-26 14:17:42 +02:00
Mazdak Farrokhzad
4f43352964
Rollup merge of #65743 - eddyb:generator-on-call, r=matthewjasper
rustc_typeck: don't record direct callees in generator_interior.

For expressions like `f(g().await)` we were recording `f` as needing to be kept in a temporary (and therefore be tracked by the generator type) across the suspend, even if a function/method path.
However, this is never needed, and can cause issues with complex function types (see #65244).

cc @Zoxc @nikomatsakis
2019-10-26 14:17:40 +02:00
Ohad Ravid
8f988bd92c Coherence should allow fundamental types to impl traits 2019-10-26 13:08:50 +02:00