diff options
| author | bors <bors@rust-lang.org> | 2020-10-18 16:10:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-18 16:10:00 +0000 |
| commit | 4d247ad7d3d2a9f72cd60e281f39b5d85bd6a463 (patch) | |
| tree | 9f0630d41ba5e14274e052921b2ae339c690528e /src | |
| parent | 834821e3b666f77bb7caf1ed88ed662c395fbc11 (diff) | |
| parent | ac893b8a02788eec6f6fad0cc89de0177b0c0a50 (diff) | |
Auto merge of #77306 - lcnr:inline-ok, r=eddyb
normalize substs while inlining fixes #68347 or more precisely, this fixes the same ICE in rust analyser as veloren is pinned to a specific nightly and had an error with the current one. I didn't look into creating an MVCE here as that seems fairly annoying, will spend a few minutes doing so rn. (failed) r? `@eddyb` cc `@bjorn3`
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/mir/mir-inlining/ice-issue-68347.rs | 28 | ||||
| -rw-r--r-- | src/test/ui/mir/mir-inlining/ice-issue-77306-1.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/mir/mir-inlining/ice-issue-77306-2.rs | 32 |
3 files changed, 77 insertions, 0 deletions
diff --git a/src/test/ui/mir/mir-inlining/ice-issue-68347.rs b/src/test/ui/mir/mir-inlining/ice-issue-68347.rs new file mode 100644 index 00000000000..88b80bc3333 --- /dev/null +++ b/src/test/ui/mir/mir-inlining/ice-issue-68347.rs @@ -0,0 +1,28 @@ +// run-pass +// compile-flags:-Zmir-opt-level=2 +pub fn main() { + let _x: fn() = handle_debug_column; +} + +fn handle_debug_column() { + let sampler = sample_columns(); + + let foo = || { + sampler.get(17); + }; + foo(); +} + +fn sample_columns() -> impl Sampler { + ColumnGen {} +} + +struct ColumnGen {} + +trait Sampler { + fn get(&self, index: i32); +} + +impl Sampler for ColumnGen { + fn get(&self, _index: i32) {} +} diff --git a/src/test/ui/mir/mir-inlining/ice-issue-77306-1.rs b/src/test/ui/mir/mir-inlining/ice-issue-77306-1.rs new file mode 100644 index 00000000000..4d083bf2321 --- /dev/null +++ b/src/test/ui/mir/mir-inlining/ice-issue-77306-1.rs @@ -0,0 +1,17 @@ +// run-pass +// compile-flags:-Zmir-opt-level=2 + +// Previously ICEd because we did not normalize during inlining, +// see https://github.com/rust-lang/rust/pull/77306 for more discussion. + +pub fn write() { + create()() +} + +pub fn create() -> impl FnOnce() { + || () +} + +fn main() { + write(); +} diff --git a/src/test/ui/mir/mir-inlining/ice-issue-77306-2.rs b/src/test/ui/mir/mir-inlining/ice-issue-77306-2.rs new file mode 100644 index 00000000000..a346d450586 --- /dev/null +++ b/src/test/ui/mir/mir-inlining/ice-issue-77306-2.rs @@ -0,0 +1,32 @@ +// run-pass +// compile-flags:-Zmir-opt-level=2 + +struct Cursor {} +struct TokenTree {} + +impl Iterator for Cursor { + type Item = TokenTree; + + fn next(&mut self) -> Option<TokenTree> { + None + } +} + +fn tokenstream_probably_equal_for_proc_macro() { + fn break_tokens(_tree: TokenTree) -> impl Iterator<Item = TokenTree> { + let token_trees: Vec<TokenTree> = vec![]; + token_trees.into_iter() + } + + let c1 = Cursor {}; + let c2 = Cursor {}; + + let mut t1 = c1.flat_map(break_tokens); + let mut t2 = c2.flat_map(break_tokens); + + for (_t1, _t2) in t1.by_ref().zip(t2.by_ref()) {} +} + +fn main() { + tokenstream_probably_equal_for_proc_macro(); +} |
