Skip to content

t27o: std table gaps found on compiler.rs (is_ascii_*, chars().all, find, max, trim_start_matches, strip_prefix, let-bound receivers, matches! on a call) #9100

Closed

Description

@gHashTag

Part of the t27o epic (see #8998). Found by the dogfood run of tri t27o on bootstrap/src/compiler.rs (see #9090, see #9093).

Std calls that are missing from the table in specs/tools/t27o/rust_std.t27 refuse 11 of the 77 primitive-argument helpers of compiler.rs, each run alone. Over the whole file, they refuse 18 fns, plus 4 for matches!.

call where (compiler.rs fn) count, whole file
b.is_ascii_alphanumeric(), b.is_ascii_alphabetic() (u8) is_ident_byte, contains_call 1 + 1
s.chars().all(|c| c.is_ascii_digit()) zig_is_primitive, is_type_name 3
s.find(']'), s.find(t) scalar_field_width (and while let users) 1
x.max(1) on an integer calc_addr_width 2
s.trim_start_matches('0') literal_fits 2
s.strip_prefix('[') / strip_suffix(']') is_copy_rust_type 2
v.starts_with("0x") where let v = s.trim(); parse_int_value, is_string_field_type 5
matches!(ty.trim(), "u8" | ...): a std call as the scrutinee is_int_type, is_primitive_scalar_type, type_is_signed 4

Note on starts_with. It is in the table. It is refused here because the receiver is a local bound to a std call's result (let v = s.trim();), and the receiver's class is not carried through the let. match s.trim() { .. } converts, and matches!(s.trim(), ..) does not.

User Scenarios

  • Given fn is_ident_byte(b: u8) -> bool { b.is_ascii_alphanumeric() || b == b'_' }, when tri t27o --check runs on it, then it converts and its oracle passes, through tri::t27b::type_text's word / alpha / digit where they have the same I/O (DRY).
  • Given let v = s.trim(); if v.starts_with("0x") { .. }, when t27o converts it, then v is known to be a text, and starts_with maps as it does on a parameter.
  • Given matches!(ty.trim(), "u8" | "u16"), when t27o converts it, then it lowers like match ty.trim().

Requirements

  • FR-001: rust_std.t27 MUST map u8 is_ascii_alphanumeric, is_ascii_alphabetic, is_ascii_digit, integer max / min, text find (char or text needle, as ?usize), trim_start_matches / trim_end_matches of a char, strip_prefix / strip_suffix (as ?[]const u8), and chars().all(<one ASCII class test>). Each entry MUST name existing t27 when one has the same I/O, and MUST have rustc-printed vectors like the existing entries.
  • FR-002: rust_convert.t27 MUST carry the receiver class through let x = <std call>; when the call's result class is known.
  • FR-003: matches! MUST accept any scrutinee that match accepts.

Success Criteria

  • tri t27o bootstrap/src/compiler.rs | grep -cE 'method .(is_ascii_alphanumeric|is_ascii_alphabetic|chars|find|max|trim_start_matches|strip_prefix|starts_with). at' prints 0 (17 at master ea1bccd).
  • tri t27o bootstrap/src/compiler.rs | grep -c 'macro .matches. at' prints 0 (4 at master ea1bccd).
  • t27c test-report specs/tools/t27o/rust_std.t27 passes with a test per new entry, 0 vacuous.

Boundary

  • specs/tools/t27o/rust_std.t27
  • specs/tools/t27o/rust_convert.t27
  • gen/rust/tools/t27o/rust_convert.rs
  • .trinity/seals/t27o_T27oRust.json
  • .trinity/seals/t27o_T27oRustStd.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions