Skip to content

Rollup of 8 pull requests #84564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
756be4a
refactored StyledBuffer parts into StyledChar
klensy Apr 16, 2021
f522991
added default for StyledChar
klensy Apr 16, 2021
e97dded
added some docs for StyledBuffer
klensy Apr 16, 2021
7e9d3c6
StyledBuffer::prepend: if line is empty, insert content without inser…
klensy Apr 16, 2021
247d74f
StyledBuffer::set_style: check overwrite first
klensy Apr 16, 2021
cb2d522
rename StyledBuffer.text to lines
klensy Apr 16, 2021
e4ce655
Handle pretty printing of `else if let` clauses
syvb Apr 23, 2021
fc97ce6
add tests for new behavior
syvb Apr 23, 2021
8629017
Add regression test
estebank Apr 24, 2021
64ee9cc
Recover trait import suggestion
estebank Apr 24, 2021
fb1fb7d
Tweak suggestion output
estebank Apr 24, 2021
ad78b50
Implemented suggestion.
Apr 24, 2021
0e7489a
Added a test.
Apr 24, 2021
8bc81a0
Refactor.
Apr 24, 2021
05a5a11
More tests.
Apr 24, 2021
8ebd811
review
klensy Apr 17, 2021
3b50461
One more test case.
Apr 24, 2021
fbc2aad
Inline most raw socket, fd and handle conversions
Apr 25, 2021
e558ddb
Improve diagnostics for function passed when a type was expected.
hameerabbasi Apr 24, 2021
9082078
unsafety checking: no longer care about is_min_const_fn
RalfJung Apr 25, 2021
1ecdaa2
remove now-unused 'is_min_const_fn'
RalfJung Apr 25, 2021
43126f3
get rid of min_const_fn references in library/ and rustdoc
RalfJung Apr 25, 2021
b1ad1fb
make sure raw ptr casts in 'const' context are unsafe
RalfJung Apr 25, 2021
421d54e
fix clippy
RalfJung Apr 25, 2021
588530d
fix typography
RalfJung Apr 25, 2021
d326a4b
Give a better error when std or core are missing
jyn514 Apr 22, 2021
e7e22b4
Rollup merge of #84235 - klensy:styled-buffer, r=lcnr
Dylan-DPC Apr 25, 2021
379a55c
Rollup merge of #84450 - jyn514:missing-std, r=petrochenkov
Dylan-DPC Apr 25, 2021
a0dcbdf
Rollup merge of #84486 - Smittyvb:else-if-let-hir-pretty-print, r=pet…
Dylan-DPC Apr 25, 2021
ae316d6
Rollup merge of #84499 - estebank:issue-84272, r=jackh726
Dylan-DPC Apr 25, 2021
ad3389a
Rollup merge of #84516 - torhovland:issue-84114, r=estebank
Dylan-DPC Apr 25, 2021
1397499
Rollup merge of #84520 - hameerabbasi:fn-as-ty, r=lcnr
Dylan-DPC Apr 25, 2021
25508eb
Rollup merge of #84541 - KaiJewson:inline-raw, r=m-ou-se
Dylan-DPC Apr 25, 2021
000a630
Rollup merge of #84547 - RalfJung:max_const_fn, r=oli-obk
Dylan-DPC Apr 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,8 @@ impl<'a> State<'a> {

fn print_else(&mut self, els: Option<&hir::Expr<'_>>) {
match els {
Some(_else) => {
match _else.kind {
Some(else_) => {
match else_.kind {
// "another else-if"
hir::ExprKind::If(ref i, ref then, ref e) => {
self.cbox(INDENT_UNIT - 1);
Expand All @@ -1114,6 +1114,26 @@ impl<'a> State<'a> {
self.s.word(" else ");
self.print_block(&b)
}
hir::ExprKind::Match(ref expr, arms, _) => {
// else if let desugared to match
assert!(arms.len() == 2, "if let desugars to match with two arms");

self.s.word(" else ");
self.s.word("{");

self.cbox(INDENT_UNIT);
self.ibox(INDENT_UNIT);
self.word_nbsp("match");
self.print_expr_as_cond(&expr);
self.s.space();
self.bopen();
for arm in arms {
self.print_arm(arm);
}
self.bclose(expr.span);

self.s.word("}");
}
// BLEAH, constraints would be great here
_ => {
panic!("print_if saw if with weird alternative");
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/match/issue-82392.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://github.com/rust-lang/rust/issues/82329
// compile-flags: -Zunpretty=hir,typed
// check-pass

pub fn main() {
if true {
} else if let Some(a) = Some(3) {
}
}
20 changes: 20 additions & 0 deletions src/test/ui/match/issue-82392.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
// https://github.com/rust-lang/rust/issues/82329
// compile-flags: -Zunpretty=hir,typed
// check-pass

pub fn main() ({
(if (true as bool)
({ } as
()) else {match ((Some as
fn(i32) -> Option<i32> {Option::<i32>::Some})((3
as
i32))
as Option<i32>) {
Some(a) => { }
_ => { }
}} as ())
} as ())
18 changes: 18 additions & 0 deletions src/test/ui/match/issue-84434.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// https://github.com/rust-lang/rust/issues/84434
// check-pass

use std::path::Path;
struct A {
pub func: fn(check: bool, a: &Path, b: Option<&Path>),
}
const MY_A: A = A {
func: |check, a, b| {
if check {
let _ = ();
} else if let Some(parent) = b.and_then(|p| p.parent()) {
let _ = ();
}
},
};

fn main() {}