aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_def/src/item_tree.rs5
-rw-r--r--crates/hir_ty/src/infer/expr.rs7
-rw-r--r--crates/hir_ty/src/lower.rs8
-rw-r--r--crates/hir_ty/src/tests/regression.rs37
-rw-r--r--crates/project_model/src/sysroot.rs2
5 files changed, 55 insertions, 4 deletions
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs
index c6ada271e..b08167281 100644
--- a/crates/hir_def/src/item_tree.rs
+++ b/crates/hir_def/src/item_tree.rs
@@ -246,7 +246,10 @@ struct GenericParamsStorage {
246 246
247impl GenericParamsStorage { 247impl GenericParamsStorage {
248 fn alloc(&mut self, params: GenericParams) -> GenericParamsId { 248 fn alloc(&mut self, params: GenericParams) -> GenericParamsId {
249 if params.types.is_empty() && params.where_predicates.is_empty() { 249 if params.types.is_empty()
250 && params.lifetimes.is_empty()
251 && params.where_predicates.is_empty()
252 {
250 return GenericParamsId::EMPTY; 253 return GenericParamsId::EMPTY;
251 } 254 }
252 255
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index ca005bc99..2cdce2cef 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -856,7 +856,12 @@ impl<'a> InferenceContext<'a> {
856 // handle provided type arguments 856 // handle provided type arguments
857 if let Some(generic_args) = generic_args { 857 if let Some(generic_args) = generic_args {
858 // if args are provided, it should be all of them, but we can't rely on that 858 // if args are provided, it should be all of them, but we can't rely on that
859 for arg in generic_args.args.iter().take(type_params) { 859 for arg in generic_args
860 .args
861 .iter()
862 .filter(|arg| matches!(arg, GenericArg::Type(_)))
863 .take(type_params)
864 {
860 match arg { 865 match arg {
861 GenericArg::Type(type_ref) => { 866 GenericArg::Type(type_ref) => {
862 let ty = self.make_ty(type_ref); 867 let ty = self.make_ty(type_ref);
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 92f779360..8392cb770 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -565,7 +565,13 @@ fn substs_from_path_segment(
565 if generic_args.has_self_type { self_params + type_params } else { type_params }; 565 if generic_args.has_self_type { self_params + type_params } else { type_params };
566 let skip = if generic_args.has_self_type && self_params == 0 { 1 } else { 0 }; 566 let skip = if generic_args.has_self_type && self_params == 0 { 1 } else { 0 };
567 // if args are provided, it should be all of them, but we can't rely on that 567 // if args are provided, it should be all of them, but we can't rely on that
568 for arg in generic_args.args.iter().skip(skip).take(expected_num) { 568 for arg in generic_args
569 .args
570 .iter()
571 .filter(|arg| matches!(arg, GenericArg::Type(_)))
572 .skip(skip)
573 .take(expected_num)
574 {
569 match arg { 575 match arg {
570 GenericArg::Type(type_ref) => { 576 GenericArg::Type(type_ref) => {
571 had_explicit_type_args = true; 577 had_explicit_type_args = true;
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs
index 8cf4e7012..da8170417 100644
--- a/crates/hir_ty/src/tests/regression.rs
+++ b/crates/hir_ty/src/tests/regression.rs
@@ -883,3 +883,40 @@ fn issue_6628() {
883 "#]], 883 "#]],
884 ); 884 );
885} 885}
886
887#[test]
888fn issue_6852() {
889 check_infer(
890 r#"
891 #[lang = "deref"]
892 pub trait Deref {
893 type Target;
894 }
895
896 struct BufWriter {}
897
898 struct Mutex<T> {}
899 struct MutexGuard<'a, T> {}
900 impl<T> Mutex<T> {
901 fn lock(&self) -> MutexGuard<'_, T> {}
902 }
903 impl<'a, T: 'a> Deref for MutexGuard<'a, T> {
904 type Target = T;
905 }
906 fn flush(&self) {
907 let w: &Mutex<BufWriter>;
908 *(w.lock());
909 }
910 "#,
911 expect![[r#"
912 156..160 'self': &Mutex<T>
913 183..185 '{}': ()
914 267..271 'self': &{unknown}
915 273..323 '{ ...()); }': ()
916 283..284 'w': &Mutex<BufWriter>
917 309..320 '*(w.lock())': BufWriter
918 311..312 'w': &Mutex<BufWriter>
919 311..319 'w.lock()': MutexGuard<BufWriter>
920 "#]],
921 );
922}
diff --git a/crates/project_model/src/sysroot.rs b/crates/project_model/src/sysroot.rs
index f0a43eaf6..95b622715 100644
--- a/crates/project_model/src/sysroot.rs
+++ b/crates/project_model/src/sysroot.rs
@@ -143,7 +143,7 @@ fn discover_sysroot_src_dir(current_dir: &AbsPath) -> Result<AbsPathBuf> {
143can't load standard library from sysroot 143can't load standard library from sysroot
144{} 144{}
145(discovered via `rustc --print sysroot`) 145(discovered via `rustc --print sysroot`)
146try running `rustup component add rust-src` or set `RUST_SRC_PATH`", 146try installing the Rust source the same way you installed rustc",
147 sysroot_path.display(), 147 sysroot_path.display(),
148 ) 148 )
149 }) 149 })