Skip to content

Commit

Permalink
Auto merge of #83042 - JohnTitor:rollup-s8efv94, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 11 pull requests

Successful merges:

 - #80385 (Clarify what `Cell::replace` returns)
 - #82571 (Rustdoc Json: Add tests for Reexports, and improve jsondocck)
 - #82860 (Add `-Z unpretty` flag for the THIR)
 - #82950 (convert slice doc link to intra-doc links)
 - #82965 (Add spirv extension handling in compiletest)
 - #82966 (update MSYS2 link in README)
 - #82979 (Fix "run" button position in error index)
 - #83001 (Ignore Vim swap files)
 - #83003 (rustdoc: tweak the search index format)
 - #83013 (Adjust some `#[cfg]`s to take non-Unix non-Windows operating systems into account)
 - #83018 (Reintroduce accidentally deleted assertions.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 12, 2021
2 parents 03e864f + 14846d9 commit 77b996e
Show file tree
Hide file tree
Showing 29 changed files with 377 additions and 176 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# configure your local ignore list.
# FIXME: This needs cleanup.
*~
*.swp
*.swo
.#*
.DS_Store
.cproject
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3870,13 +3870,15 @@ dependencies = [
"rustc_metadata",
"rustc_middle",
"rustc_mir",
"rustc_mir_build",
"rustc_parse",
"rustc_plugin_impl",
"rustc_save_analysis",
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_typeck",
"tracing",
"tracing-subscriber",
"tracing-tree",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ build.
[MSYS2][msys2] can be used to easily build Rust on Windows:
[msys2]: https://msys2.github.io/
[msys2]: https://www.msys2.org/
1. Grab the latest [MSYS2 installer][msys2] and go through the installer.
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
status.signal() == Some(libc::SIGILL)
}

