Aramis Razzaghipour
9583dd5725
Replace if let
with match
where appropriate
2021-10-05 09:00:21 +11:00
Lukas Wirth
a044175412
Simplify
2021-09-13 18:50:19 +02:00
Florian Diebold
a2d9f7d7bb
Avoid type inference panic on bitslice methods
...
Should fix #10090 , #10046 , #10179 .
This is only a workaround, but the proper fix requires some bigger
refactoring (also related to fixing #10058 ), and this at least prevents
the crash.
2021-09-12 10:49:40 +02:00
Aleksey Kladov
9b2bac621e
minor: make code clearer with ControlFlow
2021-09-11 20:49:10 +03:00
Yotam Ofek
ebb891246c
Split and document array method resolution logic.
2021-09-08 13:15:40 +03:00
Yotam Ofek
9593fe684d
Fix resolution of inherent array methods.
2021-09-08 11:49:05 +03:00
Lukas Wirth
36a5ce9790
minor: fix some clippy lints
2021-09-03 16:00:50 +02:00
Jonas Schievink
418b163a4b
Allow inherent impl for arrays
2021-08-31 14:15:39 +02:00
Aleksey Kladov
cfa3f679e9
internal: don't expose impl details out of hir
2021-08-29 18:55:25 +03:00
Aleksey Kladov
76b60efbfb
internal: improve compile times a bit
...
before after for cargo llvm-lines -q --lib --release -p ide_ssr | head -n 24
Lines Copies Function name
----- ------ -------------
297146 (100%) 12748 (100%) (TOTAL)
5970 (2.0%) 47 (0.4%) core::iter::traits::iterator::Iterator::try_fold
4750 (1.6%) 27 (0.2%) hashbrown::raw::RawTable<T,A>::resize
4080 (1.4%) 30 (0.2%) alloc::raw_vec::RawVec<T,A>::grow_amortized
3933 (1.3%) 69 (0.5%) alloc::raw_vec::RawVec<T,A>::current_memory
3668 (1.2%) 89 (0.7%) <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
3500 (1.2%) 50 (0.4%) hashbrown::raw::RawTable<T,A>::drop_elements
3436 (1.2%) 33 (0.3%) hashbrown::raw::RawTable<T,A>::find
3415 (1.1%) 17 (0.1%) hashbrown::raw::RawTable<T,A>::rehash_in_place
3400 (1.1%) 50 (0.4%) <hashbrown::raw::RawIterRange<T> as core::iter::traits::iterator::Iterator>::next
2840 (1.0%) 20 (0.2%) alloc::raw_vec::RawVec<T,A>::allocate_in
2700 (0.9%) 30 (0.2%) core::alloc::layout::Layout::array
2666 (0.9%) 86 (0.7%) core::ptr::metadata::from_raw_parts_mut
2495 (0.8%) 50 (0.4%) core::option::Option<T>::map
2354 (0.8%) 38 (0.3%) alloc::alloc::box_free
2302 (0.8%) 7 (0.1%) ide_ssr::parsing::RuleBuilder::try_add
2146 (0.7%) 45 (0.4%) core::mem::replace
2070 (0.7%) 69 (0.5%) <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
1979 (0.7%) 16 (0.1%) hashbrown::map::HashMap<K,V,S,A>::insert
1926 (0.6%) 18 (0.1%) <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
1922 (0.6%) 62 (0.5%) core::fmt::ArgumentV1::new
1885 (0.6%) 13 (0.1%) alloc::raw_vec::RawVec<T,A>::shrink
Lines Copies Function name
----- ------ -------------
261717 (100%) 11666 (100%) (TOTAL)
5239 (2.0%) 42 (0.4%) core::iter::traits::iterator::Iterator::try_fold
4750 (1.8%) 27 (0.2%) hashbrown::raw::RawTable<T,A>::resize
3933 (1.5%) 69 (0.6%) alloc::raw_vec::RawVec<T,A>::current_memory
3536 (1.4%) 26 (0.2%) alloc::raw_vec::RawVec<T,A>::grow_amortized
3500 (1.3%) 50 (0.4%) hashbrown::raw::RawTable<T,A>::drop_elements
3400 (1.3%) 50 (0.4%) <hashbrown::raw::RawIterRange<T> as core::iter::traits::iterator::Iterator>::next
3124 (1.2%) 30 (0.3%) hashbrown::raw::RawTable<T,A>::find
2812 (1.1%) 14 (0.1%) hashbrown::raw::RawTable<T,A>::rehash_in_place
2604 (1.0%) 84 (0.7%) core::ptr::metadata::from_raw_parts_mut
2340 (0.9%) 26 (0.2%) core::alloc::layout::Layout::array
2302 (0.9%) 7 (0.1%) ide_ssr::parsing::RuleBuilder::try_add
2272 (0.9%) 16 (0.1%) alloc::raw_vec::RawVec<T,A>::allocate_in
2201 (0.8%) 35 (0.3%) alloc::alloc::box_free
2104 (0.8%) 44 (0.4%) core::mem::replace
2079 (0.8%) 42 (0.4%) <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
2070 (0.8%) 69 (0.6%) <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
1926 (0.7%) 18 (0.2%) <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
1885 (0.7%) 13 (0.1%) alloc::raw_vec::RawVec<T,A>::shrink
1833 (0.7%) 13 (0.1%) hashbrown::raw::RawTable<T,A>::shrink_to
1771 (0.7%) 91 (0.8%) core::ptr::read
1701 (0.6%) 35 (0.3%) core::option::Option<T>::map
2021-08-29 18:49:16 +03:00
Florian Diebold
5ca71a1990
Make block-local trait impls work
...
As long as either the trait or the implementing type are defined in the
same block.
2021-06-13 13:00:34 +02:00
Maan2003
75370312fb
clippy::redundant_closure
2021-06-13 09:29:36 +05:30
Maan2003
c9b4ac5be4
clippy::redudant_borrow
2021-06-13 09:24:16 +05:30
Jonas Schievink
955064b6aa
Implement #[rustc_skip_array_during_method_dispatch]
2021-06-01 21:34:08 +02:00
cynecx
759cb07891
hir_ty: use correct receiver_ty in method resolution
2021-05-31 20:26:38 +02:00
Florian Diebold
1250ddc5cf
Rework obligation handling
...
We can't do the easy hack that we did before anymore, where we kept
track of whether any inference variables changed since the last time we
rechecked obligations. Instead, we store the obligations in
canonicalized form; that way we can easily check the inference variables
to see whether they have changed since the goal was canonicalized.
2021-05-21 17:48:34 +02:00
Florian Diebold
84074cb185
Remove our unification code, use Chalk's instead
2021-05-21 17:48:33 +02:00
Jonas Schievink
20c27dbdbe
Collect inherent impls in unnamed consts
2021-04-19 01:06:26 +02:00
Florian Diebold
97d6e36dbe
Remove assertion in impl collection
...
This condition should always be true for *valid* code, but of course
there might be invalid code or things that we can't currently resolve.
Fixes #8464 .
2021-04-11 12:07:58 +02:00
Jonas Schievink
5f2efae3ba
Include more info in assert
2021-04-11 01:41:40 +02:00
bors[bot]
99ed68a109
Merge #8406
...
8406: Improve indexing of impls r=flodiebold a=flodiebold
Store impls for e.g. &Foo with the ones for Foo instead of the big "other" bucket. This can improve performance and simplifies the HIR impl search a bit.
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-09 10:45:34 +00:00
Florian Diebold
fdd721e9ef
Improve indexing of impls
...
Store impls for e.g. &Foo with the ones for Foo instead of the big
"other" bucket. This can improve performance and simplifies the HIR impl
search a bit.
2021-04-09 11:21:31 +02:00
Florian Diebold
272a8dce4f
Fix crash on syn involving lifetimes returned by Chalk
...
If we get lifetime variables back in autoderef, just immediately replace
them by static lifetimes for now. Method resolution doesn't really deal
correctly with new variables being introduced (this needs to be fixed
more properly).
This fixes `rust-analyzer analysis-stats --with-deps` crashing in the RA
repo.
2021-04-09 11:17:07 +02:00
Florian Diebold
d992736e79
Remove unused
2021-04-08 14:36:14 +02:00
Florian Diebold
caee3b6c2d
Replace some fold
calls
2021-04-08 14:08:55 +02:00
Florian Diebold
be0084a0bc
InEnvironment::new takes a reference
2021-04-07 20:48:58 +02:00
Florian Diebold
6777a4975d
Move hir_trait_id to extension trait
2021-04-07 20:40:01 +02:00
Lukas Wirth
c3c8e8225f
Free Ty::def_crates
2021-04-07 13:09:31 +02:00
Jonas Schievink
7c1c0e6fea
Collect trait impls inside unnamed consts
2021-04-07 03:33:22 +02:00
Lukas Wirth
9b4699a9be
Move Ty accessors to TyExt
2021-04-06 13:58:48 +02:00
Lukas Wirth
9fbba7bc45
Add chalk_ir::Const to TyKind::Array
2021-04-06 11:45:41 +02:00
Lukas Wirth
08dc69599e
Use a constructor function for Static lifetimes
2021-04-06 10:50:55 +02:00
Lukas Wirth
96756f1b1d
Add Lifetime to TyKind::Ref
2021-04-06 10:45:30 +02:00
Florian Diebold
edc59d897d
Align FnPointer with Chalk
2021-04-05 22:23:30 +02:00
Florian Diebold
2a83645e1b
Get rid of Substitution::suffix
2021-04-05 21:58:03 +02:00
Florian Diebold
30a339e038
Add Interner parameter to Binders::substitute
2021-04-05 19:21:01 +02:00
Florian Diebold
05eba0db3d
Binders::subst -> substitute
2021-04-05 19:20:28 +02:00
Florian Diebold
69714d36e6
Hide Binders internals more
2021-04-05 19:19:18 +02:00
Laurențiu Nicola
72c54c53cd
Rename TyKind::ForeignType to Foreign
2021-04-05 15:39:06 +03:00
Laurențiu Nicola
65c2e51940
Rename TyKind::Unknown to Error
2021-04-05 15:39:06 +03:00
Florian Diebold
645a9c3a27
Move things from traits
module to types
as well
2021-04-04 20:27:40 +02:00
Florian Diebold
5d2b488aeb
Replace remaining uses of Substitution::build_for_def
2021-04-04 13:16:38 +02:00
Florian Diebold
cd227f581e
Add and start using TraitRef and ProjectionTy builders
2021-04-04 13:16:38 +02:00
Jonas Schievink
ee4b5a34d8
Use bitflags to compress function properties
...
Very minor savings, only 1 MB or so
2021-04-03 20:58:42 +02:00
Florian Diebold
c551604b5a
Rename Ty::interned to Ty::kind
...
... since that's the actual method on Chalk side that matches the signature.
2021-04-03 13:08:29 +02:00
Florian Diebold
e480d81988
Introduce GenericArg
like in Chalk
...
Plus some more adaptations to Substitution.
Lots of `assert_ty_ref` that we should revisit when introducing
lifetime/const parameters.
2021-04-03 11:17:13 +02:00
Laurențiu Nicola
9787bddac5
Use arrayvec 0.6
2021-03-25 21:03:20 +02:00
bors[bot]
d7db38fff9
Merge #7907
...
7907: Autoderef with visibility r=cynecx a=cynecx
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/7841 .
I am not sure about the general approach here. Right now this simply tries to check whether the autoderef candidate is reachable from the current module. ~~However this doesn't exactly work with traits (see the `tests::macros::infer_derive_clone_in_core` test, which fails right now).~~ see comment below
Refs:
- `rustc_typeck` checking fields: 66ec64ccf3/compiler/rustc_typeck/src/check/expr.rs (L1610)
r? @flodiebold
Co-authored-by: cynecx <me@cynecx.net>
2021-03-24 22:37:48 +00:00
cynecx
96c88680b2
hir_def: move visibility queries from hir_ty to hir_def
2021-03-24 23:00:03 +01:00
Florian Diebold
c4fd3f47f5
Align InEnvironment with Chalk
...
This in particular means storing a chalk_ir::Environment, not our
TraitEnvironment. This makes InEnvironment not usable for Type, where we
need to keep the full TraitEnvironment.
2021-03-21 20:19:07 +01:00