Skip to content

Commit 77b996e

Browse files
committed
Auto merge of rust-lang#83042 - JohnTitor:rollup-s8efv94, r=JohnTitor
Rollup of 11 pull requests Successful merges: - rust-lang#80385 (Clarify what `Cell::replace` returns) - rust-lang#82571 (Rustdoc Json: Add tests for Reexports, and improve jsondocck) - rust-lang#82860 (Add `-Z unpretty` flag for the THIR) - rust-lang#82950 (convert slice doc link to intra-doc links) - rust-lang#82965 (Add spirv extension handling in compiletest) - rust-lang#82966 (update MSYS2 link in README) - rust-lang#82979 (Fix "run" button position in error index) - rust-lang#83001 (Ignore Vim swap files) - rust-lang#83003 (rustdoc: tweak the search index format) - rust-lang#83013 (Adjust some `#[cfg]`s to take non-Unix non-Windows operating systems into account) - rust-lang#83018 (Reintroduce accidentally deleted assertions.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 03e864f + 14846d9 commit 77b996e

File tree

29 files changed

+377
-176
lines changed

29 files changed

+377
-176
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# configure your local ignore list.
88
# FIXME: This needs cleanup.
99
*~
10+
*.swp
11+
*.swo
1012
.#*
1113
.DS_Store
1214
.cproject

Cargo.lock

+2
Original file line numberDiff line numberDiff line change
@@ -3870,13 +3870,15 @@ dependencies = [
38703870
"rustc_metadata",
38713871
"rustc_middle",
38723872
"rustc_mir",
3873+
"rustc_mir_build",
38733874
"rustc_parse",
38743875
"rustc_plugin_impl",
38753876
"rustc_save_analysis",
38763877
"rustc_serialize",
38773878
"rustc_session",
38783879
"rustc_span",
38793880
"rustc_target",
3881+
"rustc_typeck",
38803882
"tracing",
38813883
"tracing-subscriber",
38823884
"tracing-tree",

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ build.
9090
9191
[MSYS2][msys2] can be used to easily build Rust on Windows:
9292
93-
[msys2]: https://msys2.github.io/
93+
[msys2]: https://www.msys2.org/
9494
9595
1. Grab the latest [MSYS2 installer][msys2] and go through the installer.
9696

compiler/rustc_codegen_ssa/src/back/link.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
711711
status.signal() == Some(libc::SIGILL)
712712
}
713713

714-
#[cfg(windows)]
714+
#[cfg(not(unix))]
715715
fn is_illegal_instruction(_status: &ExitStatus) -> bool {
716716
false
717717
}
@@ -1198,7 +1198,7 @@ fn exec_linker(
11981198
flush_linked_file(&output, out_filename)?;
11991199
return output;
12001200

1201-
#[cfg(unix)]
1201+
#[cfg(not(windows))]
12021202
fn flush_linked_file(_: &io::Result<Output>, _: &Path) -> io::Result<()> {
12031203
Ok(())
12041204
}
@@ -1238,6 +1238,11 @@ fn exec_linker(
12381238
err.raw_os_error() == Some(ERROR_FILENAME_EXCED_RANGE)
12391239
}
12401240

1241+
#[cfg(not(any(unix, windows)))]
1242+
fn command_line_too_big(_: &io::Error) -> bool {
1243+
false
1244+
}
1245+
12411246
struct Escape<'a> {
12421247
arg: &'a str,
12431248
is_like_msvc: bool,

compiler/rustc_driver/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ rustc_interface = { path = "../rustc_interface" }
3434
rustc_serialize = { path = "../rustc_serialize" }
3535
rustc_ast = { path = "../rustc_ast" }
3636
rustc_span = { path = "../rustc_span" }
37+
rustc_mir_build = { path = "../rustc_mir_build" }
38+
rustc_typeck = { path = "../rustc_typeck" }
3739

3840
[target.'cfg(windows)'.dependencies]
3941
winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"] }

compiler/rustc_driver/src/pretty.rs

+17
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ use rustc_hir_pretty as pprust_hir;
99
use rustc_middle::hir::map as hir_map;
1010
use rustc_middle::ty::{self, TyCtxt};
1111
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
12+
use rustc_mir_build::thir;
1213
use rustc_session::config::{Input, PpAstTreeMode, PpHirMode, PpMode, PpSourceMode};
1314
use rustc_session::Session;
1415
use rustc_span::symbol::Ident;
1516
use rustc_span::FileName;
1617

1718
use std::cell::Cell;
19+
use std::fmt::Write;
1820
use std::path::Path;
1921

2022
pub use self::PpMode::*;
@@ -469,6 +471,21 @@ pub fn print_after_hir_lowering<'tcx>(
469471
format!("{:#?}", krate)
470472
}),
471473

