Commit Graph

87 Commits

Author SHA1 Message Date
Nilstrieb
d1ef8180f9 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Takayuki Maeda
b33c3d6cd6 use smaller span for suggestions 2022-08-27 15:22:08 +09:00
Hampus Lidin
afd34765f6 Move LitKind logic to session_diagnostics module 2022-08-22 20:19:20 +02:00
Hampus Lidin
944a3e22ef Change to diag attributes 2022-08-22 20:19:19 +02:00
Hampus Lidin
1c28006bf6 Reorder diagnostics in code order, then alphabetical order 2022-08-22 20:19:19 +02:00
Hampus Lidin
c4f59605d2 Refactor remaining diagnostics 2022-08-22 20:19:19 +02:00
Hampus Lidin
b3be7698d6 Refactor additional diagnostics in rustc_attr 2022-08-22 20:19:19 +02:00
Hampus Lidin
40c5184eec Add internal diagnistics lints 2022-08-22 20:19:19 +02:00
Hampus Lidin
83a724eab5 Refactor more diagnostics in rustc_attr 2022-08-22 20:19:19 +02:00
Hampus Lidin
0005f628f0 Refactor diagnostics in handle_errors function 2022-08-22 20:19:15 +02:00
Mark Rousskov
154a09dd91 Adjust cfgs 2022-08-12 16:28:15 -04:00
Maybe Waffle
e11b4b8e02 Panic when checking an unknown stability attribute 2022-07-31 16:02:45 +04:00
Maybe Waffle
177af47104 Implement #[rustc_default_body_unstable]
This attribute allows to mark default body of a trait function as
unstable. This means that implementing the trait without implementing
the function will require enabling unstable feature.

This is useful in conjunction with `#[rustc_must_implement_one_of]`,
we may want to relax requirements for a trait, for example allowing
implementing either of `PartialEq::{eq, ne}`, but do so in a safe way
-- making implementation of only `PartialEq::ne` unstable.
2022-07-26 15:38:03 +04:00
klensy
b38c94857d avoid embedding StabilityLevel::Unstable reason string into metadata multiple times 2022-07-21 22:53:02 +03:00
David Wood
224aec213d middle: add implies_by to #[unstable]
If part of a feature is stabilized and a new feature is added for the
remaining parts, then the `implied_by` attribute can be used to indicate
which now-stable feature previously contained a item. If the now-stable
feature is still active (if the user has only just updated rustc, for
example) then there will not be an stability error for uses of the item
from the implied feature.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20 14:53:01 +01:00
David Wood
a1d5af24ec attr: fix expected meta-item for #[stable]
When an unexpected meta item is provided to `#[stable]`, the diagnostic
lists "since" and "note" as expected meta-items, however the surrounding
code actually expects "feature" and "since".

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20 11:29:56 +01:00
David Wood
6f0b8f1a4b attr/passes: comment -> doc comment
Change some regular comments into documentation comments.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20 11:29:56 +01:00
Caio
3266460749 Stabilize let_chains 2022-07-16 20:17:58 -03:00
bors
24699bcbad Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot
Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of https://github.com/rust-lang/rust/pull/90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
2022-07-14 13:42:09 +00: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
Oli Scherer
2a899dc1cf UnsafeCell now has no niches, ever. 2022-07-07 10:46:22 +00:00
Jacob Pratt
fb05b53745
Remove rustc_deprecated diagnostics 2022-06-14 19:46:13 -04:00
Takayuki Maeda
77d6176e69 remove unnecessary to_string and String::new 2022-06-13 15:48:40 +09:00
Loïc BRANSTETT
8345571cd0 RFC3239: Implement compact cfg(target(..)) 2022-05-24 13:51:36 +02:00
Loïc BRANSTETT
ae38533ed7 Clean up condition evaluation system 2022-05-24 13:43:08 +02:00
Jacob Pratt
a9dd4cfa6b Add and use stability helper methods
This avoids an ambiguity (when reading) where `.level.is_stable()` is
not immediately clear whether it is general stability or const
stability.
2022-05-19 12:21:45 +00:00
lcnr
6c8265dc56 only_local: always check for misuse 2022-05-10 12:07:35 +02:00
Jacob Pratt
0b3db4e4ee
Use native duplicate attribute check 2022-04-14 21:19:48 -04:00
Jacob Pratt
e46f8b23dd
Error on #[rustc_deprecated] 2022-04-14 21:19:44 -04:00
Matthias Krüger
db374bd440
Rollup merge of #94948 - jhpratt:rustc_deprecated, r=Dylan-DPC
Fix diagnostics for `#![feature(deprecated_suggestion)]`

Follow up from #94635, where I missed a couple things.
2022-03-20 09:14:59 +01:00
Matthias Krüger
d15006ceca
Rollup merge of #94295 - Urgau:cfg-always-eval-all-predicate, r=petrochenkov
Always evaluate all cfg predicate in all() and any()

This pull-request adjust the handling of the `all()` and `any()` to always evaluate every cfg predicate because not doing so result in accepting incorrect `cfg`:

