From 4db87f9346d5bcda4fe0d6bded9a3862b186b37e Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Tue, 18 Apr 2023 01:41:40 +0900 Subject: [PATCH] Fix release channel detection See bootstrap code in rust-lang/rust for versioning details: https://github.com/rust-lang/rust/blob/e49122fb1ca87a6c3e3c22abb315fc75cfe8daed/src/bootstrap/lib.rs#L1244 --- crates/base-db/src/input.rs | 4 ++-- crates/ide-completion/src/tests/use_tree.rs | 1 - crates/project-model/src/workspace.rs | 2 +- crates/test-utils/src/fixture.rs | 5 +++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs index c4ada9c7653..a38ab4f6286 100644 --- a/crates/base-db/src/input.rs +++ b/crates/base-db/src/input.rs @@ -284,9 +284,9 @@ impl ReleaseChannel { pub fn from_str(str: &str) -> Option { Some(match str { - "stable" => ReleaseChannel::Stable, - "beta" => ReleaseChannel::Beta, + "" => ReleaseChannel::Stable, "nightly" => ReleaseChannel::Nightly, + _ if str.starts_with("beta") => ReleaseChannel::Beta, _ => return None, }) } diff --git a/crates/ide-completion/src/tests/use_tree.rs b/crates/ide-completion/src/tests/use_tree.rs index ba2e047999e..4c74dba526b 100644 --- a/crates/ide-completion/src/tests/use_tree.rs +++ b/crates/ide-completion/src/tests/use_tree.rs @@ -387,7 +387,6 @@ use self::foo::impl$0 fn use_tree_no_unstable_items_on_stable() { check( r#" -//- toolchain:stable //- /lib.rs crate:main deps:std use std::$0 //- /std.rs crate:std diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index c8e83a687e0..9439d94f031 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -779,7 +779,7 @@ fn project_json_to_crate_graph( CrateOrigin::Local { repo: None, name: None } }, target_layout.clone(), - None, + channel, ); if *is_proc_macro { if let Some(path) = proc_macro_dylib_path.clone() { diff --git a/crates/test-utils/src/fixture.rs b/crates/test-utils/src/fixture.rs index dffc7fccdab..29ab21ac1db 100644 --- a/crates/test-utils/src/fixture.rs +++ b/crates/test-utils/src/fixture.rs @@ -111,8 +111,9 @@ impl FixtureWithProjectMeta { /// //- minicore: sized /// ``` /// - /// That will include predefined proc macros and a subset of `libcore` into the fixture, see - /// `minicore.rs` for what's available. + /// That will set toolchain to nightly and include predefined proc macros and a subset of + /// `libcore` into the fixture, see `minicore.rs` for what's available. Note that toolchain + /// defaults to stable. pub fn parse(ra_fixture: &str) -> Self { let fixture = trim_indent(ra_fixture); let mut fixture = fixture.as_str();