Commit Graph

442 Commits

Author SHA1 Message Date
Bryanskiy
e26614e6a7 Replace old private-in-public diagnostic with type privacy lints 2023-08-02 13:40:28 +03:00
David Rheinsberg
b0dadff6de error/E0691: include alignment in error message
Include the computed alignment of the violating field when rejecting
transparent types with non-trivially aligned ZSTs.

ZST member fields in transparent types must have an alignment of 1 (to
ensure it does not raise the layout requirements of the transparent
field). The current error message looks like this:

 LL | struct Foobar(u32, [u32; 0]);
    |                    ^^^^^^^^ has alignment larger than 1

This patch changes the report to include the alignment of the violating
field:

 LL | struct Foobar(u32, [u32; 0]);
    |                    ^^^^^^^^ has alignment of 4, which is larger than 1

In case of unknown alignments, it will yield:

 LL | struct Foobar<T>(u32, [T; 0]);
    |                       ^^^^^^ may have alignment larger than 1

This allows developers to get a better grasp why a specific field is
rejected. Knowing the alignment of the violating field makes it easier
to judge where that alignment-requirement originates, and thus hopefully
provide better hints on how to mitigate the problem.

This idea was proposed in 2022 in #98071 as part of a bigger change.
This commit simply extracts this error-message change, to decouple it
from the other diagnostic improvements.
2023-07-21 11:04:16 +02:00
nxya
c429a72db9 add links to query documentation for E0391 2023-07-18 09:20:25 -04:00
Michael Goulet
847d50453c Implement custom diagnostic for ConstParamTy 2023-06-01 18:21:42 +00:00
Wim Looman
8f94253254
Add details about unsafe_op_in_unsafe_fn to E0133 2023-05-28 13:11:30 +02:00
Matthias Krüger
363d158cd8
Rollup merge of #111215 - BoxyUwU:resolve_anon_consts_differently, r=cjgillot
Various changes to name resolution of anon consts

Sorry this PR is kind of all over the place ^^'

Fixes #111012

- Rewrites anon const nameres to all go through `fn resolve_anon_const` explicitly instead of `visit_anon_const` to ensure that we do not accidentally resolve anon consts as if they are allowed to use generics when they aren't. Also means that we dont have bits of code for resolving anon consts that will get out of sync (i.e. legacy const generics and resolving path consts that were parsed as type arguments)
- Renames two of the `LifetimeRibKind`, `AnonConst -> ConcreteAnonConst` and `ConstGeneric -> ConstParamTy`
- Noticed while doing this that under `generic_const_exprs` all lifetimes currently get resolved to errors without any error being emitted which was causing a bunch of tests to pass without their bugs having been fixed, incidentally fixed that in this PR and marked those tests as `// known-bug:`. I'm fine to break those since `generic_const_exprs` is a very unstable incomplete feature and this PR _does_ make generic_const_exprs "less broken" as a whole, also I can't be assed to figure out what the underlying causes of all of them are. This PR reopens #77357 #83993
- Changed `generics_of` to stop providing generics and predicates to enum variant discriminant anon consts since those are not allowed to use generic parameters
- Updated the error for non 'static lifetime in const arguments and the error for non 'static lifetime in const param tys to use `derive(Diagnostic)`

