about summary refs log tree commit diff
path: root/compiler/rustc_passes
AgeCommit message (Collapse)AuthorLines
2022-04-02Rollup merge of #95544 - jam1garner:improve-naked-noreturn-diagnostic, r=tmiaskoDylan DPC-1/+14
Add error message suggestion for missing noreturn in naked function I had to google the syntax for inline asm's `noreturn` option when I got this error earlier today, so I figured I'd save others the trouble and add the syntax/fix as a suggestion in the error.
2022-04-02Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnrDylan DPC-4/+7
Handle rustc_const_stable attribute in library feature collector The library feature collector in [compiler/rustc_passes/src/lib_features.rs](https://github.com/rust-lang/rust/blob/551b4fa395fa588d91cbecfb0cdfe1baa02670cf/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were: - When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable". This can be seen in the way that https://github.com/rust-lang/rust/pull/93957#issuecomment-1079794660 failed after rebase: ```console error[E0635]: unknown feature `const_ptr_offset` --> $DIR/offset_from_ub.rs:1:35 | LL | #![feature(const_ptr_offset_from, const_ptr_offset)] | ^^^^^^^^^^^^^^^^ ``` - We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes. This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
2022-04-01Reword purpose description of noreturn in naked functionjam1garner-1/+1
2022-04-01Don't emit non-asm contents error for naked function composed of errorsjam1garner-3/+22
2022-03-31Add error message suggestion for missing noreturn in naked functionjam1garner-1/+14
2022-03-31Handle rustc_const_stable attribute in library feature collectorDavid Tolnay-4/+7
2022-03-31Merge impl_constness and is_const_fn_raw.Camille GILLOT-1/+1
2022-03-31Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errorsDylan DPC-4/+4
Spellchecking compiler comments This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-1/+1
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30Addressed comments by @compiler-errors and @bjorn3Yuri Astrakhan-1/+1
2022-03-30Spellchecking compiler commentsYuri Astrakhan-5/+5
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30rework implementation for inherent impls for builtin typeslcnr-0/+21
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-1/+1
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-22use `format-args-capture` and remove unnecessary nested if blocks in some ↵Takayuki Maeda-78/+61
parts of rustc_passes break before the `&&` Update compiler/rustc_passes/src/check_const.rs Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2022-03-16rustc_error: make ErrorReported impossible to constructmark-7/+7
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-16Reject `#[thread_local]` attribute on non-static itemsTomasz Miąsko-0/+16
2022-03-15Support other types of pluralization in pluralize macroest31-1/+1
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-12/+12
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-10Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwcoMatthias Krüger-1/+1
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-1/+1
2022-03-09Rollup merge of #94686 - ChayimFriedman2:issue-94629, r=jackh726Dylan DPC-1/+1
Do not allow `#[rustc_legacy_const_generics]` on methods It caused an ICE since `item` was `None`. Fixes #94629.
2022-03-08Rollup merge of #94580 - xFrednet:55112-only-reason-in-lint-attr, r=lcnrMatthias Krüger-29/+51
Emit `unused_attributes` if a level attr only has a reason Fixes a comment from `compiler/rustc_lint/src/levels.rs`. Lint level attributes that only contain a reason will also trigger the `unused_attribute` lint. The lint now also checks for the `expect` lint level. That's it, have a great rest of the day for everyone reasoning this :upside_down_face: cc: #55112
2022-03-07Do not allow `#[rustc_legacy_const_generics]` on methodsChayim Refael Friedman-1/+1
It caused an ICE since `item` was `None`.
2022-03-05Auto merge of #93142 - estebank:missing-main, r=wesleywiserbors-3/+3
Do not point at whole file missing `fn main` Only point at the end of the crate. We could try making it point at the beginning of the crate, but that is confused with `DUMMY_SP`, causing the output to be *worse*. This change will make it so that VSCode will *not* underline the whole file when `main` is missing, so other errors will be visible.
2022-03-05Do not point at whole file missing `fn main`Esteban Kuber-3/+3
Only point at the end of the crate. We could try making it point at the beginning of the crate, but that is confused with `DUMMY_SP`, causing the output to be *worse*. This change will make it so that VSCode will *not* underline the whole file when `main` is missing, so other errors will be visible.
2022-03-03Emit `unused_attributes` if a level attr only has a reasonxFrednet-29/+51
2022-03-03Make unknown feature error deterministic.Camille GILLOT-3/+3
2022-03-03Gate stability attrs with other attributes.Camille GILLOT-56/+9
2022-03-03Move query providers.Camille GILLOT-1/+10
2022-03-03Remove useless map.Camille GILLOT-9/+5
2022-03-03Move the set of features to the `features` query.Camille GILLOT-11/+0
2022-03-01Rollup merge of #94448 - c410-f3r:yet-more-let-chains, r=estebankDylan DPC-68/+63
5 - Make more use of `let_chains` Continuation of #94376. cc #53667
2022-03-01Rollup merge of #93926 - PatchMixolydic:bugfix/must_use-on-exprs, r=cjgillotDylan DPC-1/+34
Lint against more useless `#[must_use]` attributes This expands the existing `#[must_use]` check in `unused_attributes` to lint against pretty much everything `#[must_use]` doesn't support. Fixes #93906.
2022-02-285 - Make more use of let_chainsCaio-68/+63
2022-02-27Lint against more useless `#[must_use]` attributesRuby Lazuli-1/+34
This expands the existing `#[must_use]` check in `unused_attributes` to lint against pretty much everything `#[must_use]` doesn't support. Fixes #93906.
2022-02-25`check_used` should only look at actual `used` attributescynecx-2/+2
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-3/+5
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-1/+1
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-24Auto merge of #94129 - cjgillot:rmeta-table, r=petrochenkovbors-10/+8
Back more metadata using per-query tables r? `@ghost`
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-3/+5
2022-02-21Take CodegenFnAttrs into account when validating asm! register operandsAmanieu d'Antras-15/+28
Checking of asm! register operands now properly takes function attributes such as #[target_feature] and #[instruction_set] into account.
2022-02-19Adopt let else in more placesest31-60/+42
2022-02-19Stop interning stability.Camille GILLOT-10/+8
2022-02-12change to a struct variantEllen-1/+1
2022-02-09Rollup merge of #91504 - cynecx:used_retain, r=nikicMatthias Krüger-1/+38
`#[used(linker)]` attribute See https://github.com/dtolnay/linkme/issues/41#issuecomment-927255631.
2022-02-08add more tests and make used(linker/compiler) mutually exclusivecynecx-0/+34
2022-02-06`#[used(linker)]` attribute (https://github.com/dtolnay/linkme/issues/41)cynecx-1/+4
2022-02-06Rollup merge of #90998 - jhpratt:require-const-stability, r=oli-obkMatthias Krüger-18/+18
Require const stability attribute on all stable functions that are `const` This PR requires all stable functions (of all kinds) that are `const fn` to have a `#[rustc_const_stable]` or `#[rustc_const_unstable]` attribute. Stability was previously implied if omitted; a follow-up PR is planned to change the fallback to be unstable.
2022-02-03Require const stability on all stable const itemsJacob Pratt-18/+18
This was supposed to be the case previously, but a missed method call meant that trait impls were not checked.