Commit graph

779 commits

Author SHA1 Message Date
lcnr e00146f504 fulfillment typo 2021-05-07 12:17:58 +02:00
lcnr 3c3cf08e39 wfcheck fcx <-> tcx cleanup 2021-05-07 12:15:38 +02:00
Dylan DPC aaf23892ab
Rollup merge of #84871 - richkadel:no-coverage-unstable-only, r=nagisa
Disallows `#![feature(no_coverage)]` on stable and beta (using standard crate-level gating)

Fixes: #84836

Removes the function-level feature gating solution originally implemented, and solves the same problem using `allow_internal_unstable`, so normal crate-level feature gating mechanism can still be used (which disallows the feature on stable and beta).

I tested this, building the compiler with and without `CFG_DISABLE_UNSTABLE_FEATURES=1`

With unstable features disabled, I get the expected result as shown here:

```shell
$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc     src/test/run-make-fulldeps/coverage/no_cov_crate.rs
error[E0554]: `#![feature]` may not be used on the dev release channel
 --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1
  |
2 | #![feature(no_coverage)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
```

r? ````@Mark-Simulacrum````
cc: ````@tmandry```` ````@wesleywiser````
2021-05-07 00:38:40 +02:00
Ralf Jung 2cbcfae654
Rollup merge of #84913 - estebank:issue-84831, r=varkor
Do not ICE on invalid const param

When encountering a path that can't have generics, do not call
`generics_of`. This would happen when writing something like
`path::this_is_a_mod<const_val>`.

Fix #84831.
2021-05-05 17:52:29 +02:00
Ralf Jung db77072a25
Rollup merge of #84808 - estebank:issue-84769, r=petrochenkov
Account for unsatisfied bounds in E0599

Fix #84769, follow up to #84499, #83667.
2021-05-05 17:52:23 +02:00
Rich Kadel 3584c1dd0c Disallows #![feature(no_coverage)] on stable and beta
using allow_internal_unstable (as recommended)

Fixes: #84836

```shell
$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc     src/test/run-make-fulldeps/coverage/no_cov_crate.rs
error[E0554]: `#![feature]` may not be used on the dev release channel
 --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1
  |
2 | #![feature(no_coverage)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
```
2021-05-05 07:52:26 -07:00
Esteban Küber 11379f0494 Do not ICE on invalid const param
When encountering a path that can't have generics, do not call
`generics_of`. This would happen when writing something like
`path::this_is_a_mod<const_val>`.

Fix #84831.
2021-05-04 08:41:40 -07:00
bors 7a0f1781d0 Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021

This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition.

r? `@estebank`
2021-05-04 08:09:23 +00:00
Dylan DPC 0133af504b
Rollup merge of #84784 - JulianKnodt:suggest_const, r=lcnr
Add help message to suggest const for unused type param

r? `@lcnr`
2021-05-03 00:32:42 +02:00
Dylan DPC a00edce017
Rollup merge of #84358 - sexxi-goose:print_captures_borrowck_rebased, r=nikomatsakis
Update closure capture error logging for disjoint captures for disjoint captures

Improved error logging when `#![feature(capture_disjoint_fields)]` is used.

Closes https://github.com/rust-lang/project-rfc-2229/issues/8
Closes https://github.com/rust-lang/project-rfc-2229/issues/36
Closes https://github.com/rust-lang/project-rfc-2229/issues/39
Closes #76005
2021-05-02 17:00:21 +02:00
Esteban Küber 1e89b583c3 Account for unsatisfied bounds in E0599
Fix #84769, follow up to #84499, #83667.
2021-05-01 17:18:04 -07:00
Chris Pardy 08c4fbcea7 Closure capture borrow diagnostics for disjoint captures 2021-05-01 19:01:05 -04:00
kadmin 50c86db4fa Add help message for unused type param 2021-05-01 21:58:06 +00:00
bors 4de7572097 Auto merge of #84410 - BoxyUwU:blue, r=varkor
Fix generic arg mismatch errors being ignored with explicit late bound lifetimes

Fixes #83466

r? `@varkor`
2021-05-01 21:07:10 +00:00
Ellen 39054339c1 test: *sneezes* 2021-05-01 18:36:05 +01:00
bors bcd696d722 Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov
Implement RFC 1260 with feature_name `imported_main`.

This is the second extraction part of #84062 plus additional adjustments.
This (mostly) implements RFC 1260.

However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure.

cc https://github.com/rust-lang/rust/issues/28937
r? `@petrochenkov`
2021-04-30 06:59:37 +00:00
lcnr da6261e07f make feature recommendations optional 2021-04-29 20:44:19 +02:00
Charles Lew d261df4a72 Implement RFC 1260 with feature_name imported_main. 2021-04-29 08:35:08 +08:00
bors 20040fa332 Auto merge of #84562 - richkadel:issue-83601, r=tmandry
Adds feature-gated `#[no_coverage]` function attribute, to fix derived Eq `0` coverage issue #83601

Derived Eq no longer shows uncovered

The Eq trait has a special hidden function. MIR `InstrumentCoverage`
would add this function to the coverage map, but it is never called, so
the `Eq` trait would always appear uncovered.

Fixes: #83601

The fix required creating a new function attribute `no_coverage` to mark
functions that should be ignored by `InstrumentCoverage` and the
coverage `mapgen` (during codegen).

Adding a `no_coverage` feature gate with tracking issue #84605.

r? `@tmandry`
cc: `@wesleywiser`
2021-04-28 13:05:16 +00:00
Rich Kadel 3a5df48021 adds feature gating of no_coverage at either crate- or function-level 2021-04-27 17:12:51 -07:00
Rich Kadel 888d0b4c96 Derived Eq no longer shows uncovered
The Eq trait has a special hidden function. MIR `InstrumentCoverage`
would add this function to the coverage map, but it is never called, so
the `Eq` trait would always appear uncovered.

Fixes: #83601

The fix required creating a new function attribute `no_coverage` to mark
functions that should be ignored by `InstrumentCoverage` and the
coverage `mapgen` (during codegen).

While testing, I also noticed two other issues:

* spanview debug file output ICEd on a function with no body. The
workaround for this is included in this PR.
* `assert_*!()` macro coverage can appear covered if followed by another
`assert_*!()` macro. Normally they appear uncovered. I submitted a new
Issue #84561, and added a coverage test to demonstrate this issue.
2021-04-27 11:11:56 -07:00
lcnr b3629d21ba move representability out of rustc_middle 2021-04-27 15:01:37 +02:00
bors 22b686ad99 Auto merge of #77246 - yaahc:typeof-errors, r=oli-obk
try enabling typeof for fun error messages
2021-04-27 04:46:45 +00:00
Dylan DPC 139749934b
Rollup merge of #84520 - hameerabbasi:fn-as-ty, r=lcnr
Improve diagnostics for function passed when a type was expected.

This PR improves diagnostics, it provides more information when a function is passed where a type is expected.

r? `@lcnr`
2021-04-25 23:15:16 +02:00
Dylan DPC ad3389a6df
Rollup merge of #84516 - torhovland:issue-84114, r=estebank
Add suggestion to "use break" when attempting to implicit-break a loop

Fixes #84114
2021-04-25 23:15:14 +02:00
Dylan DPC ae316d6603
Rollup merge of #84499 - estebank:issue-84272, r=jackh726
Tweak trait not `use`d suggestion

Fix #84272. Follow up to #83667.
2021-04-25 23:15:13 +02:00
bors 58bdb08947 Auto merge of #84299 - lcnr:const-generics-defaults-name-res, r=varkor
various const parameter defaults improvements

Actually resolve names in const parameter defaults, fixing `struct Foo<const N: usize = { usize::MAX }>`.

---
Split generic parameter ban rib for types and consts, allowing
```rust
#![feature(const_generics_defaults)]
struct Q;
struct Foo<T = Q, const Q: usize = 3>(T);
```

---
Remove the type/const ordering restriction if `const_generics_defaults` is active, even if `const_generics` is not. allowing us to stabilize and test const param defaults separately.

---
Check well formedness of const parameter defaults, eagerly emitting an error for `struct Foo<const N: usize = { 0 - 1 }>`

---
Do not forbid const parameters in param defaults, allowing `struct Foo<const N: usize, T = [u8; N]>(T)` and `struct Foo<const N: usize, const M: usize = N>`. Note that this should not change anything which is stabilized, as on stable, type parameters must be in front of const parameters, which means that type parameter defaults are only allowed if no const parameters exist.

