Skip to content
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

Rollup of 11 pull requests #83042

Merged
merged 27 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c71f523
Clarify what `Cell::replace` returns
camelid Dec 26, 2020
14e23f1
convert slice doc link to intra-doc links
mockersf Mar 9, 2021
a6624d3
Add spirv extension handling in compiletest
XAMPPRocky Mar 10, 2021
3a3e7eb
update MSYS2 link in README
tspiteri Mar 10, 2021
a4d7046
Fix "run" button position in error index
GuillaumeGomez Mar 10, 2021
0d07153
add back sort_by_key link, allow linter and add comment
mockersf Mar 10, 2021
0666905
remove slice linkcheck exceptions
mockersf Mar 10, 2021
232b9f1
apply review
mockersf Mar 10, 2021
9925ecb
Add reexport tests
aDotInTheVoid Feb 26, 2021
5f24798
Improve some jsondocck errors
aDotInTheVoid Feb 26, 2021
68f50c8
Ignore Vim swap files
camelid Mar 11, 2021
3934dd1
rustdoc: tweak the search index format
notriddle Mar 11, 2021
00c0872
Adjust some `#[cfg]`s to take non-Unix non-Windows operating systems …
Mar 11, 2021
c69b108
Reintroduce accidentally deleted assertions.
oli-obk Mar 11, 2021
2a34428
Make THIR data structures public
LeSeulArtichaut Mar 7, 2021
6bf4147
Add `-Z unpretty` flag for the THIR
LeSeulArtichaut Mar 7, 2021
2f0bbc0
Rollup merge of #80385 - camelid:clarify-cell-replace-docs, r=Mark-Si…
JohnTitor Mar 11, 2021
a98dc9b
Rollup merge of #82571 - aDotInTheVoid:reexport-tests, r=CraftSpider
JohnTitor Mar 11, 2021
f183a3e
Rollup merge of #82860 - LeSeulArtichaut:unpretty-thir, r=spastorino
JohnTitor Mar 11, 2021
16ce4f7
Rollup merge of #82950 - mockersf:slice-intra-doc-link, r=jyn514
JohnTitor Mar 11, 2021
bb790d3
Rollup merge of #82965 - XAMPPRocky:spv-ext, r=nagisa
JohnTitor Mar 11, 2021
a86ac16
Rollup merge of #82966 - tspiteri:msys2-link, r=Mark-Simulacrum
JohnTitor Mar 11, 2021
6ea1685
Rollup merge of #82979 - GuillaumeGomez:run-button-pos, r=Nemo157
JohnTitor Mar 11, 2021
3e6e808
Rollup merge of #83001 - camelid:gitignore-vim-swap, r=Mark-Simulacrum
JohnTitor Mar 11, 2021
02326d5
Rollup merge of #83003 - notriddle:rustdoc-index-v3, r=GuillaumeGomez
JohnTitor Mar 11, 2021
5ab8f53
Rollup merge of #83013 - hyd-dev:cfg-unix-windows, r=bjorn3
JohnTitor Mar 11, 2021
14846d9
Rollup merge of #83018 - oli-obk:float_check, r=davidtwco
JohnTitor Mar 11, 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
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