```rust
#[cfg(any(unix, foo::bar))] // Should error on foo::bar, but does not on unix platform (but does on non unix platform)
fn foo1() {}

#[cfg(all(foo, foo::bar))] // Should error on foo::bar, but does not
fn foo2() {}

#[cfg(all(foo::bar, foo))] // Correctly error on foo::bar
fn foo3() {}

#[cfg(any(foo::bar, foo))] // Correctly error on foo::bar
fn foo4() {}
```
This pull-request take the side to directly turn it into a hard error instead of having a future incompatibility lint because the combination to get this incorrect behavior is unusual and highly probable that some code have this without noticing.

A [search](https://cs.github.com/?scopeName=All+repos&scope=&q=lang%3Arust+%2Fany%5C%28%5Ba-zA-Z%5D%2C+%5Ba-zA-Z%5D%2B%3A%3A%5Ba-zA-Z%5D%2B%2F) on Github reveal no such instance nevertheless a Crater run should probably be done before merging this.

This was discover in https://github.com/rust-lang/rust/pull/94175 when trying to lint on the second predicate. Also note that this seems to have being introduce with Rust 1.27.0: https://rust.godbolt.org/z/KnfqKv15f.

r? `@petrochenkov`
2022-03-18 21:50:46 +01:00
Jacob Pratt
06a1fc98eb
Correct meta item diagnostic 2022-03-15 19:38:59 -04:00
Jacob Pratt
08fbe3dafa
Include tracking issue in diagnostic 2022-03-15 19:38:57 -04:00
Matthias Krüger
313a668234
Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwco
Merge `#[deprecated]` and `#[rustc_deprecated]`

The first commit makes "reason" an alias for "note" in `#[rustc_deprecated]`, while still prohibiting it in `#[deprecated]`.

The second commit changes "suggestion" to not just be a feature of `#[rustc_deprecated]`. This is placed behind the new `deprecated_suggestion` feature. This needs a tracking issue; let me know if this PR will be approved and I can create one.

The third commit is what permits `#[deprecated]` to be used when `#![feature(staged_api)]` is enabled. This isn't yet used in stdlib (only tests), as it would require duplicating all deprecation attributes until a bootstrap occurs. I intend to submit a follow-up PR that replaces all uses and removes the remaining `#[rustc_deprecated]` code after the next bootstrap.

`@rustbot` label +T-libs-api +C-feature-request +A-attributes +S-waiting-on-review
2022-03-10 12:20:51 +01:00
Jacob Pratt
38478ea0cd
Permit #[deprecated] in stdlib 2022-03-09 16:32:47 -05:00
Jacob Pratt
5636655d0f
New deprecated_suggestion feature, use in tests 2022-03-09 16:32:47 -05:00
Loïc BRANSTETT
92544f43b0 Improve unexpected_cfgs lint when their is no value expected 2022-03-05 12:11:05 +01:00
Jacob Pratt
6efc8e34d8
Change rustc_deprecated to use note
This keeps `reason` around for the time being. This is necessary to
avoid breakage during the bootstrap process. This change, as a whole,
brings `#[rustc_deprecated]` more in line with `#[deprecated]`.
2022-03-04 18:15:49 -05:00
Loïc BRANSTETT
765205b9b8 Improve allowness of the unexpected_cfgs lint 2022-03-01 14:29:12 +01:00
Dylan DPC
000e38d9cb
Rollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkov
Improve `--check-cfg` implementation

This pull-request is a mix of improvements regarding the `--check-cfg` implementation:

- Simpler internal representation (usage of `Option` instead of separate bool)
- Add --check-cfg to the unstable book (based on the RFC)
- Improved diagnostics:
    * List possible values when the value is unexpected
    * Suggest if possible a name or value that is similar
- Add more tests (well known names, mix of combinations, ...)

r? ```@petrochenkov```
2022-02-24 21:42:13 +01:00
Loïc BRANSTETT
f57cc8ca5c Always evaluate all cfg predicate in all() and any() 2022-02-23 15:44:57 +01:00
Loïc BRANSTETT
8d3de56da1 Continue improvements on the --check-cfg implementation
- Test the combinations of --check-cfg with partial values() and --cfg
- Test that we detect unexpected value when none are expected
2022-02-23 13:22:23 +01:00
Loïc BRANSTETT
3d234770b1 Improve diagnostic of the unexpected_cfgs lint 2022-02-22 23:17:13 +01:00
Loïc BRANSTETT
da896d35f4 Improve CheckCfg internal representation 2022-02-22 22:41:49 +01:00
Matthias Krüger
f2d6770f77
Rollup merge of #94146 - est31:let_else, r=cjgillot
Adopt let else in more places

Continuation of #89933, #91018, #91481, #93046, #93590, #94011.

I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.
2022-02-20 00:37:34 +01:00
est31
2ef8af6619 Adopt let else in more places 2022-02-19 17:27:43 +01:00
Loïc BRANSTETT
3a73ca587b Implement --check-cfg option (RFC 3013)
Co-authored-by: Urgau <lolo.branstett@numericable.fr>
Co-authored-by: Marcelina Kościelnicka <mwk@0x04.net>
2022-02-16 13:03:12 +01:00
Camille GILLOT
6c2ee885e6 Ensure that queries only return Copy types. 2022-02-09 20:07:38 +01:00
est31
670f5c6ef3 More let_else adoptions 2022-02-02 17:11:01 +01:00