Commit Graph

132144 Commits

Author SHA1 Message Date
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
Santiago Pastorino
cc9ab1cd58
Merge unsized locals pat tests 2020-10-27 14:45:42 -03:00
Santiago Pastorino
00fd703eb7
Use unsized_feature_enabled helper function 2020-10-27 14:45:42 -03:00
Santiago Pastorino
9584b00b1d
is -> are both 2020-10-27 14:45:41 -03:00
Santiago Pastorino
4760338ad2
Bless tests again 2020-10-27 14:45:41 -03:00
Santiago Pastorino
89eac50a87
Hide outermost_fn_param_pat, it's an internal detail 2020-10-27 14:45:40 -03:00
Santiago Pastorino
f0fe0a6eba
or -> and 2020-10-27 14:45:40 -03:00
Santiago Pastorino
8b8b6392ba
Add comment explaining why in these tests unsized locals are not accepted 2020-10-27 14:45:40 -03:00
Santiago Pastorino
497ee0e1ff
param -> parameter, pat -> pattern 2020-10-27 14:45:39 -03:00
Santiago Pastorino
bdd1b85f95
Rename within_fn_param to outermost_fn_param_pat 2020-10-27 14:45:39 -03:00
Santiago Pastorino
ca41681bf0
Do not use unsized_fn_params in patterns 2020-10-27 14:45:38 -03:00
Santiago Pastorino
58018d438b
Properly restore within_fn_param value to the previous state 2020-10-27 14:45:38 -03:00
Santiago Pastorino
a3470b13ab
Test that unsized locals fail when turning unsized_fn_params feature flag on 2020-10-27 14:45:37 -03:00
Santiago Pastorino
f0a71f7f4d
Better test unsized_fn_params 2020-10-27 14:45:37 -03:00
Santiago Pastorino
70b8c79a96
Bless issue-53448 test 2020-10-27 14:45:36 -03:00
Santiago Pastorino
2040b790e8
unsized_locals feature is not needed in this test 2020-10-27 14:45:36 -03:00
Santiago Pastorino
ba59aa2b77
Do not depend on except for bootstrap 2020-10-27 14:45:36 -03:00
Santiago Pastorino
1b7d0b22c0
Fix unstable-book doc tests 2020-10-27 14:45:35 -03:00
Santiago Pastorino
d57d3f300a
Using unsized_local feature is not needed in these tests 2020-10-27 14:45:35 -03:00
Santiago Pastorino
e049ba0808
Make tidy happy 2020-10-27 14:45:34 -03:00
Santiago Pastorino
072e230b1b
This flag is not really needed in the test 2020-10-27 14:45:33 -03:00
Santiago Pastorino
953d7a64a5
Add unsized_locals to INCOMPLETE_FEATURES list 2020-10-27 14:45:28 -03:00
Santiago Pastorino
708fc3b1a2
Add unsized_fn_params feature 2020-10-27 14:45:02 -03:00
bors
07e968b640 Auto merge of #76269 - ayrtonm:function-reference-lint, r=oli-obk
added a lint against function references

this lint suggests casting function references to `*const ()`
closes #75239
r? `@RalfJung`
2020-10-27 16:32:23 +00:00
Ayrton
c791c64e84 Added suggestion to function_item_references lint and fixed warning message
Also updated tests accordingly and tweaked some wording in the lint declaration.
2020-10-27 11:04:04 -04:00
Ayrton
935fc3642a Added documentation for function_item_references lint
Added documentation for `function_item_references` lint to the rustc book and
fixed comments in the lint checker itself.
2020-10-27 11:04:04 -04:00
Ayrton
d6fa7e15d6 Fixed compiler error in lint checker triggered by associated types
When a function argument bound by `Pointer` is an associated type, we only
perform substitutions using the parameters from the callsite but don't attempt
to normalize since it may not succeed. A simplified version of the scenario that
triggered this error was added as a test case. Also fixed `Pointer::fmt` which
was being double-counted when called outside of macros and added a test case for
this.
2020-10-27 11:04:04 -04:00
Ayrton
432ebd57ef Removed test for unhandled case in function_item_references lint
Removed test for the unhandled case of calls to `fn f<T>(x: &T)` where `x` is a
function reference and is formatted as a pointer in `f`. This compiles since
`&T` implements `Pointer`, but is unlikely to occur in practice. Also tweaked
the lint's wording and modified tests accordingly.
2020-10-27 11:04:04 -04:00
Ayrton
511fe048b4 Changed lint to check for std::fmt::Pointer and transmute
The lint checks arguments in calls to `transmute` or functions that have
`Pointer` as a trait bound and displays a warning if the argument is a function
reference. Also checks for `std::fmt::Pointer::fmt` to handle formatting macros
although it doesn't depend on the exact expansion of the macro or formatting
internals. `std::fmt::Pointer` and `std::fmt::Pointer::fmt` were also added as
diagnostic items and symbols.
2020-10-27 11:04:04 -04:00
Ayrton
3214de7359 modified lint to work with MIR
Working with MIR let's us exclude expressions like `&fn_name as &dyn Something`
and `(&fn_name)()`. Also added ABI, unsafety and whether a function is variadic
in the lint suggestion, included the `&` in the span of the lint and updated the
test.
2020-10-27 11:04:04 -04:00
Ayrton
975547d475 changed lint to suggest casting to the proper function type and added a test 2020-10-27 11:04:03 -04:00
Ayrton
dd4d4e29c3 added a lint against function references
this lint suggests casting function references to `*const ()`
2020-10-27 11:04:03 -04:00
bors
2a71e45411 Auto merge of #78434 - jonas-schievink:disable-miropt, r=wesleywiser
Disable "optimization to avoid load of address" in InstCombine

