From 88fdebe765142687083f56f392a208d7d972a1ce Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Thu, 9 Jul 2026 20:53:00 +0200 Subject: [PATCH 1/8] chore: Make tls optional to the web-server --- Cargo.toml | 3 +- src/std_lib/http.rs | 215 ++++++++++++++++++++++---------------------- 2 files changed, 107 insertions(+), 111 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a95589101..33e926870 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,12 +140,11 @@ web = [ "http-body-util", "http", "tower-service", - "native-tls", "tokio/net", "tokio-stream", - "tokio-native-tls", "pin-project-lite", ] +web-tls = ["tokio/fs", "native-tls", "tokio-native-tls"] gluon_completion = ["dep:gluon_completion", "gluon_vm/gluon_completion"] diff --git a/src/std_lib/http.rs b/src/std_lib/http.rs index 68c9008dd..be3470fbe 100644 --- a/src/std_lib/http.rs +++ b/src/std_lib/http.rs @@ -1,4 +1,6 @@ -use crate::real_std::{fmt, fs, net::SocketAddr, path::PathBuf, pin::Pin, sync::Arc}; +use tokio::net::TcpListener; + +use crate::real_std::{fmt, net::SocketAddr, path::PathBuf, pin::Pin, sync::Arc}; use { collect_mac::collect, @@ -202,99 +204,87 @@ fn listen( settings: Settings, WithVM { vm, value }: WithVM>>, ) -> impl Future> + Send + 'static { - let vm = vm.root_thread(); - listen_(settings, vm, value).map(IO::from) + let thread = match vm.new_thread() { + Ok(thread) => thread, + Err(err) => return async { IO::from(Err(err)) }.left_future(), + }; + + let addr = SocketAddr::from(([0, 0, 0, 0], settings.port)); + + let handler = Handler::new(&thread, value); + + async move { + if let Some(cert_path) = &settings.tls_cert { + #[cfg(feature = "web-tls")] + return listen_https(cert_path, addr, handler).await; + #[cfg(not(feature = "web-tls"))] + return Err(vm::Error::Message(format!( + "TLS support is not enabled, but a certificate was provided: {}", + cert_path.display() + ))); + } else { + listen_http(addr, handler).await + } + } + .map(IO::from) + .right_future() } type RequestBody = Incoming; type ResponseHttpBody = BoxBody; -async fn listen_( - settings: Settings, - thread: RootedThread, - handler: OpaqueValue>, +#[cfg(feature = "web-tls")] +async fn listen_https( + cert_path: &::std::path::Path, + addr: SocketAddr, + handler: Handler, ) -> vm::Result<()> { - let thread = match thread.new_thread() { - Ok(thread) => thread, - Err(err) => return Err(err), - }; + let identity = tokio::fs::read(cert_path).await.map_err(|err| { + vm::Error::Message(format!( + "Unable to open certificate `{}`: {}", + cert_path.display(), + err + )) + })?; + + let identity = native_tls::Identity::from_pkcs12(&identity, "") + .map_err(|err| vm::Error::Message(err.to_string()))?; + let acceptor = tokio_native_tls::TlsAcceptor::from( + native_tls::TlsAcceptor::new(identity) + .map_err(|err| vm::Error::Message(err.to_string()))?, + ); - let addr = SocketAddr::from(([0, 0, 0, 0], settings.port)); + let tcp_listener = tokio::net::TcpListener::bind(&addr) + .map_err(|err| vm::Error::Message(err.to_string())) + .await?; + let incoming = tokio_stream::wrappers::TcpListenerStream::new(tcp_listener) + .err_into() + .and_then(|stream| { + acceptor.accept(stream).map_err(|err| { + info!("Unable to accept TLS connection: {}", err); + Box::new(err) as Box + }) + }); - let listener = Handler::new(&thread, handler); - - if let Some(cert_path) = &settings.tls_cert { - let identity = fs::read(cert_path).map_err(|err| { - vm::Error::Message(format!( - "Unable to open certificate `{}`: {}", - cert_path.display(), - err - )) - })?; - - let identity = native_tls::Identity::from_pkcs12(&identity, "") - .map_err(|err| vm::Error::Message(err.to_string()))?; - let acceptor = tokio_native_tls::TlsAcceptor::from( - native_tls::TlsAcceptor::new(identity) - .map_err(|err| vm::Error::Message(err.to_string()))?, - ); - - let tcp_listener = tokio::net::TcpListener::bind(&addr) - .map_err(|err| vm::Error::Message(err.to_string())) - .await?; - let incoming = tokio_stream::wrappers::TcpListenerStream::new(tcp_listener) - .err_into() - .and_then(|stream| { - acceptor.accept(stream).map_err(|err| { - info!("Unable to accept TLS connection: {}", err); - Box::new(err) as Box - }) - }); - - tokio::pin!(incoming); - loop { - let stream = match incoming.next().await { - Some(Ok(stream)) => stream, - Some(Err(err)) => { - info!("Error accepting TLS connection: {}", err); - continue; - } - None => break, - }; - - let io = TokioIo::new(stream); - let listener = listener.clone(); - tokio::spawn(async move { - let service = service_fn(move |request: hyper::Request| { - let mut listener = listener.clone(); - async move { - Ok::<_, ::std::convert::Infallible>(match request.into_parts() { - (parts, body) => match listener - .handle(parts.method, parts.uri, body.into_data_stream()) - .await - { - Ok(response) => response, - Err(err) => { - info!("{}", err); - internal_error_response() - } - }, - }) - } - }); - if let Err(err) = ServerBuilder::new(TokioExecutor::new()) - .serve_connection(io, service) - .await - { - info!("Server error: {}", err); - } - }); - } + tokio::pin!(incoming); + loop { + let stream = match incoming.next().await { + Some(Ok(stream)) => stream, + Some(Err(err)) => { + info!("Error accepting TLS connection: {}", err); + continue; + } + None => break, + }; - return Ok(()); + accept_stream(handler.clone(), stream); } - let tcp_listener = tokio::net::TcpListener::bind(&addr) + Ok(()) +} + +async fn listen_http(addr: SocketAddr, handler: Handler) -> vm::Result<()> { + let tcp_listener = TcpListener::bind(&addr) .map_err(|err| vm::Error::Message(err.to_string())) .await?; @@ -303,34 +293,41 @@ async fn listen_( .accept() .map_err(|err| vm::Error::Message(err.to_string())) .await?; - let io = TokioIo::new(stream); - let listener = listener.clone(); - tokio::spawn(async move { - let service = service_fn(move |request: hyper::Request| { - let mut listener = listener.clone(); - async move { - Ok::<_, ::std::convert::Infallible>(match request.into_parts() { - (parts, body) => match listener - .handle(parts.method, parts.uri, body.into_data_stream()) - .await - { - Ok(response) => response, - Err(err) => { - info!("{}", err); - internal_error_response() - } - }, - }) - } - }); - if let Err(err) = ServerBuilder::new(TokioExecutor::new()) - .serve_connection(io, service) - .await - { - info!("Server error: {}", err); + + accept_stream(handler.clone(), stream); + } +} + +fn accept_stream( + handler: Handler, + stream: impl tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + Unpin + 'static, +) { + let io = TokioIo::new(stream); + tokio::spawn(async move { + let service = service_fn(move |request: hyper::Request| { + let mut handler = handler.clone(); + async move { + Ok::<_, ::std::convert::Infallible>(match request.into_parts() { + (parts, body) => match handler + .handle(parts.method, parts.uri, body.into_data_stream()) + .await + { + Ok(response) => response, + Err(err) => { + info!("{}", err); + internal_error_response() + } + }, + }) } }); - } + if let Err(err) = ServerBuilder::new(TokioExecutor::new()) + .serve_connection(io, service) + .await + { + info!("Server error: {}", err); + } + }); } type ListenFn = fn(OpaqueValue>, HttpState) -> IO; From c5f3820540e64dd1ad41a4799982f89f38240023 Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Thu, 9 Jul 2026 21:36:41 +0200 Subject: [PATCH 2/8] chore: Use dep: in cargo.toml --- CHANGELOG.md | 12 ++++++++++++ Cargo.lock | 22 +++++++++++----------- Cargo.toml | 42 +++++++++++++++++++++--------------------- README.md | 2 +- base/Cargo.toml | 4 ++-- base/src/lib.rs | 2 +- c-api/Cargo.toml | 4 ++-- c-api/src/lib.rs | 2 +- check/Cargo.toml | 8 ++++---- check/src/lib.rs | 2 +- codegen/Cargo.toml | 2 +- completion/Cargo.toml | 8 ++++---- completion/src/lib.rs | 2 +- doc/Cargo.toml | 6 +++--- format/Cargo.toml | 6 +++--- format/src/lib.rs | 2 +- parser/Cargo.toml | 4 ++-- parser/src/lib.rs | 2 +- repl/Cargo.toml | 14 +++++++------- src/lib.rs | 2 +- vm/Cargo.toml | 14 +++++++------- vm/src/lib.rs | 2 +- 22 files changed, 88 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f948890d7..b55e340cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## [0.18.4](https://github.com/gluon-lang/gluon/compare/v0.18.3..0.18.4) - 2026-08-03 + +### Bug Fixes + +- Don't cascade errors if a module (or variable) is undefined - ([d7df0aa](https://github.com/gluon-lang/gluon/commit/d7df0aaf5f12652196ec1c52449d4d528f66d977)) - Markus Westerlind + +## [0.18.4](https://github.com/gluon-lang/gluon/compare/v0.18.3..0.18.4) - 2026-08-03 + +### Bug Fixes + +- Don't cascade errors if a module (or variable) is undefined - ([d7df0aa](https://github.com/gluon-lang/gluon/commit/d7df0aaf5f12652196ec1c52449d4d528f66d977)) - Markus Westerlind + ## [0.18.3](https://github.com/gluon-lang/gluon/compare/v0.18.2..0.18.3) - 2026-07-08 ### Bug Fixes diff --git a/Cargo.lock b/Cargo.lock index 162023c3f..eb7eff030 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1335,7 +1335,7 @@ checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "gluon" -version = "0.18.3" +version = "0.18.4" dependencies = [ "anyhow", "async-trait", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "gluon_base" -version = "0.18.3" +version = "0.18.4" dependencies = [ "anymap", "bitflags 1.3.2", @@ -1452,7 +1452,7 @@ dependencies = [ [[package]] name = "gluon_c-api" -version = "0.18.3" +version = "0.18.4" dependencies = [ "futures 0.3.32", "gluon", @@ -1461,7 +1461,7 @@ dependencies = [ [[package]] name = "gluon_check" -version = "0.18.3" +version = "0.18.4" dependencies = [ "codespan", "codespan-reporting", @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "gluon_codegen" -version = "0.18.3" +version = "0.18.4" dependencies = [ "env_logger 0.11.11", "gluon", @@ -1500,7 +1500,7 @@ dependencies = [ [[package]] name = "gluon_completion" -version = "0.18.3" +version = "0.18.4" dependencies = [ "codespan", "collect-mac", @@ -1517,7 +1517,7 @@ dependencies = [ [[package]] name = "gluon_doc" -version = "0.18.3" +version = "0.18.4" dependencies = [ "anyhow", "cargo-deadlinks", @@ -1543,7 +1543,7 @@ dependencies = [ [[package]] name = "gluon_format" -version = "0.18.3" +version = "0.18.4" dependencies = [ "codespan", "difference", @@ -1563,7 +1563,7 @@ dependencies = [ [[package]] name = "gluon_parser" -version = "0.18.3" +version = "0.18.4" dependencies = [ "codespan", "codespan-reporting", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "gluon_repl" -version = "0.18.3" +version = "0.18.4" dependencies = [ "ansi_term", "anyhow", @@ -1613,7 +1613,7 @@ dependencies = [ [[package]] name = "gluon_vm" -version = "0.18.3" +version = "0.18.4" dependencies = [ "async-trait", "bitflags 1.3.2", diff --git a/Cargo.toml b/Cargo.toml index 33e926870..98f3bec30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus "] keywords = ["script", "scripting", "language"] build = "build.rs" @@ -24,13 +24,13 @@ name = "gluon" path = "src/lib.rs" [dependencies] -gluon_base = { path = "base", version = "0.18.3" } # GLUON -gluon_check = { path = "check", version = "0.18.3" } # GLUON -gluon_parser = { path = "parser", version = "0.18.3" } # GLUON -gluon_codegen = { path = "codegen", version = "0.18.3" } # GLUON -gluon_vm = { path = "vm", version = "0.18.3", default-features = false } # GLUON -gluon_format = { path = "format", version = "0.18.3", default-features = false } # GLUON -gluon_completion = { path = "completion", version = "0.18.3", default-features = false, optional = true } # GLUON +gluon_base = { path = "base", version = "0.18.4" } # GLUON +gluon_check = { path = "check", version = "0.18.4" } # GLUON +gluon_parser = { path = "parser", version = "0.18.4" } # GLUON +gluon_codegen = { path = "codegen", version = "0.18.4" } # GLUON +gluon_vm = { path = "vm", version = "0.18.4", default-features = false } # GLUON +gluon_format = { path = "format", version = "0.18.4", default-features = false } # GLUON +gluon_completion = { path = "completion", version = "0.18.4", default-features = false, optional = true } # GLUON async-trait = "0.1.73" log = "0.4.20" @@ -79,7 +79,7 @@ rand = { version = "0.10", optional = true } rand_xorshift = { version = "0.5", optional = true } [build-dependencies] -gluon_base = { path = "base", version = "0.18.3" } # GLUON +gluon_base = { path = "base", version = "0.18.4" } # GLUON itertools.workspace = true little-skeptic = { version = "0.15.2", optional = true } @@ -108,8 +108,8 @@ bincode = "2.0.0" pulldown-cmark = "0.13.4" -gluon_completion = { path = "completion", version = "0.18.3" } # GLUON -gluon_codegen = { path = "codegen", version = "0.18.3" } # GLUON +gluon_completion = { path = "completion", version = "0.18.4" } # GLUON +gluon_codegen = { path = "codegen", version = "0.18.4" } # GLUON [workspace.dependencies] env_logger = "0.11" @@ -126,7 +126,7 @@ lalrpop-util = "0.23.1" [features] default = ["async", "regex", "random"] async = ["tokio"] -random = ["rand", "rand_xorshift"] +random = ["dep:rand", "dep:rand_xorshift"] serialization = [ "serde", "serde_state", @@ -135,23 +135,23 @@ serialization = [ ] web = [ "async", - "hyper", - "hyper-util", - "http-body-util", + "dep:hyper", + "dep:hyper-util", + "dep:http-body-util", "http", - "tower-service", + "dep:tower-service", "tokio/net", - "tokio-stream", - "pin-project-lite", + "dep:tokio-stream", + "dep:pin-project-lite", ] -web-tls = ["tokio/fs", "native-tls", "tokio-native-tls"] +web-tls = ["tokio/fs", "dep:native-tls", "dep:tokio-native-tls"] gluon_completion = ["dep:gluon_completion", "gluon_vm/gluon_completion"] docs_rs = ["serialization"] -test = ["serialization", "little-skeptic", "http", "web", "gluon_vm/test"] -nightly = ["compiletest_rs", "gluon_base/nightly"] +test = ["serialization", "dep:little-skeptic", "http", "web", "gluon_vm/test"] +nightly = ["dep:compiletest_rs", "gluon_base/nightly"] test_nightly = ["test", "nightly"] [[bench]] diff --git a/README.md b/README.md index 9e1ee1f98..f6ca62bfc 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,7 @@ Gluon requires a recent Rust compiler to build (1.9.0 or later) and is available ```toml [dependencies] -gluon = "0.18.3" +gluon = "0.18.4" ``` ### Other languages diff --git a/base/Cargo.toml b/base/Cargo.toml index 79f33a789..478afa0de 100644 --- a/base/Cargo.toml +++ b/base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_base" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus "] edition = "2024" @@ -30,7 +30,7 @@ either = "1.9.0" vec_map = "0.8.2" typed-arena = "2.0.2" -gluon_codegen = { version = "0.18.3", path = "../codegen" } # GLUON +gluon_codegen = { version = "0.18.4", path = "../codegen" } # GLUON serde = { version = "1.0.188", features = ["rc"], optional = true } serde_state = { version = "0.4.8", features = ["rc"], optional = true } diff --git a/base/src/lib.rs b/base/src/lib.rs index 29debbe72..d30959fdc 100644 --- a/base/src/lib.rs +++ b/base/src/lib.rs @@ -1,4 +1,4 @@ -#![doc(html_root_url = "https://docs.rs/gluon_base/0.18.3")] // # GLUON +#![doc(html_root_url = "https://docs.rs/gluon_base/0.18.4")] // # GLUON #![allow(unknown_lints)] //! The base crate contains pervasive types used in the compiler such as type representations, the //! AST and some basic containers. diff --git a/c-api/Cargo.toml b/c-api/Cargo.toml index 64dbd1936..3f9d460b4 100644 --- a/c-api/Cargo.toml +++ b/c-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_c-api" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus Westerlind "] edition = "2024" @@ -16,7 +16,7 @@ documentation = "https://docs.rs/gluon" crate-type = ["cdylib"] [dependencies] -gluon = { version = "0.18.3", path = ".." } # GLUON +gluon = { version = "0.18.4", path = ".." } # GLUON futures = "0.3.28" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/c-api/src/lib.rs b/c-api/src/lib.rs index 76f259bbe..28777310b 100644 --- a/c-api/src/lib.rs +++ b/c-api/src/lib.rs @@ -1,5 +1,5 @@ //! A (WIP) C API allowing use of gluon in other langauges than Rust. -#![doc(html_root_url = "https://docs.rs/gluon_c-api/0.18.3")] // # GLUON +#![doc(html_root_url = "https://docs.rs/gluon_c-api/0.18.4")] // # GLUON use std::{slice, str}; diff --git a/check/Cargo.toml b/check/Cargo.toml index bfa86c755..60d8ddb33 100644 --- a/check/Cargo.toml +++ b/check/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_check" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus "] edition = "2024" @@ -27,14 +27,14 @@ codespan-reporting.workspace = true strsim = "0.11.1" -gluon_base = { path = "../base", version = "0.18.3" } # GLUON -gluon_codegen = { path = "../codegen", version = "0.18.3" } # GLUON +gluon_base = { path = "../base", version = "0.18.4" } # GLUON +gluon_codegen = { path = "../codegen", version = "0.18.4" } # GLUON [dev-dependencies] env_logger.workspace = true insta = "1.31.0" -gluon_parser = { path = "../parser", version = "0.18.3" } # GLUON +gluon_parser = { path = "../parser", version = "0.18.4" } # GLUON gluon_format = { path = "../format", version = ">=0.9" } collect-mac = "0.1.0" diff --git a/check/src/lib.rs b/check/src/lib.rs index 09763ff71..654794e4b 100644 --- a/check/src/lib.rs +++ b/check/src/lib.rs @@ -3,7 +3,7 @@ //! If an AST passes the checks in `Typecheck::typecheck_expr` (which runs all of theses checks //! the expression is expected to compile succesfully (if it does not it should be considered an //! internal compiler error. -#![doc(html_root_url = "https://docs.rs/gluon_check/0.18.3")] // # GLUON +#![doc(html_root_url = "https://docs.rs/gluon_check/0.18.4")] // # GLUON #[macro_use] extern crate collect_mac; diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index ee5767817..39a8d7a6c 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_codegen" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus "] edition = "2024" diff --git a/completion/Cargo.toml b/completion/Cargo.toml index bb126199c..66ac22af1 100644 --- a/completion/Cargo.toml +++ b/completion/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_completion" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus "] edition = "2024" @@ -17,7 +17,7 @@ itertools.workspace = true walkdir = "2.3.3" codespan.workspace = true -gluon_base = { path = "../base", version = "0.18.3" } # GLUON +gluon_base = { path = "../base", version = "0.18.4" } # GLUON [dev-dependencies] collect-mac = "0.1.0" @@ -25,5 +25,5 @@ env_logger.workspace = true pretty_assertions = "1.4.0" quick-error = "2.0.1" -gluon_check = { path = "../check", version = "0.18.3" } # GLUON -gluon_parser = { path = "../parser", version = "0.18.3" } # GLUON +gluon_check = { path = "../check", version = "0.18.4" } # GLUON +gluon_parser = { path = "../parser", version = "0.18.4" } # GLUON diff --git a/completion/src/lib.rs b/completion/src/lib.rs index 0c8f30e40..2f696b971 100644 --- a/completion/src/lib.rs +++ b/completion/src/lib.rs @@ -1,5 +1,5 @@ //! Primitive auto completion and type quering on ASTs -#![doc(html_root_url = "https://docs.rs/gluon_completion/0.18.3")] // # GLUON +#![doc(html_root_url = "https://docs.rs/gluon_completion/0.18.4")] // # GLUON extern crate gluon_base as base; diff --git a/doc/Cargo.toml b/doc/Cargo.toml index 432272d06..6b67ee75a 100644 --- a/doc/Cargo.toml +++ b/doc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_doc" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus Westerlind "] edition = "2024" @@ -31,8 +31,8 @@ serde = "1.0.188" serde_derive = "1.0.188" serde_json = "1.0.105" -gluon = { version = "0.18.3", default-features = false, path = ".." } # GLUON -completion = { package = "gluon_completion", version = "0.18.3", path = "../completion" } # GLUON +gluon = { version = "0.18.4", default-features = false, path = ".." } # GLUON +completion = { package = "gluon_completion", version = "0.18.4", path = "../completion" } # GLUON [dev-dependencies] diff --git a/format/Cargo.toml b/format/Cargo.toml index a6b45e22e..269f7bf46 100644 --- a/format/Cargo.toml +++ b/format/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_format" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus "] edition = "2024" @@ -17,7 +17,7 @@ pretty.workspace = true itertools.workspace = true codespan.workspace = true -gluon_base = { path = "../base", version = "0.18.3" } # GLUON +gluon_base = { path = "../base", version = "0.18.4" } # GLUON [dev-dependencies] difference = "2.0.0" @@ -28,7 +28,7 @@ pretty_assertions = "1.4.0" tokio = { version = "1.32.0", features = ["macros"] } walkdir = "2.3.3" -gluon_base = { path = "../base", version = "0.18.3" } # GLUON +gluon_base = { path = "../base", version = "0.18.4" } # GLUON gluon = { path = "..", version = ">=0.9" } tensile = { version = "0.8", features = ["tokio"] } diff --git a/format/src/lib.rs b/format/src/lib.rs index 046c7195b..f8979d31e 100644 --- a/format/src/lib.rs +++ b/format/src/lib.rs @@ -1,5 +1,5 @@ //! Code formatter. -#![doc(html_root_url = "https://docs.rs/gluon_formatter/0.18.3")] // # GLUON +#![doc(html_root_url = "https://docs.rs/gluon_formatter/0.18.4")] // # GLUON extern crate codespan; #[macro_use] diff --git a/parser/Cargo.toml b/parser/Cargo.toml index 907a9b5f0..56114f0b6 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_parser" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus "] edition = "2024" @@ -20,7 +20,7 @@ itertools.workspace = true quick-error = "2.0.1" lalrpop-util.workspace = true log = "0.4.20" -gluon_base = { path = "../base", version = "0.18.3" } # GLUON +gluon_base = { path = "../base", version = "0.18.4" } # GLUON ordered-float.workspace = true codespan.workspace = true codespan-reporting.workspace = true diff --git a/parser/src/lib.rs b/parser/src/lib.rs index 3cd0e3092..c5b40c520 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -1,7 +1,7 @@ //! The parser is a bit more complex than it needs to be as it needs to be fully specialized to //! avoid a recompilation every time a later part of the compiler is changed. Due to this the //! string interner and therefore also garbage collector needs to compiled before the parser. -#![doc(html_root_url = "https://docs.rs/gluon_parser/0.18.3")] // # GLUON +#![doc(html_root_url = "https://docs.rs/gluon_parser/0.18.4")] // # GLUON extern crate gluon_base as base; #[macro_use] diff --git a/repl/Cargo.toml b/repl/Cargo.toml index a13cf047d..63ecf85dc 100644 --- a/repl/Cargo.toml +++ b/repl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_repl" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus Westerlind "] edition = "2024" @@ -17,12 +17,12 @@ path = "src/main.rs" doc = false [dependencies] -gluon = { version = "0.18.3", path = "..", features = ["serialization",] } # GLUON -gluon_vm = { version = "0.18.3", path = "../vm", features = ["gluon_completion", "serialization"] } # GLUON -gluon_completion = { path = "../completion", version = "0.18.3" } # GLUON -gluon_codegen = { path = "../codegen", version = "0.18.3" } # GLUON -gluon_format = { version = "0.18.3", path = "../format" } # GLUON -gluon_doc = { version = "0.18.3", path = "../doc" } # GLUON +gluon = { version = "0.18.4", path = "..", features = ["serialization",] } # GLUON +gluon_vm = { version = "0.18.4", path = "../vm", features = ["gluon_completion", "serialization"] } # GLUON +gluon_completion = { path = "../completion", version = "0.18.4" } # GLUON +gluon_codegen = { path = "../codegen", version = "0.18.4" } # GLUON +gluon_format = { version = "0.18.4", path = "../format" } # GLUON +gluon_doc = { version = "0.18.4", path = "../doc" } # GLUON app_dirs = { package = "app_dirs2", version = "2.5.5" } anyhow = "1.0.75" diff --git a/src/lib.rs b/src/lib.rs index 3d62419b4..05cf56844 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ //! behaviour. For information about how to use this library the best resource currently is the //! [tutorial](http://gluon-lang.org/book/index.html) which contains examples //! on how to write gluon programs as well as how to run them using this library. -#![doc(html_root_url = "https://docs.rs/gluon/0.18.3")] // # GLUON +#![doc(html_root_url = "https://docs.rs/gluon/0.18.4")] // # GLUON #![recursion_limit = "128"] pub use either; diff --git a/vm/Cargo.toml b/vm/Cargo.toml index 5b01294e2..615159b0f 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluon_vm" -version = "0.18.3" # GLUON +version = "0.18.4" # GLUON authors = ["Markus "] edition = "2024" build = "build.rs" @@ -43,11 +43,11 @@ serde_state = { version = "0.4.8", optional = true } serde_derive = { version = "1.0.188", optional = true } serde_derive_state = { version = "0.4.10", optional = true } -gluon_base = { path = "../base", version = "0.18.3" } # GLUON -gluon_check = { path = "../check", version = "0.18.3" } # GLUON -gluon_codegen = { path = "../codegen", version = "0.18.3" } # GLUON -gluon_parser = { path = "../parser", version = "0.18.3", optional = true } # GLUON -gluon_completion = { path = "../completion", version = "0.18.3", optional = true } # GLUON +gluon_base = { path = "../base", version = "0.18.4" } # GLUON +gluon_check = { path = "../check", version = "0.18.4" } # GLUON +gluon_codegen = { path = "../codegen", version = "0.18.4" } # GLUON +gluon_parser = { path = "../parser", version = "0.18.4", optional = true } # GLUON +gluon_completion = { path = "../completion", version = "0.18.4", optional = true } # GLUON [build-dependencies] lalrpop = { workspace = true, features = ["lexer"], optional = true } @@ -66,7 +66,7 @@ regex = "1.9.4" serde_json = "1.0.105" tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] } -gluon_parser = { path = "../parser", version = "0.18.3" } # GLUON +gluon_parser = { path = "../parser", version = "0.18.4" } # GLUON [features] serialization = [ diff --git a/vm/src/lib.rs b/vm/src/lib.rs index 1c8a8658c..901bb2f26 100644 --- a/vm/src/lib.rs +++ b/vm/src/lib.rs @@ -1,5 +1,5 @@ //! Crate which contain the virtual machine which executes gluon programs -#![doc(html_root_url = "https://docs.rs/gluon_vm/0.18.3")] // # GLUON +#![doc(html_root_url = "https://docs.rs/gluon_vm/0.18.4")] // # GLUON #![recursion_limit = "1024"] #[macro_use] From 776a218249328f4e1eb76fed92c744641b29fc1a Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Mon, 3 Aug 2026 21:14:13 +0200 Subject: [PATCH 3/8] Version 0.18.4 ## [0.18.4](https://github.com/gluon-lang/gluon/compare/v0.18.3..0.18.4) - 2026-08-03 ### Bug Fixes - Don't cascade errors if a module (or variable) is undefined - ([d7df0aa](https://github.com/gluon-lang/gluon/commit/d7df0aaf5f12652196ec1c52449d4d528f66d977)) - Markus Westerlind --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b55e340cf..b8ca9e060 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ - Don't cascade errors if a module (or variable) is undefined - ([d7df0aa](https://github.com/gluon-lang/gluon/commit/d7df0aaf5f12652196ec1c52449d4d528f66d977)) - Markus Westerlind +## [0.18.4](https://github.com/gluon-lang/gluon/compare/v0.18.3..0.18.4) - 2026-08-03 + +### Bug Fixes + +- Don't cascade errors if a module (or variable) is undefined - ([d7df0aa](https://github.com/gluon-lang/gluon/commit/d7df0aaf5f12652196ec1c52449d4d528f66d977)) - Markus Westerlind + ## [0.18.3](https://github.com/gluon-lang/gluon/compare/v0.18.2..0.18.3) - 2026-07-08 ### Bug Fixes From 622eee0626c1c1b94341292346fca2244409e1d4 Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Mon, 3 Aug 2026 23:46:46 +0200 Subject: [PATCH 4/8] chore: Error reporting --- examples/24.rs | 2 +- tests/compiletest.rs | 8 +++++++- tests/skeptic-tests.rs | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/24.rs b/examples/24.rs index 6b367c439..a4566b3c6 100644 --- a/examples/24.rs +++ b/examples/24.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "rand")] +#![cfg(feature = "random")] use std::{fs::File, io::Read}; diff --git a/tests/compiletest.rs b/tests/compiletest.rs index e06e39964..6ce5df0cf 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -10,7 +10,13 @@ fn lib_dir(out_dir: &Path, lib_name: &str, extension: &str) -> PathBuf { // flags which gives ambiguity errors. // Instead retrieve the latest compiled gluon library which should usually be the correct one let mut gluon_rlibs: Vec<_> = fs::read_dir(out_dir.join("deps")) - .unwrap() + .unwrap_or_else(|err| { + panic!( + "Failed to read dir {}: {}", + out_dir.join("deps").display(), + err + ) + }) .filter_map(|entry| { let entry = entry.expect("dir entry"); if entry diff --git a/tests/skeptic-tests.rs b/tests/skeptic-tests.rs index c4a781cf3..62eb735ce 100644 --- a/tests/skeptic-tests.rs +++ b/tests/skeptic-tests.rs @@ -1,2 +1,2 @@ -#![cfg(feature = "little-skeptic")] +#![cfg(feature = "test")] include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs")); From 2c1c51c468dd1e91dd2dcb6562aa4cc05f6cf0b6 Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Wed, 5 Aug 2026 00:06:07 +0200 Subject: [PATCH 5/8] chore: Remove duplicates from changelog --- CHANGELOG.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8ca9e060..1ef379b24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,18 +4,6 @@ - Don't cascade errors if a module (or variable) is undefined - ([d7df0aa](https://github.com/gluon-lang/gluon/commit/d7df0aaf5f12652196ec1c52449d4d528f66d977)) - Markus Westerlind -## [0.18.4](https://github.com/gluon-lang/gluon/compare/v0.18.3..0.18.4) - 2026-08-03 - -### Bug Fixes - -- Don't cascade errors if a module (or variable) is undefined - ([d7df0aa](https://github.com/gluon-lang/gluon/commit/d7df0aaf5f12652196ec1c52449d4d528f66d977)) - Markus Westerlind - -## [0.18.4](https://github.com/gluon-lang/gluon/compare/v0.18.3..0.18.4) - 2026-08-03 - -### Bug Fixes - -- Don't cascade errors if a module (or variable) is undefined - ([d7df0aa](https://github.com/gluon-lang/gluon/commit/d7df0aaf5f12652196ec1c52449d4d528f66d977)) - Markus Westerlind - ## [0.18.3](https://github.com/gluon-lang/gluon/compare/v0.18.2..0.18.3) - 2026-07-08 ### Bug Fixes From f87ea7af8adb4d508ec51ba62748c5f7b0ae29c1 Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Tue, 4 Aug 2026 21:00:08 +0200 Subject: [PATCH 6/8] refactor: Switch to ui_test from compiletest Compile test is no longer maintained --- Cargo.lock | 353 +++-- Cargo.toml | 9 +- base/Cargo.toml | 8 +- base/tests/compile-fail/Cargo.lock | 309 +++++ base/tests/compile-fail/Cargo.toml | 12 + base/tests/compile-fail/arena-1.rs | 4 +- base/tests/compile-fail/arena-1.stderr | 26 + base/tests/compile-fail/arena-2.rs | 6 +- base/tests/compile-fail/arena-2.stderr | 41 + base/tests/compile-fail/compile_fail_lib.in | 1 + base/tests/compiletest.rs | 77 +- tests/compile-fail/Cargo.lock | 1205 +++++++++++++++++ tests/compile-fail/Cargo.toml | 14 + tests/compile-fail/compile_fail_lib.in | 1 + tests/compile-fail/get-reference.rs | 14 +- tests/compile-fail/get-reference.stderr | 15 + tests/compile-fail/getable-reference-str.rs | 3 +- .../compile-fail/getable-reference-str.stderr | 23 + tests/compile-fail/getable-reference.rs | 3 +- tests/compile-fail/getable-reference.stderr | 25 + tests/compile-fail/run_expr_str_ref.rs | 6 +- tests/compile-fail/run_expr_str_ref.stderr | 26 + tests/compile-fail/store-ref.rs | 3 +- tests/compile-fail/store-ref.stderr | 31 + tests/compiletest.rs | 102 +- tests/main.rs | 2 +- 26 files changed, 2035 insertions(+), 284 deletions(-) create mode 100644 base/tests/compile-fail/Cargo.lock create mode 100644 base/tests/compile-fail/Cargo.toml create mode 100644 base/tests/compile-fail/arena-1.stderr create mode 100644 base/tests/compile-fail/arena-2.stderr create mode 100644 base/tests/compile-fail/compile_fail_lib.in create mode 100644 tests/compile-fail/Cargo.lock create mode 100644 tests/compile-fail/Cargo.toml create mode 100644 tests/compile-fail/compile_fail_lib.in create mode 100644 tests/compile-fail/get-reference.stderr create mode 100644 tests/compile-fail/getable-reference-str.stderr create mode 100644 tests/compile-fail/getable-reference.stderr create mode 100644 tests/compile-fail/run_expr_str_ref.stderr create mode 100644 tests/compile-fail/store-ref.stderr diff --git a/Cargo.lock b/Cargo.lock index eb7eff030..f88ed83bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,6 +59,16 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "annotate-snippets" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4" +dependencies = [ + "anstyle", + "unicode-width", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -163,7 +173,7 @@ version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef1e3e699d84ab1b0911a1010c5c106aa34ae89aeac103be5ce0c3859db1e891" dependencies = [ - "term 1.2.1", + "term", ] [[package]] @@ -365,6 +375,15 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-platform" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122ec45a44b270afd1402f351b782c676b173e3c3fb28d86ff7ebfb4d86a4ee4" +dependencies = [ + "serde", +] + [[package]] name = "cargo_metadata" version = "0.8.2" @@ -384,12 +403,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", - "cargo-platform", + "cargo-platform 0.1.9", "semver 1.0.28", "serde", "serde_json", ] +[[package]] +name = "cargo_metadata" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" +dependencies = [ + "camino", + "cargo-platform 0.3.1", + "semver 1.0.28", + "serde", + "serde_json", + "thiserror 2.0.18", +] + [[package]] name = "cast" version = "0.3.0" @@ -544,12 +577,48 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f168712e49987bd2f51cb855c4585999e12b1a0abdff60fea4b81b41f2010264" +[[package]] +name = "color-eyre" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "colorchoice" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" +[[package]] +name = "colored" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "combine" version = "4.6.7" @@ -566,28 +635,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335" -[[package]] -name = "compiletest_rs" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f150fe9105fcd2a57cad53f0c079a24de65195903ef670990f5909f695eac04c" -dependencies = [ - "diff", - "filetime", - "getopts", - "lazy_static", - "libc", - "log", - "miow", - "regex", - "rustfix", - "serde", - "serde_derive", - "serde_json", - "tester", - "windows-sys 0.59.0", -] - [[package]] name = "console" version = "0.16.4" @@ -596,6 +643,7 @@ checksum = "4fe5f465a4f6fee88fad41b85d990f84c835335e85b5d9e6e63e0d06d28cba7c" dependencies = [ "encode_unicode", "libc", + "unicode-width", "windows-sys 0.61.2", ] @@ -674,6 +722,15 @@ dependencies = [ "itertools 0.13.0", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d85363c37faeca707aef026efa9f3b34d077bce547e48f770770625c6013679e" +dependencies = [ + "crossbeam-utils 0.8.21", +] + [[package]] name = "crossbeam-deque" version = "0.8.6" @@ -884,27 +941,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if 1.0.4", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "displaydoc" version = "0.2.6" @@ -1056,6 +1092,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "failure" version = "0.1.8" @@ -1084,16 +1130,6 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" -[[package]] -name = "filetime" -version = "0.2.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" -dependencies = [ - "cfg-if 1.0.4", - "libc", -] - [[package]] name = "find-msvc-tools" version = "0.1.9" @@ -1344,7 +1380,6 @@ dependencies = [ "codespan", "codespan-reporting", "collect-mac", - "compiletest_rs", "criterion", "either", "env_logger 0.11.11", @@ -1386,6 +1421,7 @@ dependencies = [ "tokio-native-tls", "tokio-stream", "tower-service", + "ui_test", "walkdir", ] @@ -1429,7 +1465,6 @@ dependencies = [ "codespan", "codespan-reporting", "collect-mac", - "compiletest_rs", "either", "env_logger 0.11.11", "fnv", @@ -1447,6 +1482,7 @@ dependencies = [ "serde_state", "smallvec", "typed-arena", + "ui_test", "vec_map", ] @@ -2007,6 +2043,12 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "indenter" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" + [[package]] name = "indexmap" version = "1.9.3" @@ -2027,6 +2069,19 @@ dependencies = [ "hashbrown 0.17.1", ] +[[package]] +name = "indicatif" +version = "0.18.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9433806cd6b4ec1aba79c021c7e4c58fb4c3b9977c085062e611ac929998fb0c" +dependencies = [ + "console", + "portable-atomic", + "unicode-width", + "unit-prefix", + "web-time", +] + [[package]] name = "insta" version = "1.48.0" @@ -2199,7 +2254,7 @@ dependencies = [ "regex-syntax", "sha3", "string_cache", - "term 1.2.1", + "term", "unicode-xid", "walkdir", ] @@ -2226,19 +2281,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] -name = "libc" -version = "0.2.186" +name = "levenshtein" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" [[package]] -name = "libredox" -version = "0.1.18" +name = "libc" +version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c943259e342f1e06ff2da7a83eabdfe7f92ce10262688dbf1895ff0b3e6e4652" -dependencies = [ - "libc", -] +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "linux-raw-sys" @@ -2343,15 +2395,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "miow" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "536bfad37a309d62069485248eeaba1e8d9853aaf951caaeaed0585a95346f08" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "native-tls" version = "0.2.18" @@ -2541,6 +2584,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "owo-colors" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d211803b9b6b570f68772237e415a029d5a50c65d382910b879fb19d3271f94d" + [[package]] name = "page_size" version = "0.6.0" @@ -2833,6 +2882,15 @@ dependencies = [ "yansi", ] +[[package]] +name = "prettydiff" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac17546d82912e64874e3d5b40681ce32eac4e5834344f51efcf689ff1550a65" +dependencies = [ + "owo-colors", +] + [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -3067,17 +3125,6 @@ dependencies = [ "bitflags 2.13.0", ] -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom 0.2.17", - "libredox", - "thiserror 1.0.69", -] - [[package]] name = "regex" version = "1.12.4" @@ -3444,6 +3491,15 @@ dependencies = [ "keccak", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "2.0.1" @@ -3500,6 +3556,17 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "spanned" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4b0c055fde758f086eb4a6e73410247df8a3837fd606d2caeeaf72aa566d" +dependencies = [ + "anyhow", + "bstr", + "color-eyre", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -3611,17 +3678,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", -] - [[package]] name = "term" version = "1.2.1" @@ -3640,19 +3696,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "tester" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e8bf7e0eb2dd7b4228cc1b6821fc5114cd6841ae59f652a85488c016091e5f" -dependencies = [ - "cfg-if 1.0.4", - "getopts", - "libc", - "num_cpus", - "term 0.7.0", -] - [[package]] name = "thin-slice" version = "0.1.1" @@ -3699,6 +3742,15 @@ dependencies = [ "syn 2.0.118", ] +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if 1.0.4", +] + [[package]] name = "tinystr" version = "0.8.3" @@ -3803,6 +3855,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-error" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "sharded-slab", + "thread_local", + "tracing-core", ] [[package]] @@ -3835,6 +3909,32 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +[[package]] +name = "ui_test" +version = "0.30.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c8811281d587a786747c0c49245925016c07767bc996305bdd34d5ce076786a" +dependencies = [ + "annotate-snippets", + "anyhow", + "bstr", + "cargo-platform 0.3.1", + "cargo_metadata 0.23.1", + "color-eyre", + "colored", + "comma", + "crossbeam-channel", + "indicatif", + "levenshtein", + "prettydiff", + "regex", + "rustc_version", + "rustfix", + "serde", + "serde_json", + "spanned", +] + [[package]] name = "unicase" version = "2.9.0" @@ -3865,6 +3965,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unit-prefix" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" + [[package]] name = "untrusted" version = "0.9.0" @@ -3916,6 +4022,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + [[package]] name = "vcpkg" version = "0.2.15" @@ -4026,6 +4138,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.26.11" @@ -4099,15 +4221,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.61.2" diff --git a/Cargo.toml b/Cargo.toml index 98f3bec30..2153f7980 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,7 +72,7 @@ native-tls = { version = "0.2.11", optional = true } tokio-native-tls = { version = "0.3.1", optional = true } # Crates used in testing -compiletest_rs = { version = "0.11", optional = true } +ui_test = { version = "0.30", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] rand = { version = "0.10", optional = true } @@ -151,7 +151,7 @@ gluon_completion = ["dep:gluon_completion", "gluon_vm/gluon_completion"] docs_rs = ["serialization"] test = ["serialization", "dep:little-skeptic", "http", "web", "gluon_vm/test"] -nightly = ["dep:compiletest_rs", "gluon_base/nightly"] +nightly = ["dep:ui_test", "gluon_base/nightly"] test_nightly = ["test", "nightly"] [[bench]] @@ -171,6 +171,11 @@ name = "main" harness = false required-features = ["serialization"] +[[test]] +name = "compiletest" +harness = false +required-features = ["nightly"] + [[example]] name = "marshalling" required-features = ["serialization"] diff --git a/base/Cargo.toml b/base/Cargo.toml index 478afa0de..f563bbc81 100644 --- a/base/Cargo.toml +++ b/base/Cargo.toml @@ -38,7 +38,7 @@ serde_derive = { version = "1.0.188", optional = true } serde_derive_state = { version = "0.4.10", optional = true } # Crates used in testing -compiletest_rs = { version = "0.11", optional = true } +ui_test = { version = "0.30", optional = true } [dev-dependencies] env_logger.workspace = true @@ -52,4 +52,8 @@ serialization = [ "serde_derive_state", "anymap", ] -nightly = ["compiletest_rs"] +nightly = ["ui_test"] + +[[test]] +name = "compiletest" +harness = false diff --git a/base/tests/compile-fail/Cargo.lock b/base/tests/compile-fail/Cargo.lock new file mode 100644 index 000000000..043c6c853 --- /dev/null +++ b/base/tests/compile-fail/Cargo.lock @@ -0,0 +1,309 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "codespan" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583f52b0658b321b25fd6b209b6c76cf058f433071297de64e5980c3d9aad937" +dependencies = [ + "codespan-reporting", + "serde", +] + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "collect-mac" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f168712e49987bd2f51cb855c4585999e12b1a0abdff60fea4b81b41f2010264" + +[[package]] +name = "compile-fail" +version = "0.1.0" +dependencies = [ + "gluon_base", +] + +[[package]] +name = "either" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "gluon_base" +version = "0.18.4" +dependencies = [ + "bitflags", + "codespan", + "codespan-reporting", + "collect-mac", + "either", + "fnv", + "gluon_codegen", + "hashbrown", + "itertools", + "log", + "ordered-float", + "pretty", + "quick-error", + "smallvec", + "typed-arena", + "vec_map", +] + +[[package]] +name = "gluon_codegen" +version = "0.18.4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "itertools" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" +dependencies = [ + "either", +] + +[[package]] +name = "log" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ordered-float" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7d950ca161dc355eaf28f82b11345ed76c6e1f6eb1f4f4479e0323b9e2fbd0e" +dependencies = [ + "num-traits", +] + +[[package]] +name = "pretty" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad9940b913ee56ddd94aec2d3cd179dd47068236f42a1a6415ccf9d880ce2a61" +dependencies = [ + "arrayvec", + "typed-arena", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] diff --git a/base/tests/compile-fail/Cargo.toml b/base/tests/compile-fail/Cargo.toml new file mode 100644 index 000000000..c31292c44 --- /dev/null +++ b/base/tests/compile-fail/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "compile-fail" +version = "0.1.0" +edition = "2024" + +[workspace] + +[lib] +path = "compile_fail_lib.in" + +[dependencies] +gluon_base = { path = "../.." } diff --git a/base/tests/compile-fail/arena-1.rs b/base/tests/compile-fail/arena-1.rs index 92fef38c7..2cca0c258 100644 --- a/base/tests/compile-fail/arena-1.rs +++ b/base/tests/compile-fail/arena-1.rs @@ -1,4 +1,5 @@ extern crate gluon_base; +//@no-rustfix use gluon_base::{ ast::{Arena, Expr, RootExpr}, @@ -8,7 +9,8 @@ use gluon_base::{ fn main() { mk_ast_arena!(arena1); mk_ast_arena!(arena2); - //~^ temporary value dropped while borrowed [E0716] + //~^ E0716 + // temporary value dropped while borrowed let arena1_expr = arena1.alloc(pos::spanned( Default::default(), diff --git a/base/tests/compile-fail/arena-1.stderr b/base/tests/compile-fail/arena-1.stderr new file mode 100644 index 000000000..9e6d1d7bb --- /dev/null +++ b/base/tests/compile-fail/arena-1.stderr @@ -0,0 +1,26 @@ +warning: unused import: `Arena` + --> tests/compile-fail/arena-1.rs:5:11 + | +5 | ast::{Arena, Expr, RootExpr}, + | ^^^^^ + | + = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default + +error[E0716]: temporary value dropped while borrowed + --> tests/compile-fail/arena-1.rs:11:5 + | +11 | mk_ast_arena!(arena2); + | ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use +... +21 | } + | - + | | + | temporary value is freed at the end of this statement + | borrow might be used here, when `_guard` is dropped and runs the `Drop` code for type `main::Guard` + | + = note: consider using a `let` binding to create a longer lived value + = note: this error originates in the macro `mk_ast_arena` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0716`. diff --git a/base/tests/compile-fail/arena-2.rs b/base/tests/compile-fail/arena-2.rs index f15d6c6ff..1a93911b3 100644 --- a/base/tests/compile-fail/arena-2.rs +++ b/base/tests/compile-fail/arena-2.rs @@ -1,4 +1,5 @@ extern crate gluon_base; +//@no-rustfix use gluon_base::{ ast::{Arena, Expr, RootExpr}, @@ -8,8 +9,9 @@ use gluon_base::{ fn main() { mk_ast_arena!(arena1); mk_ast_arena!(arena2); - //~^ temporary value dropped while borrowed [E0716] - //~| temporary value dropped while borrowed [E0716] + //~^ E0716 + //~| E0716 + // temporary value dropped while borrowed (twice) let arena2_expr = arena2.alloc(pos::spanned( Default::default(), diff --git a/base/tests/compile-fail/arena-2.stderr b/base/tests/compile-fail/arena-2.stderr new file mode 100644 index 000000000..d2a5f29a5 --- /dev/null +++ b/base/tests/compile-fail/arena-2.stderr @@ -0,0 +1,41 @@ +warning: unused import: `Arena` + --> tests/compile-fail/arena-2.rs:5:11 + | +5 | ast::{Arena, Expr, RootExpr}, + | ^^^^^ + | + = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default + +error[E0716]: temporary value dropped while borrowed + --> tests/compile-fail/arena-2.rs:11:5 + | +11 | mk_ast_arena!(arena2); + | ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use +... +23 | } + | - + | | + | temporary value is freed at the end of this statement + | borrow might be used here, when `_guard` is dropped and runs the `Drop` code for type `main::Guard` + | + = note: consider using a `let` binding to create a longer lived value + = note: this error originates in the macro `mk_ast_arena` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0716]: temporary value dropped while borrowed + --> tests/compile-fail/arena-2.rs:11:5 + | +11 | mk_ast_arena!(arena2); + | ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use +... +23 | } + | - + | | + | temporary value is freed at the end of this statement + | borrow might be used here, when `_guard` is dropped and runs the `Drop` code for type `main::Guard` + | + = note: consider using a `let` binding to create a longer lived value + = note: this error originates in the macro `mk_ast_arena` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0716`. diff --git a/base/tests/compile-fail/compile_fail_lib.in b/base/tests/compile-fail/compile_fail_lib.in new file mode 100644 index 000000000..a2c8704b4 --- /dev/null +++ b/base/tests/compile-fail/compile_fail_lib.in @@ -0,0 +1 @@ +// Helper crate used by ui compile-fail tests for dependency resolution. diff --git a/base/tests/compiletest.rs b/base/tests/compiletest.rs index ccef0848c..aaa583d4a 100644 --- a/base/tests/compiletest.rs +++ b/base/tests/compiletest.rs @@ -1,65 +1,22 @@ #![cfg(feature = "nightly")] -extern crate compiletest_rs as compiletest; -extern crate env_logger; +use ui_test::{Config, dependencies::DependencyBuilder, run_tests}; -use std::fs; -use std::path::{Path, PathBuf}; +fn main() -> ui_test::color_eyre::Result<()> { + let mut config = Config::rustc("tests/compile-fail"); + config.skip_files.extend([ + ".fixed".into(), + ".stderr".into(), + "compile_fail_lib.in".into(), + ]); -fn lib_dir(out_dir: &Path, lib_name: &str) -> PathBuf { - // Just loading gluon through -L dir does not work as we compile gluon with different sets of - // flags which gives ambiguity errors. - // Instead retrieve the latest compiled gluon library which should usually be the correct one - let mut gluon_rlibs: Vec<_> = fs::read_dir(out_dir.join("deps")) - .unwrap() - .filter_map(|entry| { - let entry = entry.expect("dir entry"); - if entry - .path() - .to_str() - .map_or(false, |name| name.contains(lib_name)) - && entry.path().extension().map_or(false, |ext| ext == "rlib") - { - Some(entry) - } else { - None - } - }) - .collect(); - gluon_rlibs.sort_by(|l, r| { - l.metadata() - .unwrap() - .modified() - .unwrap() - .cmp(&r.metadata().unwrap().modified().unwrap()) - }); - gluon_rlibs - .last() - .unwrap_or_else(|| panic!("{lib_name} not found")) - .path() -} - -fn run_mode(mode: &'static str) { - // Retrieve the path where library dependencies are output - let out_dir = PathBuf::from("../target/debug"); - let gluon_base_rlib = lib_dir(&out_dir, "libgluon_base-"); - - let mut config = compiletest::Config::default(); - let cfg_mode = mode.parse().ok().expect("Invalid mode"); - - config.verbose = true; - config.mode = cfg_mode; - config.src_base = PathBuf::from(format!("tests/{}", mode)); - config.target_rustcflags = Some(format!( - "-L {}/deps --extern gluon_base={}", - out_dir.display(), - gluon_base_rlib.display(), - )); - println!("{}", config.target_rustcflags.as_ref().unwrap()); - compiletest::run_tests(&config); -} + config.comment_defaults.base().set_custom( + "dependencies", + DependencyBuilder { + crate_manifest_path: "tests/compile-fail/Cargo.toml".into(), + bless_lockfile: true, + ..DependencyBuilder::default() + }, + ); -#[test] -fn compile_test() { - let _ = env_logger::try_init(); - run_mode("compile-fail"); + run_tests(config) } diff --git a/tests/compile-fail/Cargo.lock b/tests/compile-fail/Cargo.lock new file mode 100644 index 000000000..cc95be109 --- /dev/null +++ b/tests/compile-fail/Cargo.lock @@ -0,0 +1,1205 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "archery" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e0a5f99dfebb87bb342d0f53bb92c81842e100bbb915223e38349580e5441d" +dependencies = [ + "triomphe", +] + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "ascii-canvas" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1e3e699d84ab1b0911a1010c5c106aa34ae89aeac103be5ce0c3859db1e891" +dependencies = [ + "term", +] + +[[package]] +name = "async-trait" +version = "0.1.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae36dc4177970ef04fde5178d3e2429882def40e57a451f919c098f72baa6cec" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bit-set" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ddef2995421ab6a5c779542c81ee77c115206f4ad9d5a8e05f4ff49716a3dd" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chacha20" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +dependencies = [ + "cfg-if 1.0.4", + "cpufeatures 0.3.0", + "rand_core", +] + +[[package]] +name = "codespan" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583f52b0658b321b25fd6b209b6c76cf058f433071297de64e5980c3d9aad937" +dependencies = [ + "codespan-reporting", + "serde", +] + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "collect-mac" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f168712e49987bd2f51cb855c4585999e12b1a0abdff60fea4b81b41f2010264" + +[[package]] +name = "compile-fail" +version = "0.1.0" +dependencies = [ + "gluon", + "gluon_codegen", + "gluon_vm", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "downcast-rs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117240f60069e65410b3ae1bb213295bd828f707b5bec6596a1afc8793ce0cbc" + +[[package]] +name = "either" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d" + +[[package]] +name = "ena" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabffdaee24bd1bf95c5ef7cec31260444317e72ea56c4c91750e8b7ee58d5f1" +dependencies = [ + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "frunk_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bd3c9ba2e323e8b19e77f15873f60974a7d82f89b80e50c53be44b8b92927c1" +dependencies = [ + "serde", +] + +[[package]] +name = "futures" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" + +[[package]] +name = "futures" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88cf1f829d945f548cf8fec32c61b1f202b6d93b45848602fc02af4b12ad218" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "262590f4fe6afeb0bc83be1daa64e52657fe185690a958af7f3ad0e92085c5ae" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7" + +[[package]] +name = "futures-executor" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6754879cc9f2c66f88c6e5c35344bb0bdb0708b0352b1201815667c7eabc7458" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4577ecaa3c4f96589d473f679a71b596316f6641bc350038b962a5daf0085d7a" + +[[package]] +name = "futures-macro" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d6d3cde68c518367be28956066ddfef33813991b77a55005a69dae04bf3b10b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "futures-sink" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e34418ac499d6305c2fb5ad0ed2f6ac998c5f8ca209b4510f7f94242c647e307" + +[[package]] +name = "futures-task" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109" + +[[package]] +name = "futures-util" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa" +dependencies = [ + "futures 0.1.31", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "libc", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if 1.0.4", + "libc", + "r-efi", + "rand_core", +] + +[[package]] +name = "gluon" +version = "0.18.4" +dependencies = [ + "async-trait", + "codespan", + "codespan-reporting", + "collect-mac", + "either", + "futures 0.3.33", + "gluon-salsa", + "gluon_base", + "gluon_check", + "gluon_codegen", + "gluon_format", + "gluon_parser", + "gluon_vm", + "itertools 0.15.0", + "log", + "quick-error", + "rand", + "rand_xorshift", + "regex", + "tokio", + "walkdir", +] + +[[package]] +name = "gluon-salsa" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4644d498c04e71e60947f837bf9729379bd922e5b745c36bea5a4ce03e551fe5" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures-channel", + "futures-util", + "gluon-salsa-macros", + "indexmap 1.9.3", + "lock_api", + "log", + "oorandom", + "parking_lot 0.11.2", + "rustc-hash", + "smallvec", +] + +[[package]] +name = "gluon-salsa-macros" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "807a2b17a92e21080379cf696063642c70caea95c04b547320d37fd6844b8e0f" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "gluon_base" +version = "0.18.4" +dependencies = [ + "bitflags 1.3.2", + "codespan", + "codespan-reporting", + "collect-mac", + "either", + "fnv", + "gluon_codegen", + "hashbrown 0.17.1", + "itertools 0.15.0", + "log", + "ordered-float", + "pretty", + "quick-error", + "smallvec", + "typed-arena", + "vec_map", +] + +[[package]] +name = "gluon_check" +version = "0.18.4" +dependencies = [ + "codespan", + "codespan-reporting", + "collect-mac", + "ena", + "gluon_base", + "gluon_codegen", + "itertools 0.15.0", + "log", + "pretty", + "quick-error", + "rpds", + "smallvec", + "strsim", +] + +[[package]] +name = "gluon_codegen" +version = "0.18.4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "gluon_format" +version = "0.18.4" +dependencies = [ + "codespan", + "gluon_base", + "itertools 0.15.0", + "log", + "pretty", +] + +[[package]] +name = "gluon_parser" +version = "0.18.4" +dependencies = [ + "codespan", + "codespan-reporting", + "collect-mac", + "gluon_base", + "itertools 0.15.0", + "lalrpop", + "lalrpop-util", + "log", + "ordered-float", + "quick-error", +] + +[[package]] +name = "gluon_vm" +version = "0.18.4" +dependencies = [ + "async-trait", + "bitflags 1.3.2", + "codespan", + "codespan-reporting", + "collect-mac", + "crossbeam-utils 0.8.22", + "downcast-rs", + "frunk_core", + "futures 0.3.33", + "gluon_base", + "gluon_check", + "gluon_codegen", + "itertools 0.15.0", + "log", + "ordered-float", + "parking_lot 0.12.5", + "petgraph", + "pretty", + "quick-error", + "slab", + "smallvec", + "typed-arena", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if 1.0.4", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" +dependencies = [ + "either", +] + +[[package]] +name = "keccak" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653" +dependencies = [ + "cpufeatures 0.2.17", +] + +[[package]] +name = "lalrpop" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98a80a963123205c7157323c99611bc4abb65dcbd62ef46dc4bac74a3941bc75" +dependencies = [ + "ascii-canvas", + "bit-set", + "ena", + "itertools 0.14.0", + "lalrpop-util", + "petgraph", + "pico-args", + "regex", + "regex-syntax", + "sha3", + "string_cache", + "term", + "unicode-xid", + "walkdir", +] + +[[package]] +name = "lalrpop-util" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884f3e747ed2dcee867cda1b0c31a048f9e20de2d916a248949319921a2e666e" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "ordered-float" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7d950ca161dc355eaf28f82b11345ed76c6e1f6eb1f4f4479e0323b9e2fbd0e" +dependencies = [ + "num-traits", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.12", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if 1.0.4", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if 1.0.4", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap 2.14.0", + "serde", +] + +[[package]] +name = "phf_shared" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "pretty" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad9940b913ee56ddd94aec2d3cd179dd47068236f42a1a6415ccf9d880ce2a61" +dependencies = [ + "arrayvec", + "typed-arena", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +dependencies = [ + "chacha20", + "getrandom", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_xorshift" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60aa6af80be32871323012e02e6e65f8a7cc7890931ae421d217ad8fe0df2ccf" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.1", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "rpds" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e025feb26210bc196b908e72deb063b1b4000754304341cbc168a1e72c857ebc" +dependencies = [ + "archery", + "smallvec", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "sha3" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77fd7028345d415a4034cf8777cd4f8ab1851274233b45f84e3d955502d93874" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "siphasher" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + +[[package]] +name = "string_cache" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18596f8c785a729f2819c0f6a7eae6ebeebdfffbfe4214ae6b087f690e31901" +dependencies = [ + "new_debug_unreachable", + "parking_lot 0.12.5", + "phf_shared", + "precomputed-hash", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "term" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8c27177b12a6399ffc08b98f76f7c9a1f4fe9fc967c784c5a071fa8d93cf7e1" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "tokio" +version = "1.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "triomphe" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b40688ea6389c8171614b25491f71d4a27946e0c7ce2da1c6de27e25abf1a0ae" + +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] diff --git a/tests/compile-fail/Cargo.toml b/tests/compile-fail/Cargo.toml new file mode 100644 index 000000000..4a6a63fa5 --- /dev/null +++ b/tests/compile-fail/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "compile-fail" +version = "0.1.0" +edition = "2024" + +[workspace] + +[lib] +path = "compile_fail_lib.in" + +[dependencies] +gluon = { path = "../.." } +gluon_vm = { path = "../../vm" } +gluon_codegen = { path = "../../codegen" } diff --git a/tests/compile-fail/compile_fail_lib.in b/tests/compile-fail/compile_fail_lib.in new file mode 100644 index 000000000..a2c8704b4 --- /dev/null +++ b/tests/compile-fail/compile_fail_lib.in @@ -0,0 +1 @@ +// Helper crate used by ui compile-fail tests for dependency resolution. diff --git a/tests/compile-fail/get-reference.rs b/tests/compile-fail/get-reference.rs index 0223a7932..29da2edc2 100644 --- a/tests/compile-fail/get-reference.rs +++ b/tests/compile-fail/get-reference.rs @@ -1,16 +1,12 @@ -extern crate gluon; use gluon::new_vm; +use gluon::vm::Variants; use gluon::vm::api::Getable; use gluon::vm::internal::Value; -use gluon::vm::Variants; #[cfg_attr(rustfmt, rustfmt_skip)] fn main() { - unsafe { - let vm = new_vm(); - let value = Value::int(0); - let value = Variants::new(&value); - //~^ Error `value` does not live long enough - let _: &'static str = <&'static str>::from_value(&vm, value); - } + let vm = new_vm(); + let value = Value::int(0); + let value = Variants::new(&value); //~ ERROR: does not live long enough + let _: &'static str = <&'static str>::from_value(&vm, value); } diff --git a/tests/compile-fail/get-reference.stderr b/tests/compile-fail/get-reference.stderr new file mode 100644 index 000000000..4bc947bb7 --- /dev/null +++ b/tests/compile-fail/get-reference.stderr @@ -0,0 +1,15 @@ +error[E0597]: `value` does not live long enough + --> tests/compile-fail/get-reference.rs:10:31 + | + 9 | let value = Value::int(0); + | ----- binding `value` declared here +10 | let value = Variants::new(&value); + | ^^^^^^ borrowed value does not live long enough +11 | let _: &'static str = <&'static str>::from_value(&vm, value); + | -------------------------------------- argument requires that `value` is borrowed for `'static` +12 | } + | - `value` dropped here while still borrowed + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/compile-fail/getable-reference-str.rs b/tests/compile-fail/getable-reference-str.rs index f7d5c56fe..f4e5eabd9 100644 --- a/tests/compile-fail/getable-reference-str.rs +++ b/tests/compile-fail/getable-reference-str.rs @@ -1,6 +1,7 @@ #[macro_use] extern crate gluon_vm; extern crate gluon; +//@no-rustfix use gluon::{ import::add_extern_module, new_vm, @@ -18,6 +19,6 @@ fn main() { let vm = new_vm(); add_extern_module(&vm, "test", |vm| { ExternModule::new(vm, primitive!(1, f)) - //~^ lifetime may not live long enough + //~^ ERROR: lifetime may not live long enough }); } diff --git a/tests/compile-fail/getable-reference-str.stderr b/tests/compile-fail/getable-reference-str.stderr new file mode 100644 index 000000000..58850a25b --- /dev/null +++ b/tests/compile-fail/getable-reference-str.stderr @@ -0,0 +1,23 @@ +warning: unused imports: `Status`, `Thread`, and `api::primitive_f` + --> tests/compile-fail/getable-reference-str.rs:9:9 + | + 9 | api::primitive_f, + | ^^^^^^^^^^^^^^^^ +10 | thread::{Status, Thread}, + | ^^^^^^ ^^^^^^ + | + = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default + +error: lifetime may not live long enough + --> tests/compile-fail/getable-reference-str.rs:21:31 + | +21 | ExternModule::new(vm, primitive!(1, f)) + | ^^^^^^^^^^^^^^^^ + | | + | lifetime `'thread` defined here + | cast requires that `'thread` must outlive `'static` + | + = note: this error originates in the macro `primitive` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error; 1 warning emitted + diff --git a/tests/compile-fail/getable-reference.rs b/tests/compile-fail/getable-reference.rs index dcd427811..022a4ce67 100644 --- a/tests/compile-fail/getable-reference.rs +++ b/tests/compile-fail/getable-reference.rs @@ -2,6 +2,7 @@ extern crate gluon_vm; extern crate gluon; extern crate gluon_codegen; +//@no-rustfix use gluon::{ import::add_extern_module, @@ -30,6 +31,6 @@ fn main() { let vm = new_vm(); add_extern_module(&vm, "test", |vm| { ExternModule::new(vm, primitive!(1, f)) - //~^ lifetime may not live long enough + //~^ ERROR: lifetime may not live long enough }); } diff --git a/tests/compile-fail/getable-reference.stderr b/tests/compile-fail/getable-reference.stderr new file mode 100644 index 000000000..1be404c50 --- /dev/null +++ b/tests/compile-fail/getable-reference.stderr @@ -0,0 +1,25 @@ +warning: unused imports: `Gc`, `Status`, `Thread`, `Trace`, and `primitive_f` + --> tests/compile-fail/getable-reference.rs:11:15 + | +11 | api::{primitive_f, Userdata, VmType}, + | ^^^^^^^^^^^ +12 | gc::{Gc, Trace}, + | ^^ ^^^^^ +13 | thread::{Status, Thread}, + | ^^^^^^ ^^^^^^ + | + = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default + +error: lifetime may not live long enough + --> tests/compile-fail/getable-reference.rs:33:31 + | +33 | ExternModule::new(vm, primitive!(1, f)) + | ^^^^^^^^^^^^^^^^ + | | + | lifetime `'thread` defined here + | cast requires that `'thread` must outlive `'static` + | + = note: this error originates in the macro `primitive` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error; 1 warning emitted + diff --git a/tests/compile-fail/run_expr_str_ref.rs b/tests/compile-fail/run_expr_str_ref.rs index 48d4720eb..453a40b42 100644 --- a/tests/compile-fail/run_expr_str_ref.rs +++ b/tests/compile-fail/run_expr_str_ref.rs @@ -1,10 +1,12 @@ +//@normalize-stderr-test: "(/|\w:)[^ ]*/src/lib.rs" -> "../src/lib.rs" +//@normalize-stderr-test: "(/|\w:)[^ ]*/mod.rs" -> "../mod.rs" extern crate gluon; -use gluon::{new_vm, ThreadExt}; +use gluon::{ThreadExt, new_vm}; fn main() { let vm = new_vm(); let _ = vm.run_expr::<&str>("", r#" "test" "#); - //~^ the trait bound `for<'value> &str: Getable<'_, 'value>` is not satisfied [E0277] + //~^ ERROR: the trait bound `for<'value> &str: Getable<'_, 'value>` is not satisfied } diff --git a/tests/compile-fail/run_expr_str_ref.stderr b/tests/compile-fail/run_expr_str_ref.stderr new file mode 100644 index 000000000..eb9dcb41f --- /dev/null +++ b/tests/compile-fail/run_expr_str_ref.stderr @@ -0,0 +1,26 @@ +error[E0277]: the trait bound `for<'value> &str: Getable<'_, 'value>` is not satisfied + --> tests/compile-fail/run_expr_str_ref.rs:10:27 + | + 10 | let _ = vm.run_expr::<&str>("", r#" "test" "#); + | -------- ^^^^ the trait `for<'value> Getable<'_, 'value>` is not implemented for `&str` + | | + | required by a bound introduced by this call + | +help: the trait `Getable<'_, 'value>` is not implemented for `&str` + but trait `Getable<'_, '_>` is implemented for it + --> ../mod.rs:746:1 + | +746 | impl<'vm, 'value> Getable<'vm, 'value> for &'value str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `gluon::ThreadExt::run_expr` + --> ../src/lib.rs:705:12 + | +703 | fn run_expr<'vm, T>(&'vm self, name: &str, expr_str: &str) -> Result<(T, ArcType)> + | -------- required by a bound in this associated function +704 | where +705 | T: for<'value> Getable<'vm, 'value> + VmType + Send + 'vm, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ThreadExt::run_expr` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/compile-fail/store-ref.rs b/tests/compile-fail/store-ref.rs index b2d630aab..b1f06a948 100644 --- a/tests/compile-fail/store-ref.rs +++ b/tests/compile-fail/store-ref.rs @@ -2,6 +2,7 @@ extern crate gluon_vm; extern crate gluon; extern crate gluon_codegen; +//@no-rustfix use std::{fmt, sync::Mutex}; @@ -41,6 +42,6 @@ fn main() { let vm = new_vm(); add_extern_module(&vm, "test", |vm| { ExternModule::new(vm, primitive!(2, f)) - //~^ borrowed data escapes outside of function [E0521] + //~^ ERROR: borrowed data escapes outside of function }); } diff --git a/tests/compile-fail/store-ref.stderr b/tests/compile-fail/store-ref.stderr new file mode 100644 index 000000000..af2f9f471 --- /dev/null +++ b/tests/compile-fail/store-ref.stderr @@ -0,0 +1,31 @@ +warning: unused imports: `Status`, `Thread`, `gc::Trace`, and `primitive_f` + --> tests/compile-fail/store-ref.rs:13:15 + | +13 | api::{primitive_f, Userdata, VmType}, + | ^^^^^^^^^^^ +14 | gc::Trace, + | ^^^^^^^^^ +15 | thread::{Status, Thread}, + | ^^^^^^ ^^^^^^ + | + = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default + +error[E0521]: borrowed data escapes outside of function + --> tests/compile-fail/store-ref.rs:44:31 + | +44 | ExternModule::new(vm, primitive!(2, f)) + | ^^^^^^^^^^^^^^^^ + | | + | `thread` is a reference that is only valid in the function body + | `thread` escapes the function body here + | lifetime `'thread` defined here + | argument requires that `'thread` must outlive `'static` + | + = note: requirement occurs because of the type `Test<'_>`, which makes the generic argument `'_` invariant + = note: the struct `Test<'vm>` is invariant over the parameter `'vm` + = help: see for more information about variance + = note: this error originates in the macro `primitive` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0521`. diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 6ce5df0cf..034000704 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -1,87 +1,25 @@ #![cfg(feature = "nightly")] -extern crate compiletest_rs as compiletest; -extern crate env_logger; +use ui_test::{Config, dependencies::DependencyBuilder, run_tests}; -use std::fs; -use std::path::{Path, PathBuf}; +fn main() -> ui_test::color_eyre::Result<()> { + let mut config = Config::rustc("tests/compile-fail"); + config.skip_files.extend([ + ".fixed".into(), + ".stderr".into(), + "compile_fail_lib.in".into(), + ]); -fn lib_dir(out_dir: &Path, lib_name: &str, extension: &str) -> PathBuf { - // Just loading gluon through -L dir does not work as we compile gluon with different sets of - // flags which gives ambiguity errors. - // Instead retrieve the latest compiled gluon library which should usually be the correct one - let mut gluon_rlibs: Vec<_> = fs::read_dir(out_dir.join("deps")) - .unwrap_or_else(|err| { - panic!( - "Failed to read dir {}: {}", - out_dir.join("deps").display(), - err - ) - }) - .filter_map(|entry| { - let entry = entry.expect("dir entry"); - if entry - .path() - .to_str() - .map_or(false, |name| name.contains(lib_name)) - && entry - .path() - .extension() - .map_or(false, |ext| ext == extension) - { - Some(entry) - } else { - None - } - }) - .collect(); - gluon_rlibs.sort_by(|l, r| { - l.metadata() - .unwrap() - .modified() - .unwrap() - .cmp(&r.metadata().unwrap().modified().unwrap()) - }); - gluon_rlibs - .last() - .unwrap_or_else(|| panic!("{lib_name} not found")) - .path() -} - -fn run_mode(mode: &'static str) { - // Retrieve the path where library dependencies are output - let mut out_dir = PathBuf::from(env!("OUT_DIR")); - loop { - match out_dir.file_name() { - Some(name) => match name.to_str() { - Some(name) if name == "debug" => break, - _ => (), - }, - None => break, - } - out_dir.pop(); - } - let gluon_rlib = lib_dir(&out_dir, "libgluon-", "rlib"); - let gluon_vm_rlib = lib_dir(&out_dir, "libgluon_vm-", "rlib"); - - let mut config = compiletest::Config::default(); - let cfg_mode = mode.parse().ok().expect("Invalid mode"); - - config.verbose = true; - config.mode = cfg_mode; - config.src_base = PathBuf::from(format!("tests/{}", mode)); - config.target_rustcflags = Some(format!( - "-L {}/deps --extern gluon={} --extern gluon_vm={} --extern gluon_codegen={}", - out_dir.display(), - gluon_rlib.display(), - gluon_vm_rlib.display(), - lib_dir(&out_dir, "gluon_codegen-", std::env::consts::DLL_EXTENSION).display() - )); - println!("{}", config.target_rustcflags.as_ref().unwrap()); - compiletest::run_tests(&config); -} + config.comment_defaults.base().set_custom( + "dependencies", + DependencyBuilder { + crate_manifest_path: "tests/compile-fail/Cargo.toml".into(), + bless_lockfile: true, + ..DependencyBuilder::default() + }, + ); -#[test] -fn compile_test() { - let _ = env_logger::try_init(); - run_mode("compile-fail"); + // Compile all `.rs` files in the given directory (relative to your + // Cargo.toml) and compare their output against the corresponding + // `.stderr` files. + run_tests(config) } diff --git a/tests/main.rs b/tests/main.rs index e7c80f4c1..5b17d3a62 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -482,7 +482,7 @@ async fn main_(options: &Opt) -> Result<(), Error> { &tensile::Options::default().filter(filter.map_or("", |s| &s[..])), ) .await?; - if !report.passes() { + if report.failed_tests > 0 { return Err("Some tests failed".into()); } Ok(()) From 4dace58d5a88afaf22082f7afb7388bfe8b13c56 Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Wed, 5 Aug 2026 14:31:53 +0200 Subject: [PATCH 7/8] test: Correct a command line test so it works with the new build output structure --- repl/tests/basic.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/repl/tests/basic.rs b/repl/tests/basic.rs index 63915bc69..48f0ba400 100644 --- a/repl/tests/basic.rs +++ b/repl/tests/basic.rs @@ -1,18 +1,11 @@ #[macro_use] extern crate pretty_assertions; -use std::env; -use std::path::Path; use std::process::{Command, Stdio}; #[test] fn issue_365_run_io_from_command_line() { - let path = env::args().next().unwrap(); - let gluon_path = Path::new(&path[..]) - .parent() - .and_then(|p| p.parent()) - .expect("folder") - .join("gluon"); + let gluon_path = std::env::var("CARGO_BIN_EXE_gluon").unwrap(); let output = Command::new(&*gluon_path) .stdin(Stdio::piped()) .stdout(Stdio::piped()) @@ -20,7 +13,7 @@ fn issue_365_run_io_from_command_line() { .env("GLUON_PATH", "..") .arg("tests/print.glu") .output() - .unwrap_or_else(|err| panic!("{}\nWhen opening `{}`", err, gluon_path.display())); + .unwrap_or_else(|err| panic!("{}\nWhen opening `{}`", err, gluon_path)); let stderr = String::from_utf8_lossy(&output.stderr); if stderr != "" { From 6bb51fe641270d8df3d4e2ddb55cc4521bf88ddc Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Wed, 5 Aug 2026 15:38:23 +0200 Subject: [PATCH 8/8] chore: Get the ui tests working with windows paths --- .gitattributes | 1 + base/tests/compile-fail/arena-1.rs | 1 + base/tests/compile-fail/arena-1.stderr | 10 +++++----- base/tests/compile-fail/arena-2.rs | 1 + base/tests/compile-fail/arena-2.stderr | 18 ++++++++--------- tests/compile-fail/get-reference.rs | 1 + tests/compile-fail/get-reference.stderr | 10 +++++----- tests/compile-fail/getable-reference-str.rs | 11 ++-------- .../compile-fail/getable-reference-str.stderr | 16 +++------------ tests/compile-fail/getable-reference.rs | 5 ++--- tests/compile-fail/getable-reference.stderr | 18 +++-------------- tests/compile-fail/run_expr_str_ref.rs | 3 +-- tests/compile-fail/run_expr_str_ref.stderr | 8 ++++---- tests/compile-fail/store-ref.rs | 5 ++--- tests/compile-fail/store-ref.stderr | 20 ++++--------------- 15 files changed, 44 insertions(+), 84 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..94f480de9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/base/tests/compile-fail/arena-1.rs b/base/tests/compile-fail/arena-1.rs index 2cca0c258..8400585f5 100644 --- a/base/tests/compile-fail/arena-1.rs +++ b/base/tests/compile-fail/arena-1.rs @@ -1,3 +1,4 @@ +//@normalize-stderr-test: "[^ ]*?[\\/]([^\\/]+).rs" -> ".../$1.rs" extern crate gluon_base; //@no-rustfix diff --git a/base/tests/compile-fail/arena-1.stderr b/base/tests/compile-fail/arena-1.stderr index 9e6d1d7bb..c688795d8 100644 --- a/base/tests/compile-fail/arena-1.stderr +++ b/base/tests/compile-fail/arena-1.stderr @@ -1,18 +1,18 @@ warning: unused import: `Arena` - --> tests/compile-fail/arena-1.rs:5:11 + --> .../arena-1.rs:6:11 | -5 | ast::{Arena, Expr, RootExpr}, +6 | ast::{Arena, Expr, RootExpr}, | ^^^^^ | = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default error[E0716]: temporary value dropped while borrowed - --> tests/compile-fail/arena-1.rs:11:5 + --> .../arena-1.rs:12:5 | -11 | mk_ast_arena!(arena2); +12 | mk_ast_arena!(arena2); | ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use ... -21 | } +22 | } | - | | | temporary value is freed at the end of this statement diff --git a/base/tests/compile-fail/arena-2.rs b/base/tests/compile-fail/arena-2.rs index 1a93911b3..ff113286e 100644 --- a/base/tests/compile-fail/arena-2.rs +++ b/base/tests/compile-fail/arena-2.rs @@ -1,3 +1,4 @@ +//@normalize-stderr-test: "[^ ]*?[\\/]([^\\/]+).rs" -> ".../$1.rs" extern crate gluon_base; //@no-rustfix diff --git a/base/tests/compile-fail/arena-2.stderr b/base/tests/compile-fail/arena-2.stderr index d2a5f29a5..1870eace0 100644 --- a/base/tests/compile-fail/arena-2.stderr +++ b/base/tests/compile-fail/arena-2.stderr @@ -1,18 +1,18 @@ warning: unused import: `Arena` - --> tests/compile-fail/arena-2.rs:5:11 + --> .../arena-2.rs:6:11 | -5 | ast::{Arena, Expr, RootExpr}, +6 | ast::{Arena, Expr, RootExpr}, | ^^^^^ | = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default error[E0716]: temporary value dropped while borrowed - --> tests/compile-fail/arena-2.rs:11:5 + --> .../arena-2.rs:12:5 | -11 | mk_ast_arena!(arena2); +12 | mk_ast_arena!(arena2); | ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use ... -23 | } +24 | } | - | | | temporary value is freed at the end of this statement @@ -22,12 +22,12 @@ error[E0716]: temporary value dropped while borrowed = note: this error originates in the macro `mk_ast_arena` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0716]: temporary value dropped while borrowed - --> tests/compile-fail/arena-2.rs:11:5 + --> .../arena-2.rs:12:5 | -11 | mk_ast_arena!(arena2); +12 | mk_ast_arena!(arena2); | ^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use ... -23 | } +24 | } | - | | | temporary value is freed at the end of this statement @@ -36,6 +36,6 @@ error[E0716]: temporary value dropped while borrowed = note: consider using a `let` binding to create a longer lived value = note: this error originates in the macro `mk_ast_arena` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous err.rs; 1 warning emitted For more information about this error, try `rustc --explain E0716`. diff --git a/tests/compile-fail/get-reference.rs b/tests/compile-fail/get-reference.rs index 29da2edc2..a177d7fc2 100644 --- a/tests/compile-fail/get-reference.rs +++ b/tests/compile-fail/get-reference.rs @@ -1,3 +1,4 @@ +//@normalize-stderr-test: "[^ ]*?[\\/]([^\\/]+).rs" -> ".../$1.rs" use gluon::new_vm; use gluon::vm::Variants; use gluon::vm::api::Getable; diff --git a/tests/compile-fail/get-reference.stderr b/tests/compile-fail/get-reference.stderr index 4bc947bb7..4852c71cc 100644 --- a/tests/compile-fail/get-reference.stderr +++ b/tests/compile-fail/get-reference.stderr @@ -1,13 +1,13 @@ error[E0597]: `value` does not live long enough - --> tests/compile-fail/get-reference.rs:10:31 + --> .../get-reference.rs:11:31 | - 9 | let value = Value::int(0); +10 | let value = Value::int(0); | ----- binding `value` declared here -10 | let value = Variants::new(&value); +11 | let value = Variants::new(&value); | ^^^^^^ borrowed value does not live long enough -11 | let _: &'static str = <&'static str>::from_value(&vm, value); +12 | let _: &'static str = <&'static str>::from_value(&vm, value); | -------------------------------------- argument requires that `value` is borrowed for `'static` -12 | } +13 | } | - `value` dropped here while still borrowed error: aborting due to 1 previous error diff --git a/tests/compile-fail/getable-reference-str.rs b/tests/compile-fail/getable-reference-str.rs index f4e5eabd9..ed416ca64 100644 --- a/tests/compile-fail/getable-reference-str.rs +++ b/tests/compile-fail/getable-reference-str.rs @@ -1,16 +1,9 @@ +//@normalize-stderr-test: "[^ ]*?[\\/]([^\\/]+).rs" -> ".../$1.rs" #[macro_use] extern crate gluon_vm; extern crate gluon; //@no-rustfix -use gluon::{ - import::add_extern_module, - new_vm, - vm::{ - api::primitive_f, - thread::{Status, Thread}, - ExternModule, - }, -}; +use gluon::{import::add_extern_module, new_vm, vm::ExternModule}; fn f(_: &'static str) {} diff --git a/tests/compile-fail/getable-reference-str.stderr b/tests/compile-fail/getable-reference-str.stderr index 58850a25b..abd420d4c 100644 --- a/tests/compile-fail/getable-reference-str.stderr +++ b/tests/compile-fail/getable-reference-str.stderr @@ -1,17 +1,7 @@ -warning: unused imports: `Status`, `Thread`, and `api::primitive_f` - --> tests/compile-fail/getable-reference-str.rs:9:9 - | - 9 | api::primitive_f, - | ^^^^^^^^^^^^^^^^ -10 | thread::{Status, Thread}, - | ^^^^^^ ^^^^^^ - | - = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default - error: lifetime may not live long enough - --> tests/compile-fail/getable-reference-str.rs:21:31 + --> .../getable-reference-str.rs:14:31 | -21 | ExternModule::new(vm, primitive!(1, f)) +14 | ExternModule::new(vm, primitive!(1, f)) | ^^^^^^^^^^^^^^^^ | | | lifetime `'thread` defined here @@ -19,5 +9,5 @@ error: lifetime may not live long enough | = note: this error originates in the macro `primitive` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error diff --git a/tests/compile-fail/getable-reference.rs b/tests/compile-fail/getable-reference.rs index 022a4ce67..f85b69127 100644 --- a/tests/compile-fail/getable-reference.rs +++ b/tests/compile-fail/getable-reference.rs @@ -1,3 +1,4 @@ +//@normalize-stderr-test: "[^ ]*?[\\/]([^\\/]+).rs" -> ".../$1.rs" #[macro_use] extern crate gluon_vm; extern crate gluon; @@ -8,10 +9,8 @@ use gluon::{ import::add_extern_module, new_vm, vm::{ - api::{primitive_f, Userdata, VmType}, - gc::{Gc, Trace}, - thread::{Status, Thread}, ExternModule, + api::{Userdata, VmType}, }, }; diff --git a/tests/compile-fail/getable-reference.stderr b/tests/compile-fail/getable-reference.stderr index 1be404c50..cd8cf3673 100644 --- a/tests/compile-fail/getable-reference.stderr +++ b/tests/compile-fail/getable-reference.stderr @@ -1,19 +1,7 @@ -warning: unused imports: `Gc`, `Status`, `Thread`, `Trace`, and `primitive_f` - --> tests/compile-fail/getable-reference.rs:11:15 - | -11 | api::{primitive_f, Userdata, VmType}, - | ^^^^^^^^^^^ -12 | gc::{Gc, Trace}, - | ^^ ^^^^^ -13 | thread::{Status, Thread}, - | ^^^^^^ ^^^^^^ - | - = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default - error: lifetime may not live long enough - --> tests/compile-fail/getable-reference.rs:33:31 + --> .../getable-reference.rs:32:31 | -33 | ExternModule::new(vm, primitive!(1, f)) +32 | ExternModule::new(vm, primitive!(1, f)) | ^^^^^^^^^^^^^^^^ | | | lifetime `'thread` defined here @@ -21,5 +9,5 @@ error: lifetime may not live long enough | = note: this error originates in the macro `primitive` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error diff --git a/tests/compile-fail/run_expr_str_ref.rs b/tests/compile-fail/run_expr_str_ref.rs index 453a40b42..4d53eeda0 100644 --- a/tests/compile-fail/run_expr_str_ref.rs +++ b/tests/compile-fail/run_expr_str_ref.rs @@ -1,5 +1,4 @@ -//@normalize-stderr-test: "(/|\w:)[^ ]*/src/lib.rs" -> "../src/lib.rs" -//@normalize-stderr-test: "(/|\w:)[^ ]*/mod.rs" -> "../mod.rs" +//@normalize-stderr-test: "[^ ]*?[\\/]([^\\/]+)\.rs" -> ".../$1.rs" extern crate gluon; use gluon::{ThreadExt, new_vm}; diff --git a/tests/compile-fail/run_expr_str_ref.stderr b/tests/compile-fail/run_expr_str_ref.stderr index eb9dcb41f..e21b74eab 100644 --- a/tests/compile-fail/run_expr_str_ref.stderr +++ b/tests/compile-fail/run_expr_str_ref.stderr @@ -1,19 +1,19 @@ error[E0277]: the trait bound `for<'value> &str: Getable<'_, 'value>` is not satisfied - --> tests/compile-fail/run_expr_str_ref.rs:10:27 + --> .../run_expr_str_ref.rs:9:27 | - 10 | let _ = vm.run_expr::<&str>("", r#" "test" "#); + 9 | let _ = vm.run_expr::<&str>("", r#" "test" "#); | -------- ^^^^ the trait `for<'value> Getable<'_, 'value>` is not implemented for `&str` | | | required by a bound introduced by this call | help: the trait `Getable<'_, 'value>` is not implemented for `&str` but trait `Getable<'_, '_>` is implemented for it - --> ../mod.rs:746:1 + --> .../mod.rs:746:1 | 746 | impl<'vm, 'value> Getable<'vm, 'value> for &'value str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `gluon::ThreadExt::run_expr` - --> ../src/lib.rs:705:12 + --> .../lib.rs:705:12 | 703 | fn run_expr<'vm, T>(&'vm self, name: &str, expr_str: &str) -> Result<(T, ArcType)> | -------- required by a bound in this associated function diff --git a/tests/compile-fail/store-ref.rs b/tests/compile-fail/store-ref.rs index b1f06a948..a9ec040ec 100644 --- a/tests/compile-fail/store-ref.rs +++ b/tests/compile-fail/store-ref.rs @@ -1,3 +1,4 @@ +//@normalize-stderr-test: "[^ ]*?[\\/]([^\\/]+).rs" -> ".../$1.rs" #[macro_use] extern crate gluon_vm; extern crate gluon; @@ -10,10 +11,8 @@ use gluon::{ import::add_extern_module, new_vm, vm::{ - api::{primitive_f, Userdata, VmType}, - gc::Trace, - thread::{Status, Thread}, ExternModule, + api::{Userdata, VmType}, }, }; diff --git a/tests/compile-fail/store-ref.stderr b/tests/compile-fail/store-ref.stderr index af2f9f471..85e5da922 100644 --- a/tests/compile-fail/store-ref.stderr +++ b/tests/compile-fail/store-ref.stderr @@ -1,19 +1,7 @@ -warning: unused imports: `Status`, `Thread`, `gc::Trace`, and `primitive_f` - --> tests/compile-fail/store-ref.rs:13:15 - | -13 | api::{primitive_f, Userdata, VmType}, - | ^^^^^^^^^^^ -14 | gc::Trace, - | ^^^^^^^^^ -15 | thread::{Status, Thread}, - | ^^^^^^ ^^^^^^ - | - = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default - error[E0521]: borrowed data escapes outside of function - --> tests/compile-fail/store-ref.rs:44:31 + --> .../store-ref.rs:43:31 | -44 | ExternModule::new(vm, primitive!(2, f)) +43 | ExternModule::new(vm, primitive!(2, f)) | ^^^^^^^^^^^^^^^^ | | | `thread` is a reference that is only valid in the function body @@ -21,11 +9,11 @@ error[E0521]: borrowed data escapes outside of function | lifetime `'thread` defined here | argument requires that `'thread` must outlive `'static` | - = note: requirement occurs because of the type `Test<'_>`, which makes the generic argument `'_` invariant + = note: requirement occ.rs because of the type `Test<'_>`, which makes the generic argument `'_` invariant = note: the struct `Test<'vm>` is invariant over the parameter `'vm` = help: see for more information about variance = note: this error originates in the macro `primitive` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0521`.