Commit Graph

174 Commits

Author SHA1 Message Date
Michael Howell
435cdd0f9a
Update E0785.md 2021-08-30 22:18:55 -07:00
Michael Howell
026322c34b fix(rustc_typeck): produce better errors for dyn auto trait
Fixes #85026
2021-08-30 22:15:11 -07:00
lcnr
87e781799a feature(const_param_types) -> feature(adt_const_params) 2021-08-30 12:07:36 +02:00
lcnr
0c28e028b6 feature(const_generics) -> feature(const_param_types) 2021-08-30 11:00:21 +02:00
asquared31415
385a233f18 Detect incorrect number of lang item generics 2021-08-23 10:15:25 -04:00
bors
99b73e81b3 Auto merge of #88134 - rylev:force-warn-improvements, r=nikomatsakis
Force warn improvements

As part of stablization of the `--force-warn` option (#86516) I've made the following changes:
* Error when the `warnings` lint group is based to the `--force-warn` option
* Tests have been updated to make it easier to understand the semantics of `--force-warn`

r? `@nikomatsakis`
2021-08-21 15:51:50 +00:00
Anton Golov
ba83b39d4e Change example and tests for E0161.
The code will not emit this warning once box expressions require a sized
type (since that error is emitted earlier in the flow).
2021-08-20 15:59:42 +02:00
Ryan Levick
d70056e30c Error when warnings lint group is used with force-warn 2021-08-18 11:53:59 +02:00
bors
02b27f1e70 Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut
Stabilize `arbitrary_enum_discriminant`

Closes #60553.

----

## Stabilization Report

_copied from https://github.com/rust-lang/rust/issues/60553#issuecomment-865922311_

### Summary

Enables a user to specify *explicit* discriminants on arbitrary enums.

Previously, this was hard to achieve:

```rust
#[repr(u8)]
enum Foo {
    A(u8) = 0,
    B(i8) = 1,
    C(bool) = 42,
}
```

Someone would need to add 41 hidden variants in between as a workaround with implicit discriminants.

In conjunction with [RFC 2195](https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md), this feature would provide more flexibility for FFI and unsafe code involving enums.

### Test cases

Most tests are in [`src/test/ui/enum-discriminant`](https://github.com/rust-lang/rust/tree/master/src/test/ui/enum-discriminant), there are two [historical](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/tag-variant-disr-non-nullary.rs) [tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/issue-17383.rs) that are now covered by the feature (removed by this pr due to them being obsolete).

### Edge cases

The feature is well defined and does not have many edge cases.
One [edge case](https://github.com/rust-lang/rust/issues/70509) was related to another unstable feature named `repr128` and is resolved.

### Previous PRs

The [implementation PR](https://github.com/rust-lang/rust/pull/60732) added documentation to the Unstable Book, https://github.com/rust-lang/reference/pull/1055 was opened as a continuation of https://github.com/rust-lang/reference/pull/639.

### Resolution of unresolved questions

The questions are resolved in https://github.com/rust-lang/rust/issues/60553#issuecomment-511235271.

----

(someone please add `needs-fcp`)
2021-08-18 01:00:17 +00:00
Yuki Okushi
4442806626
Rollup merge of #87700 - kornelski:e530text, r=oli-obk
Expand explanation of E0530

The explanation didn't cover a puzzling case of enum variants missing fields.
2021-08-11 04:18:36 +09:00
bors
442e627bee Auto merge of #87697 - GuillaumeGomez:add-e0784, r=nagisa
Assign E0784 error code for union expression errors
2021-08-08 16:40:14 +00:00
Yuki Okushi
772db06e10
Rollup merge of #87715 - bhgomes:long-explanation-E0625, r=GuillaumeGomez
Add long error explanation for E0625

For #61137.
2021-08-06 11:21:29 +09:00
Brandon H. Gomes
dc5f6d2e48 move full explanation to after erroneous example 2021-08-04 15:49:00 -04:00
Alex Crichton
1c07096a45 rustc: Fill out remaining parts of C-unwind ABI
This commit intends to fill out some of the remaining pieces of the
C-unwind ABI. This has a number of other changes with it though to move
this design space forward a bit. Notably contained within here is:

* On `panic=unwind`, the `extern "C"` ABI is now considered as "may
  unwind". This fixes a longstanding soundness issue where if you
  `panic!()` in an `extern "C"` function defined in Rust that's actually
  UB because the LLVM representation for the function has the `nounwind`
  attribute, but then you unwind.

* Whether or not a function unwinds now mainly considers the ABI of the
  function instead of first checking the panic strategy. This fixes a
  miscompile of `extern "C-unwind"` with `panic=abort` because that ABI
  can still unwind.

* The aborting stub for non-unwinding ABIs with `panic=unwind` has been
  reimplemented. Previously this was done as a small tweak during MIR
  generation, but this has been moved to a separate and dedicated MIR
  pass. This new pass will, for appropriate functions and function
  calls, insert a `cleanup` landing pad for any function call that may
  unwind within a function that is itself not allowed to unwind. Note
  that this subtly changes some behavior from before where previously on
  an unwind which was caught-to-abort it would run active destructors in
  the function, and now it simply immediately aborts the process.

* The `#[unwind]` attribute has been removed and all users in tests and
  such are now using `C-unwind` and `#![feature(c_unwind)]`.

I think this is largely the last piece of the RFC to implement.
Unfortunately I believe this is still not stabilizable as-is because
activating the feature gate changes the behavior of the existing `extern
"C"` ABI in a way that has no replacement. My thinking for how to enable
this is that we add support for the `C-unwind` ABI on stable Rust first,
and then after it hits stable we change the behavior of the `C` ABI.
That way anyone straddling stable/beta/nightly can switch to `C-unwind`
safely.
2021-08-03 07:06:19 -07:00
Brandon H. Gomes
2f85aa6590 remove trailing newline 2021-08-03 09:25:18 -04:00
Kornel
ecb6686914 Expand explanation of E0530 2021-08-03 11:11:17 +01:00
Brandon H. Gomes
a77d6ff359 add long error explanation for E0625 2021-08-02 23:03:16 -04:00
Guillaume Gomez
c364a4e30f Assign E0784 to union expression error 2021-08-02 16:51:39 +02:00
bors
b53a93db2d Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
Jonas Schievink
c5a29f9245 Update error code description 2021-07-30 00:33:30 +02:00
Jade
3cf820e17d rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
Yuki Okushi
1d5f15f9fb
Rollup merge of #87521 - midgleyc:long-E0498, r=GuillaumeGomez
Add long explanation for E0498

Helps with #61137
2021-07-29 06:11:47 +09:00
Yuki Okushi
9222984636
Rollup merge of #87435 - ibraheemdev:patch-4, r=JohnTitor
fix example code for E0617

Closes #86908
2021-07-29 06:11:44 +09:00
Ibraheem Ahmed
00198dd902 fix example code for E0617 2021-07-28 16:33:02 -04:00
Deadbeef
7a62f29f31
Stabilize arbitrary_enum_discriminant 2021-07-28 18:08:34 +08:00
Jacob Pratt
5ae2371ceb
Indicate E0665 is no longer emitted 2021-07-27 15:47:49 -04:00
Chris Midgley
bc70252f50 Mark code as ignored due to requiring external plugin 2021-07-27 19:44:50 +01:00
Chris Midgley
7f563f7f4e Add long explanation for E0498 2021-07-27 18:06:34 +01:00
Chris Midgley
b21024f7b9 Add long explanation for E0544. 2021-07-26 22:59:16 +01:00
Guillaume Gomez
3a8bc0d7da
Rollup merge of #87342 - midgleyc:add-E0757-long, r=GuillaumeGomez
Add long explanation for E0757

Helps with #61137
2021-07-21 15:52:53 +02:00
Chris Midgley
8b75fecedd docs: normalise wording in line with docs 2021-07-21 14:13:46 +01:00
Chris Midgley
3e981e2209 docs: add additional links for ffi_pure / ffi_const 2021-07-21 14:13:40 +01:00
Chris Midgley
27ffc3725a Add long explanation for E0757 2021-07-21 13:31:47 +01:00
Chris Midgley
b24d4915b8 docs: add newline before example 2021-07-21 10:58:35 +01:00
Chris Midgley
adc5de601f docs: remove spurious main functions 2021-07-21 10:57:27 +01:00
Chris Midgley
e09d782609 add working code example 2021-07-21 10:29:20 +01:00
Chris Midgley
320d049e87 Add long explanation for E0722 2021-07-20 20:30:07 +01:00
Guillaume Gomez
d85718ad01
Rollup merge of #86838 - lambinoo:I-69630-rust_const_unstable_check_const, r=oli-obk
Checking that function is const if marked with rustc_const_unstable

Fixes #69630

This one is still missing tests to check the behavior but I checked by hand and it seemed to work.
I would not mind some direction for writing those unit tests!
2021-07-08 18:30:34 +02:00
Lamb
07f903e0e0 fn must be const if marked with stability attribut
remove trailing newline

fix: test with attribute but missing const

Update compiler/rustc_passes/src/stability.rs

Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>

Add test for extern functions

fix: using span_help instead of span_suggestion

add test for some ABIs + fmt fix

Update compiler/rustc_passes/src/stability.rs

Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>

Refractor and add test for `impl const`

Add test to make sure no output + cleanup condition

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

remove stdcall test, failing CI test

C abi is already tested in this, so it is not that useful to test another one.
The tested code is blind to which specific ABI for now, as long as it's not an intrinsic one
2021-07-08 07:52:05 +02:00
Yuki Okushi
5d555bf239
Rollup merge of #86477 - tlyu:e0716-clarification, r=JohnTitor
E0716: clarify that equivalent code example is erroneous

In E0716, there is a code block that is equivalent to the erroneous
code example. Especially when viewed with `rustc --explain`, it's
not obvious that it is also erroneous, and some users have been
confused when they try to change their code to match the erroneous
equivalent.

`@rustbot` label +A-diagnostics +D-newcomer-roadblock +T-compiler
2021-07-05 07:13:22 +09:00
Taylor Yu
92197a551f E0716: clarify that equivalent code example is erroneous
In E0716, there is a code block that is equivalent to the erroneous
code example. Especially when viewed with `rustc --explain`, it's
not obvious that it is also erroneous, and some users have been
confused when they try to change their code to match the erroneous
equivalent.
2021-07-04 10:04:37 -05:00
Yuki Okushi
ab4d16fe7a
Rollup merge of #86148 - FabianWolff:issue-85855, r=varkor
Check the number of generic lifetime and const parameters of intrinsics

This pull request fixes #85855. The current code for type checking intrinsics only checks the number of generic _type_ parameters, but does not check for an incorrect number of lifetime or const parameters, which can cause problems later on, such as the ICE in #85855, where the code thought that it was looking at a type parameter but found a lifetime parameter:
```
error: internal compiler error: compiler/rustc_middle/src/ty/generics.rs:188:18:
    expected type parameter, but found another generic parameter
```

The changes in this PR add checks for the number of lifetime and const parameters, expand the scope of `E0094` to also apply to these cases, and improve the error message by properly pluralizing the number of expected generic parameters.
2021-07-02 06:20:28 +09:00
Fabian Wolff
fe93349109 Minor adjustments and refactoring 2021-07-01 17:48:19 +02:00
Fabian Wolff
4e08bb5225 Fix typo and improve documentation for E0632 2021-06-29 01:09:44 +02:00
bors
456a03227e Auto merge of #86279 - JohnTitor:transparent-zero-size-fields, r=nikomatsakis
Permit zero non-zero-field on transparent types

Fixes #77841

This makes the transparent fields meet the below:
> * A `repr(transparent)` type `T` must meet the following rules:
>   * It may have any number of 1-ZST fields
>   * In addition, it may have at most one other field of type U

r? `@nikomatsakis`
2021-06-24 07:29:59 +00:00
Guillaume Gomez
12b6d32387 Remove unused error codes from error_codes.rs and from EXEMPTED_FROM_TEST constant 2021-06-23 21:32:37 +02:00
mbartlett21
9db5c483ab
Add destructuring example of E0508
This adds an example that destructures the array to move the value, instead of taking a reference or cloning.
2021-06-22 22:24:46 +10:00
Yuki Okushi
4e755a96a7
Adjust documentation 2021-06-14 07:42:15 +09:00
Shadlock0133
dab89b51ac
Fix typo with custom a custom -> with a custom 2021-06-13 21:21:45 +02:00
Fabian Wolff
7b2befc27b Check the number of generic lifetime and const parameters of intrinsics 2021-06-08 20:41:16 +02:00