about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
AgeCommit message (Collapse)AuthorLines
2024-02-19Remove suspicious auto trait lintSantiago Pastorino-160/+4
2024-02-19Drive-by `DUMMY_SP` -> `Span` and fmt changesEsteban Küber-1/+1
Noticed these while doing something else. There's no practical change, but it's preferable to use `DUMMY_SP` as little as possible, particularly when we have perfectlly useful `Span`s available.
2024-02-19Prefer `DiagnosticBuilder` over `Diagnostic` in diagnostic modifiers.Nicholas Nethercote-28/+32
There are lots of functions that modify a diagnostic. This can be via a `&mut Diagnostic` or a `&mut DiagnosticBuilder`, because the latter type wraps the former and impls `DerefMut`. This commit converts all the `&mut Diagnostic` occurrences to `&mut DiagnosticBuilder`. This is a step towards greatly simplifying `Diagnostic`. Some of the relevant function are made generic, because they deal with both errors and warnings. No function bodies are changed, because all the modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`.
2024-02-19split `project` into multiple fileslcnr-11/+10
2024-02-18Rollup merge of #121247 - scottmcm:intrinsic-reminder, r=petrochenkovMatthias Krüger-0/+2
Add help to `hir_analysis_unrecognized_intrinsic_function` To help remind forgetful people like me what step they forgot. (If this just ICE'd, https://github.com/rust-lang/compiler-team/issues/620 style, the stack trace would point me here, but since there's a "nice" error that information is lost.)
2024-02-18Auto merge of #117772 - surechen:for_117448, r=petrochenkovbors-7/+4
Tracking import use types for more accurate redundant import checking fixes #117448 By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking. For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
2024-02-18Propagate the resolved type of assoc const bindings via query feedingLeón Orell Valerian Liehr-31/+30
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-7/+4
situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
2024-02-18Auto merge of #121034 - obeis:improve-static-mut-ref, r=RalfJungbors-52/+35
Improve wording of `static_mut_ref` Close #120964
2024-02-17Add help to `hir_analysis_unrecognized_intrinsic_function`Scott McMurray-0/+2
To help remind forgetful people like me what step they forgot.
2024-02-18Auto merge of #121252 - fmease:rollup-x7zogl8, r=fmeasebors-186/+156
Rollup of 7 pull requests Successful merges: - #120526 (rustdoc: Correctly handle long crate names on mobile) - #121100 (Detect when method call on argument could be removed to fulfill failed trait bound) - #121160 (rustdoc: fix and refactor HTML rendering a bit) - #121198 (Add more checks for `unnamed_fields` during HIR analysis) - #121218 (Fix missing trait impls for type in rustc docs) - #121221 (AstConv: Refactor lowering of associated item bindings a bit) - #121237 (Use better heuristic for printing Cargo specific diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-18Rollup merge of #121221 - fmease:refactor-astconv-assoc-item-bindings, ↵León Orell Valerian Liehr-175/+125
r=compiler-errors AstConv: Refactor lowering of associated item bindings a bit Split off from #119385 as discussed, namely the first two commits (modulo one `FIXME` getting turned into a `NOTE`). The second commit removes `astconv::ConvertedBinding{,Kind}` in favor of `hir::TypeBinding{,Kind}`. The former was a — in my opinion — super useless intermediary. As you can tell from the diff, its removal shaves off some code. Furthermore, yeeting it will make it easier to implement the type resolution fixes in #119385. Nothing in this PR should have any semantic effect. r? `@compiler-errors` <sub>**Addendum** as in #118668: What I call “associated item bindings” are commonly referred to as “type bindings” for historical reasons. Nowadays, “type bindings” include assoc type bindings, assoc const bindings and RTN (return type notation) which is why I prefer not to use this outdated term.</sub>
2024-02-18Auto merge of #120780 - fmease:lta-in-impls, r=oli-obkbors-18/+70
Properly deal with weak alias types as self types of impls Fixes #114216. Fixes #116100. Not super happy about the two ad hoc “normalization” implementations for weak alias types: 1. In `inherent_impls`: The “peeling”, normalization to [“WHNF”][whnf]: Semantically that's exactly what we want (neither proper normalization nor shallow normalization would be correct here). Basically a weak alias type is “nominal” (well...^^) if the WHNF is nominal. [#97974](https://github.com/rust-lang/rust/pull/97974) followed the same approach. 2. In `constrained_generic_params`: Generic parameters are constrained by a weak alias type if the corresp. “normalized” type constrains them (where we only normalize *weak* alias types not arbitrary ones). Weak alias types are injective if the corresp. “normalized” type is injective. Both have ad hoc overflow detection mechanisms. **Coherence** is handled in #117164. r? `@oli-obk` or types [whnf]: https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form
2024-02-18Improve wording of static_mut_refObei Sideg-52/+35
Rename `static_mut_ref` lint to `static_mut_refs`.
2024-02-17Add more checks for `unnamed_field` during HIR analysisclubby789-11/+31
2024-02-17Fix non_local_definitions lint in rustc_hir_analysisUrgau-5/+5
2024-02-17Rollup merge of #121192 - oli-obk:intrinsics2.0, r=WaffleLapkinGuillaume Boisseau-3/+3
Give some intrinsics fallback bodies cc #93145
2024-02-17Properly check constrainedness of gen params in the presence of weak alias typesLeón Orell Valerian Liehr-17/+40
2024-02-17Support weak alias types as self type of inherent implsLeón Orell Valerian Liehr-1/+30
2024-02-17Remove astconv::ConvertedBindingLeón Orell Valerian Liehr-151/+96
2024-02-17Update comments and variable namesLeón Orell Valerian Liehr-34/+39
2024-02-16Give the (`un`)`likely` intrinsics fallback bodiesOli Scherer-2/+2
2024-02-16Give the `assume` intrinsic a fallback bodyOli Scherer-1/+1
2024-02-16Move trait into attr so it's greppableMichael Goulet-2/+2
2024-02-16Use extension trait deriveMichael Goulet-10/+2
2024-02-16Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkinbors-129/+178
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-2/+3
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-15Auto merge of #121142 - GuillaumeGomez:rollup-5qmksjw, r=GuillaumeGomezbors-2/+3
Rollup of 8 pull requests Successful merges: - #120449 (Document requirements for unsized {Rc,Arc}::from_raw) - #120505 (Fix BTreeMap's Cursor::remove_{next,prev}) - #120672 (std::thread update freebsd stack guard handling.) - #121088 (Implicitly enable evex512 if avx512 is enabled) - #121104 (Ignore unsized types when trying to determine the size of the original type) - #121107 (Fix msg for verbose suggestions with confusable capitalization) - #121113 (Continue compilation even if inherent impl checks fail) - #121120 (Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`.) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-15Auto merge of #120931 - chenyukang:yukang-cleanup-hashmap, r=michaelwoeristerbors-34/+34
Clean up potential_query_instability with FxIndexMap and UnordMap From https://github.com/rust-lang/rust/pull/120485#issuecomment-1916437191 r? `@michaelwoerister`
2024-02-15Use generic `NonZero` internally.Markus Reiter-2/+3
2024-02-14Continue compilation even if inherent impl checks failOli Scherer-2/+3
2024-02-14Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errorsbors-2/+4
Continue compilation after check_mod_type_wf errors The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too. The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication. fixes https://github.com/rust-lang/rust/issues/120860
2024-02-14Continue compilation after check_mod_type_wf errorsOli Scherer-2/+4
2024-02-14Rollup merge of #121071 - nnethercote:fewer-delayed-bugs, r=oli-obkOli Scherer-7/+7
Use fewer delayed bugs. For some cases where it's clear that an error has already occurred, e.g.: - there's a comment stating exactly that, or - things like HIR lowering, where we are lowering an error kind The commit also tweaks some comments around delayed bug sites. r? `@oli-obk`
2024-02-14Rollup merge of #120530 - trevyn:issue-116434, r=compiler-errorsOli Scherer-1/+1
Be less confident when `dyn` suggestion is not checked for object safety #120275 no longer checks bare traits for object safety when making a `dyn` suggestion on Rust < 2021. In this case, qualify the suggestion with a note that the trait must be object safe, to prevent user confusion as seen in #116434 r? ```@fmease```
2024-02-14clean up potential_query_instability with FxIndexMap and UnordMapyukang-34/+34
2024-02-14Use fewer delayed bugs.Nicholas Nethercote-7/+7
For some cases where it's clear that an error has already occurred, e.g.: - there's a comment stating exactly that, or - things like HIR lowering, where we are lowering an error kind The commit also tweaks some comments around delayed bug sites.
2024-02-14Auto merge of #121018 - oli-obk:impl_unsafety, r=TaKO8Kibors-69/+79
Fully stop using the HIR in trait impl checks At least I hope I found all happy path usages. I'll need to check if I can figure out a way to make queries declare that they don't access the HIR except in error paths
2024-02-13Bump `indexmap`clubby789-2/+4
`swap` has been deprecated in favour of `swap_remove` - the behaviour is the same though.
2024-02-13Just pass the checker instead of individual fieldsOli Scherer-39/+33
2024-02-13Remove an `impl_polarity` call where the information is already available in ↵Oli Scherer-16/+23
the header
2024-02-13Avoid using the HIR span in the happy pathOli Scherer-5/+8
2024-02-13Don't reinvoke `trait_header` query twiceOli Scherer-11/+11
2024-02-13Invoke `trait_def` query only onceOli Scherer-10/+13
This may be a small performance boost as we have to hash less to lookup the value
2024-02-13Store impl unsafety in impl trait headerOli Scherer-24/+27
2024-02-13Auto merge of #120919 - oli-obk:impl_polarity, r=compiler-errorsbors-56/+54
Merge `impl_polarity` and `impl_trait_ref` queries Hopefully this is perf neutral. I want to finish https://github.com/rust-lang/rust/pull/120835 and stop using the HIR in `coherent_trait`, which should then give us a perf improvement.
2024-02-12Rollup merge of #120958 - ShoyuVanilla:remove-subst, r=oli-obkMatthias Krüger-76/+82
Dejargonize `subst` In favor of #110793, replace almost every occurence of `subst` and `substitution` from rustc codes, but they still remains in subtrees under `src/tools/` like clippy and test codes (I'd like to replace them after this)
2024-02-12Support safe intrinsics with fallback bodiesOli Scherer-3/+8
Turn `is_val_statically_known` into such an intrinsic to demonstrate. It is perfectly safe to call after all.
2024-02-12Give const_deallocate a default bodyOli Scherer-1/+1
2024-02-12Teach llvm backend how to fall back to default bodiesOli Scherer-1/+1