@@ -445,6 +445,10 @@ fn find_in_dep(
445
445
} ;
446
446
cov_mark:: hit!( partially_imported) ;
447
447
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
+ }
448
452
choice. stability = Unstable ;
449
453
}
450
454
@@ -670,6 +674,7 @@ mod tests {
670
674
prefer_prelude : bool ,
671
675
prefer_absolute : bool ,
672
676
prefer_no_std : bool ,
677
+ allow_unstable : bool ,
673
678
expect : Expect ,
674
679
) {
675
680
let ( db, pos) = TestDB :: with_position ( ra_fixture) ;
@@ -711,7 +716,7 @@ mod tests {
711
716
module,
712
717
prefix,
713
718
ignore_local_imports,
714
- ImportPathConfig { prefer_no_std, prefer_prelude, prefer_absolute } ,
719
+ ImportPathConfig { prefer_no_std, prefer_prelude, prefer_absolute, allow_unstable } ,
715
720
) ;
716
721
format_to ! (
717
722
res,
@@ -732,31 +737,39 @@ mod tests {
732
737
path : & str ,
733
738
expect : Expect ,
734
739
) {
735
- check_found_path_ ( ra_fixture, path, false , false , false , expect) ;
740
+ check_found_path_ ( ra_fixture, path, false , false , false , false , expect) ;
736
741
}
737
742
738
743
fn check_found_path_prelude (
739
744
#[ rust_analyzer:: rust_fixture] ra_fixture : & str ,
740
745
path : & str ,
741
746
expect : Expect ,
742
747
) {
743
- check_found_path_ ( ra_fixture, path, true , false , false , expect) ;
748
+ check_found_path_ ( ra_fixture, path, true , false , false , false , expect) ;
744
749
}
745
750
746
751
fn check_found_path_absolute (
747
752
#[ rust_analyzer:: rust_fixture] ra_fixture : & str ,
748
753
path : & str ,
749
754
expect : Expect ,
750
755
) {
751
- check_found_path_ ( ra_fixture, path, false , true , false , expect) ;
756
+ check_found_path_ ( ra_fixture, path, false , true , false , false , expect) ;
752
757
}
753
758
754
759
fn check_found_path_prefer_no_std (
755
760
#[ rust_analyzer:: rust_fixture] ra_fixture : & str ,
756
761
path : & str ,
757
762
expect : Expect ,
758
763
) {
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) ;
760
773
}
761
774
762
775
#[ test]
@@ -1951,7 +1964,7 @@ pub mod ops {
1951
1964
1952
1965
#[ test]
1953
1966
fn respect_unstable_modules ( ) {
1954
- check_found_path_prefer_no_std (
1967
+ check_found_path_prefer_no_std_allow_unstable (
1955
1968
r#"
1956
1969
//- /main.rs crate:main deps:std,core
1957
1970
extern crate std;
0 commit comments