mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-17 13:58:05 +00:00
Rust: Bump MSRV to 1.88 (#9640)
As required by the upcoming WGPU 27 update
This commit is contained in:
parent
427cdaf9fa
commit
c246d5c636
9 changed files with 11 additions and 76 deletions
12
.github/workflows/ci.yaml
vendored
12
.github/workflows/ci.yaml
vendored
|
@ -49,7 +49,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-22.04, macos-14, windows-2022]
|
||||
rust_version: [stable, "1.85"]
|
||||
rust_version: [stable, "1.88"]
|
||||
include:
|
||||
- os: windows-2022
|
||||
extra_args: "--exclude ffmpeg --exclude gstreamer-player"
|
||||
|
@ -60,13 +60,11 @@ jobs:
|
|||
extra_args: "--exclude ffmpeg --exclude gstreamer-player"
|
||||
- os: ubuntu-22.04
|
||||
rust_version: "nightly"
|
||||
# Bevy requires 1.86, won't compile with 1.85
|
||||
- rust_version: "1.85"
|
||||
maybe_exclude_bevy: "--exclude bevy-example"
|
||||
exclude:
|
||||
# There is only a limited amount of mac worker machine allocated and this is currently the bottleneck, so disable it
|
||||
- os: macos-14
|
||||
rust_version: "1.85"
|
||||
# We already test 1.85 and nightly. Stable is in the middle and already covered by other jobs
|
||||
rust_version: "1.88"
|
||||
# We already test 1.88 and nightly. Stable is in the middle and already covered by other jobs
|
||||
- os: ubuntu-22.04
|
||||
rust_version: "stable"
|
||||
|
||||
|
@ -274,7 +272,7 @@ jobs:
|
|||
matrix:
|
||||
include:
|
||||
- os: macos-14
|
||||
rust_version: "1.85"
|
||||
rust_version: "1.88"
|
||||
- os: windows-2022
|
||||
rust_version: "nightly"
|
||||
- os: ubuntu-22.04
|
||||
|
|
|
@ -37,6 +37,7 @@ All notable changes to this project are documented in this file.
|
|||
|
||||
### Rust
|
||||
|
||||
- Minimum Supported Rust Version (MSRV) is 1.88
|
||||
- Slint macro: Use new Rust 1.88 API proc_macro API to be able to access file relative to the .rs file
|
||||
- Fixed error in generated Rust code when convering some expressions to void
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ homepage = "https://slint.dev"
|
|||
keywords = ["gui", "toolkit", "graphics", "design", "ui"]
|
||||
license = "GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0"
|
||||
repository = "https://github.com/slint-ui/slint"
|
||||
rust-version = "1.85"
|
||||
rust-version = "1.88"
|
||||
version = "1.14.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
|
|
|
@ -22,7 +22,7 @@ if (NOT Corrosion_FOUND)
|
|||
endif (NOT Corrosion_FOUND)
|
||||
|
||||
list(PREPEND CMAKE_MODULE_PATH ${Corrosion_SOURCE_DIR}/cmake)
|
||||
find_package(Rust 1.85 REQUIRED MODULE)
|
||||
find_package(Rust 1.88 REQUIRED MODULE)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build Slint as shared library" ON)
|
||||
option(SLINT_FEATURE_COMPILER "Enable support for compiling .slint files to C++ ahead of time" ON)
|
||||
|
|
|
@ -49,7 +49,7 @@ In the next section you will learn how to use the installed library in your appl
|
|||
First you need to install the prerequisites:
|
||||
|
||||
* Install Rust by following the [Rust Getting Started Guide](https://www.rust-lang.org/learn/get-started). If you already
|
||||
have Rust installed, make sure that it's at least version 1.85 or newer. You can check which version you have installed
|
||||
have Rust installed, make sure that it's at least version 1.88 or newer. You can check which version you have installed
|
||||
by running `rustc --version`. Once this is done, you should have the `rustc` compiler and the `cargo` build system installed in your path.
|
||||
|
||||
You can either choose to compile Slint from source along with your application or include Slint as an external CMake package.
|
||||
|
|
|
@ -9,7 +9,7 @@ following generic instructions on what's needed to compile and use Slint.
|
|||
## Prerequisites
|
||||
|
||||
* Install Rust by following the [Rust Getting Started Guide](https://www.rust-lang.org/learn/get-started). If you already
|
||||
have Rust installed, make sure that it's at least version 1.85 or newer. You can check which version you have installed
|
||||
have Rust installed, make sure that it's at least version 1.88 or newer. You can check which version you have installed
|
||||
by running `rustc --version`. Once this is done, you should have the `rustc` compiler and the `cargo` build system installed in your path.
|
||||
|
||||
* A C++ cross-compiler compiler that supports C++20.
|
||||
|
|
|
@ -23,7 +23,6 @@ default = []
|
|||
|
||||
[dependencies]
|
||||
i-slint-compiler = { workspace = true, features = ["default", "proc_macro_span", "rust", "display-diagnostics"] }
|
||||
rustversion = "1.0"
|
||||
proc-macro2 = "1.0.17"
|
||||
quote = "1.0"
|
||||
spin_on = { workspace = true }
|
||||
|
|
|
@ -19,7 +19,6 @@ use std::path::PathBuf;
|
|||
/// it was written like so in the source code: `foo-` but not when written like so `foo -`
|
||||
///
|
||||
/// Returns None if we couldn't detect whether they are touching (eg, our heuristics don't work with rust-analyzer)
|
||||
#[rustversion::since(1.88)]
|
||||
fn are_token_touching(token1: proc_macro::Span, token2: proc_macro::Span) -> Option<bool> {
|
||||
let t1 = token1.end();
|
||||
let t2 = token2.start();
|
||||
|
@ -31,63 +30,6 @@ fn are_token_touching(token1: proc_macro::Span, token2: proc_macro::Span) -> Opt
|
|||
}
|
||||
Some(t1.line() == t2.line() && t1_column == t2.column())
|
||||
}
|
||||
#[rustversion::before(1.88)]
|
||||
fn are_token_touching(token1: proc_macro::Span, token2: proc_macro::Span) -> Option<bool> {
|
||||
// There is no way with stable API to find out if the token are touching, so do it by
|
||||
// extracting the range from the debug representation of the span
|
||||
are_token_touching_impl(&format!("{token1:?}"), &format!("{token2:?}"))
|
||||
}
|
||||
|
||||
#[rustversion::before(1.88)]
|
||||
fn are_token_touching_impl(token1_debug: &str, token2_debug: &str) -> Option<bool> {
|
||||
// The debug representation of a span look like this: "#0 bytes(6662789..6662794)"
|
||||
// we just have to find out if the first number of the range of second span
|
||||
// is the same as the second number of the first span
|
||||
let is_byte_char = |c: char| c.is_numeric() || c == ':';
|
||||
let not_is_byte_char = |c: char| !is_byte_char(c);
|
||||
let end_of_token1 = token1_debug
|
||||
.trim_end_matches(not_is_byte_char)
|
||||
.rsplit(not_is_byte_char)
|
||||
.next()?
|
||||
.trim_matches(':');
|
||||
let begin_of_token2 = token2_debug
|
||||
.trim_end_matches(not_is_byte_char)
|
||||
.strip_suffix(is_byte_char)?
|
||||
.trim_end_matches(is_byte_char)
|
||||
.trim_end_matches(not_is_byte_char)
|
||||
.rsplit(not_is_byte_char)
|
||||
.next()?
|
||||
.trim_matches(':');
|
||||
(!begin_of_token2.is_empty()).then_some(end_of_token1 == begin_of_token2)
|
||||
}
|
||||
|
||||
#[rustversion::before(1.88)]
|
||||
#[test]
|
||||
fn are_token_touching_impl_test() {
|
||||
assert!(are_token_touching_impl("#0 bytes(6662788..6662789)", "#0 bytes(6662789..6662794)")
|
||||
.unwrap());
|
||||
assert!(!are_token_touching_impl("#0 bytes(6662788..6662789)", "#0 bytes(6662790..6662794)")
|
||||
.unwrap());
|
||||
assert!(!are_token_touching_impl("#0 bytes(6662789..6662794)", "#0 bytes(6662788..6662789)")
|
||||
.unwrap());
|
||||
assert!(
|
||||
!are_token_touching_impl("#0 bytes(6662788..6662789)", "#0 bytes(662789..662794)").unwrap()
|
||||
);
|
||||
assert!(are_token_touching_impl("#0 bytes(123..456)", "#0 bytes(456..789)").unwrap());
|
||||
|
||||
// Alternative representation on nightly with a special flag
|
||||
assert!(are_token_touching_impl("/foo/bar.rs:12:7: 12:18", "/foo/bar.rs:12:18: 12:19").unwrap());
|
||||
assert!(are_token_touching_impl("/foo/bar.rs:2:7: 13:18", "/foo/bar.rs:13:18: 14:29").unwrap());
|
||||
assert!(!are_token_touching_impl("/foo/bar.rs:2:7: 13:18", "/foo/bar.rs:14:18: 14:29").unwrap());
|
||||
assert!(!are_token_touching_impl("/foo/bar.rs:2:7: 2:8", "/foo/bar.rs:2:18: 2:29").unwrap());
|
||||
|
||||
// What happens if the representation change
|
||||
assert!(are_token_touching_impl("hello", "hello").is_none());
|
||||
assert!(are_token_touching_impl("hello42", "hello42").is_none());
|
||||
|
||||
// rust-analyzer just has indices that means nothing
|
||||
assert!(are_token_touching_impl("55", "56").is_none());
|
||||
}
|
||||
|
||||
fn fill_token_vec(stream: impl Iterator<Item = TokenTree>, vec: &mut Vec<parser::Token>) {
|
||||
let mut prev_spacing = Spacing::Alone;
|
||||
|
@ -410,14 +352,9 @@ pub fn slint(stream: TokenStream) -> TokenStream {
|
|||
let mut tokens = vec![];
|
||||
fill_token_vec(token_iter, &mut tokens);
|
||||
|
||||
#[rustversion::since(1.88)]
|
||||
fn local_file(tokens: &[parser::Token]) -> Option<PathBuf> {
|
||||
tokens.first()?.span?.local_file()
|
||||
}
|
||||
#[rustversion::before(1.88)]
|
||||
fn local_file(_: &[parser::Token]) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
let source_file = if let Some(path) = local_file(&tokens) {
|
||||
diagnostics::SourceFileInner::from_path_only(path)
|
||||
|
|
|
@ -9,7 +9,7 @@ This page explains how to build and test Slint.
|
|||
### Installing Rust
|
||||
|
||||
Install Rust by following the [Rust Getting Started Guide](https://www.rust-lang.org/learn/get-started). If you already
|
||||
have Rust installed, make sure that it's at least version 1.85 or newer. You can check which version you have installed
|
||||
have Rust installed, make sure that it's at least version 1.88 or newer. You can check which version you have installed
|
||||
by running `rustc --version`.
|
||||
|
||||
Once this is done, you should have the `rustc` compiler and the `cargo` build system installed in your path.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue