about summary refs log tree commit diff
path: root/compiler/rustc_attr/src
AgeCommit message (Collapse)AuthorLines
2022-07-21avoid embedding StabilityLevel::Unstable reason string into metadata ↵klensy-2/+33
multiple times
2022-07-20middle: add `implies_by` to `#[unstable]`David Wood-1/+27
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-20attr: fix expected meta-item for `#[stable]`David Wood-1/+1
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-20attr/passes: comment -> doc commentDavid Wood-3/+16
Change some regular comments into documentation comments. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-16Stabilize `let_chains`Caio-1/+1
2022-07-14Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillotbors-2/+27
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-08fixes post rebaseJane Losare-Lusby-1/+1
2022-07-08add opt in attribute for stable-in-unstable itemsJane Lusby-2/+27
2022-07-07`UnsafeCell` now has no niches, ever.Oli Scherer-5/+3
2022-06-14Remove `rustc_deprecated` diagnosticsJacob Pratt-28/+1
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-2/+2
2022-05-24RFC3239: Implement compact `cfg(target(..))`Loïc BRANSTETT-0/+20
2022-05-24Clean up condition evaluation systemLoïc BRANSTETT-58/+64
2022-05-19Add and use stability helper methodsJacob Pratt-0/+20
This avoids an ambiguity (when reading) where `.level.is_stable()` is not immediately clear whether it is general stability or const stability.
2022-05-10only_local: always check for misuselcnr-138/+141
2022-04-14Use native duplicate attribute checkJacob Pratt-8/+0
2022-04-14Error on `#[rustc_deprecated]`Jacob Pratt-2/+22
2022-03-20Rollup merge of #94948 - jhpratt:rustc_deprecated, r=Dylan-DPCMatthias Krüger-5/+4
Fix diagnostics for `#![feature(deprecated_suggestion)]` Follow up from #94635, where I missed a couple things.
2022-03-18Rollup merge of #94295 - Urgau:cfg-always-eval-all-predicate, r=petrochenkovMatthias Krüger-2/+10
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-15Correct meta item diagnosticJacob Pratt-3/+3
2022-03-15Include tracking issue in diagnosticJacob Pratt-2/+1
2022-03-10Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwcoMatthias Krüger-11/+24
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-09Permit `#[deprecated]` in stdlibJacob Pratt-3/+6
2022-03-09New `deprecated_suggestion` feature, use in testsJacob Pratt-5/+13
2022-03-05Improve unexpected_cfgs lint when their is no value expectedLoïc BRANSTETT-4/+3
2022-03-04Change `rustc_deprecated` to use `note`Jacob Pratt-3/+5
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-01Improve allowness of the unexpected_cfgs lintLoïc BRANSTETT-5/+9
2022-02-24Rollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkovDylan DPC-16/+25
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-23Always evaluate all cfg predicate in all() and any()Loïc BRANSTETT-2/+10
2022-02-23Continue improvements on the --check-cfg implementationLoïc BRANSTETT-22/+17
- Test the combinations of --check-cfg with partial values() and --cfg - Test that we detect unexpected value when none are expected
2022-02-22Improve diagnostic of the unexpected_cfgs lintLoïc BRANSTETT-2/+13
2022-02-22Improve CheckCfg internal representationLoïc BRANSTETT-14/+17
2022-02-20Rollup merge of #94146 - est31:let_else, r=cjgillotMatthias Krüger-14/+10
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-19Adopt let else in more placesest31-14/+10
2022-02-16Implement --check-cfg option (RFC 3013)Loïc BRANSTETT-3/+28
Co-authored-by: Urgau <lolo.branstett@numericable.fr> Co-authored-by: Marcelina Kościelnicka <mwk@0x04.net>
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-1/+1
2022-02-02More let_else adoptionsest31-71/+69
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-3/+3
2021-11-30re-format with new rustfmtMark Rousskov-2/+4
2021-10-16Correct typonhamovitz-1/+1
2021-10-03Move some HashStable impls.Camille GILLOT-3/+3
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-16/+9
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-03rustc: Fill out remaining parts of C-unwind ABIAlex Crichton-44/+0
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-07-09Enhance well-formedness checks for `#[repr(...)]` attributesFabian Wolff-8/+96
2021-05-24remove cfg(bootstrap)Pietro Albini-2/+0
2021-04-05Allow specifying alignment for functionsWesley Norris-36/+14
2021-03-19stabilize or_patternsmark-1/+1
2021-03-05Auto merge of #71481 - estebank:inherit-stability, r=nikomatsakisbors-11/+16
Inherit `#[stable(..)]` annotations in enum variants and fields from its item Lint changes for #65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.
2021-02-21remove redundant wrapping of return types of allow_internal_unstable() and ↵Matthias Krüger-4/+4
rustc_allow_const_fn_unstable()
2021-02-21remove unneccessary wrapping of return value of allow_unstable(), it would ↵Matthias Krüger-5/+5
always return Some(thing)