474+
ThirTree => {
475+
let mut out = String::new();
476+
abort_on_err(rustc_typeck::check_crate(tcx), tcx.sess);
477+
debug!("pretty printing THIR tree");
478+
for did in tcx.body_owners() {
479+
let hir = tcx.hir();
480+
let body = hir.body(hir.body_owned_by(hir.local_def_id_to_hir_id(did)));
481+
let arena = thir::Arena::default();
482+
let thir =
483+
thir::build_thir(tcx, ty::WithOptConstParam::unknown(did), &arena, &body.value);
484+
let _ = writeln!(out, "{:?}:\n{:#?}\n", did, thir);
485+
}
486+
out
487+
}
488+
472489
_ => unreachable!(),
473490
};
474491

compiler/rustc_mir_build/src/build/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::build;
22
use crate::build::scope::DropKind;
3-
use crate::thir::cx::build_thir;
4-
use crate::thir::{Arena, BindingMode, Expr, LintLevel, Pat, PatKind};
3+
use crate::thir::{build_thir, Arena, BindingMode, Expr, LintLevel, Pat, PatKind};
54
use rustc_attr::{self as attr, UnwindAttr};
65
use rustc_errors::ErrorReported;
76
use rustc_hir as hir;

compiler/rustc_mir_build/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern crate rustc_middle;
2020

2121
mod build;
2222
mod lints;
23-
mod thir;
23+
pub mod thir;
2424

2525
use rustc_middle::ty::query::Providers;
2626

