about summary refs log tree commit diff
path: root/compiler/rustc_attr/src
AgeCommit message (Collapse)AuthorLines
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)
2021-02-10Tweak stability attribute diagnostic outputEsteban Küber-11/+16
2021-02-05Never MIR inline functions with a different instruction setTomasz Miąsko-1/+1
2021-01-30Rollup merge of #81468 - est31:cfg_version, r=petrochenkovYuki Okushi-4/+6
cfg(version): treat nightlies as complete This PR makes cfg(version) treat the nightlies for version 1.n.0 as 1.n.0, even though that nightly version might not have all stabilizations and features of the released 1.n.0. This is done for greater convenience for people who want to test a newly stabilized feature on nightly, or in other words, give newly stabilized features as many eyeballs as possible. For users who wish to pin nightlies, this commit adds a -Z assume-incomplete-release option that they can enable if they run into any issues due to this change. Implements the suggestion in https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454
2021-01-29Treat nightlies for a version as completeest31-4/+6
This commit makes cfg(version) treat the nightlies for version 1.n.0 as 1.n.0, even though that nightly version might not have all stabilizations and features of the released 1.n.0. This is done for greater convenience for people who want to test a newly stabilized feature on nightly. For users who wish to pin nightlies, this commit adds a -Z assume-incomplete-release option that they can enable if there are any issues due to this change.
2021-01-26Auto merge of #80692 - Aaron1011:feature/query-result-debug, r=estebankbors-3/+3
Enforce that query results implement Debug Currently, we require that query keys implement `Debug`, but we do not do the same for query values. This can make incremental compilation bugs difficult to debug - there isn't a good place to print out the result loaded from disk. This PR adds `Debug` bounds to several query-related functions, allowing us to debug-print the query value when an 'unstable fingerprint' error occurs. This required adding `#[derive(Debug)]` to a fairly large number of types - hopefully, this doesn't have much of an impact on compiler bootstrapping times.
2021-01-24Replace version_check dependency with own version parsing codeest31-4/+28
This gives compiler maintainers a better degree of control over how the version gets parsed and is a good way to ensure that there are no changes of behaviour in the future. Also, issue a warning if the version is invalid instead of erroring so that we stay forwards compatible with possible future changes of the versioning scheme. Last, this improves the present test a little.
2021-01-16Enforce that query results implement DebugAaron Hill-3/+3
2020-12-14Get rid of `clean::Deprecation`Joshua Nelson-1/+1
This brings the size of `item.deprecation` from 56 to 16 bytes.
2020-12-01Created NestedMetaItem::name_value_literal_span methodGuillaume Gomez-1/+1