I have a vague idea why const-arg-in-const-arg.rs, in-closure.rs and simple.rs have started failing which is unfortunate since these were deliberately made to work, I think lifetime resolution being broken just means this regressed at some point and nobody noticed because the tests were not testing anything :( I'm fine breaking these too for the same reason as the tests for #77357 #83993. I couldn't get `// known-bug` to work for these ICEs and just kept getting different stderr between CI and local `--bless` so I just removed them and will create an issue to track re-adding (and fixing) the bugs if this PR lands.

r? `@cjgillot` cc `@compiler-errors`
2023-05-09 20:49:32 +02:00
Astroide
d6ef6e0080
Update compiler/rustc_error_codes/src/error_codes/E0726.md
Co-authored-by: Michael Goulet <michael@errs.io>
2023-05-06 19:39:08 -04:00
Astroide
b2acf3ea64
rustc --explain E0726 - grammar fixing (it's => its + add a the where it felt right to do so) 2023-05-06 12:42:52 -04:00
Boxy
442617c046 misc nameres changes for anon consts 2023-05-05 21:31:35 +01:00
Josh Soref
e09d0d2a29 Spelling - compiler
* account
* achieved
* advising
* always
* ambiguous
* analysis
* annotations
* appropriate
* build
* candidates
* cascading
* category
* character
* clarification
* compound
* conceptually
* constituent
* consts
* convenience
* corresponds
* debruijn
* debug
* debugable
* debuggable
* deterministic
* discriminant
* display
* documentation
* doesn't
* ellipsis
* erroneous
* evaluability
* evaluate
* evaluation
* explicitly
* fallible
* fulfill
* getting
* has
* highlighting
* illustrative
* imported
* incompatible
* infringing
* initialized
* into
* intrinsic
* introduced
* javascript
* liveness
* metadata
* monomorphization
* nonexistent
* nontrivial
* obligation
* obligations
* offset
* opaque
* opportunities
* opt-in
* outlive
* overlapping
* paragraph
* parentheses
* poisson
* precisely
* predecessors
* predicates
* preexisting
* propagated
* really
* reentrant
* referent
* responsibility
* rustonomicon
* shortcircuit
* simplifiable
* simplifications
* specify
* stabilized
* structurally
* suggestibility
* translatable
* transmuting
* two
* unclosed
* uninhabited
* visibility
* volatile
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17 16:09:18 -04:00
Tam Pham
87b3ae3909 Make "unneccesary visibility qualifier" error much more clear 2023-04-03 21:52:27 -05:00
Matthias Krüger
eee3f484f9
Rollup merge of #109565 - WaffleLapkin:better_docs_for_e0223, r=oli-obk
Improve documentation for E0223

See discussion in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Inconsistency.20in.20prohibiting.20.60Type.3A.3AAssocType.60
2023-03-28 07:01:08 +02:00
Maybe Waffle
904dd2c398 Bless tidy 2023-03-27 18:58:07 +00:00
Maybe Waffle
3c4fabc341 Improve documentation for E0223 2023-03-27 18:00:22 +00:00
Matthias Krüger
783f3a1965
Rollup merge of #109501 - lukas-code:link, r=WaffleLapkin
make link clickable
2023-03-22 22:44:43 +01:00
Lukas Markeffsky
1581b97acb make link clickable 2023-03-22 22:01:19 +01:00
Eric Huss
572c56cb7e Update links for custom discriminants. 2023-03-18 10:22:37 -07:00
Matthias Krüger
9599f3cc54
Rollup merge of #107416 - czzrr:issue-80618, r=GuillaumeGomez
Error code E0794 for late-bound lifetime parameter error.

This PR addresses [#80618](https://github.com/rust-lang/rust/issues/80618).
2023-03-18 12:04:21 +01:00
Matthias Krüger
e7d6369ed4
Rollup merge of #109211 - mili-l:mili_l/update_e0206_description, r=WaffleLapkin
E0206 - update description

added `union` to description
2023-03-18 00:05:52 +01:00
Jamilya Shurukhova
c4bb47ac36
Update compiler/rustc_error_codes/src/error_codes/E0206.md
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-03-17 15:50:37 +01:00
Jamilya Shurukhova
05dc132adb E0206 - code review changes 2023-03-17 14:54:39 +01:00
Jamilya Shurukhova
1f12c3e397 E0206 - removed space 2023-03-16 10:26:34 +01:00
Jamilya Shurukhova
dc39bf8efc E0206 - added union to description 2023-03-16 10:18:31 +01:00
gimbles
e5a5b90afc unequal → not equal 2023-03-15 23:55:48 +05:30
clubby789
dd7df04e16 Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
est31
7f4cc178f0 Address the new odd backticks tidy lint in compiler/ 2023-03-11 20:40:18 +01:00
Christopher Acosta
75563cd725 Error code E0794 for late-bound lifetime parameter error. 2023-03-07 21:26:19 +01:00
Ezra Shaw
90677edcba
refactor: statically guarantee that current error codes are documented 2023-02-26 20:12:36 +13:00
Ezra Shaw
9f876cc900
docs/test: add UI test and docs for E0476 2023-02-25 19:31:02 +13:00
Matthew Kelly
2bcd4e256a Add extended error message for E0523
Adds the extended error documentation for E0523 to indicate that the
error is no longer produced by the compiler.

Update the E0464 documentation to include example code that produces the
error.

Remove the error message E0523 from the compiler and replace it with an
internal compiler error.
2023-02-06 06:58:30 -05:00
Ralf Jung
dfc4a7b2d0 make unaligned_reference a hard error 2023-01-31 20:28:11 +01:00
Samuel Ortiz
706132d409 compiler: Fix E0587 explanation
We meant to use 8 as the packed argument.

Signed-off-by: Samuel Ortiz <sameo@rivosinc.com>
2023-01-27 10:59:51 +01:00
Ezra Shaw
00ff718da8
add UI test + docs for E0789 2023-01-23 20:38:14 +13:00
Guillaume Gomez
246daa49ee
Rollup merge of #106931 - Ezrashaw:docs-e0208, r=compiler-errors
document + UI test `E0208` and make its output more user-friendly

Cleans up `E0208`'s output a lot. It could actually be useful for someone learning about variance now. I also added a UI test for it in `tests/ui/error-codes/` and wrote some docs for it.

r? `@GuillaumeGomez` another error code, can't be bothered to find the issue :P. Obviously there's some compiler stuff, so you'll have to hand it off.

Part of https://github.com/rust-lang/rust/issues/61137.
2023-01-19 11:19:35 +01:00
Ezra Shaw
708861e5b7
remove error code from #[rustc_variance] and document its remains 2023-01-18 21:10:27 +13:00
Matthias Krüger
68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
Oli Scherer
6b69b5e460 Improve a TAIT error and add an error code plus documentation 2023-01-16 16:54:14 +00:00
nils
c61f29ca52
Rollup merge of #106714 - Ezrashaw:remove-e0490, r=davidtwco
remove unreachable error code `E0490`

AFAIK, the untested and undocumented error code `E0490` is now unreachable, it was from the days of the original borrow checker.

cc ``@GuillaumeGomez`` #61137
2023-01-12 15:44:52 +01:00
Ezra Shaw
02005e9f22
remove unreachable error code E0490 2023-01-12 14:15:21 +13:00
bowlerman
f75eb24f4f remove E0280 and ICE instead 2023-01-10 03:04:28 +01:00
Ezra Shaw
24ce65c8d6
docs/test: add error-docs and UI test for E0711 2023-01-09 15:48:53 +13:00
Ezra Shaw
ecc0507fdd
docs/test: add empty error-docs for E0208, E0640 and E0717 2023-01-09 15:48:52 +13:00
Yuki Okushi
6459a51c3f
Rollup merge of #106580 - Ezrashaw:remove-e0313, r=compiler-errors
remove unreachable error code `E0313`

Fixes #103742
Makes #103433 redundant

Implements removal of `E0313`. I agree with the linked issue that this error code is unreachable but if someone could confirm that would be great, are crater runs done for this sort of thing?

Also removed a redundant `// ignore-tidy-filelength` that I found while reading code.

cc ``@GuillaumeGomez`` #61137
2023-01-08 17:01:49 +09:00
Yuki Okushi
3b5afa590b
Rollup merge of #106557 - Ezrashaw:ui-test-fixups-1, r=GuillaumeGomez
Add some UI tests and reword error-code docs

Added UI tests for `E0013` and `E0015`. Error code docs for `E0015` were a bit unclear (they referred to all non-const errors in const context, when only non-const functions applied), so I touched them up a bit.

I also fixed up some issues in the new `error_codes.rs` tidy check (linked #106341), that I overlooked previously.

r? ``@GuillaumeGomez``
2023-01-08 17:01:48 +09:00
Ezra Shaw
93c0d8d5d5
remove unreachable error code E0313 2023-01-08 14:47:12 +13:00
Ezra Shaw
ae61c250cd
doc/test: add UI test and reword docs for E0013 and E0015 2023-01-08 13:33:09 +13:00
Michael Goulet
01cb9dcd5b
Rollup merge of #106554 - LingMan:explanation_typo, r=compiler-errors
Fix a typo in the explanation of E0588
2023-01-06 21:54:01 -08:00
LingMan
dc0e4207d4 Fix a typo in the explanation of E0588 2023-01-07 05:10:53 +01:00
Ezra Shaw
9618f646b3
docs: revert removal of E0729 2023-01-02 09:11:36 +13:00
Ezra Shaw
04b9038610
refactor: clean up errors.rs and error_codes_check.rs
Move them into new `error_codes.rs` tidy check.
2023-01-01 15:22:01 +13:00
Ezra Shaw
24b39ece2f
refactor: merge E0465 into E0464 2022-12-31 20:44:54 +13:00
Ezra Shaw
726519d4f5
docs: add long-form error docs for E0514 2022-12-29 14:32:39 +13:00
Ezra Shaw
da7fcc7a09
docs/test: add UI test and long-form error docs for E0519 2022-12-29 13:16:10 +13:00
Ezra Shaw
f66e7529b5
docs: add long-form error docs for E0461 2022-12-27 17:03:39 +13:00
Matthias Krüger
e08dd9d998
Rollup merge of #105970 - Ezrashaw:add-docs+test-e0462, r=GuillaumeGomez
docs/test: add UI test and long-form error docs for E0462

Another UI test/ docs combo.

r? ``@GuillaumeGomez``
2022-12-24 00:31:40 +01:00
Ezra Shaw
66ed1812cf
docs/test: add UI test and long-form error docs for E0462 2022-12-23 10:56:16 +13:00
Matthias Krüger
4726e514d7
Rollup merge of #105791 - Ezrashaw:add-e0472-long-docs, r=GuillaumeGomez
docs: add long error explanation for error E0472

Add long-form error docs for E0472: "inline assembly not supported on this target" and update UI tests.

R? `@GuillaumeGomez`
2022-12-20 23:35:14 +01:00
Ezra Shaw
082ca1e461
docs: add long error explanation for error E0472 2022-12-20 21:34:30 +13:00
Ezra Shaw
e798fdf7be
docs/test: add UI test and long-form error docs for E0377 2022-12-20 18:31:15 +13:00
Ezra Shaw
5ecac8ede6
more markdown list formatting
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2022-12-19 22:50:31 +13:00
Ezra Shaw
540c3f434f
docs: add long-form error-code docs for E0457 2022-12-19 08:55:08 +13:00
Ezra Shaw
7e66d451ad
docs: add long-form error-code docs for E0460 2022-12-19 08:55:08 +13:00
Ezra Shaw
fe52882986
docs: add long error explanation for error E0320 2022-12-17 07:38:23 +13:00
Ezra Shaw
fded03ee2d
docs: rewrite E0158 error-code docs for clarity 2022-12-16 08:36:40 +13:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Peter Collingbourne
f44a0153bc Support Option and similar enums as type of static variable with linkage attribute.
Compiler MCP:
https://github.com/rust-lang/compiler-team/issues/565
2022-12-05 15:05:43 -08:00
bors
7fe6f36224 Auto merge of #103491 - cjgillot:self-rpit, r=oli-obk
Support using `Self` or projections inside an RPIT/async fn

I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait.

The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`.  This PR changes the scheme
```rust
impl<'a> Foo<'a> {
    fn foo<'b, T>() -> impl Into<Self> + 'b { ... }
}

opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b;
impl<'a> Foo<'a> {
    // OLD
    fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... }
                             ^^^^^^^ the `Self` becomes `Foo<'static>`

    // NEW
    fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... }
                             ^^ the `Self` stays `Foo<'a>`
}
```

There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one.

This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more.  The same trick allows to use projections like `T::Assoc` where `Self` is allowed.  The feature is gated behind a `impl_trait_projections` feature gate.

The implementation relies on 2 tweaking rules for opaques in 2 places:
- we only relate substs that correspond to captured lifetimes during TypeRelation;
- we only list captured lifetimes in choice region computation.

For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques.

Impl-trait that do not reference `Self` or projections will have their variances as:
- `o` (invariant) for each parent type or const;
- `*` (bivariant) for each parent lifetime --> will not participate in borrowck;
- `o` (invariant) for each own lifetime.

Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck.  In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`.

r? types
cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-21 12:17:03 +00:00
Matthias Krüger
55ff8bf847
Rollup merge of #104339 - compiler-errors:rustc_deny_explicit_impl, r=cjgillot
Add `rustc_deny_explicit_impl`

Also adjust `E0322` error message to be more general, since it's used for `DiscriminantKind` and `Pointee` as well.

Also add `rustc_deny_explicit_impl` on the `Tuple` and `Destruct` marker traits.
2022-11-15 10:44:12 +01:00
Michael Goulet
b5b6467810 Add rustc_deny_explicit_impl 2022-11-14 03:23:41 +00:00
Camille GILLOT
da9dca7040 Retire error code. 2022-11-12 10:03:13 +00:00
Dylan DPC
6e819af3a7
Rollup merge of #103924 - PeteDevoy:patch-1, r=estebank
Fix broken link in description of error code E0706

Corresponding subsection in async book is `07.05` not `07.06`.

The information on the linked page is the same so it may be reasonable to remove the whole sentence.
2022-11-11 20:51:39 +05:30
Dylan DPC
408b8cf7c4
Rollup merge of #103757 - ffmancera:ff/clarify_E0207, r=jackh726
Mention const and lifetime parameters in error E0207

Error Index for E0207 must mention const and lifetime parameters. In addition, add code examples for these situations.

Fixes #80862
2022-11-07 18:35:23 +05:30
Pete
4b5cff5b55
Fix broken link in error code E0706 docs
Corresponding subsection in async book is not `07.05` not `07.06`.

The information on the linked page is the same so it may be reasonable to remove the whole sentence.
2022-11-03 14:15:32 +01:00
Dominic Farolino
b978bba6a9
Update E0382.md 2022-10-31 00:41:12 -04:00
Fernando Fernandez Mancera
2159df22a2 Mention const and lifetime parameters in error E0207
Error Index for E0207 must mention const and lifetime parameters. In
addition, add code examples for these situations.

Fixes #80862
2022-10-30 12:01:39 +01:00
Dylan DPC
5b6455318a
Rollup merge of #95710 - fee1-dead-contrib:stabilize_arbitrary_enum_discriminant, r=joshtriplett
Stabilize arbitrary_enum_discriminant, take 2

Documentation has been updated in https://github.com/rust-lang/reference/pull/1055. cc #86860 for previous stabilization report.

Not yet marks https://github.com/rust-lang/rust/issues/60553 as done: need documentation in the rust reference.
2022-10-26 17:32:53 +05:30
Jesse Ruderman
e3a091ad6a
Remove redundant sentence 2022-10-24 00:52:26 -07:00
Deadbeef
988e75bb65 Stabilize arbitrary_enum_discriminant, take 2 2022-10-22 13:54:39 +08:00
Rageking8
d1982bd0af fix small word dupe typos 2022-10-13 00:53:46 +08:00
nils
1df0a1890a Cleanup some error code explanations
E0045: Use a stable non-C ABI instead
E0092: Use an atomic intrinsic that actually exists
E0161: Don't use box_syntax
E0579: Format ranges in the rustfmt style
E0622: Use the rustfmt style
E0743: Remove feature gate as it's not needed
2022-10-03 08:53:06 +02:00
bors
ce7f0f1aa0 Auto merge of #100719 - CohenArthur:rust-safe-intrinsic-attribute, r=wesleywiser
Add `#[rustc_safe_intrinsic]`

This PR adds the `#[rustc_safe_intrinsic]` attribute as mentionned on Zulip. The goal of this attribute is to avoid keeping a list of symbols as the source for stable intrinsics, and instead rely on an attribute. This is similar to `#[rustc_const_stable]` and `#[rustc_const_unstable]`, which among other things, are used to mark the constness of intrinsic functions.
2022-09-28 19:07:50 +00:00
Matthew Kelly
c0d32fd2cc review updates 2022-09-27 19:23:59 -04:00
Arthur Cohen
99d57ee23d core: Mark all safe intrinsics with #[rustc_safe_intrinsic] 2022-09-27 15:55:42 +02:00
Matthew Kelly
0d9c01480b remove implied link bound per review
also update .stderr outputs
2022-09-26 20:50:33 -04:00
Matthew Kelly
eda2a40145 Merge remote-tracking branch 'origin/master' into mpk/add-long-error-message-for-E0311 2022-08-31 19:39:39 -04:00
Matthew Kelly
4a443dfb82 review updates to E0311 description 2022-08-29 06:05:01 -04:00
Matthew Kelly
deadf071ed fix trailing ] 2022-08-27 14:36:17 -04:00
Matthew Kelly
de3e95b56c Review updates: simpler MWE and docs
- use the simpler minimum working example from the review
- add an alterate "fix" that helps make the cause of the error more
  clear
- attempt to add an improved description of what is going on
2022-08-27 14:20:59 -04:00
Matthew Kelly
4f194a76c8 Fix rust-doc error
There was a partial rust code block in the readme that was invalid
because of a missing line. I inlined the code snippet into the text to
fix the error. This also improves readability a bit.
2022-08-25 05:46:47 -04:00
Matthew Kelly
fc02eee8f6 fix wrapping 2022-08-24 20:51:48 -04:00
Matthew Kelly
dd7c48e529 Improve description again
-- update summary based on review
-- rewrite explanation to be more clear and correct
2022-08-24 20:44:09 -04:00
Joshua Nelson
31e39446ec Stabilize #![feature(label_break_value)]
# Stabilization proposal

The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.

There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234
2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176
3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630

Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251. This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395
- Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006

Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249

nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983) but there are no open RFCs,
and the design space seems rather speculative.

joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804

withoutboats has regrettably left the language team.

joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353

[issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+

 ## Report

+ Feature gate:
    - d695a497bb/src/test/ui/feature-gates/feature-gate-label_break_value.rs
+ Diagnostics:
    - 6b2d3d5f3c/compiler/rustc_parse/src/parser/diagnostics.rs (L2629)
    - f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L749)
    - f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L1001)
    - 111df9e6ed/compiler/rustc_passes/src/loops.rs (L254)
    - d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L2079)
    - d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L1569)
+ Tests:
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs

 ## Interactions with other features

Labels follow the hygiene of local variables.

label-break-value is permitted within `try` blocks:
```rust
let _: Result<(), ()> = try {
    'foo: {
        Err(())?;
        break 'foo;
    }
};
```

label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
    || break 'a
    //~^ ERROR use of unreachable label `'a`
    //~| ERROR `break` inside of a closure
}
```

label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
    match false 'b: { //~ ERROR block label not supported here
        _ => {}
    }
}

macro_rules! m {
    ($b:block) => {
        'lab: $b; //~ ERROR cannot use a `block` macro fragment here
        unsafe $b; //~ ERROR cannot use a `block` macro fragment here
        |x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here
    }
}

fn foo() {
    m!({});
}
```

[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
2022-08-23 21:14:12 -05:00
Matthew Kelly
231e3a0415 actually fix typo this time 2022-08-23 05:26:47 -04:00
Matthew Kelly
dbcc409556 Improve E0311.md description 2022-08-23 05:19:04 -04:00
Matthew Kelly
a9cefd0441 fix line lengths 2022-08-19 10:53:14 -04:00
Matthew Kelly
63de1ec070
Apply suggestions from code review
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2022-08-19 09:34:20 -04:00
Matthew Kelly
fa91980d2d Add long description and test for E0311
Adds a long description and unit test for the E0311 compiler error.
2022-08-19 06:46:37 -04:00
5225225
09ea9f0a87 Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
lcnr
43ccacf89b region_outlives_predicate no snapshot 2022-07-21 13:09:01 +02:00
bors
9a7b7d5e50 Auto merge of #98180 - notriddle:notriddle/rustdoc-fn, r=petrochenkov,GuillaumeGomez
Improve the function pointer docs

This is #97842 but for function pointers instead of tuples. The concept is basically the same.

* Reduce duplicate impls; show `fn (T₁, T₂, …, Tₙ)` and include a sentence saying that there exists up to twelve of them.
* Show `Copy` and `Clone`.
* Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.

https://notriddle.com/notriddle-rustdoc-test/std/primitive.fn.html
2022-07-19 19:36:57 +00:00
Michael Howell
5271e32c46 Improve the function pointer docs
* Reduce duplicate impls; show only the `fn (T)` and include a sentence
  saying that there exists up to twelve of them.
* Show `Copy` and `Clone`.
* Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.
2022-07-19 08:52:24 -07:00
aticu
38ea23558e Don't use main; improve example 2022-07-19 10:23:34 +02:00
aticu
1cbacc0c8a Add E0790 as more specific variant of E0283 2022-07-19 10:16:10 +02:00
Jane Losare-Lusby
e4e6b1ebc6 fixes post rebase 2022-07-08 21:18:16 +00:00
Jane Lusby
b55453dbad add opt in attribute for stable-in-unstable items 2022-07-08 21:18:15 +00:00
Dylan DPC
45740acd34
Rollup merge of #97423 - m-ou-se:memory-ordering-intrinsics, r=tmiasko
Simplify memory ordering intrinsics

This changes the names of the atomic intrinsics to always fully include their memory ordering arguments.

```diff
- atomic_cxchg
+ atomic_cxchg_seqcst_seqcst

- atomic_cxchg_acqrel
+ atomic_cxchg_acqrel_release

- atomic_cxchg_acqrel_failrelaxed
+ atomic_cxchg_acqrel_relaxed

// And so on.
```

- `seqcst` is no longer implied
- The failure ordering on chxchg is no longer implied in some cases, but now always explicitly part of the name.
- `release` is no longer shortened to just `rel`. That was especially confusing, since `relaxed` also starts with `rel`.
- `acquire` is no longer shortened to just `acq`, such that the names now all match the `std::sync::atomic::Ordering` variants exactly.
- This now allows for more combinations on the compare exchange operations, such as `atomic_cxchg_acquire_release`, which is necessary for #68464.
- This PR only exposes the new possibilities through unstable intrinsics, but not yet through the stable API. That's for [a separate PR](https://github.com/rust-lang/rust/pull/98383) that requires an FCP.

Suffixes for operations with a single memory order:

| Order   | Before       | After      |
|---------|--------------|------------|
| Relaxed | `_relaxed`   | `_relaxed` |
| Acquire | `_acq`       | `_acquire` |
| Release | `_rel`       | `_release` |
| AcqRel  | `_acqrel`    | `_acqrel`  |
| SeqCst  | (none)       | `_seqcst`  |

Suffixes for compare-and-exchange operations with two memory orderings:

| Success | Failure | Before                   | After              |
|---------|---------|--------------------------|--------------------|
| Relaxed | Relaxed | `_relaxed`               | `_relaxed_relaxed` |
| Relaxed | Acquire |                       | `_relaxed_acquire` |
| Relaxed | SeqCst  |                       | `_relaxed_seqcst`  |
| Acquire | Relaxed | `_acq_failrelaxed`       | `_acquire_relaxed` |
| Acquire | Acquire | `_acq`                   | `_acquire_acquire` |
| Acquire | SeqCst  |                       | `_acquire_seqcst`  |
| Release | Relaxed | `_rel`                   | `_release_relaxed` |
| Release | Acquire |                       | `_release_acquire` |
| Release | SeqCst  |                       | `_release_seqcst`  |
| AcqRel  | Relaxed | `_acqrel_failrelaxed`    | `_acqrel_relaxed`  |
| AcqRel  | Acquire | `_acqrel`                | `_acqrel_acquire`  |
| AcqRel  | SeqCst  |                       | `_acqrel_seqcst`   |
| SeqCst  | Relaxed | `_failrelaxed`           | `_seqcst_relaxed`  |
| SeqCst  | Acquire | `_failacq`               | `_seqcst_acquire`  |
| SeqCst  | SeqCst  | (none)                   | `_seqcst_seqcst`   |
2022-06-29 10:28:18 +05:30
Mara Bos
4982a59986 Rename/restructure memory ordering intrinsics. 2022-06-28 08:58:27 +02:00
onlinesoftwaredevok
99672fb2dc Add comment for internal error codes 2022-06-12 19:52:49 -03:00
Dylan DPC
f1f44b9e4d
Rollup merge of #96868 - nrc:turbo-stable, r=jhpratt,nbdd0121,nagisa
Stabilize explicit_generic_args_with_impl_trait

This is a stabilisation PR for `explicit_generic_args_with_impl_trait`.

* [tracking issue](https://github.com/rust-lang/rust/issues/83701)
  - [Stabilisation report](https://github.com/rust-lang/rust/issues/83701#issuecomment-1109949897)
  - [FCP entered](https://github.com/rust-lang/rust/issues/83701#issuecomment-1120285703)
* [implementation PR](https://github.com/rust-lang/rust/pull/86176)
* [Reference PR](https://github.com/rust-lang/reference/pull/1212)
* There is no mention of using the turbofish operator in the book (other than an entry in the operator list in the appendix), so there is no documentation to change/add there, unless we felt like we should add a section on using turbofish, but that seems orthogonal to `explicit_generic_args_with_impl_trait`
2022-06-11 07:42:12 +02:00
CorinJG
6227d89d6a E0577 fixed Sea struct CamelCase/sea module snake_case 2022-06-10 14:21:40 +01:00
CorinJG
20e166eab4 Fixed several error_codes/Exxxx.md messages which used UpperCamelCase instead of snake_case for module names 2022-06-10 11:25:47 +01:00
Vadim Petrochenkov
a8ee1f3a4f Stabilize the bundle native library modifier 2022-06-09 23:12:58 +04:00
bors
bb55bd449e Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakis
Remove migrate borrowck mode

Closes #58781
Closes #43234

# Stabilization proposal

This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile.

Tracking issue: #43234
RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md
Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable).

## Motivation

Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors.

The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition.

In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker.

In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver.

While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff.

## What is stabilized

As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise.

There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl.

As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions.

## What isn't stabilized

This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck.

## Tests

Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll`

## History

* On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234)
* On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271)
* On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094)
* On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825)
* On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862)
* On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083)
* On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681)
* On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114)
* On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221)
* On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-07 05:04:14 +00:00
Dylan DPC
99afe26032
Rollup merge of #97787 - matthiaskrgr:e0432_explain, r=Dylan-DPC
E0432: rust 2018 -> rust 2018 or later    in --explain message
2022-06-06 14:34:59 +02:00
Dylan DPC
cb787bea46
Rollup merge of #97495 - clarfonthey:e0788-no-coverage, r=nagisa
Add E0788 for improper #[no_coverage] usage

Essentially, this adds proper checking for the attribute (tracking issue #84605) and throws errors when it's put in obviously-wrong places, like on struct or const definitions. Most of the code is taken directly from the checks for the `#[inline]` attribute, since it's very similar.

Right now, the code only checks at the function level, but it seems reasonable to allow adding `#[no_coverage]` to individual blocks or expressions, so, for now those just throw `unused_attributes` warnings. Similarly, since there was a lot of desire to eventually allow recursive definitions as well on modules and impl blocks, these also throw `unused_attributes` instead of an error.

I'm not sure if anything has to be done since this error is technically for an unstable feature, but since an error for using unstable features will show up anyway, I think it's okay.

This is the first big piece needed for stabilising this attribute, although I personally would like to explore renaming it to `#[coverage(never)]` on a separate PR, which I will offer soon. There's a lot of discussion still to be had about that, which is why it will be kept separate.

I don't think much is needed besides adding this simple check and a UI test, but let me know if there's something else that should be added to make this happen.
2022-06-06 14:34:56 +02:00
Nick Cameron
640a461388 Deactivate feature gate explicit_generic_args_with_impl_trait
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-06-06 12:21:49 +01:00
Matthias Krüger
343c135e0c E0432: rust 2018 -> rust 2018 or later in --explain message 2022-06-06 11:58:49 +02:00
ltdk
9473e21955 Changes from code review 2022-06-05 22:24:14 -04:00
Jack Huey
410dcc9674 Fully stabilize NLL 2022-06-03 17:16:41 -04:00
Camille GILLOT
2aa9c703ce Use the same message as type & const generics. 2022-06-03 08:26:10 +02:00
ltdk
5fabdb8f7f Add E0788 for improper #[no_coverage] usage 2022-05-28 17:20:43 -04:00
Vadim Petrochenkov
4fa24bcb54 rustc: Stricter checking for #[link] attributes 2022-05-15 02:45:47 +03:00
bors
8a2fe75d0e Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors
Remove `#[rustc_deprecated]`

This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`.

I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-05-09 04:47:30 +00:00
CAD97
09f758fe3b Remove ``` `ignore``` from E0705 test 2022-04-30 10:48:38 -05:00
Jacob Pratt
dac487ae2b
Add note to E0550
With the change to built-in duplicate checking, E0550 is no longer
emitted.
2022-04-14 22:44:21 -04:00
Jacob Pratt
bfdf234fae
Update error code docs 2022-04-14 21:19:46 -04:00
lcnr
00cf7af44a rework error messages for incorrect inherent impls 2022-03-30 11:23:58 +02:00
Guillaume Gomez
eae2903150 Add long error explanation for E0667 2022-03-27 14:09:52 +02:00
Matthias Krüger
939c1585a4
Rollup merge of #94555 - cuishuang:master, r=oli-obk
all: fix some typos

Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-03 20:01:48 +01:00
cuishuang
00fffdddd2 all: fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-03 19:47:23 +08:00
Thiago Trannin
bc31b3e5ef Remove out-of-context line at end of E0284 message 2022-03-02 10:09:02 -03:00
Matthias Krüger
34657ccbe7
Rollup merge of #94449 - GuillaumeGomez:explanation-e0726, r=Urgau
Add long explanation for E0726

This is the cleaned up version of #87655 with the missing fixes.

Part of https://github.com/rust-lang/rust/issues/61137.

r? `@Urgau`
2022-02-28 20:05:18 +01:00
Guillaume Gomez
911de7b98c Add explanation for E0726 2022-02-28 15:51:05 +01:00
Michael Goulet
bb548a918a Remove in-band lifetimes 2022-02-24 18:50:33 -08:00
Oli Scherer
86d17b98f2 Revert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk"
This reverts commit 3cfa4def7c, reversing
changes made to 5d8767cb22.
2022-02-17 16:00:04 +00:00
bors
3cfa4def7c Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk
Inherit lifetimes for async fn instead of duplicating them.

The current desugaring of `async fn foo<'a>(&usize) -> &u8` is equivalent to
```rust
fn foo<'a, '0>(&'0 usize) -> foo<'static, 'static>::Opaque<'a, '0, '_>;
type foo<'_a, '_0>::Opaque<'a, '0, '1> = impl Future<Output = &'1 u8>;
```
following the RPIT model.

Duplicating all the inherited lifetime parameters and setting the inherited version to `'static` makes lowering more complex and causes issues like #61949. This PR removes the duplication of inherited lifetimes to directly use
```rust
fn foo<'a, '0>(&'0 usize) -> foo<'a, '0>::Opaque<'_>;
type foo<'a, '0>::Opaque<'1> = impl Future<Output = &'1 u8>;
```
following the TAIT model.

Fixes https://github.com/rust-lang/rust/issues/61949
2022-02-12 21:42:10 +00:00
Camille GILLOT
c6a3f5d606 Update error code documentation. 2022-02-12 01:26:17 +01:00
Guillaume Gomez
087fb23dc9 Add missing E0192 in the error code listing 2022-02-12 00:43:09 +01:00
Matthias Krüger
58bfe72f52
Rollup merge of #91939 - GKFX:feature-91866, r=cjgillot
Clarify error on casting larger integers to char

Closes #91836 with changes to E0604.md and a `span_help`.
2022-02-06 04:13:29 +01:00
Matthias Krüger
11898a56c2
Rollup merge of #88205 - danii:e0772, r=GuillaumeGomez
Add Explanation For Error E0772

I've added an error explanation for the error code E0772.

Assists with #61137
2022-01-29 14:46:29 +01:00
Daniel Conley
4f8b9a4126
Add Explanation For Error E0772 2022-01-28 11:00:56 -05:00
Tomasz Miąsko
888332fee4 Reject unsupported naked functions
Transition unsupported naked functions future incompatibility lint into
an error:

* Naked functions must contain a single inline assembly block.
  Introduced as future incompatibility lint in 1.50 #79653.
  Change into an error fixes a soundness issue described in #32489.

* Naked functions must not use any forms of inline attribute.
  Introduced as future incompatibility lint in 1.56 #87652.
2022-01-21 17:38:21 +01:00
Matthias Krüger
4de63e7c23
Rollup merge of #92752 - jamestiotio:error-codes-typos, r=nagisa
Correct minor typos in some long error code explanations

Just a little nitpick to improve the long explanations of the error codes. 😊
2022-01-17 20:07:04 +01:00
Tomasz Miąsko
b085eb0b10 Error codes specific to LLVM-style inline asssembly are no longer emitted 2022-01-12 21:43:36 +01:00
James R T
842bf71fda
fix(compiler): correct minor typos in some long error code explanations 2022-01-11 10:42:51 +08:00
TmLev
406d6d4028 docs(error-codes): Add long error explanation for E0227 2021-12-28 15:46:20 +03:00
George Bateman
a15cb49362
#91836: Clarify error on casting larger integers to char 2021-12-14 21:49:49 +00:00
Graydon Hoare
7907fa8ec4
Clarify and tidy up explanation of E0038 2021-11-30 09:25:17 -08:00
bstrie
3024efff59 Update Copy/Clone documentation WRT arrays 2021-11-08 13:11:59 -05:00