compiler/rustc_mir_build/src/thir/constant.rs

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_apfloat::Float;
12
use rustc_ast as ast;
23
use rustc_middle::mir::interpret::{
34
Allocation, ConstValue, LitToConstError, LitToConstInput, Scalar,
@@ -61,20 +62,40 @@ fn parse_float<'tcx>(num: Symbol, fty: ty::FloatTy, neg: bool) -> Result<ConstVa
6162
use rustc_apfloat::ieee::{Double, Single};
6263
let scalar = match fty {
6364
ty::FloatTy::F32 => {
64-
num.parse::<f32>().map_err(|_| ())?;
65+
let rust_f = num.parse::<f32>().map_err(|_| ())?;
6566
let mut f = num.parse::<Single>().unwrap_or_else(|e| {
6667
panic!("apfloat::ieee::Single failed to parse `{}`: {:?}", num, e)
6768
});
69+
assert!(
70+
u128::from(rust_f.to_bits()) == f.to_bits(),
71+
"apfloat::ieee::Single gave different result for `{}`: \
72+
{}({:#x}) vs Rust's {}({:#x})",
73+
rust_f,
74+
f,
75+
f.to_bits(),
76+
Single::from_bits(rust_f.to_bits().into()),
77+
rust_f.to_bits()
78+
);
6879
if neg {
6980
f = -f;
7081
}
7182
Scalar::from_f32(f)
7283
}
7384
ty::FloatTy::F64 => {
74-
num.parse::<f64>().map_err(|_| ())?;
85+
let rust_f = num.parse::<f64>().map_err(|_| ())?;
7586
let mut f = num.parse::<Double>().unwrap_or_else(|e| {
7687
panic!("apfloat::ieee::Double failed to parse `{}`: {:?}", num, e)
7788
});
89+
assert!(
90+
u128::from(rust_f.to_bits()) == f.to_bits(),
91+
"apfloat::ieee::Double gave different result for `{}`: \
92+
{}({:#x}) vs Rust's {}({:#x})",
93+
rust_f,
94+
f,
95+
f.to_bits(),
96+
Double::from_bits(rust_f.to_bits().into()),
97+
rust_f.to_bits()
98+
);
7899
if neg {
79100
f = -f;
80101
}

compiler/rustc_mir_build/src/thir/cx/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::middle::region;
1414
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
1515
use rustc_middle::ty::{self, Ty, TyCtxt};
1616

17-
crate fn build_thir<'thir, 'tcx>(
17+
pub fn build_thir<'thir, 'tcx>(
1818
tcx: TyCtxt<'tcx>,
1919
owner_def: ty::WithOptConstParam<LocalDefId>,
2020
arena: &'thir Arena<'thir, 'tcx>,

compiler/rustc_mir_build/src/thir/mod.rs

+40-39
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,51 @@ use rustc_target::abi::VariantIdx;
1818
use rustc_target::asm::InlineAsmRegOrRegClass;
1919

2020
crate mod constant;
21+
2122
crate mod cx;
23+
pub use cx::build_thir;
2224

2325
crate mod pattern;
24-
crate use self::pattern::PatTyProj;
25-
crate use self::pattern::{BindingMode, FieldPat, Pat, PatKind, PatRange};
26+
pub use self::pattern::{Ascription, BindingMode, FieldPat, Pat, PatKind, PatRange, PatTyProj};
2627

2728
mod arena;
28-
crate use arena::Arena;
29+
pub use arena::Arena;
2930

3031
mod util;
3132

3233
#[derive(Copy, Clone, Debug)]
33-
crate enum LintLevel {
34+
pub enum LintLevel {
3435
Inherited,
3536
Explicit(hir::HirId),
3637
}
3738

3839
#[derive(Debug)]
39-
crate struct Block<'thir, 'tcx> {
40-
crate targeted_by_break: bool,
41-
crate region_scope: region::Scope,
42-
crate opt_destruction_scope: Option<region::Scope>,
43-
crate span: Span,
44-
crate stmts: &'thir [Stmt<'thir, 'tcx>],
45-
crate expr: Option<&'thir Expr<'thir, 'tcx>>,
46-
crate safety_mode: BlockSafety,
40+
pub struct Block<'thir, 'tcx> {
41+
pub targeted_by_break: bool,
42+
pub region_scope: region::Scope,
43+
pub opt_destruction_scope: Option<region::Scope>,
44+
pub span: Span,
45+
pub stmts: &'thir [Stmt<'thir, 'tcx>],
46+
pub expr: Option<&'thir Expr<'thir, 'tcx>>,
47+
pub safety_mode: BlockSafety,
4748
}
4849

4950
#[derive(Copy, Clone, Debug)]
50-
crate enum BlockSafety {
51+
pub enum BlockSafety {
5152
Safe,
5253
ExplicitUnsafe(hir::HirId),
5354
PushUnsafe,
5455
PopUnsafe,
5556
}
5657

5758
#[derive(Debug)]
58-
crate struct Stmt<'thir, 'tcx> {
59-
crate kind: StmtKind<'thir, 'tcx>,
60-
crate opt_destruction_scope: Option<region::Scope>,
59+
pub struct Stmt<'thir, 'tcx> {
60+
pub kind: StmtKind<'thir, 'tcx>,
61+
pub opt_destruction_scope: Option<region::Scope>,
6162
}
6263

6364
#[derive(Debug)]
64-
crate enum StmtKind<'thir, 'tcx> {
65+
pub enum StmtKind<'thir, 'tcx> {
6566
Expr {
6667
/// scope for this statement; may be used as lifetime of temporaries
6768
scope: region::Scope,
@@ -111,23 +112,23 @@ rustc_data_structures::static_assert_size!(Expr<'_, '_>, 144);
111112
/// example, method calls and overloaded operators are absent: they are
112113
/// expected to be converted into `Expr::Call` instances.
113114
#[derive(Debug)]
114-
crate struct Expr<'thir, 'tcx> {
115+
pub struct Expr<'thir, 'tcx> {
115116
/// type of this expression
116-
crate ty: Ty<'tcx>,
117+
pub ty: Ty<'tcx>,
117118

118119
/// lifetime of this expression if it should be spilled into a
119120
/// temporary; should be None only if in a constant context
120-
crate temp_lifetime: Option<region::Scope>,
121+
pub temp_lifetime: Option<region::Scope>,
121122

122123
/// span of the expression in the source
123-
crate span: Span,
124+
pub span: Span,
124125

125126
/// kind of expression
126-
crate kind: ExprKind<'thir, 'tcx>,
127+
pub kind: ExprKind<'thir, 'tcx>,
127128
}
128129

129130
#[derive(Debug)]
130-
crate enum ExprKind<'thir, 'tcx> {
131+
pub enum ExprKind<'thir, 'tcx> {
131132
Scope {
132133
region_scope: region::Scope,
133134
lint_level: LintLevel,
@@ -316,41 +317,41 @@ crate enum ExprKind<'thir, 'tcx> {
316317
}
317318

318319
#[derive(Debug)]
319-
crate struct FieldExpr<'thir, 'tcx> {
320-
crate name: Field,
321-
crate expr: &'thir Expr<'thir, 'tcx>,
320+
pub struct FieldExpr<'thir, 'tcx> {
321+
pub name: Field,
322+
pub expr: &'thir Expr<'thir, 'tcx>,
322323
}
323324

324325
#[derive(Debug)]
325-
crate struct FruInfo<'thir, 'tcx> {
326-
crate base: &'thir Expr<'thir, 'tcx>,
327-
crate field_types: &'thir [Ty<'tcx>],
326+
pub struct FruInfo<'thir, 'tcx> {
327+
pub base: &'thir Expr<'thir, 'tcx>,
328+
pub field_types: &'thir [Ty<'tcx>],
328329
}
329330

330331
#[derive(Debug)]
331-
crate struct Arm<'thir, 'tcx> {
332-
crate pattern: Pat<'tcx>,
333-
crate guard: Option<Guard<'thir, 'tcx>>,
334-
crate body: &'thir Expr<'thir, 'tcx>,
335-
crate lint_level: LintLevel,
336-
crate scope: region::Scope,
337-
crate span: Span,
332+
pub struct Arm<'thir, 'tcx> {
333+
pub pattern: Pat<'tcx>,
334+
pub guard: Option<Guard<'thir, 'tcx>>,
335+
pub body: &'thir Expr<'thir, 'tcx>,
336+
pub lint_level: LintLevel,
337+
pub scope: region::Scope,
338+
pub span: Span,
338339
}
339340

340341
#[derive(Debug)]
341-
crate enum Guard<'thir, 'tcx> {
342+
pub enum Guard<'thir, 'tcx> {
342343
If(&'thir Expr<'thir, 'tcx>),
343344
IfLet(Pat<'tcx>, &'thir Expr<'thir, 'tcx>),
344345
}
345346

346347
#[derive(Copy, Clone, Debug)]
347-
crate enum LogicalOp {
348+
pub enum LogicalOp {
348349
And,
349350
Or,
350351
}
351352

352353
#[derive(Debug)]
353-
crate enum InlineAsmOperand<'thir, 'tcx> {
354+
pub enum InlineAsmOperand<'thir, 'tcx> {
354355
In {
355356
reg: InlineAsmRegOrRegClass,
356357
expr: &'thir Expr<'thir, 'tcx>,

0 commit comments

Comments
 (0)