mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Merge #1032
1032: Fix apply_substs assertion failure r=matklad a=flodiebold Fixes #1030. Co-authored-by: Florian Diebold <flodiebold@gmail.com>
This commit is contained in:
commit
2dfb47cc3d
2 changed files with 25 additions and 2 deletions
|
@ -407,7 +407,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
|
|
||||||
let substs =
|
let substs =
|
||||||
Ty::substs_from_path_segment(self.db, &self.resolver, segment, typable);
|
Ty::substs_from_path_segment(self.db, &self.resolver, segment, typable);
|
||||||
self.db.type_for_def(typable, Namespace::Types).apply_substs(substs)
|
self.db.type_for_def(typable, Namespace::Types).subst(&substs)
|
||||||
}
|
}
|
||||||
Resolution::LocalBinding(_) => {
|
Resolution::LocalBinding(_) => {
|
||||||
// can't have a local binding in an associated item path
|
// can't have a local binding in an associated item path
|
||||||
|
@ -466,7 +466,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
let typable: Option<TypableDef> = def.into();
|
let typable: Option<TypableDef> = def.into();
|
||||||
let typable = typable?;
|
let typable = typable?;
|
||||||
let substs = Ty::substs_from_path(self.db, &self.resolver, path, typable);
|
let substs = Ty::substs_from_path(self.db, &self.resolver, path, typable);
|
||||||
let ty = self.db.type_for_def(typable, Namespace::Values).apply_substs(substs);
|
let ty = self.db.type_for_def(typable, Namespace::Values).subst(&substs);
|
||||||
let ty = self.insert_type_vars(ty);
|
let ty = self.insert_type_vars(ty);
|
||||||
Some(ty)
|
Some(ty)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1791,6 +1791,29 @@ fn test<R>(query_response: Canonical<QueryResponse<R>>) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bug_1030() {
|
||||||
|
assert_snapshot_matches!(infer(r#"
|
||||||
|
struct HashSet<T, H>;
|
||||||
|
struct FxHasher;
|
||||||
|
type FxHashSet<T> = HashSet<T, FxHasher>;
|
||||||
|
|
||||||
|
impl<T, H> HashSet<T, H> {
|
||||||
|
fn default() -> HashSet<T, H> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn main_loop() {
|
||||||
|
FxHashSet::default();
|
||||||
|
}
|
||||||
|
"#),
|
||||||
|
@r###"
|
||||||
|
[144; 146) '{}': ()
|
||||||
|
[169; 198) '{ ...t(); }': ()
|
||||||
|
[175; 193) 'FxHash...efault': fn default<{unknown}, {unknown}>() -> HashSet<T, H>
|
||||||
|
[175; 195) 'FxHash...ault()': HashSet<{unknown}, {unknown}>"###
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cross_crate_associated_method_call() {
|
fn cross_crate_associated_method_call() {
|
||||||
let (mut db, pos) = MockDatabase::with_position(
|
let (mut db, pos) = MockDatabase::with_position(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue