Skip to content

Commit 4f7aed6

Browse files
authored
Rollup merge of #140246 - nnethercote:fix-never-pattern-printing, r=Nadrieril
Fix never pattern printing It's currently broken, but there's an easy fix. r? `@Nadrieril`
2 parents 267cae5 + 49ca89d commit 4f7aed6

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ impl<'a> State<'a> {
876876
}
877877
}
878878
} else {
879+
self.end(); // Close the ibox for the pattern.
879880
self.word(",");
880881
}
881882
self.end(); // Close enclosing cbox.

tests/pretty/never-pattern.pp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(prelude_import)]
2+
#![no_std]
3+
//@ pretty-mode:expanded
4+
//@ pp-exact:never-pattern.pp
5+
//@ only-x86_64
6+
7+
#![allow(incomplete_features)]
8+
#![feature(never_patterns)]
9+
#![feature(never_type)]
10+
#[prelude_import]
11+
use ::std::prelude::rust_2015::*;
12+
#[macro_use]
13+
extern crate std;
14+
15+
fn f(x: Result<u32, !>) { _ = match x { Ok(x) => x, Err(!) , }; }
16+
17+
fn main() {}

tests/pretty/never-pattern.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ pretty-mode:expanded
2+
//@ pp-exact:never-pattern.pp
3+
//@ only-x86_64
4+
5+
#![allow(incomplete_features)]
6+
#![feature(never_patterns)]
7+
#![feature(never_type)]
8+
9+
fn f(x: Result<u32, !>) {
10+
_ = match x {
11+
Ok(x) => x,
12+
Err(!),
13+
};
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)