mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Fix ICE in span_extend_prev_while with multibyte characters
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user