Commit Graph

360 Commits

Author SHA1 Message Date
bors
15ef5f5523 Auto merge of #14641 - lowr:fix/obligation-for-value-path, r=Veykril
Register obligations during path inference

Fixes #14635

When we infer path expressions that resolve to some generic item, we need to consider their generic bounds. For example, when we resolve a path `Into::into` to `fn into<?0, ?1>` (note that `?0` is the self type of trait ref), we should register an obligation `?0: Into<?1>` or else their relationship would be lost.

Relevant part in rustc is [`add_required_obligations_with_code()`] that's called in [`instantiate_value_path()`].

[`instantiate_value_path()`]: 3462f79e94/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs (L1052)
[`add_required_obligations_with_code()`]: 3462f79e94/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs (L1411)
2023-04-24 19:56:43 +00:00
bors
1b835da0f5 Auto merge of #14639 - HKalbasi:dev2, r=Veykril
Fix some typos in `StructFlags`

And a question: what is the benefit of storing things like `IS_BOX` in struct flags over using `lang_attr`?
2023-04-24 05:59:23 +00:00
Ryo Yoshida
12ba5cab11
Register obligations during path inference 2023-04-24 12:39:48 +09:00
hkalbasi
01c1b3dc71 Fix panic in const eval and parameter destructing 2023-04-24 00:49:57 +03:30
hkalbasi
232f293c19 Fix some typos in StructFlags 2023-04-23 21:55:47 +03:30
Ryo Yoshida
c6aea8c2f9
Minor refactorings 2023-04-24 02:19:08 +09:00
bors
1379b5fac7 Auto merge of #14630 - Veykril:arc, r=Veykril
internal: `Arc<String>` -> `Arc<str>`
2023-04-22 07:58:13 +00:00
Lukas Wirth
f00dcf9a69 internal: Arc<String> -> Arc<str> 2023-04-22 09:48:37 +02:00
hkalbasi
0c621065fb Fix need-mut large span in closures and a false positive 2023-04-21 02:15:19 +03:30
bors
2400b36a2e Auto merge of #14577 - jsoref:spelling, r=lnicola
Spelling

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling).

The misspellings have been reported at https://github.com/jsoref/rust-analyzer/actions/runs/4699991040#summary-12751355796

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/rust-analyzer/actions/runs/4699991284#summary-12751356293

closes #14567
2023-04-19 14:05:40 +00:00
Josh Soref
bc7d84c3ce Spelling
* a rule
* access
* after
* amount
* annotations
* assignment
* assist
* associated
* attribute
* borrowed
* built-in type
* clarification
* command
* const
* constructor
* corresponding
* counterparts
* curlies
* dependencies
* deterministic
* diagnostic
* duplicates
* edge
* edited
* efficient
* elsewhere
* execution
* expression
* extensions
* extracted
* fill
* github
* helper
* heuristic
* incomplete
* indent end
* inlay
* invocation
* lifetime
* looking
* maybe
* move
* mutability
* mutable
* necessarily
* necessary
* negative
* nonexistent
* occurred
* offsets
* offsetted
* overridden
* parameters
* params
* params_and_where_preds_in_scope
* paredit
* parent
* parentheses
* prepended if
* punctuation
* receive
* receiver
* referring
* repeated
* representing
* semantically
* separately
* shouldnot
* siblings
* similar
* something's
* statement
* struct
* structure
* surprise
* the
* this
* transparent
* unimplemented
* unnamed
* unnecessary
* unneeded
* unreachable
* unterminated
* utilities
* variant
* variants
* visibility
* work around (v)
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-19 09:45:55 -04:00
bors
9b835f334f Auto merge of #14594 - Veykril:Simplify, r=Veykril
internal: Move Expander and LowerCtx into separate modules
2023-04-17 19:00:42 +00:00
Lukas Wirth
bca8029a6e Move Expander and LowerCtx into separate modules 2023-04-17 20:44:06 +02:00
Laurențiu Nicola
160ab88bb9 Bump bitflags 2023-04-17 18:42:59 +03:00
Lukas Wirth
a2a3fecae3 Option begone part 2 2023-04-16 19:20:48 +02:00
Lukas Wirth
d1632c2727 Report syntax errors from item level macro expansions 2023-04-16 17:22:06 +02:00
Lukas Wirth
0bb9a17312 internal: Move layout logic from hir-def to hir-ty 2023-04-16 12:21:12 +02:00
bors
b218009f46 Auto merge of #14576 - HKalbasi:dev2, r=HKalbasi
Fix explicit deref problems in closure capture

