Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 2 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 17 additions & 0 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 23 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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>,

0 commit comments

Comments
 (0)