summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2022-08-15Revert let_chains stabilizationNilstrieb-1/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. It was discovered that they are not implemented correctly, which does not make them ready for stabilization.
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-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-03Warn about dead tuple struct fieldsFabian Wolff-25/+113
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-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-25passes: port more of `check_attr` moduleDavid Wood-268/+391
Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-21avoid embedding StabilityLevel::Unstable reason string into metadata ↵klensy-5/+2
multiple times
2022-07-20Auto merge of #99058 - michaelwoerister:remove-stable-set-and-map, r=nagisabors-1/+1
Remove the unused StableSet and StableMap types from rustc_data_structures. The current implementation is not "stable" in the same sense that `HashStable` and `StableHasher` are stable, i.e. across compilation sessions. So, in my opinion, it's better to remove those types (which are basically unused anyway) than to give the wrong impression that these are safe for incr. comp. I plan to provide new "stable" collection types soon that can be used to replace `FxHashMap` and `FxHashSet` in query results (see [draft](https://github.com/michaelwoerister/rust/commit/69d03ac7a7d651a397ab793e9d78f8fce3edf7a6)). It's unsound that `HashMap` and `HashSet` implement `HashStable` (see https://github.com/rust-lang/rust/issues/98890 for a recent P-critical bug caused by this) -- so we should make some progress there.
2022-07-20passes: check implied feature existsDavid Wood-23/+35
Add a check confirming that features referenced in `implied_by` meta items actually exist. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20passes: improved partial stabilization diagnosticDavid Wood-8/+50
Improves the diagnostic when a feature attribute is specified unnecessarily but the feature implies another (i.e. it was partially stabilized) to refer to the implied feature. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20middle: add `implies_by` to `#[unstable]`David Wood-0/+1
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-20Use FxIndexMap instead of otherwise unused StableMap for WEAK_ITEMS_REFS.Michael Woerister-1/+1
2022-07-20attr/passes: comment -> doc commentDavid Wood-13/+13
Change some regular comments into documentation comments. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-19Auto merge of #98180 - notriddle:notriddle/rustdoc-fn, ↵bors-9/+15
r=petrochenkov,GuillaumeGomez Improve the function pointer docs This is #97842 but for function pointers instead of tuples. The concept is basically the same. * Reduce duplicate impls; show `fn (T₁, T₂, …, Tₙ)` and include a sentence saying that there exists up to twelve of them. * Show `Copy` and `Clone`. * Show auto traits like `Send` and `Sync`, and blanket impls like `Any`. https://notriddle.com/notriddle-rustdoc-test/std/primitive.fn.html
2022-07-19Rollup merge of #99401 - TaKO8Ki:avoid-symbol-to-&str-conversions, r=nnethercoteMatthias Krüger-1/+1
Avoid `Symbol` to `&str` conversions `Symbol::as_str` is a slowish operation, so this patch removes some usages of it.
2022-07-18avoid `Symbol` to `&str` conversionsTakayuki Maeda-1/+1
2022-07-17rustdoc: extend `#[doc(tuple_variadic)]` to fn pointersMichael Howell-9/+15
The attribute is also renamed `fake_variadic`.
2022-07-16Stabilize `let_chains`Caio-1/+1
2022-07-15passes: migrate half of `check_attr`David Wood-445/+610
Migrate half of the `rustc_passes::check_attr` diagnostics to using diagnostic derives and being translatable.
2022-07-14Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillotbors-3/+49
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-14Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPCbors-2/+11
Rollup of 5 pull requests Successful merges: - #97720 (Always create elided lifetime parameters for functions) - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`) - #98705 (Implement `for<>` lifetime binder for closures) - #99126 (remove allow(rustc::potential_query_instability) in rustc_span) - #99139 (Give a better error when `x dist` fails for an optional tool) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-14Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillotDylan DPC-2/+11
Implement `for<>` lifetime binder for closures This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following: ```rust let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) }; // ^^^^^^^^^^^--- new! ``` cc ``@Aaron1011`` ``@cjgillot``
2022-07-14Auto merge of #98975 - jyn514:unstable_opts, r=wesleywiserbors-5/+5
Rename `debugging_opts` to `unstable_opts` This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear. cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Codegen.20options.20.2F.20debugging.20options r? `@Amanieu` cc `@nikic` `@joshtriplett`
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-5/+5
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-13remove untagged_union feature gateRalf Jung-66/+2
2022-07-13also allow arrays of allowed typesRalf Jung-0/+5
2022-07-13allow unions with mutable references and tuples of allowed typesRalf Jung-5/+22
2022-07-13factor 'is this type allowed as union field on stable' into separate functionRalf Jung-3/+11
2022-07-13Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddybDylan DPC-19/+2
`UnsafeCell` blocks niches inside its nested type from being available outside fixes #87341 This implements the plan by `@eddyb` in https://github.com/rust-lang/rust/issues/87341#issuecomment-886083646 Somewhat related PR (not strictly necessary, but that cleanup made this PR simpler): #94527
2022-07-12Add an indirection for closures in `hir::ExprKind`Maybe Waffle-2/+11
This helps bring `hir::Expr` size down, `Closure` was the biggest variant, especially after `for<>` additions.
2022-07-11move else block into the `Local` structDing Xiang Fei-10/+10
2022-07-11lower let-else in MIR insteadDing Xiang Fei-13/+48
2022-07-08fixes post rebaseJane Losare-Lusby-1/+1
2022-07-08add opt in attribute for stable-in-unstable itemsJane Lusby-2/+20
2022-07-08clarify commentJane Lusby-2/+2
2022-07-08update commentJane Lusby-1/+4
2022-07-08Support unstable moves via stable in unstable itemsJane Lusby-2/+27
2022-07-07Reword comments and rename HIR visiting methods.Camille GILLOT-8/+8
2022-07-07`UnsafeCell` now has no niches, ever.Oli Scherer-19/+2
2022-07-07Auto merge of #98841 - Kobzol:hir-validator-bitset, r=cjgillotbors-19/+22
Use a bitset instead of a hash map in HIR ID validator The hashset insertion was slightly hot in incr patched runs, but it seems unnecessary to use a hashset here, as it just checks that a dense set of N integers was seen. I'm not sure if it's possible to know the amount of items beforehand to preallocate the bitset? I suppose not.
2022-07-05Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errorsDylan DPC-1/+1
lints: mostly translatable diagnostics As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway). r? ``@compiler-errors``
2022-07-04Only validate HIR with `debug_assertions` onJakub Beránek-19/+22