fix the `need-mut` part of #14562

Perhaps surprisingly, it wasn't unique immutable borrow. The code still doesn't emit any of them, and I think those won't happen in edition 2021 (which is currently the only thing implemented), since we always capture `&mut *x` instead of `&mut x`. But I'm not very sure about it.
2023-04-14 13:23:49 +00:00
Laurențiu Nicola
febd5065ad Make inherent_impls_in_block and trait_impls_in_block infallible 2023-04-14 16:03:45 +03:00
hkalbasi
7cb4318331 Fix explicit deref problems in closure capture 2023-04-14 15:32:40 +03:30
Lukas Wirth
c32d51979d internal: Make block_def_map infallible 2023-04-14 13:17:38 +02:00
Ryo Yoshida
ac03de773f
Add flag to disallow opaque types for DisplayTarget::SourceCode 2023-04-12 19:03:48 +09:00
bors
7afd2048f0 Auto merge of #14544 - HKalbasi:dev, r=Veykril
Infer types of nested RPITs

fix https://github.com/rust-lang/rust-analyzer/issues/14474#issuecomment-1501235394
2023-04-11 14:49:04 +00:00
hkalbasi
85f9235de8 fix inference in nested closure 2023-04-11 17:02:00 +03:30
hkalbasi
a584cb998f Infer types of nested RPITs 2023-04-11 04:32:11 +03:30
hkalbasi
59b6f2d9f2 Compute closure captures 2023-04-10 23:04:34 +03:30
hkalbasi
c54cb88950 Add bounds for associated types in derive macro 2023-04-07 19:33:14 +03:30
bors
d73161b491 Auto merge of #14524 - Veykril:hir-pretty, r=Veykril
internal: Render function parameters in hir-def pretty printing
2023-04-07 07:34:45 +00:00
Lukas Wirth
513d4a9c9a Render function parameters in hir-def pretty printing 2023-04-07 09:34:04 +02:00
bors
e739c999cd Auto merge of #14511 - HKalbasi:dev, r=Veykril
Always reborrow mutable reference receiver in methods

Dependency of #14470
2023-04-06 21:18:15 +00:00
hkalbasi
7ba93cb8cf Always reborrow reference receiver in methods 2023-04-07 00:32:28 +03:30
Ryo Yoshida
5ab4e64a4c
fix: unify types in infer_expr_coerce_never() 2023-04-07 05:46:30 +09:00
Lukas Wirth
f742943a4b Don't recreate Hygiene unnecessarily 2023-04-06 21:16:11 +02:00
Lukas Wirth
a1b96b1e00 Remove unnecessary Names from FunctionData::params 2023-04-06 20:14:51 +02:00
Lukas Wirth
99b69525f4 hir_def::expr -> hir_def::hir, hir_def::type_ref -> hir_def::hir::type_ref 2023-04-06 19:36:25 +02:00
Lukas Wirth
8e7c104b3a Move hir_def::adt to hir_def::data::adt 2023-04-06 19:23:29 +02:00
Lukas Wirth
fbb1bd5880 Re-enable controlflow outside loop diagnostic 2023-04-06 15:37:53 +02:00
Lukas Wirth
0e7117900c internal: Resolve labels in body lowering 2023-04-06 14:21:20 +02:00
bors
e9e57725aa Auto merge of #14505 - Veykril:block-trait-impls, r=Veykril
fix: Fix block local impl trait solving regressions

Fixes https://github.com/rust-lang/rust-analyzer/issues/14443
2023-04-06 08:37:33 +00:00
Lukas Wirth
1c16e4ee97 fix: Fix block local impl trait solving regressions 2023-04-06 10:37:00 +02:00
Ryo Yoshida
0a2d0b15a1
Add regression test for #10989 2023-04-06 03:39:59 +09:00
bors
25124a84de Auto merge of #14490 - Veykril:crategraph-dedup, r=Veykril
internal: Switch crate graph to use an Arena instead of a hashmap
2023-04-05 14:12:11 +00:00
bors
a1ca52e2a9 Auto merge of #14486 - HKalbasi:dev, r=Veykril
Desugar async fn completely

fix #14479
2023-04-05 13:58:38 +00:00
bors
af30656785 Auto merge of #14436 - lowr:patch/normalize-assoc-type-in-path-expr, r=HKalbasi
Normalize associated types in paths in expressions

Part of #14393

When we resolve paths in expressions (either path expressions or paths in struct expressions), there's a need of projection normalization, which `TyLoweringContext` cannot do on its own. We've been properly applying normalization for paths in struct expressions without type anchor, but not for others:

```rust
enum E {
    S { v: i32 }
    Empty,
}

impl Foo for Bar {
    type Assoc = E;
    fn foo() {
        let _ = Self::Assoc::S { v: 42 };   // path in struct expr without type anchor; we already support this
        let _ = <Self>::Assoc::S { v: 42 }; // path in struct expr with type anchor; resolves with this PR
        let _ = Self::Assoc::Empty;         // path expr; resolves with this PR
    }
}
```

With this PR we correctly resolve the whole path, but we need some more tweaks in HIR and/or IDE layers to properly resolve a qualifier (prefix) of such paths and provide IDE features that are pointed out in #14393 to be currently broken.
2023-04-05 10:47:47 +00:00
Lukas Wirth
7f0fbf7f9d Switch crate graph to use an Arena instead of a hashmap 2023-04-05 10:32:02 +02:00
hkalbasi
c26b12d01c Desugar async fn completely 2023-04-04 23:07:38 +03:30
hkalbasi
d7fe4e2fa8 lower adjusts in simple index except the last one 2023-04-01 16:49:32 +03:30
hkalbasi
8a6ca86247 Use async block in async fn type inference 2023-04-01 04:35:28 +03:30
Lukas Wirth
e244942209 internal: Set Durability to HIGH for enable_proc_attr_macros input 2023-03-30 15:11:22 +02:00
bors
5390949c11 Auto merge of #14448 - Veykril:infer-table, r=Veykril
internal: Don't expose InferenceTable outside of hir-ty
2023-03-30 12:49:23 +00:00
Lukas Wirth
fc840dbb2d internal: Don't expose InferenceTable outside of hir-ty 2023-03-30 13:27:10 +02:00
Lukas Wirth
33b6012827 Introduce StructFlags 2023-03-30 12:49:08 +02:00
Lukas Wirth
251b3a47af Simplify 2023-03-30 09:21:10 +02:00
Lukas Wirth
e797479651 fix: Handle box and raw pointers correctly in builtin_deref 2023-03-29 21:38:32 +02:00
Ryo Yoshida
6447d485e3
Normalize type anchor type before resolving the rest of value paths 2023-03-29 23:37:01 +09:00
Ryo Yoshida
8aef04f1a7
Resolve and normalize path segments one by one in variant resolution 2023-03-29 23:32:37 +09:00
Lukas Wirth
798990bf33 fix: Add missing autoborrow adjustment for index expressions 2023-03-29 16:11:48 +02:00
Lukas Wirth
bea1c71f83 Use struct_tail_without_normalization in Expectation::rvalue_hint 2023-03-29 14:49:06 +02:00
bors
7a98e24777 Auto merge of #14431 - Veykril:simplify, r=Veykril
minor: Simplify
2023-03-29 07:28:42 +00:00
Lukas Wirth
8ea1afce28 Simplify 2023-03-28 16:32:26 +02:00
hkalbasi
d0d4245a74 use FxHashSet instead of FxHashMap 2023-03-28 15:59:16 +03:30
hkalbasi
d5c7ec499a fix stack overflow in is_ty_uninhabited_from 2023-03-28 15:45:35 +03:30
Lukas Wirth
342fd2b9f3 fix: Properly handle local trait impls 2023-03-28 08:34:29 +02:00
bors
3321799e8f Auto merge of #14368 - HKalbasi:mir, r=HKalbasi
MIR episode 3

