makepad/libs/relax/compiler/tests/cmp_ref_str.rs
Admin b22a714840 makepad run: the Rust JIT (libs/relax) and makepad-remote
The JIT that runs makepad apps from source: lexer, front end, type checker,
lazy borrow checker (Gandalf; `--check-first` opts in), codegen, session and
warm/cold caches keyed by compiler stamp, provided crates bound late,
startup images, live patching. User-facing name is `makepad run` (binary
`makepad`, MAKEPAD_RUN_* env, ~/.makepad-run); libs/relax stays the internal
library name. `makepad check` reports rustc-style diagnostics with rustc
error codes and checks a whole workspace (`--workspace`). Runs on macOS,
Linux, Windows and Android. makepad-remote: one tool schema for apps and the
WM (app/1): grabs, captures, traces, frame profiles and tweaks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 12:26:21 +02:00

14 lines
1.1 KiB
Rust

// `&str != String` (and `==`) is rejected: "cannot compare `&str` with `String`", although relax std has
// `impl<'a> PartialEq<String> for &'a str` (core/string.rs:666). `String != &str` works (c). rustc accepts all four.
// Counter at 539fbdfdda: widgets/core/src/app_icon.rs:87 `.is_none_or(|s| s.as_ref() != asset.svg)` (s: &Arc<str>,
// asset.svg: String) -> compile error in makepad_widgets_core::app_icon::install at t=3.9 s, main thread panics.
// Not a regression: fails the same at 9346e5ef58; the counter reaches it now that F41 is fixed.
use std::sync::Arc;
fn differs(s: &Arc<str>, svg: &String) -> bool { s.as_ref() != *svg }
fn differs2(a: &str, b: String) -> bool { a != b }
fn differs3(a: String, b: &str) -> bool { a != b }
fn differs4(a: &str, b: &String) -> bool { a != *b }
#[test] fn a_arc_as_ref_vs_string() { let a: Arc<str> = Arc::from("x"); assert!(!differs(&a, &"x".to_string())); }
#[test] fn b_ref_str_vs_string() { assert!(differs2("x", "y".to_string())); }
#[test] fn c_string_vs_ref_str() { assert!(differs3("x".to_string(), "y")); }
#[test] fn d_ref_str_vs_deref_string() { assert!(differs4("x", &"y".to_string())); }