#[cfg(windows)]
#[cfg(not(unix))]
fn is_illegal_instruction(_status: &ExitStatus) -> bool {
false
}
Expand Down Expand Up @@ -1198,7 +1198,7 @@ fn exec_linker(
flush_linked_file(&output, out_filename)?;
return output;

#[cfg(unix)]
#[cfg(not(windows))]
fn flush_linked_file(_: &io::Result<Output>, _: &Path) -> io::Result<()> {
Ok(())
}
Expand Down Expand Up @@ -1238,6 +1238,11 @@ fn exec_linker(
err.raw_os_error() == Some(ERROR_FILENAME_EXCED_RANGE)
}

#[cfg(not(any(unix, windows)))]
fn command_line_too_big(_: &io::Error) -> bool {
false
}

struct Escape<'a> {
arg: &'a str,
is_like_msvc: bool,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ rustc_interface = { path = "../rustc_interface" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
rustc_mir_build = { path = "../rustc_mir_build" }
rustc_typeck = { path = "../rustc_typeck" }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"] }
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_driver/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ use rustc_hir_pretty as pprust_hir;
use rustc_middle::hir::map as hir_map;
use rustc_middle::ty::{self, TyCtxt};
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
use rustc_mir_build::thir;
use rustc_session::config::{Input, PpAstTreeMode, PpHirMode, PpMode, PpSourceMode};
use rustc_session::Session;
use rustc_span::symbol::Ident;
use rustc_span::FileName;

use std::cell::Cell;
use std::fmt::Write;
use std::path::Path;

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

ThirTree => {
let mut out = String::new();
abort_on_err(rustc_typeck::check_crate(tcx), tcx.sess);
debug!("pretty printing THIR tree");
for did in tcx.body_owners() {
let hir = tcx.hir();
let body = hir.body(hir.body_owned_by(hir.local_def_id_to_hir_id(did)));
let arena = thir::Arena::default();
let thir =
thir::build_thir(tcx, ty::WithOptConstParam::unknown(did), &arena, &body.value);
let _ = writeln!(out, "{:?}:\n{:#?}\n", did, thir);
}
out
}

_ => unreachable!(),
};

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_build/src/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::build;
use crate::build::scope::DropKind;
use crate::thir::cx::build_thir;
use crate::thir::{Arena, BindingMode, Expr, LintLevel, Pat, PatKind};
use crate::thir::{build_thir, Arena, BindingMode, Expr, LintLevel, Pat, PatKind};
use rustc_attr::{self as attr, UnwindAttr};
use rustc_errors::ErrorReported;
use rustc_hir as hir;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern crate rustc_middle;

mod build;
mod lints;
mod thir;
pub mod thir;

use rustc_middle::ty::query::Providers;

Expand Down
25 changes: 23 additions & 2 deletions compiler/rustc_mir_build/src/thir/constant.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rustc_apfloat::Float;
use rustc_ast as ast;
use rustc_middle::mir::interpret::{
Allocation, ConstValue, LitToConstError, LitToConstInput, Scalar,
Expand Down Expand Up @@ -61,20 +62,40 @@ fn parse_float<'tcx>(num: Symbol, fty: ty::FloatTy, neg: bool) -> Result<ConstVa
use rustc_apfloat::ieee::{Double, Single};
let scalar = match fty {
ty::FloatTy::F32 => {
num.parse::<f32>().map_err(|_| ())?;
let rust_f = num.parse::<f32>().map_err(|_| ())?;
let mut f = num.parse::<Single>().unwrap_or_else(|e| {
panic!("apfloat::ieee::Single failed to parse `{}`: {:?}", num, e)
});
assert!(
u128::from(rust_f.to_bits()) == f.to_bits(),
"apfloat::ieee::Single gave different result for `{}`: \
{}({:#x}) vs Rust's {}({:#x})",
rust_f,
f,
f.to_bits(),
Single::from_bits(rust_f.to_bits().into()),
rust_f.to_bits()
);
if neg {
f = -f;
}
Scalar::from_f32(f)
}
ty::FloatTy::F64 => {
num.parse::<f64>().map_err(|_| ())?;
let rust_f = num.parse::<f64>().map_err(|_| ())?;
let mut f = num.parse::<Double>().unwrap_or_else(|e| {
panic!("apfloat::ieee::Double failed to parse `{}`: {:?}", num, e)
});
assert!(
u128::from(rust_f.to_bits()) == f.to_bits(),
"apfloat::ieee::Double gave different result for `{}`: \
{}({:#x}) vs Rust's {}({:#x})",
rust_f,
f,
f.to_bits(),
Double::from_bits(rust_f.to_bits().into()),
rust_f.to_bits()
);
if neg {
f = -f;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_middle::middle::region;
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
use rustc_middle::ty::{self, Ty, TyCtxt};

crate fn build_thir<'thir, 'tcx>(
pub fn build_thir<'thir, 'tcx>(
tcx: TyCtxt<'tcx>,
owner_def: ty::WithOptConstParam<LocalDefId>,
arena: &'thir Arena<'thir, 'tcx>,
Expand Down
79 changes: 40 additions & 39 deletions compiler/rustc_mir_build/src/thir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,51 @@ use rustc_target::abi::VariantIdx;
use rustc_target::asm::InlineAsmRegOrRegClass;

crate mod constant;

crate mod cx;
pub use cx::build_thir;

crate mod pattern;
crate use self::pattern::PatTyProj;
crate use self::pattern::{BindingMode, FieldPat, Pat, PatKind, PatRange};
pub use self::pattern::{Ascription, BindingMode, FieldPat, Pat, PatKind, PatRange, PatTyProj};

mod arena;
crate use arena::Arena;
pub use arena::Arena;

mod util;

#[derive(Copy, Clone, Debug)]
crate enum LintLevel {
pub enum LintLevel {
Inherited,
Explicit(hir::HirId),
}

#[derive(Debug)]
crate struct Block<'thir, 'tcx> {
crate targeted_by_break: bool,
crate region_scope: region::Scope,
crate opt_destruction_scope: Option<region::Scope>,
crate span: Span,
crate stmts: &'thir [Stmt<'thir, 'tcx>],
crate expr: Option<&'thir Expr<'thir, 'tcx>>,
crate safety_mode: BlockSafety,
pub struct Block<'thir, 'tcx> {
pub targeted_by_break: bool,
pub region_scope: region::Scope,
pub opt_destruction_scope: Option<region::Scope>,
pub span: Span,
pub stmts: &'thir [Stmt<'thir, 'tcx>],
pub expr: Option<&'thir Expr<'thir, 'tcx>>,
pub safety_mode: BlockSafety,
}

#[derive(Copy, Clone, Debug)]
crate enum BlockSafety {
pub enum BlockSafety {
Safe,
ExplicitUnsafe(hir::HirId),
PushUnsafe,
PopUnsafe,
}

#[derive(Debug)]
crate struct Stmt<'thir, 'tcx> {
crate kind: StmtKind<'thir, 'tcx>,
crate opt_destruction_scope: Option<region::Scope>,
pub struct Stmt<'thir, 'tcx> {
pub kind: StmtKind<'thir, 'tcx>,
pub opt_destruction_scope: Option<region::Scope>,
}

#[derive(Debug)]
crate enum StmtKind<'thir, 'tcx> {
pub enum StmtKind<'thir, 'tcx> {
Expr {
/// scope for this statement; may be used as lifetime of temporaries
scope: region::Scope,
Expand Down Expand Up @@ -111,23 +112,23 @@ rustc_data_structures::static_assert_size!(Expr<'_, '_>, 144);
/// example, method calls and overloaded operators are absent: they are
/// expected to be converted into `Expr::Call` instances.
#[derive(Debug)]
crate struct Expr<'thir, 'tcx> {
pub struct Expr<'thir, 'tcx> {
/// type of this expression
crate ty: Ty<'tcx>,
pub ty: Ty<'tcx>,

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

/// span of the expression in the source
crate span: Span,
pub span: Span,

/// kind of expression
crate kind: ExprKind<'thir, 'tcx>,
pub kind: ExprKind<'thir, 'tcx>,
}

#[derive(Debug)]
crate enum ExprKind<'thir, 'tcx> {
pub enum ExprKind<'thir, 'tcx> {
Scope {
region_scope: region::Scope,
lint_level: LintLevel,
Expand Down Expand Up @@ -316,41 +317,41 @@ crate enum ExprKind<'thir, 'tcx> {
}

#[derive(Debug)]
crate struct FieldExpr<'thir, 'tcx> {
crate name: Field,
crate expr: &'thir Expr<'thir, 'tcx>,
pub struct FieldExpr<'thir, 'tcx> {
pub name: Field,
pub expr: &'thir Expr<'thir, 'tcx>,
}

#[derive(Debug)]
crate struct FruInfo<'thir, 'tcx> {
crate base: &'thir Expr<'thir, 'tcx>,
crate field_types: &'thir [Ty<'tcx>],
pub struct FruInfo<'thir, 'tcx> {
pub base: &'thir Expr<'thir, 'tcx>,
pub field_types: &'thir [Ty<'tcx>],
}

#[derive(Debug)]
crate struct Arm<'thir, 'tcx> {
crate pattern: Pat<'tcx>,
crate guard: Option<Guard<'thir, 'tcx>>,
crate body: &'thir Expr<'thir, 'tcx>,
crate lint_level: LintLevel,
crate scope: region::Scope,
crate span: Span,
pub struct Arm<'thir, 'tcx> {
pub pattern: Pat<'tcx>,
pub guard: Option<Guard<'thir, 'tcx>>,
pub body: &'thir Expr<'thir, 'tcx>,
pub lint_level: LintLevel,
pub scope: region::Scope,
pub span: Span,
}

#[derive(Debug)]
crate enum Guard<'thir, 'tcx> {
pub enum Guard<'thir, 'tcx> {
If(&'thir Expr<'thir, 'tcx>),
IfLet(Pat<'tcx>, &'thir Expr<'thir, 'tcx>),
}

#[derive(Copy, Clone, Debug)]
crate enum LogicalOp {
pub enum LogicalOp {
And,
Or,
}

#[derive(Debug)]
crate enum InlineAsmOperand<'thir, 'tcx> {
pub enum InlineAsmOperand<'thir, 'tcx> {
In {
reg: InlineAsmRegOrRegClass,
expr: &'thir Expr<'thir, 'tcx>,
Expand Down
Loading

0 comments on commit 77b996e

Please sign in to comment.