E0077#

Warning name: lexmatch_longest_match

この警告は、longest-match lexmatch の以前の実験的な形式を説明するものであり、現在のコンパイラでは発生しません。

現在の lexmatch ... with longest は、ケースが正規表現の定数式を使う場合、メモリ上の StringStringView の入力に対して利用できます。

Erroneous example#

///|
fn classify(input : String) -> String {
  lexmatch input with longest {
    ("if|[a-z]*" as token) => token.to_owned()
    _ => "other"
  }
}

///|
test {
  inspect(classify("iff"), content="iff")
}

Suggestion#

各レガシー文字列パターンを正規表現リテラルに変換し、^ で先頭に固定してください。ケースが入力全体を消費する必要がある場合は、$ でも末尾に固定します。末尾の残余部分の束縛は after= に置き換えてください。

///|
fn classify(input : String) -> String {
  lexmatch input with longest {
    re"^(if|[a-z]*)$" as token => token.to_owned()
    _ => "other"
  }
}

///|
test {
  inspect(classify("iff"), content="iff")
}