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 7 pull requests #76558

Merged
merged 20 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0065e33
rustbuild: don't set PYTHON_EXECUTABLE and WITH_POLLY cmake vars sinc…
matthiaskrgr Sep 8, 2020
325acef
Use intra-doc links in `core::ptr`
camelid Sep 8, 2020
c19b237
Add -Zgraphviz_dark_mode
richkadel Sep 8, 2020
15ccdeb
Update to hashbrown 0.9
mbrubeck Sep 3, 2020
ebd15e7
Implement HashSet in terms of hashbrown::HashSet
mbrubeck Aug 10, 2020
49aef96
Add HashMap::drain_filter and HashSet::drain_filter
mbrubeck Aug 10, 2020
fb1fab5
Tests for HashMap/HashSet::drain_filter
mbrubeck Sep 7, 2020
d24026b
Fix broken link
camelid Sep 9, 2020
10d3f8a
Move `rustllvm` into `rustc_llvm`
petrochenkov Jul 26, 2020
884a1b4
Fix anchor links
camelid Sep 9, 2020
f7aee33
Also fixed monospace font for d3-graphviz engine
richkadel Sep 9, 2020
f42dac0
Document btree's unwrap_unchecked
ssomers Jul 23, 2020
fdff7de
Revert "Rollup merge of #76285 - matklad:censor-spacing, r=petrochenkov"
tmandry Sep 10, 2020
f09372a
Rollup merge of #74787 - petrochenkov:rustllvm, r=cuviper
tmandry Sep 10, 2020
fa56cf5
Rollup merge of #76458 - mbrubeck:hash_drain_filter, r=Amanieu
tmandry Sep 10, 2020
9fa0794
Rollup merge of #76472 - matthiaskrgr:llvm_cmake_vars, r=Mark-Simulacrum
tmandry Sep 10, 2020
d013e60
Rollup merge of #76497 - camelid:intra-doc-links-for-core-ptr, r=jyn514
tmandry Sep 10, 2020
ba6e2b3
Rollup merge of #76500 - richkadel:mir-graphviz-dark, r=tmandry
tmandry Sep 10, 2020
8bf03c3
Rollup merge of #76543 - ssomers:btree_cleanup_4, r=Mark-Simulacrum
tmandry Sep 10, 2020
193503e
Rollup merge of #76556 - tmandry:revert-76285, r=tmandry
tmandry Sep 10, 2020
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ __pycache__/
/mingw-build/
# Created by default with `src/ci/docker/run.sh`:
/obj/
/rustllvm/
/unicode-downloads
/target
# Generated by compiletest for incremental:
Expand Down
9 changes: 4 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1259,11 +1259,10 @@ dependencies = [

[[package]]
name = "hashbrown"
version = "0.8.2"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25"
checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7"
dependencies = [
"autocfg",
"compiler_builtins",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -1401,9 +1400,9 @@ dependencies = [

[[package]]
name = "indexmap"
version = "1.5.1"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86b45e59b16c76b11bf9738fd5d38879d3bd28ad292d7b313608becb17ae2df9"
checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
dependencies = [
"autocfg",
"hashbrown",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ impl Cursor {
self.index = index;
}

pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> {
self.stream.0[self.index..].get(n).map(|(tree, _)| tree)
pub fn look_ahead(&self, n: usize) -> Option<TokenTree> {
self.stream.0[self.index..].get(n).map(|(tree, _)| tree.clone())
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hir = { path = "../rustc_hir" }
rustc_incremental = { path = "../rustc_incremental" }
rustc_index = { path = "../rustc_index" }
rustc_llvm = { path = "../../src/librustc_llvm" }
rustc_llvm = { path = "../rustc_llvm" }
rustc_session = { path = "../rustc_session" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_target = { path = "../rustc_target" }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub enum DLLStorageClass {
DllExport = 2, // Function to be accessible from DLL.
}

/// Matches LLVMRustAttribute in rustllvm.h
/// Matches LLVMRustAttribute in LLVMWrapper.h
/// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
/// though it is not ABI compatible (since it's a C++ enum)
#[repr(C)]
Expand Down Expand Up @@ -1705,7 +1705,7 @@ extern "C" {
PM: &PassManager<'_>,
);

// Stuff that's in rustllvm/ because it's not upstream yet.
// Stuff that's in llvm-wrapper/ because it's not upstream yet.

/// Opens an object file.
pub fn LLVMCreateObjectFile(
Expand Down
22 changes: 5 additions & 17 deletions compiler/rustc_expand/src/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,15 @@ impl ToInternal<token::DelimToken> for Delimiter {
}
}

impl
FromInternal<(
TreeAndJoint,
Option<&'_ tokenstream::TokenTree>,
&'_ ParseSess,
&'_ mut Vec<Self>,
)> for TokenTree<Group, Punct, Ident, Literal>
impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
for TokenTree<Group, Punct, Ident, Literal>
{
fn from_internal(
((tree, is_joint), look_ahead, sess, stack): (
TreeAndJoint,
Option<&tokenstream::TokenTree>,
&ParseSess,
&mut Vec<Self>,
),
((tree, is_joint), sess, stack): (TreeAndJoint, &ParseSess, &mut Vec<Self>),
) -> Self {
use rustc_ast::token::*;

let joint = is_joint == Joint
&& matches!(look_ahead, Some(tokenstream::TokenTree::Token(t)) if t.is_op());
let joint = is_joint == Joint;
let Token { kind, span } = match tree {
tokenstream::TokenTree::Delimited(span, delim, tts) => {
let delimiter = Delimiter::from_internal(delim);
Expand Down Expand Up @@ -456,8 +445,7 @@ impl server::TokenStreamIter for Rustc<'_> {
loop {
let tree = iter.stack.pop().or_else(|| {
let next = iter.cursor.next_with_joint()?;
let lookahead = iter.cursor.look_ahead(0);
Some(TokenTree::from_internal((next, lookahead, self.sess, &mut iter.stack)))
Some(TokenTree::from_internal((next, self.sess, &mut iter.stack)))
})?;
// A hack used to pass AST fragments to attribute and derive macros
// as a single nonterminal token instead of a token stream.
Expand Down
20 changes: 17 additions & 3 deletions compiler/rustc_graphviz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ pub enum RenderOption {
NoNodeStyles,

Monospace,
DarkTheme,
}

/// Returns vec holding all the default render options.
Expand Down Expand Up @@ -630,10 +631,23 @@ where
writeln!(w, "digraph {} {{", g.graph_id().as_slice())?;

// Global graph properties
let mut graph_attrs = Vec::new();
let mut content_attrs = Vec::new();
if options.contains(&RenderOption::Monospace) {
writeln!(w, r#" graph[fontname="monospace"];"#)?;
writeln!(w, r#" node[fontname="monospace"];"#)?;
writeln!(w, r#" edge[fontname="monospace"];"#)?;
let font = r#"fontname="Courier, monospace""#;
graph_attrs.push(font);
content_attrs.push(font);
};
if options.contains(&RenderOption::DarkTheme) {
graph_attrs.push(r#"bgcolor="black""#);
content_attrs.push(r#"color="white""#);
content_attrs.push(r#"fontcolor="white""#);
}
if !(graph_attrs.is_empty() && content_attrs.is_empty()) {
writeln!(w, r#" graph[{}];"#, graph_attrs.join(" "))?;
let content_attrs_str = content_attrs.join(" ");
writeln!(w, r#" node[{}];"#, content_attrs_str)?;
writeln!(w, r#" edge[{}];"#, content_attrs_str)?;
}

for n in g.nodes().iter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ name = "rustc_llvm"
version = "0.0.0"
edition = "2018"

[lib]
path = "lib.rs"

[features]
static-libstdcpp = []
emscripten = []
Expand All @@ -15,5 +12,5 @@ emscripten = []
libc = "0.2.73"

[build-dependencies]
build_helper = { path = "../build_helper" }
build_helper = { path = "../../src/build_helper" }
cc = "1.0.58"
16 changes: 8 additions & 8 deletions src/librustc_llvm/build.rs → compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ fn main() {
cfg.debug(false);
}

build_helper::rerun_if_changed_anything_in_dir(Path::new("../rustllvm"));
cfg.file("../rustllvm/PassWrapper.cpp")
.file("../rustllvm/RustWrapper.cpp")
.file("../rustllvm/ArchiveWrapper.cpp")
.file("../rustllvm/CoverageMappingWrapper.cpp")
.file("../rustllvm/Linker.cpp")
build_helper::rerun_if_changed_anything_in_dir(Path::new("llvm-wrapper"));
cfg.file("llvm-wrapper/PassWrapper.cpp")
.file("llvm-wrapper/RustWrapper.cpp")
.file("llvm-wrapper/ArchiveWrapper.cpp")
.file("llvm-wrapper/CoverageMappingWrapper.cpp")
.file("llvm-wrapper/Linker.cpp")
.cpp(true)
.cpp_link_stdlib(None) // we handle this below
.compile("rustllvm");
.compile("llvm-wrapper");

let (llvm_kind, llvm_link_arg) = detect_llvm_link();

Expand Down Expand Up @@ -259,7 +259,7 @@ fn main() {
}

// Some LLVM linker flags (-L and -l) may be needed even when linking
// librustc_llvm, for example when using static libc++, we may need to
// rustc_llvm, for example when using static libc++, we may need to
// manually specify the library search path and -ldl -lpthread as link
// dependencies.
let llvm_linker_flags = tracked_env_var_os("LLVM_LINKER_FLAGS");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "rustllvm.h"
#include "LLVMWrapper.h"

#include "llvm/Object/Archive.h"
#include "llvm/Object/ArchiveWriter.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "rustllvm.h"
#include "LLVMWrapper.h"
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h"
#include "llvm/ProfileData/InstrProf.h"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "llvm/Linker/Linker.h"

#include "rustllvm.h"
#include "LLVMWrapper.h"

using namespace llvm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <vector>
#include <set>

#include "rustllvm.h"
#include "LLVMWrapper.h"

#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "rustllvm.h"
#include "LLVMWrapper.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/DiagnosticPrinter.h"
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion compiler/rustc_mir/src/dataflow/framework/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ where
let mut buf = Vec::new();

let graphviz = graphviz::Formatter::new(body, def_id, results, style);
dot::render_opts(&graphviz, &mut buf, &[dot::RenderOption::Monospace])?;
let mut render_opts = vec![dot::RenderOption::Monospace];
if tcx.sess.opts.debugging_opts.graphviz_dark_mode {
render_opts.push(dot::RenderOption::DarkTheme);
}
dot::render_opts(&graphviz, &mut buf, &render_opts)?;

if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
Expand Down
29 changes: 22 additions & 7 deletions compiler/rustc_mir/src/util/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,28 @@ where
writeln!(w, "{} {}Mir_{} {{", kind, cluster, def_name)?;

// Global graph properties
writeln!(w, r#" graph [fontname="monospace"];"#)?;
writeln!(w, r#" node [fontname="monospace"];"#)?;
writeln!(w, r#" edge [fontname="monospace"];"#)?;
let font = r#"fontname="Courier, monospace""#;
let mut graph_attrs = vec![font];
let mut content_attrs = vec![font];

let dark_mode = tcx.sess.opts.debugging_opts.graphviz_dark_mode;
if dark_mode {
graph_attrs.push(r#"bgcolor="black""#);
content_attrs.push(r#"color="white""#);
content_attrs.push(r#"fontcolor="white""#);
}

writeln!(w, r#" graph [{}];"#, graph_attrs.join(" "))?;
let content_attrs_str = content_attrs.join(" ");
writeln!(w, r#" node [{}];"#, content_attrs_str)?;
writeln!(w, r#" edge [{}];"#, content_attrs_str)?;

// Graph label
write_graph_label(tcx, def_id, body, w)?;

// Nodes
for (block, _) in body.basic_blocks().iter_enumerated() {
write_node(def_id, block, body, w)?;
write_node(def_id, block, body, dark_mode, w)?;
}

// Edges
Expand All @@ -84,6 +96,7 @@ where
pub fn write_node_label<W: Write, INIT, FINI>(
block: BasicBlock,
body: &Body<'_>,
dark_mode: bool,
w: &mut W,
num_cols: u32,
init: INIT,
Expand All @@ -100,8 +113,9 @@ where
// Basic block number at the top.
write!(
w,
r#"<tr><td {attrs} colspan="{colspan}">{blk}</td></tr>"#,
attrs = r#"bgcolor="gray" align="center""#,
r#"<tr><td bgcolor="{bgcolor}" {attrs} colspan="{colspan}">{blk}</td></tr>"#,
bgcolor = if dark_mode { "dimgray" } else { "gray" },
attrs = r#"align="center""#,
colspan = num_cols,
blk = block.index()
)?;
Expand Down Expand Up @@ -134,11 +148,12 @@ fn write_node<W: Write>(
def_id: DefId,
block: BasicBlock,
body: &Body<'_>,
dark_mode: bool,
w: &mut W,
) -> io::Result<()> {
// Start a new node with the label to follow, in one of DOT's pseudo-HTML tables.
write!(w, r#" {} [shape="none", label=<"#, node(def_id, block))?;
write_node_label(block, body, w, 1, |_| Ok(()), |_| Ok(()))?;
write_node_label(block, body, dark_mode, w, 1, |_| Ok(()), |_| Ok(()))?;
// Close the node label and the node itself.
writeln!(w, ">];")
}
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_parse/src/lexer/tokentrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ impl<'a> TokenTreesReader<'a> {
}
_ => {
let tt = TokenTree::Token(self.token.take());
let is_joint = self.bump();
let mut is_joint = self.bump();
if !self.token.is_op() {
is_joint = NonJoint;
}
Ok((tt, is_joint))
}
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,15 +822,15 @@ impl<'a> Parser<'a> {
}

let frame = &self.token_cursor.frame;
match frame.tree_cursor.look_ahead(dist - 1) {
looker(&match frame.tree_cursor.look_ahead(dist - 1) {
Some(tree) => match tree {
TokenTree::Token(token) => looker(token),
TokenTree::Token(token) => token,
TokenTree::Delimited(dspan, delim, _) => {
looker(&Token::new(token::OpenDelim(delim.clone()), dspan.open))
Token::new(token::OpenDelim(delim), dspan.open)
}
},
None => looker(&Token::new(token::CloseDelim(frame.delim), frame.span.close)),
}
None => Token::new(token::CloseDelim(frame.delim), frame.span.close),
})
}

/// Returns whether any of the given keywords are `dist` tokens ahead of the current one.
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"force all crates to be `rustc_private` unstable (default: no)"),
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
"set the optimization fuel quota for a crate"),
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
"use dark-themed colors in graphviz output (default: no)"),
hir_stats: bool = (false, parse_bool, [UNTRACKED],
"print some statistics about AST and HIR (default: no)"),
human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
Expand Down
2 changes: 1 addition & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# this flag will indicate that this version check should not be done.
#version-check = true

# Link libstdc++ statically into the librustc_llvm instead of relying on a
# Link libstdc++ statically into the rustc_llvm instead of relying on a
# dynamic version to be available.
#static-libstdcpp = false

Expand Down
3 changes: 3 additions & 0 deletions library/alloc/src/collections/btree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ trait Recover<Q: ?Sized> {
fn replace(&mut self, key: Self::Key) -> Option<Self::Key>;
}

/// Same purpose as `Option::unwrap` but doesn't always guarantee a panic
/// if the option contains no value.
/// SAFETY: the caller must ensure that the option contains a value.
#[inline(always)]
pub unsafe fn unwrap_unchecked<T>(val: Option<T>) -> T {
val.unwrap_or_else(|| {
Expand Down
Loading