Fix ICE in span_extend_prev_while with multibyte characters

This commit is contained in:
lapla
2026-04-10 06:17:17 +09:00
parent 49b6ac01d6
commit 2754a83cc6
3 changed files with 27 additions and 1 deletions
+1 -1
View File
@@ -743,7 +743,7 @@ pub fn span_extend_prev_while(
let n = s[..start]
.char_indices()
.rfind(|&(_, c)| !f(c))
.map_or(start, |(i, _)| start - i - 1);
.map_or(start, |(i, c)| start - i - c.len_utf8());
Ok(span.with_lo(span.lo() - BytePos(n as u32)))
})
}
@@ -0,0 +1,10 @@
//@ build-pass
// Regression test for https://github.com/rust-lang/rust/issues/155037
#![feature(associated_type_defaults)]
trait Trait {
type where = ();
//~^ WARNING where clause not allowed here
}
fn main() {}
@@ -0,0 +1,16 @@
warning: where clause not allowed here
--> $DIR/span-extend-prev-while-multibyte.rs:6:12
|
LL | type 否 where = ();
| ^^^^^
|
= note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
= note: `#[warn(deprecated_where_clause_location)]` on by default
help: move it to the end of the type declaration
|
LL - type 否 where = ();
LL + type 否 = () where;
|
warning: 1 warning emitted