Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
ba64c93
Lower generator expression to HIR
lowr Sep 5, 2022
aeeb9e0
Add `TyBuilder` method to build `Substitution` for generator
lowr Sep 9, 2022
77c40f8
Implement type inference for generator and yield expressions
lowr Sep 6, 2022
447596c
Implement `RustIrDatabase::generator_datum()`
lowr Sep 9, 2022
4b5a66e
Add tests for type inference for generators
lowr Sep 9, 2022
997fc46
Implemented basic enum const eval
OleStrohm Aug 6, 2022
e28046c
Removed unnecessary TODO
OleStrohm Aug 6, 2022
b63234e
Cleaned up code
OleStrohm Aug 6, 2022
2f84b6e
Almost there
OleStrohm Aug 6, 2022
ad0a6bf
Added consteval tests
OleStrohm Aug 7, 2022
301b889
Added more consteval tests and fixed consteval result
OleStrohm Aug 7, 2022
5313bd1
Cleaned up code based on feedback
OleStrohm Sep 12, 2022
177ec82
Rebased
OleStrohm Sep 12, 2022
3931e55
Fixed lints
OleStrohm Sep 12, 2022
ed0cf1c
Add functionality to unwrap tuple declarations
harudagondi Sep 17, 2022
d9f5709
Simplify feature representation in CargoConfig
Veykril Sep 19, 2022
bc6d574
Auto merge of #13259 - Veykril:cargo-config-simplify, r=Veykril
bors Sep 19, 2022
a6c067c
Simplify
Veykril Sep 19, 2022
4f2c86e
Auto merge of #13260 - Veykril:simplify, r=Veykril
bors Sep 19, 2022
cdc362e
docs(inlay-hints): remove reference to Toggle inlay hints
didibear Sep 19, 2022
4d989b5
Auto merge of #13262 - DidiBear:master, r=lnicola
bors Sep 19, 2022
f87ad8d
Added FIXME for the repr type of the enum
OleStrohm Sep 19, 2022
9845e37
Ensure at least one trait bound in `TyKind::DynTy`
lowr Sep 19, 2022
bde76b9
Auto merge of #13264 - lowr:patch/no-dyn-without-trait, r=Veykril
bors Sep 19, 2022
7e8eac3
Simplify
Veykril Sep 20, 2022
027bfd6
Fix operator highlighting tags applying too broadly
Veykril Sep 20, 2022
09600a3
Auto merge of #13268 - Veykril:simplify, r=Veykril
bors Sep 20, 2022
817a6a8
Auto merge of #12966 - OleStrohm:master, r=Veykril
bors Sep 20, 2022
6d0d051
Simplify
Veykril Sep 20, 2022
9f233cd
Parse more repr options
Veykril Sep 20, 2022
b25f0ba
Properly set the enum variant body expected type
Veykril Sep 20, 2022
2119c1f
Fix using incorrect type for variants in DefWithBody::body_type
Veykril Sep 20, 2022
9bf386f
Fix default enum representation not being isize
Veykril Sep 20, 2022
5b49745
Auto merge of #13269 - Veykril:repr, r=Veykril
bors Sep 20, 2022
c2dc32c
return None instead of assert
harudagondi Sep 21, 2022
9ede5f0
Implement `HirDisplay` for `TyKind::Generator`
lowr Sep 21, 2022
40e8f03
docs(guide): fix Analysis and AnalysisHost doc links
oknozor Sep 22, 2022
729a9eb
Fix find_path using the wrong module for visibility calculations
Veykril Sep 22, 2022
fb0ce25
Add RequestFailed error code, as per spec 3.17
alanz Sep 23, 2022
f57cd83
Don't run proc-macro-srv tests on the rust-analyzer repo
Veykril Sep 23, 2022
1440078
Auto merge of #13286 - Veykril:proc-macro-srv-tests, r=Veykril
bors Sep 23, 2022
7ec9ffa
Properly support IDE functionality in enum variants
Veykril Sep 23, 2022
4e7bb5e
Auto merge of #13285 - Veykril:variant-body, r=Veykril
bors Sep 24, 2022
0231d19
Fix diagnostics not working in enum variant bodies
Veykril Sep 24, 2022
fa38c10
Auto merge of #13288 - Veykril:variant-body, r=Veykril
bors Sep 24, 2022
73f6af5
Use the sysroot proc-macro server for analysis-stats
Veykril Sep 24, 2022
73ab709
Auto merge of #13289 - rust-lang:analysis-stats-proc-server, r=Veykril
bors Sep 24, 2022
1f92965
Auto merge of #13209 - lowr:feat/inference-for-generator, r=Veykril
bors Sep 26, 2022
7929e9c
Remove obsolete in-rust-tree feature from sourcegen
Veykril Sep 26, 2022
1a24003
Auto merge of #13248 - harudagondi:unwrap-tuple, r=Veykril
bors Sep 26, 2022
aa093f5
Fix PackageInformation having the crate name instead of package name
Strum355 Sep 26, 2022
60b432b
fix model tests
Strum355 Sep 26, 2022
651c586
formatting
Strum355 Sep 26, 2022
89107d5
Emit unconfigured code diagnostics for fields
unexge Sep 4, 2022
b21bf25
Collect diagnostics in queries instead of nameres
unexge Sep 21, 2022
3a8d84b
Use `Arc<[DefDiagnostic]>` instead of `Arc<Vec<DefDiagnostic>>`
unexge Sep 26, 2022
7e5e517
Generate `From` impls manually
unexge Sep 26, 2022
8c7e376
Auto merge of #13275 - Veykril:find-path, r=Veykril
bors Sep 27, 2022
f972cdd
Auto merge of #13295 - rust-lang:sourcegen, r=Veykril
bors Sep 27, 2022
fb73644
Use cfg(any()) instead of cfg(FALSE) for disabling proc-macro test
Veykril Sep 27, 2022
b01cdd8
Auto merge of #13189 - unexge:unconfigured-diagnostics-for-fields, r=…
bors Sep 27, 2022
8805d05
Auto merge of #13296 - Strum355:package-information-package-name, r=V…
bors Sep 27, 2022
bd8c5b6
Auto merge of #13300 - Veykril:cfg-false, r=Veykril
bors Sep 27, 2022
c3a6c96
Amalgamate file changes for the same file ids in process_changes
Veykril Sep 15, 2022
093de32
Auto merge of #13237 - Veykril:process-changes, r=Veykril
bors Sep 27, 2022
03aa704
Auto merge of #13280 - alanz:errorcode-requestfailed, r=Veykril
bors Sep 27, 2022
b16b041
Auto merge of #13272 - oknozor:master, r=Veykril
bors Sep 27, 2022
1a6c159
Don't retry requests that have already been cancelled
Veykril Sep 7, 2022
9ba55ba
Auto merge of #13202 - Veykril:cancelled-retry, r=Veykril
bors Sep 27, 2022
f5fe6b1
Make assist tests panic again on empty source changes
Veykril Sep 27, 2022
ad752bd
Auto merge of #13301 - Veykril:empty-assist-source-changes, r=Veykril
bors Sep 27, 2022
6d8903a
fix: infer for-loop item type with `IntoIterator` and `Iterator`
lowr Sep 29, 2022
97f8f4a
Auto merge of #13311 - lowr:fix/for-loop-item-resolution, r=Veykril
bors Sep 29, 2022
8c433c7
Fix requests not being retried anymore
Veykril Sep 30, 2022
8132b42
Auto merge of #13319 - Veykril:req-retry, r=Veykril
bors Sep 30, 2022
3cd57c4
Fix annotations not resolving when lens location is set to whole item
Veykril Sep 30, 2022
77cfc9b
Fix type alias hovers not rendering generic parameters
Veykril Sep 30, 2022
17363b3
Auto merge of #13320 - Veykril:ty-alias-hover, r=Veykril
bors Sep 30, 2022
2293949
Auto merge of #13318 - Veykril:annotations, r=Veykril
bors Sep 30, 2022
3ad0334
Fix move_format_string_arg being tokentree unaware
Veykril Sep 30, 2022
5b7e400
Auto merge of #13321 - Veykril:format-str-args, r=Veykril
bors Sep 30, 2022
bfd5f00
Fix trait impl item completions using macro file text ranges
Veykril Oct 1, 2022
f88293f
Auto merge of #13324 - Veykril:trait-impl-completion, r=Veykril
bors Oct 1, 2022
26cf250
Do not use the sysroot proc-macro server when a server path is given …
Veykril Oct 1, 2022
bf5cad8
Auto merge of #13326 - Veykril:proc-macro-srv-config, r=Veykril
bors Oct 1, 2022
5424c51
Add config for supplying sysroot path
Veykril Oct 1, 2022
cdc5493
Auto merge of #13327 - Veykril:proc-macro-srv-config, r=Veykril
bors Oct 1, 2022
870825b
Add proc-macro dependency to rustc crates
Veykril Oct 1, 2022
5c28ad1
Auto merge of #13328 - Veykril:rustc-proc-macro, r=Veykril
bors Oct 1, 2022
f8f5a5e
refactor: use `cast()` instead of interning `GenericArgData`
lowr Oct 2, 2022
4385d3d
Change generic parameter/argument order
lowr Oct 2, 2022
78977cd
Adapt to the new generic parameter/argument order
lowr Oct 2, 2022
7556f74
Remove hack
lowr Oct 2, 2022
5916803
Prioritize restart messages in flycheck
Veykril Oct 3, 2022
f087ebe
Auto merge of #13338 - Veykril:flycheck, r=Veykril
bors Oct 3, 2022
5bd98e3
Auto merge of #13335 - lowr:patch/change-generic-param-order, r=Veykril
bors Oct 3, 2022
e0a161b
fix: treat enum variants as generic item on their own
lowr Oct 3, 2022
974caaf
Auto merge of #13339 - lowr:patch/change-generic-param-order, r=Veykril
bors Oct 3, 2022
e0c9e28
Revert "Add proc-macro dependency to rustc crates"
Veykril Oct 4, 2022
b429df2
Auto merge of #13342 - rust-lang:revert-13328-rustc-proc-macro, r=Vey…
bors Oct 4, 2022
ded3326
fix: use `BoundVar`s from current generic scope
lowr Oct 4, 2022
476d043
Auto merge of #13344 - lowr:patch/change-generic-param-order, r=Veykril
bors Oct 4, 2022
8862fe6
Fix assertion failure in type inference (#13352)
wildbook Oct 5, 2022
a57ef6b
Fix go-to-def for shadowed `include*!`
WaffleLapkin Oct 6, 2022
f2f3528
Auto merge of #13356 - WaffleLapkin:go_to_def_shadow_include, r=Veykril
bors Oct 6, 2022
a415fb4
Auto merge of #13353 - wildbook:fix_type_inference_panic, r=Veykril
bors Oct 6, 2022
1c0ec9f
Fix go-to-def for `#[doc = include_str!("path")]`
WaffleLapkin Oct 7, 2022
8437e4b
Auto merge of #13362 - WaffleLapkin:go_to_def_fix_doc_include_str, r=…
bors Oct 7, 2022
39fa8b5
internal: :arrow_up: xflags
matklad Oct 8, 2022
61504c8
Auto merge of #13366 - matklad:xflags, r=lnicola
bors Oct 8, 2022
c867288
:arrow_up: rust-analyzer
lnicola Oct 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: use cast() instead of interning GenericArgData
  • Loading branch information
lowr committed Oct 2, 2022
commit f8f5a5ea5788a846013545d63c9b46fd70cc4f7c
39 changes: 15 additions & 24 deletions crates/hir-ty/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use chalk_ir::{
cast::{Cast, CastTo, Caster},
fold::TypeFoldable,
interner::HasInterner,
AdtId, BoundVar, DebruijnIndex, Scalar,
AdtId, DebruijnIndex, Scalar,
};
use hir_def::{
builtin_type::BuiltinType, generics::TypeOrConstParamData, ConstParamId, DefWithBodyId,
Expand All @@ -16,9 +16,9 @@ use smallvec::SmallVec;

use crate::{
consteval::unknown_const_as_generic, db::HirDatabase, infer::unify::InferenceTable, primitive,
to_assoc_type_id, to_chalk_trait_id, utils::generics, Binders, CallableSig, ConstData,
ConstValue, GenericArg, GenericArgData, Interner, ProjectionTy, Substitution, TraitRef, Ty,
TyDefId, TyExt, TyKind, ValueTyDefId,
to_assoc_type_id, to_chalk_trait_id, utils::generics, Binders, BoundVar, CallableSig,
GenericArg, Interner, ProjectionTy, Substitution, TraitRef, Ty, TyDefId, TyExt, TyKind,
ValueTyDefId,
};

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -79,20 +79,12 @@ impl<D> TyBuilder<D> {
pub fn fill_with_bound_vars(self, debruijn: DebruijnIndex, starting_from: usize) -> Self {
// self.fill is inlined to make borrow checker happy
let mut this = self;
let other = this.param_kinds.iter().skip(this.vec.len());
let other = &this.param_kinds[this.vec.len()..];
let filler = (starting_from..).zip(other).map(|(idx, kind)| match kind {
ParamKind::Type => {
GenericArgData::Ty(TyKind::BoundVar(BoundVar::new(debruijn, idx)).intern(Interner))
.intern(Interner)
ParamKind::Type => BoundVar::new(debruijn, idx).to_ty(Interner).cast(Interner),
ParamKind::Const(ty) => {
BoundVar::new(debruijn, idx).to_const(Interner, ty.clone()).cast(Interner)
}
ParamKind::Const(ty) => GenericArgData::Const(
ConstData {
value: ConstValue::BoundVar(BoundVar::new(debruijn, idx)),
ty: ty.clone(),
}
.intern(Interner),
)
.intern(Interner),
});
this.vec.extend(filler.take(this.remaining()).casted(Interner));
assert_eq!(this.remaining(), 0);
Expand All @@ -102,8 +94,8 @@ impl<D> TyBuilder<D> {
pub fn fill_with_unknown(self) -> Self {
// self.fill is inlined to make borrow checker happy
let mut this = self;
let filler = this.param_kinds.iter().skip(this.vec.len()).map(|x| match x {
ParamKind::Type => GenericArgData::Ty(TyKind::Error.intern(Interner)).intern(Interner),
let filler = this.param_kinds[this.vec.len()..].iter().map(|x| match x {
ParamKind::Type => TyKind::Error.intern(Interner).cast(Interner),
ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()),
});
this.vec.extend(filler.casted(Interner));
Expand All @@ -113,15 +105,13 @@ impl<D> TyBuilder<D> {

pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable<'_>) -> Self {
self.fill(|x| match x {
ParamKind::Type => GenericArgData::Ty(table.new_type_var()).intern(Interner),
ParamKind::Const(ty) => {
GenericArgData::Const(table.new_const_var(ty.clone())).intern(Interner)
}
ParamKind::Type => table.new_type_var().cast(Interner),
ParamKind::Const(ty) => table.new_const_var(ty.clone()).cast(Interner),
})
}

pub fn fill(mut self, filler: impl FnMut(&ParamKind) -> GenericArg) -> Self {
self.vec.extend(self.param_kinds.iter().skip(self.vec.len()).map(filler));
self.vec.extend(self.param_kinds[self.vec.len()..].iter().map(filler));
assert_eq!(self.remaining(), 0);
self
}
Expand Down Expand Up @@ -255,7 +245,8 @@ impl TyBuilder<hir_def::AdtId> {
) -> Self {
let defaults = db.generic_defaults(self.data.into());
for default_ty in defaults.iter().skip(self.vec.len()) {
if let GenericArgData::Ty(x) = default_ty.skip_binders().data(Interner) {
// NOTE(skip_binders): we only check if the arg type is error type.
if let Some(x) = default_ty.skip_binders().ty(Interner) {
if x.is_unknown() {
self.vec.push(fallback().cast(Interner));
continue;
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/chalk_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl TyExt for Ty {
TyKind::FnDef(def, parameters) => {
let callable_def = db.lookup_intern_callable_def((*def).into());
let sig = db.callable_item_signature(callable_def);
Some(sig.substitute(Interner, &parameters))
Some(sig.substitute(Interner, parameters))
}
TyKind::Closure(.., substs) => {
let sig_param = substs.at(Interner, 0).assert_ty_ref(Interner);
Expand Down
7 changes: 2 additions & 5 deletions crates/hir-ty/src/infer/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use crate::{
builder::ParamKind,
consteval,
method_resolution::{self, VisibleFromModule},
GenericArgData, Interner, Substitution, TraitRefExt, Ty, TyBuilder, TyExt, TyKind,
ValueTyDefId,
Interner, Substitution, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, ValueTyDefId,
};

use super::{ExprOrPatId, InferenceContext, TraitRef};
Expand Down Expand Up @@ -104,9 +103,7 @@ impl<'a> InferenceContext<'a> {
.use_parent_substs(&parent_substs)
.fill(|x| {
it.next().unwrap_or_else(|| match x {
ParamKind::Type => {
GenericArgData::Ty(TyKind::Error.intern(Interner)).intern(Interner)
}
ParamKind::Type => TyKind::Error.intern(Interner).cast(Interner),
ParamKind::Const(ty) => consteval::unknown_const_as_generic(ty.clone()),
})
})
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ impl<'a> TyLoweringContext<'a> {
let total_len =
parent_params + self_params + type_params + const_params + impl_trait_params;

let ty_error = GenericArgData::Ty(TyKind::Error.intern(Interner)).intern(Interner);
let ty_error = TyKind::Error.intern(Interner).cast(Interner);

let mut def_generic_iter = def_generics.iter_id();

Expand All @@ -696,7 +696,7 @@ impl<'a> TyLoweringContext<'a> {
let fill_self_params = || {
for x in explicit_self_ty
.into_iter()
.map(|x| GenericArgData::Ty(x).intern(Interner))
.map(|x| x.cast(Interner))
.chain(iter::repeat(ty_error.clone()))
.take(self_params)
{
Expand Down
43 changes: 14 additions & 29 deletions crates/hir-ty/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::iter;

use base_db::CrateId;
use chalk_ir::{fold::Shift, BoundVar, DebruijnIndex};
use chalk_ir::{cast::Cast, fold::Shift, BoundVar, DebruijnIndex};
use hir_def::{
db::DefDatabase,
generics::{
Expand All @@ -24,8 +24,7 @@ use smallvec::{smallvec, SmallVec};
use syntax::SmolStr;

use crate::{
db::HirDatabase, ChalkTraitId, ConstData, ConstValue, GenericArgData, Interner, Substitution,
TraitRef, TraitRefExt, TyKind, WhereClause,
db::HirDatabase, ChalkTraitId, Interner, Substitution, TraitRef, TraitRefExt, WhereClause,
};

pub(crate) fn fn_traits(db: &dyn DefDatabase, krate: CrateId) -> impl Iterator<Item = TraitId> {
Expand Down Expand Up @@ -282,8 +281,8 @@ impl Generics {
}
}

fn parent_generics(&self) -> Option<&Generics> {
self.parent_generics.as_ref().map(|it| &**it)
pub(crate) fn parent_generics(&self) -> Option<&Generics> {
self.parent_generics.as_deref()
}

/// Returns a Substitution that replaces each parameter by a bound variable.
Expand All @@ -295,18 +294,10 @@ impl Generics {
Substitution::from_iter(
Interner,
self.iter_id().enumerate().map(|(idx, id)| match id {
Either::Left(_) => GenericArgData::Ty(
TyKind::BoundVar(BoundVar::new(debruijn, idx)).intern(Interner),
)
.intern(Interner),
Either::Right(id) => GenericArgData::Const(
ConstData {
value: ConstValue::BoundVar(BoundVar::new(debruijn, idx)),
ty: db.const_param_ty(id),
}
.intern(Interner),
)
.intern(Interner),
Either::Left(_) => BoundVar::new(debruijn, idx).to_ty(Interner).cast(Interner),
Either::Right(id) => BoundVar::new(debruijn, idx)
.to_const(Interner, db.const_param_ty(id))
.cast(Interner),
}),
)
}
Expand All @@ -316,18 +307,12 @@ impl Generics {
Substitution::from_iter(
Interner,
self.iter_id().map(|id| match id {
Either::Left(id) => GenericArgData::Ty(
TyKind::Placeholder(crate::to_placeholder_idx(db, id.into())).intern(Interner),
)
.intern(Interner),
Either::Right(id) => GenericArgData::Const(
ConstData {
value: ConstValue::Placeholder(crate::to_placeholder_idx(db, id.into())),
ty: db.const_param_ty(id),
}
.intern(Interner),
)
.intern(Interner),
Either::Left(id) => {
crate::to_placeholder_idx(db, id.into()).to_ty(Interner).cast(Interner)
}
Either::Right(id) => crate::to_placeholder_idx(db, id.into())
.to_const(Interner, db.const_param_ty(id))
.cast(Interner),
}),
)
}
Expand Down