diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2020-01-09 22:10:18 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2020-01-09 22:10:18 -0800 |
| commit | fcd850fc5db2501d14b2e0cbfac8aa890d700e55 (patch) | |
| tree | 2047b730bd27d2c6bb90ea2be95c98d35c7ccbb8 | |
| parent | 72b2bd55edbb1e63a930c5ddd08b25e4f9044786 (diff) | |
| download | rust-fcd850fc5db2501d14b2e0cbfac8aa890d700e55.tar.gz rust-fcd850fc5db2501d14b2e0cbfac8aa890d700e55.zip | |
Do not ICE on unicode next point
Use `shrink_to_hi` instead of `next_point` Fix #68000.
3 files changed, 24 insertions, 1 deletions
diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 918e826fc26..4cd3540ea68 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -1489,7 +1489,7 @@ impl<'a> Parser<'a> { } } _ => { - let sp = self.sess.source_map().next_point(self.prev_span); + let sp = self.prev_span.shrink_to_hi(); let mut err = self.struct_span_err( sp, &format!("expected `,`, or `}}`, found {}", super::token_descr(&self.token)), diff --git a/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.rs b/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.rs new file mode 100644 index 00000000000..3c49a5a9752 --- /dev/null +++ b/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.rs @@ -0,0 +1,6 @@ +pub struct Foo { + pub bar: Vec<i32>ö + //~^ ERROR expected `,`, or `}`, found `ö` +} //~ ERROR expected `:`, found `}` + +fn main() {} diff --git a/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.stderr b/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.stderr new file mode 100644 index 00000000000..ef365a61643 --- /dev/null +++ b/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.stderr @@ -0,0 +1,17 @@ +error: expected `,`, or `}`, found `ö` + --> $DIR/issue-68000-unicode-ident-after-missing-comma.rs:2:22 + | +LL | pub bar: Vec<i32>ö + | ^ help: try adding a comma: `,` + +error: expected `:`, found `}` + --> $DIR/issue-68000-unicode-ident-after-missing-comma.rs:4:1 + | +LL | pub bar: Vec<i32>ö + | - expected `:` +LL | +LL | } + | ^ unexpected token + +error: aborting due to 2 previous errors + |