This PR adds lowering for try operator and overloaded dereference, and adds evaluating support for function pointers and trait objects. It also adds a flag to `analysis-stats` to show percentage of functions that it fails to emit mir for them, which is currently `20%` (which is somehow lying, as most of the supported `80%` are tests). The most offenders are closure (1975 items) and overloaded index (415 items). I will try to add overloaded index before monday to have it in this PR, and tackle the closure in the next episode.
2023-03-21 19:57:27 +00:00
hkalbasi
8a3ad7c3d5 Support evaluating inherent associated constants with generics 2023-03-21 02:20:30 +03:30
hkalbasi
3303a6eff5 Implement some intrinsics 2023-03-20 21:48:01 +03:30
hkalbasi
8e73ea5253 Desugar try blocks 2023-03-19 13:02:51 +03:30
Ryo Yoshida
e12460bbca
Add regression test
so that we can catch regressions when we move away from chalk.
2023-03-19 16:58:10 +09:00
Ryo Yoshida
1d1a86f350
Bump chalk to 0.89 2023-03-19 16:45:26 +09:00
hkalbasi
453ae2e00e Support range MIR lowering 2023-03-18 02:06:36 +03:30
hkalbasi
9ad83deecc Support overloaded index MIR lowering 2023-03-17 19:10:25 +03:30
hkalbasi
eb4939e217 Support overloaded deref MIR lowering 2023-03-17 14:02:55 +03:30
hkalbasi
9564773d5e Improve pattern matching MIR lowering 2023-03-17 13:08:36 +03:30
hkalbasi
051dae2221 Support record pattern MIR lowering 2023-03-17 13:08:36 +03:30
hkalbasi
513e340bd3 implement transmute intrinsic 2023-03-17 13:08:36 +03:30
hkalbasi
7525a38af5 Support evaluating dyn Trait methods 2023-03-17 13:08:35 +03:30
hkalbasi
a063f000ff Support function pointer MIR lowering 2023-03-17 13:08:35 +03:30
hkalbasi
b7b9ae59a0 desugar ? operator 2023-03-17 13:08:35 +03:30
Lukas Wirth
3bf07a5f04 Simplify 2023-03-15 13:54:06 +01:00
Zachary S
af175ddcdc Add test for async closure types.
(rebased onto 6dfd8ae)
2023-03-15 13:10:35 +01:00
Zachary S
6746a08b44 fix: Fix return type of async closures.
(rebased onto 6dfd8ae)
2023-03-15 13:10:00 +01:00
Lukas Wirth
510e4b4029 Simplify 2023-03-14 20:22:11 +01:00
Lukas Wirth
f34b2469bd lint incoherent inherent impls 2023-03-14 19:20:44 +01:00
bors
6a98e961f8 Auto merge of #14340 - Veykril:expand, r=lnicola
internal: Rename AstDatabase to ExpandDatabase
2023-03-14 09:37:54 +00:00
hkalbasi
d7da9e64d1 Add storage dead for let bindings without initializer 2023-03-14 12:15:16 +03:30
Lukas Wirth
9fb9ee3b6a internal: Rename AstDatabase to ExpandDatabase 2023-03-13 16:35:41 +01:00
Laurențiu Nicola
bdbd2a59b0 Merge branch 'master' into sync-from-rust 2023-03-13 10:21:53 +02:00
bors
70e10deee8 Auto merge of #14326 - iDawer:refactor, r=Veykril
internal: Rename `hir::diagnostics::MissingMatchArms.match_expr` field

`hir::diagnostics::MissingMatchArms.match_expr` had confusing name: it is pointing to scrutinee expression. Renamed to `scrutinee_expr` and used better fitting type for it.

Also small refactorings/cleanup.
2023-03-11 07:36:00 +00:00
iDawer
17b9d35b31 Refactor: Distinguish scrutinee expression from match expression 2023-03-10 18:43:50 +05:00
iDawer
8f189f62c6 Remove unnecessary argument 2023-03-10 16:35:04 +05:00
iDawer
c38aa5f4f0 Use anonymous lifetimes 2023-03-10 16:16:28 +05:00
hkalbasi
a980b562a7 Fix stack overflow when derefrencing &! 2023-03-10 13:44:34 +03:30
hkalbasi
71e1c025f8 Revert #14285 2023-03-10 11:57:30 +03:30
hkalbasi
8593132a43 fix block with no termination in or patterns 2023-03-09 22:32:12 +03:30
hkalbasi
cf47c15821 Evaluate consts in path_to_const 2023-03-08 16:42:20 +03:30
bors
ecc32c2f85 Auto merge of #14271 - Veykril:ty-diag-err, r=Veykril
Don't trigger unresolved method/field diagnostics on types containing errors
2023-03-07 14:25:20 +00:00
Lukas Wirth
d45708fabe Don't trigger unresolved method/field diagnostics on types containing errors 2023-03-07 15:24:43 +01:00
hkalbasi
bcd7ecb242 Add profiling to mir lower and borrowck query 2023-03-07 12:42:52 +03:30
hkalbasi
af90ec8096 Partially support "overloaded deref" MIR lowering 2023-03-06 21:09:09 +03:30
hkalbasi
bf0f99f15d Fix overloaded deref unused mut false positive 2023-03-06 21:09:09 +03:30