We still forbid generic parameters inside of const param types.

r? `@varkor` `@petrochenkov`
2021-04-25 14:00:49 +00:00
bors 13a2615883 Auto merge of #84147 - cuviper:array-method-dispatch, r=nikomatsakis,m-ou-se
Cautiously add IntoIterator for arrays by value

Add the attribute described in #84133, `#[rustc_skip_array_during_method_dispatch]`, which effectively hides a trait from method dispatch when the receiver type is an array.

Then cherry-pick `IntoIterator for [T; N]` from #65819 and gate it with that attribute. Arrays can now be used as `IntoIterator` normally, but `array.into_iter()` has edition-dependent behavior, returning `slice::Iter` for 2015 and 2018 editions, or `array::IntoIter` for 2021 and later.

r? `@nikomatsakis`
cc `@LukasKalbertodt` `@rust-lang/libs`
2021-04-25 07:26:49 +00:00
Hameer Abbasi e558ddbb3a Improve diagnostics for function passed when a type was expected. 2021-04-25 08:56:50 +02:00
Tor Hovland 8bc81a0e4d Refactor. 2021-04-24 18:49:21 +02:00
Tor Hovland ad78b50a86 Implemented suggestion. 2021-04-24 13:57:41 +02:00
Esteban Küber fb1fb7d2ef Tweak suggestion output 2021-04-23 18:57:52 -07:00
Esteban Küber 64ee9cc28c Recover trait import suggestion 2021-04-23 18:12:54 -07:00
Jane Lusby 81e4d5f96c add special case for typeof fallback 2021-04-23 13:28:17 -07:00
Jane Lusby a49b746da4 cyclesss 2021-04-23 11:07:15 -07:00
Jane Lusby 2ac171f94c try enabling typeof for fun error messages 2021-04-23 11:07:15 -07:00
Dylan DPC f180c1e05d
Rollup merge of #84404 - tmiasko:intrinsics-in-coercion-lub, r=Mark-Simulacrum
Check for intrinsics before coercing to a function pointer

Return an error if coercing function items / non-capturing closures
to a common function pointer type would require reifying an intrinsic.

Turns ICE reported in #84297 into a proper error.
2021-04-22 18:14:42 +02:00
bors 25c15cdbe0 Auto merge of #71511 - hi-rustin:rustin-patch-rename-assoc, r=eddyb,varkor
Rename AssociatedItems to AssocItems

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>

Part of https://github.com/rust-lang/rust/issues/60163#issuecomment-605308641
2021-04-22 11:32:50 +00:00
Josh Stone 2a97c690bc Note array.into_iter() specifically in method probing 2021-04-21 13:04:59 -07:00
lcnr d3e0d2f53d supply substs to anon consts in defaults 2021-04-21 15:25:58 +02:00
lcnr 312b4fdfd2 improve wf check for const param defaults 2021-04-21 15:25:58 +02:00
lcnr 7cb1dcd488 loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
Tomasz Miąsko 75732dd00e Check for intrinsics before coercing to a function pointer
Return an error if coercing function items / non-capturing closures
to a common function pointer type would require reifying an intrinsic.
2021-04-21 00:00:00 +00:00
bors e888a57da8 Auto merge of #84334 - klensy:typo-compiler, r=jyn514
fix few typos in comments
2021-04-20 00:16:45 +00:00
lcnr a8193ca4c3 fix suggestion for unsized function parameters 2021-04-19 20:06:19 +02:00
klensy f43ee8ebf6 fix few typos 2021-04-19 15:57:08 +03:00
bors 080d30235f Auto merge of #84244 - ABouttefeux:closure-return-conflict-suggest, r=estebank
fix incomplete diagnostic notes when closure returns conflicting for genric type

fixes #84128
Correctly report the span on for conflicting return type in closures
2021-04-17 07:17:31 +00:00
Josh Stone b79af2fcde Implement #[rustc_skip_array_during_method_dispatch] 2021-04-16 11:11:59 -07:00
Aliénore Bouttefeux af90cac0e1 fix reporting return type in some cases 2021-04-16 17:06:19 +02:00
bors 710da44e22 Auto merge of #84228 - SkiFire13:fix-84213, r=estebank
Suggest to borrow after failing to cast from T to *const/mut T

Fixes #84213
2021-04-16 05:13:43 +00:00