about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2022-08-27Expand the version placeholder to the current version in stability attribute ↵est31-0/+8
parsing That way, the current version is shown in rustdoc etc.
2022-08-24translations: rename warn_ to warningLuis Cardoso-8/+8
The macro warn_ was named like that because it the keyword warn is a built-in attribute and at the time this macro was created the word 'warning' was also taken. However it is no longer the case and we can rename warn_ to warning.
2022-08-23Use par_body_owners for livenessSeo Sanghyeon-55/+46
2022-08-21Replace #[lint/warning/error] with #[diag]Xiretza-85/+85
2022-08-21Disallow #[primary_span] on LintDiagnosticsXiretza-1/+0
2022-08-15Rollup merge of #100031 - GoldsteinE:try-removing-the-field, r=michaelwoeristerMatthias Krüger-2/+32
improve "try ignoring the field" diagnostic Closes #95795
2022-08-15Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillotbors-1/+13
Visit attributes in more places. This adds 3 loosely related changes (I can split PRs if desired): - Attribute checking on pattern struct fields. - Attribute checking on struct expression fields. - Lint level visiting on pattern struct fields, struct expression fields, and generic parameters. There are still some lints which ignore lint levels in various positions. This is a consequence of how the lints themselves are implemented. For example, lint levels on associated consts don't work with `unused_braces`.
2022-08-13Rollup merge of #100431 - compiler-errors:enum-ctor-variant-stab, r=estebankMichael Goulet-1/+4
Enum variant ctor inherits the stability of the enum variant Fixes #100399 Fixes #100420 Context #71481 for why enum variants don't need stability
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-08-12Check ctor for missing stabilityMichael Goulet-0/+3
2022-08-12enum variant ctor inherits stability of variantMichael Goulet-1/+1
2022-08-12Auto merge of #100328 - davidtwco:perf-implications, r=nnethercotebors-36/+91
passes: load `defined_lib_features` query less Hopefully addresses the perf regressions from #99212 (see #99905). Re-structure the stability checks for library features to avoid calling `defined_lib_features` for any more crates than necessary for each of the implications or local feature attributes that need validation. r? `@ghost` (just checking perf at first)
2022-08-12improve "try ignoring the field" diagnosticGoldstein-2/+32
Closes #95795
2022-08-11Add visitors for PatField and ExprField.Eric Huss-12/+8
This helps simplify the code. It also fixes it to use the correct parent when lowering. One consequence is the `non_snake_case` lint needed to change the way it looked for parent nodes in a struct pattern. This also includes a small fix to use the correct `Target` for expression field attribute validation.
2022-08-11Check attributes on struct expression fields.Eric Huss-1/+7
Attributes on struct expression fields were not being checked for validity. This adds the fields as HIR nodes so that `CheckAttrVisitor` can visit those nodes to check their attributes.
2022-08-11Check attributes on pattern fields.Eric Huss-1/+11
Attributes on pattern struct fields were not being checked for validity. This adds the fields as HIR nodes so that the `CheckAttrVisitor` can visit those nodes to check their attributes.
2022-08-11Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillotMatthias Krüger-27/+10
Simplify visitors By removing some unused arguments. r? `@cjgillot`
2022-08-11Rollup merge of #100398 - nnethercote:improve-Zhir-stats, r=michaelwoeristerDylan DPC-52/+253
Improve `-Zhir-stats` Add testing, improve coverage, avoid some double counting, and add more detail. r? `@michaelwoerister`
2022-08-11Add a second level to the AST size reporting.Nicholas Nethercote-34/+184
This tells you which variants of the enums are most common, which is very useful. I've only done it for the AST for now, HIR can be done later.
2022-08-11Add percentages to `-Zhir-stats` output.Nicholas Nethercote-6/+8
2022-08-11Change how `AssocItem` is reported.Nicholas Nethercote-5/+1
Currently it's reported as either `TraitItem` or `ImplItem`. This commit changes it to `AssocItem`, because having the report match the type name is (a) consistent with other types, and (b) the trait/impl split isn't that important here.
2022-08-11Improve AST stat collector.Nicholas Nethercote-13/+66
This commit: - Adds a comment explaining which `visit_*` methods should be implemented. - Adds and removes some `visit_*` methods accordingly, improving coverage, and avoiding some double counting.
2022-08-11Simplify `rustc_hir::intravisit::Visitor::visit_variant_data`.Nicholas Nethercote-27/+10
It has four arguments that are never used. This avoids lots of argument passing in functions that feed into `visit_variant_data`.
2022-08-09passes: load `defined_lib_features` query lessDavid Wood-36/+91
Re-structure the stability checks for library features to avoid calling `defined_lib_features` for any more crates than necessary for each of the implications or local feature attributes that need validation.
2022-08-09Rollup merge of #96478 - WaffleLapkin:rustc_default_body_unstable, r=Aaron1011Dylan DPC-9/+31
Implement `#[rustc_default_body_unstable]` This PR implements a new stability attribute — `#[rustc_default_body_unstable]`. `#[rustc_default_body_unstable]` controls the stability of default bodies in traits. For example: ```rust pub trait Trait { #[rustc_default_body_unstable(feature = "feat", isssue = "none")] fn item() {} } ``` In order to implement `Trait` user needs to either - implement `item` (even though it has a default implementation) - enable `#![feature(feat)]` This is useful in conjunction with [`#[rustc_must_implement_one_of]`](https://github.com/rust-lang/rust/pull/92164), 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. r? `@Aaron1011` cc `@nrc` (iirc you were interested in this wrt `read_buf`), `@danielhenrymantilla` (you were interested in the related `#[rustc_must_implement_one_of]`) P.S. This is my first time working with stability attributes, so I'm not sure if I did everything right 😅
2022-08-08Auto merge of #98489 - cjgillot:naked-nohir, r=davidtwco,tmiaskobors-53/+41
Only fetch HIR for naked functions that have the attribute.
2022-08-07Auto merge of #100091 - chenyukang:add-check-for-link-ordinal, ↵bors-0/+18
r=michaelwoerister Check link ordinal to make sure it is targetted for foreign function Fix #100009, when link ordinal is not target for foreign functions, emit an error. cc `@dpaoliello`
2022-08-05Auto merge of #100073 - dpaoliello:externvar, r=michaelwoeristerbors-1/+8
Add test for raw-dylib with an external variable All existing tests of link kind `raw-dylib` only validate the ability to link against functions, but it is also possible to link against variables. This adds tests for linking against a variable using `raw-dylib` both by-name and by-ordinal.
2022-08-05Auto merge of #95977 - FabianWolff:issue-92790-dead-tuple, r=estebankbors-25/+113
Warn about dead tuple struct fields Continuation of #92972. Fixes #92790. The language team has already commented on this in https://github.com/rust-lang/rust/pull/92972#issuecomment-1021511970; I have incorporated their requests here. Specifically, there is now a new allow-by-default `unused_tuple_struct_fields` lint (name bikesheddable), and fields of unit type are ignored (https://github.com/rust-lang/rust/pull/92972#issuecomment-1021815408), so error messages look like this: ``` error: field is never read: `1` --> $DIR/tuple-struct-field.rs:6:21 | LL | struct Wrapper(i32, [u8; LEN], String); | ^^^^^^^^^ | help: change the field to unit type to suppress this warning while preserving the field numbering | LL | struct Wrapper(i32, (), String); | ~~ ``` r? `@joshtriplett`
2022-08-04Add test for raw-dylib with an external variableDaniel Paoliello-1/+8
2022-08-04link_ordinal is available for foreign staticyukang-1/+1
2022-08-03Rollup merge of #100029 - hdelc:master, r=cjgillotMatthias Krüger-3/+28
Prevent ICE for `doc_alias` on match arm, statement, expression Fixes #99777. This is a pretty minimal fix that should be safe, since rustdoc doesn't generate documentation for match arms, statements, or expressions. I mentioned in the linked issue that the `doc_alias` target checking should probably be improved to avoid future ICEs, but as a new contributor, I'm not confident enough with the HIR types to make a larger change.
2022-08-03Only fetch HIR for naked functions that have the attribute.Camille GILLOT-53/+41
2022-08-03Compute `object_lifetime_default` per parameter.Camille GILLOT-0/+28
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-25/+113
2022-08-03fix tidyyukang-4/+2
2022-08-03check link ordinal make sure target is foreign functionyukang-0/+20
2022-08-02Add items to `DocAliasBadLocation` check error match armhdelc-4/+6
- Added `Impl`, `Closure`, ForeignMod` targets - `Target::name` changed for `Target::Impl` - Error output for `Target::ForeignMod` changed to "foreign module"
2022-08-02Add exhaustive location checking for `doc_alias` attributehdelc-4/+24
2022-08-01Remove trait_of_item query.Camille GILLOT-1/+1
2022-08-01Prevent ICE for doc_alias on match arm, statement, expressionhdelc-0/+3
2022-07-31Don't track parent body stability (it wasn't used anyway)Maybe Waffle-18/+3
2022-07-31Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillotDylan DPC-1/+1
Use LocalDefId for closures more
2022-07-30Use LocalDefId for closures moreCameron Steffen-1/+1
2022-07-29Rename local_did to def_idMiguel Guarniz-2/+2
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Change maybe_body_owned_by to take local def idMiguel Guarniz-2/+2
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-27lint: add bad opt access internal lintDavid Wood-0/+51
Some command-line options accessible through `sess.opts` are best accessed through wrapper functions on `Session`, `TyCtxt` or otherwise, rather than through field access on the option struct in the `Session`. Adds a new lint which triggers on those options that should be accessed through a wrapper function so that this is prohibited. Options are annotated with a new attribute `rustc_lint_opt_deny_field_access` which can specify the error message (i.e. "use this other function instead") to be emitted. A simpler alternative would be to simply rename the options in the option type so that it is clear they should not be used, however this doesn't prevent uses, just discourages them. Another alternative would be to make the option fields private, and adding accessor functions on the option types, however the wrapper functions sometimes rely on additional state from `Session` or `TyCtxt` which wouldn't be available in an function on the option type, so the accessor would simply make the field available and its use would be discouraged too. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-26Collect features from `#[rustc_default_body_unstable]`Maybe Waffle-5/+14
2022-07-26Implement `#[rustc_default_body_unstable]`Maybe Waffle-4/+32
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-25passes: port more of `check_attr` moduleDavid Wood-268/+391
Signed-off-by: David Wood <david.wood@huawei.com>