@@ -445,6 +445,10 @@ fn find_in_dep(
445445 } ;
446446 cov_mark:: hit!( partially_imported) ;
447447 if info. is_unstable {
448+ if !ctx. cfg . allow_unstable {
449+ // the item is unstable and we are not allowed to use unstable items
450+ continue ;
451+ }
448452 choice. stability = Unstable ;
449453 }
450454
@@ -670,6 +674,7 @@ mod tests {
670674 prefer_prelude : bool ,
671675 prefer_absolute : bool ,
672676 prefer_no_std : bool ,
677+ allow_unstable : bool ,
673678 expect : Expect ,
674679 ) {
675680 let ( db, pos) = TestDB :: with_position ( ra_fixture) ;
@@ -711,7 +716,7 @@ mod tests {
711716 module,
712717 prefix,
713718 ignore_local_imports,
714- ImportPathConfig { prefer_no_std, prefer_prelude, prefer_absolute } ,
719+ ImportPathConfig { prefer_no_std, prefer_prelude, prefer_absolute, allow_unstable } ,
715720 ) ;
716721 format_to ! (
717722 res,
@@ -732,31 +737,39 @@ mod tests {
732737 path : & str ,
733738 expect : Expect ,
734739 ) {
735- check_found_path_ ( ra_fixture, path, false , false , false , expect) ;
740+ check_found_path_ ( ra_fixture, path, false , false , false , false , expect) ;
736741 }
737742
738743 fn check_found_path_prelude (
739744 #[ rust_analyzer:: rust_fixture] ra_fixture : & str ,
740745 path : & str ,
741746 expect : Expect ,
742747 ) {
743- check_found_path_ ( ra_fixture, path, true , false , false , expect) ;
748+ check_found_path_ ( ra_fixture, path, true , false , false , false , expect) ;
744749 }
745750
746751 fn check_found_path_absolute (
747752 #[ rust_analyzer:: rust_fixture] ra_fixture : & str ,
748753 path : & str ,
749754 expect : Expect ,
750755 ) {
751- check_found_path_ ( ra_fixture, path, false , true , false , expect) ;
756+ check_found_path_ ( ra_fixture, path, false , true , false , false , expect) ;
752757 }
753758
754759 fn check_found_path_prefer_no_std (
755760 #[ rust_analyzer:: rust_fixture] ra_fixture : & str ,
756761 path : & str ,
757762 expect : Expect ,
758763 ) {
759- check_found_path_ ( ra_fixture, path, false , false , true , expect) ;
764+ check_found_path_ ( ra_fixture, path, false , false , true , false , expect) ;
765+ }
766+
767+ fn check_found_path_prefer_no_std_allow_unstable (
768+ #[ rust_analyzer:: rust_fixture] ra_fixture : & str ,
769+ path : & str ,
770+ expect : Expect ,
771+ ) {
772+ check_found_path_ ( ra_fixture, path, false , false , true , true , expect) ;
760773 }
761774
762775 #[ test]
@@ -1951,7 +1964,7 @@ pub mod ops {
19511964
19521965 #[ test]
19531966 fn respect_unstable_modules ( ) {
1954- check_found_path_prefer_no_std (
1967+ check_found_path_prefer_no_std_allow_unstable (
19551968 r#"
19561969//- /main.rs crate:main deps:std,core
19571970extern crate std;
0 commit comments