summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2024-08-04Revert "Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix"Michael Goulet-93/+28
This reverts commit 13314df21b0bb0cdd02c6760581d1b9f1052fa7e, reversing changes made to 6e534c73c35f569492ed5fb5f349075d58ed8b7e.
2024-08-04Revert "Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov"Michael Goulet-1/+1
This reverts commit 977c5fd419ade52467f7de79d5bfc25c0c893275, reversing changes made to 24c94f0e4f5aa333c665fbbba423172c30176624.
2024-06-20Add pub struct with allow(dead_code) into worklistr0cky-1/+1
(cherry picked from commit 64450732be8c3111360589e9f8c44eab83f449e0)
2024-06-07Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelixMatthias Krüger-28/+93
Detect pub structs never constructed and unused associated constants <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> Lints never constructed public structs. If we don't provide public methods to construct public structs with private fields, and don't construct them in the local crate. They would be never constructed. So that we can detect such public structs. --- Update: Also lints unused associated constants in traits.
2024-06-07Rollup merge of #124214 - carbotaniuman:parse_unsafe_attrs, r=michaelwoeristerMatthias Krüger-2/+30
Parse unsafe attributes Initial parse implementation for #123757 This is the initial work to parse unsafe attributes, which is represented as an extra `unsafety` field in `MetaItem` and `AttrItem`. There's two areas in the code where it appears that parsing is done manually and not using the parser stuff, and I'm not sure how I'm supposed to thread the change there.
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-25/+21
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-06-06Fix formattingcarbotaniuman-1/+0
2024-06-06Fix buildcarbotaniuman-1/+1
2024-06-06Error on unsafe on non-unsafe attributecarbotaniuman-2/+31
2024-06-06Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"Rémy Rakic-4/+4
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-05Also support generic constantsOli Scherer-9/+9
2024-06-05Don't walk the bodies of free constants for reachability.Oli Scherer-4/+14
2024-06-05Detect pub structs never constructed and unused associated constants in traitsr0cky-28/+93
2024-06-04Closures are recursively reachableTomasz Miąsko-0/+1
2024-06-03Opt-in diagnostics reporting to avoid doing extra work in the new solverMichael Goulet-2/+2
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-4/+4
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-4/+4
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-11/+10
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-29Don't require `visit_body` to take a lifetime that must outlive the function ↵Oli Scherer-2/+2
call
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-21/+25
2024-05-23Auto merge of #125434 - nnethercote:rm-more-extern-tracing, r=jackh726bors-5/+4
Remove more `#[macro_use] extern crate tracing` Because explicit importing of macros via use items is nicer (more standard and readable) than implicit importing via `#[macro_use]`. Continuing the work from #124511 and #124914. r? `@jackh726`
2024-05-23Rollup merge of #122382 - mu001999:dead_code/enhance, r=petrochenkovLeón Orell Valerian Liehr-16/+33
Detect unused structs which implement private traits Fixes #122361
2024-05-23Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obkMatthias Krüger-4/+4
rustc: Use `tcx.used_crates(())` more And explain when it should be used. Addresses comments from https://github.com/rust-lang/rust/pull/121167.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_passes`.Nicholas Nethercote-5/+4
2024-05-23Rollup merge of #123623 - surechen:fix_123261, r=estebankMatthias Krüger-26/+150
Fix OutsideLoop's error suggestion: adding label `'block` for `if` block. For OutsideLoop we should not suggest add `'block` label in `if` block, or we wiil get another err: block label not supported here. fixes #123261
2024-05-23Detect unused structs which implement private traitsr0cky-16/+33
2024-05-22rustc: Use `tcx.used_crates(())` moreVadim Petrochenkov-4/+4
And explain when it should be used.
2024-05-22For OutsideLoop we should not suggest add 'block label in if block, or we ↵surechen-26/+150
wiil get another err: block label not supported here. fixes #123261
2024-05-22Auto merge of #125326 - ↵bors-67/+77
weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors Move `#[do_not_recommend]` to the `#[diagnostic]` namespace This commit moves the `#[do_not_recommend]` attribute to the `#[diagnostic]` namespace. It still requires `#![feature(do_not_recommend)]` to work. r? `@compiler-errors`
2024-05-21Move `#[do_not_recommend]` to the `#[diagnostic]` namespaceGeorg Semmler-67/+77
This commit moves the `#[do_not_recommend]` attribute to the `#[diagnostic]` namespace. It still requires `#![feature(do_not_recommend)]` to work.
2024-05-21Minor `pub` and whitespace cleanups.Nicholas Nethercote-8/+6
2024-05-17Rename Unsafe to SafetySantiago Pastorino-3/+3
2024-05-15delegation: Implement list delegationVadim Petrochenkov-4/+9
```rust reuse prefix::{a, b, c} ```
2024-05-11Rollup merge of #124904 - RalfJung:reachable, r=tmiasko许杰友 Jieyou Xu (Joe)-10/+22
reachable computation: extend explanation of what this does, and why Follow-up to https://github.com/rust-lang/rust/pull/122769. I had the time to think about this some more, in particular in the context of https://github.com/rust-lang/rust/issues/119214, so I felt it was worth extending these comments some more. I also gave up on the context of "externally reachable" as it is not called that way anywhere else in the compiler. Cc `@tmiasko` `@saethlin`
2024-05-09reachable computation: extend explanation of what this does, and whyRalf Jung-10/+22
2024-05-08Fix Error Messages for `break` Inside CoroutinesVeera-13/+29
Previously, `break` inside `gen` blocks and functions were incorrectly identified to be enclosed by a closure. This PR fixes it by displaying an appropriate error message for async blocks, async closures, async functions, gen blocks, gen closures, gen functions, async gen blocks, async gen closures and async gen functions. Note: gen closure and async gen closure are not supported by the compiler yet but I have added an error message here assuming that they might be implemented in the future. Also, fixes grammar in a few places by replacing `inside of a $coroutine` with `inside a $coroutine`.
2024-05-04Various improvements to entrypoint codeNilstrieb-35/+23
This moves some code around and adds some documentation comments to make it easier to understand what's going on with the entrypoint logic, which is a bit complicated. The only change in behavior is consolidating the error messages for unix_sigpipe to make the code slightly simpler.
2024-05-03Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxuMichael Goulet-41/+10
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](https://github.com/rust-lang/rust/pull/120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](https://github.com/rust-lang/rust/pull/120832#issuecomment-2007394609) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-05-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-41/+10
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern was raised related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was also raised, namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-2/+8
2024-04-25ast: Generalize item kind visitingVadim Petrochenkov-1/+1
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-23Rollup merge of #124218 - Xiretza:subsubdiagnostics, r=davidtwcoLeón Orell Valerian Liehr-1/+1
Allow nesting subdiagnostics in #[derive(Subdiagnostic)]
2024-04-23Rollup merge of #124067 - RalfJung:weak-lang-items, r=davidtwcoMatthias Krüger-5/+34
weak lang items are not allowed to be #[track_caller] For instance the panic handler will be called via this import ```rust extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; } ``` A `#[track_caller]` would add an extra argument and thus make this the wrong signature. The 2nd commit is a consistency rename; based on the docs [here](https://doc.rust-lang.org/unstable-book/language-features/lang-items.html) and [here](https://rustc-dev-guide.rust-lang.org/lang-items.html) I figured "lang item" is more widely used. (In the compiler output, "lang item" and "language item" seem to be pretty even.)
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-21Pass translation closure to add_to_diag_with() as referenceXiretza-1/+1
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-2/+1
2024-04-17consistency rename: language item -> lang itemRalf Jung-3/+3
2024-04-17weak lang items are not allowed to be #[track_caller]Ralf Jung-2/+31
2024-04-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-7/+7
Because they're a bit redundant.
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+4