Same as #78195, fixes https://github.com/rust-lang/rust/issues/78192 (again).
2020-10-27 13:57:54 +00:00
bors
56d288fa46 Auto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-se
Capture output from threads spawned in tests

This is revival of #75172.

Original text:
> Fixes #42474.
>
> r? `@​dtolnay` since you expressed interest in this, but feel free to redirect if you aren't the right person anymore.

---

Closes #75172.
2020-10-27 11:43:18 +00:00
Jonas Schievink
0be35cf9c7 Disable "optimization to avoid load of address" in InstCombine 2020-10-27 10:59:28 +01:00
bors
20b1e05a8d Auto merge of #77502 - varkor:const-generics-suggest-enclosing-braces, r=petrochenkov
Suggest that expressions that look like const generic arguments should be enclosed in brackets

I pulled out the changes for const expressions from https://github.com/rust-lang/rust/pull/71592 (without the trait object diagnostic changes) and made some small changes; the implementation is `@estebank's.`

We're also going to want to make some changes separately to account for trait objects (they result in poor diagnostics, as is evident from one of the test cases here), such as an adaption of https://github.com/rust-lang/rust/pull/72273.

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

r? `@petrochenkov`
2020-10-27 09:25:54 +00:00
bors
824f900a96 Auto merge of #77317 - varkor:break-diverging-value, r=nikomatsakis
Fix control flow check for breaking with diverging values

Fixes https://github.com/rust-lang/rust/issues/77156.
2020-10-27 07:10:55 +00:00
bors
c9b606ed67 Auto merge of #78359 - ssomers:btree_cleanup_mem, r=Mark-Simulacrum
BTreeMap: move generic support functions out of navigate.rs

A preparatory step chipped off #78104, useful in general (if at all).

r? `@Mark-Simulacrum`
2020-10-27 04:01:52 +00:00
bors
28f03ac4c0 Auto merge of #78421 - JohnTitor:rollup-bq2d7fo, r=JohnTitor
Rollup of 16 pull requests

Successful merges:

 - #76635 (Add [T]::as_chunks(_mut))
 - #77703 (add system-llvm-libunwind config option)
 - #78219 (Prefer to use `print_def_path`)
 - #78298 (Add test for bad NLL higher-ranked subtype)
 - #78332 (Update description for error E0308)
 - #78342 (Use check-pass in single-use-lifetime ui tests)
 - #78347 (Add lexicographical comparison doc)
 - #78348 (Make some functions private that don't have to be public)
 - #78349 (Use its own `TypeckResults` to avoid ICE)
 - #78375 (Use ? in core/std macros)
 - #78377 (Fix typo in debug statement)
 - #78388 (Add some regression tests)
 - #78394 (fix(docs): typo in BufWriter documentation)
 - #78396 (Add compiler support for LLVM's x86_64 ERMSB feature)
 - #78405 (Fix typo in lint description)
 - #78412 (Improve formatting of hash collections docs)

Failed merges:

r? `@ghost`
2020-10-27 01:36:12 +00:00
Yuki Okushi
4236d27c9b
Rollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink
Improve formatting of hash collections docs
2020-10-27 08:45:30 +09:00
Yuki Okushi
7824d9abbd
Rollup merge of #78405 - notriddle:patch-3, r=lcnr
Fix typo in lint description
2020-10-27 08:45:27 +09:00
Yuki Okushi
46b8e46fe1
Rollup merge of #78396 - josephlr:ermsb, r=petrochenkov
Add compiler support for LLVM's x86_64 ERMSB feature

This change is needed for compiler-builtins to check for this feature
when implementing memcpy/memset. See:
  https://github.com/rust-lang/compiler-builtins/pull/365

Without this change, the following code compiles, but does nothing:
```rust
#[cfg(target_feature = "ermsb")]
pub unsafe fn ermsb_memcpy() { ... }
```

The change just does compile-time detection. I think that runtime
detection will have to come in a follow-up CL to std-detect.

Like all the CPU feature flags, this just references #44839

Signed-off-by: Joe Richey <joerichey@google.com>
2020-10-27 08:45:24 +09:00
Yuki Okushi
f6f8764b25
Rollup merge of #78394 - rubik:master, r=m-ou-se
fix(docs): typo in BufWriter documentation

This PR fixes a small typo in the BufWriter documentation. The current documentation looks like this:

![2020-10-26-111501_438x83_scrot](https://user-images.githubusercontent.com/238549/97160357-83d3a000-177c-11eb-8a35-3cdd3a7d89de.png)

The `<u8>` at the end is mangled by Markdown. This PR makes the `BufWriter` documentation like the `BufReader` one:

https://github.com/rust-lang/rust/blob/master/library/std/src/io/buffered/bufreader.rs#L16

I'm tagging Steve as per the Rustc dev guide.

r? @steveklabnik
2020-10-27 08:45:20 +09:00
Yuki Okushi
98e2a9564f
Rollup merge of #78388 - camelid:regression-tests, r=lcnr
Add some regression tests

Closes #75763.
Closes #76179.
2020-10-27 08:45:17 +09:00
Yuki Okushi
b72d70ef61
Rollup merge of #78377 - LeSeulArtichaut:patch-docs, r=jonas-schievink
Fix typo in debug statement
2020-10-27 08:45:14 +09:00
Yuki Okushi
5a33fa5179
Rollup merge of #78375 - taiki-e:question-in-macros, r=kennytm
Use ? in core/std macros
2020-10-27 08:45:10 +09:00