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 10 pull requests #64246

Merged
merged 34 commits into from
Sep 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6876f9b
filter linkcheck spurious failure
mark-i-m Aug 26, 2019
2e59c4a
fix bugs + review comments
mark-i-m Aug 29, 2019
3f6db84
actually compiles now?
mark-i-m Aug 30, 2019
0133941
Add an ExpnKind for AST passes
matthewjasper Aug 25, 2019
4082cd9
Allow ast passes to create hygienic spans
matthewjasper Aug 25, 2019
6fcdb36
Make use of hygiene in AST passes
matthewjasper Aug 25, 2019
2a82aec
Move tests for unit tests to their own directory
matthewjasper Aug 25, 2019
beb2f5b
Remove `Ident::{gensym, is_gensymed}`
matthewjasper Aug 25, 2019
846df20
Fix 2018 edition expanded pretty printing
matthewjasper Aug 25, 2019
0b86782
Don't call `diag_span_note_once` for suppressed lints
matthewjasper Aug 27, 2019
c8cf9f5
Add `with_{def_site,call_site,legacy}_ctxt,` methods to `Span`
petrochenkov Aug 28, 2019
e552840
Document test harness generation
matthewjasper Aug 28, 2019
afcf9b2
Bail out when encountering likely missing turbofish in parser
estebank Sep 5, 2019
3f3fc52
Simplify std lib injection
matthewjasper Sep 5, 2019
bad8147
fix reviewer comments
mark-i-m Sep 5, 2019
dc613c6
Fix test
estebank Sep 5, 2019
eedf555
rustc_codegen_llvm: give names to non-alloca variable values.
eddyb Sep 4, 2019
10f46b6
Move the HIR cfg to `rustc_ast_borrowck`
matthewjasper Sep 6, 2019
f6481ed
Correct pluralisation of various diagnostic messages
varkor Sep 6, 2019
0b97726
Update ui tests
varkor Sep 6, 2019
055d379
reduce visibility
matklad Aug 31, 2019
a26ee85
Include compiler-rt in the source tarball
maurer Sep 6, 2019
7dd5c66
Added more prereqs and note about default directory
Sep 6, 2019
3dde650
Move injection of attributes from command line to `libsyntax_ext`
petrochenkov Sep 6, 2019
db493ef
Rollup merge of #63919 - matthewjasper:remove-gensymmed, r=petrochenkov
Centril Sep 7, 2019
7dcac19
Rollup merge of #63927 - mark-i-m:filter-spurious, r=ehuss
Centril Sep 7, 2019
da61325
Rollup merge of #64149 - eddyb:llvm-var-names, r=rkruppe
Centril Sep 7, 2019
fae7bc7
Rollup merge of #64192 - estebank:turbofish-madness, r=petrochenkov
Centril Sep 7, 2019
84cb352
Rollup merge of #64231 - matthewjasper:move-ast-cfg, r=Centril
Centril Sep 7, 2019
d5caeac
Rollup merge of #64233 - varkor:correct-pluralisation, r=estebank
Centril Sep 7, 2019
e6a7689
Rollup merge of #64236 - matklad:reduce-visibility, r=Centril
Centril Sep 7, 2019
e77ba6f
Rollup merge of #64240 - maurer:include-compiler-rt, r=alexcrichton
Centril Sep 7, 2019
69121f5
Rollup merge of #64241 - adityaatluri:install-doc, r=Mark-Simulacrum
Centril Sep 7, 2019
3d4cb50
Rollup merge of #64243 - petrochenkov:cmdattr, r=alexcrichton
Centril Sep 7, 2019
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ or reading the [rustc guide][rustcguidebuild].
* `cmake` 3.4.3 or later
* `curl`
* `git`
* `ssl` which comes in `libssl-dev` or `openssl-devel`

2. Clone the [source] with `git`:

Expand All @@ -56,6 +57,8 @@ or reading the [rustc guide][rustcguidebuild].
an installation (using `./x.py install`) that you set the `prefix` value
in the `[install]` section to a directory that you have write permissions.

Create install directory if you are not installing in default directory

4. Build and install:

```sh
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
"llvm-project/lld", "llvm-project\\lld",
"llvm-project/lldb", "llvm-project\\lldb",
"llvm-project/llvm", "llvm-project\\llvm",
"llvm-project/compiler-rt", "llvm-project\\compiler-rt",
];
if spath.contains("llvm-project") && !spath.ends_with("llvm-project")
&& !LLVM_PROJECTS.iter().any(|path| spath.contains(path))
Expand Down
8 changes: 8 additions & 0 deletions src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,17 @@ impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData {
impl_stable_hash_for!(enum ::syntax_pos::hygiene::ExpnKind {
Root,
Macro(kind, descr),
AstPass(kind),
Desugaring(kind)
});

impl_stable_hash_for!(enum ::syntax_pos::hygiene::AstPass {
StdImports,
TestHarness,
ProcMacroHarness,
PluginMacroDefs,
});

impl_stable_hash_for!(enum ::syntax_pos::hygiene::DesugaringKind {
CondTemporary,
Async,
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ pub mod query;

#[macro_use]
pub mod arena;
pub mod cfg;
pub mod dep_graph;
pub mod hir;
pub mod ich;
Expand Down
46 changes: 25 additions & 21 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,30 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
(Level::Forbid, None) => sess.struct_err(msg),
};

// Check for future incompatibility lints and issue a stronger warning.
let lints = sess.lint_store.borrow();
let lint_id = LintId::of(lint);
let future_incompatible = lints.future_incompatible(lint_id);

// If this code originates in a foreign macro, aka something that this crate
// did not itself author, then it's likely that there's nothing this crate
// can do about it. We probably want to skip the lint entirely.
if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
// Any suggestions made here are likely to be incorrect, so anything we
// emit shouldn't be automatically fixed by rustfix.
err.allow_suggestions(false);

// If this is a future incompatible lint it'll become a hard error, so
// we have to emit *something*. Also allow lints to whitelist themselves
// on a case-by-case basis for emission in a foreign macro.
if future_incompatible.is_none() && !lint.report_in_external_macro {
err.cancel();
// Don't continue further, since we don't want to have
// `diag_span_note_once` called for a diagnostic that isn't emitted.
return err;
}
}

let name = lint.name_lower();
match src {
LintSource::Default => {
Expand Down Expand Up @@ -695,10 +719,6 @@ pub fn struct_lint_level<'a>(sess: &'a Session,

err.code(DiagnosticId::Lint(name));

// Check for future incompatibility lints and issue a stronger warning.
let lints = sess.lint_store.borrow();
let lint_id = LintId::of(lint);
let future_incompatible = lints.future_incompatible(lint_id);
if let Some(future_incompatible) = future_incompatible {
const STANDARD_MESSAGE: &str =
"this was previously accepted by the compiler but is being phased out; \
Expand All @@ -723,22 +743,6 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
err.note(&citation);
}

// If this code originates in a foreign macro, aka something that this crate
// did not itself author, then it's likely that there's nothing this crate
// can do about it. We probably want to skip the lint entirely.
if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
// Any suggestions made here are likely to be incorrect, so anything we
// emit shouldn't be automatically fixed by rustfix.
err.allow_suggestions(false);

// If this is a future incompatible lint it'll become a hard error, so
// we have to emit *something*. Also allow lints to whitelist themselves
// on a case-by-case basis for emission in a foreign macro.
if future_incompatible.is_none() && !lint.report_in_external_macro {
err.cancel()
}
}

return err
}

Expand Down Expand Up @@ -868,7 +872,7 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
let expn_data = span.ctxt().outer_expn_data();
match expn_data.kind {
ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop) => false,
ExpnKind::Desugaring(_) => true, // well, it's "external"
ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external"
ExpnKind::Macro(MacroKind::Bang, _) => {
if expn_data.def_site.is_dummy() {
// dummy span for the def_site means it's an external macro
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ impl<'tcx> ty::TyS<'tcx> {
ty::Array(_, n) => {
let n = tcx.lift_to_global(&n).unwrap();
match n.try_eval_usize(tcx, ty::ParamEnv::empty()) {
Some(n) => format!("array of {} elements", n).into(),
Some(n) => {
format!("array of {} element{}", n, if n != 1 { "s" } else { "" }).into()
}
None => "array".into(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use InteriorKind::*;

use rustc::hir::HirId;
use rustc::hir::Node;
use rustc::cfg;
use rustc::middle::borrowck::{BorrowCheckResult, SignalledError};
use rustc::hir::def_id::{DefId, LocalDefId};
use rustc::middle::mem_categorization as mc;
Expand All @@ -28,6 +27,7 @@ use log::debug;

use rustc::hir;

use crate::cfg;
use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};

pub mod check_loans;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_borrowck/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};

use crate::borrowck::*;
use rustc::cfg;
use crate::cfg;
use rustc::ty::{self, TyCtxt};
use rustc::util::nodemap::FxHashMap;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::cfg::*;
use crate::middle::region;
use rustc_data_structures::graph::implementation as graph;
use crate::ty::{self, TyCtxt};
use rustc::middle::region;
use rustc::ty::{self, TyCtxt};

use crate::hir::{self, PatKind};
use crate::hir::def_id::DefId;
use crate::hir::ptr::P;
use rustc::hir::{self, PatKind};
use rustc::hir::def_id::DefId;
use rustc::hir::ptr::P;

struct CFGBuilder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
Expand All @@ -30,7 +30,7 @@ struct LoopScope {
break_index: CFGIndex, // where to go on a `break`
}

pub fn construct(tcx: TyCtxt<'_>, body: &hir::Body) -> CFG {
pub(super) fn construct(tcx: TyCtxt<'_>, body: &hir::Body) -> CFG {
let mut graph = graph::Graph::new();
let entry = graph.add_node(CFGNodeData::Entry);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/// This module provides linkage between rustc::middle::graph and
/// libgraphviz traits.

// For clarity, rename the graphviz crate locally to dot.
use graphviz as dot;

use crate::cfg;
use crate::hir;
use crate::ty::TyCtxt;
use rustc::hir;
use rustc::ty::TyCtxt;

pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
pub type Edge<'a> = &'a cfg::CFGEdge;
pub(crate) type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
pub(crate) type Edge<'a> = &'a cfg::CFGEdge;

pub struct LabelledCFG<'a, 'tcx> {
pub tcx: TyCtxt<'tcx>,
Expand Down
31 changes: 13 additions & 18 deletions src/librustc/cfg/mod.rs → src/librustc_ast_borrowck/cfg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
//! Uses `Graph` as the underlying representation.

use rustc_data_structures::graph::implementation as graph;
use crate::ty::TyCtxt;
use crate::hir;
use crate::hir::def_id::DefId;
use rustc::ty::TyCtxt;
use rustc::hir;
use rustc::hir::def_id::DefId;

mod construct;
pub mod graphviz;

pub struct CFG {
pub owner_def_id: DefId,
pub graph: CFGGraph,
pub entry: CFGIndex,
pub exit: CFGIndex,
owner_def_id: DefId,
pub(crate) graph: CFGGraph,
pub(crate) entry: CFGIndex,
exit: CFGIndex,
}

#[derive(Copy, Clone, Debug, PartialEq)]
Expand All @@ -26,7 +26,7 @@ pub enum CFGNodeData {
}

impl CFGNodeData {
pub fn id(&self) -> hir::ItemLocalId {
pub(crate) fn id(&self) -> hir::ItemLocalId {
if let CFGNodeData::AST(id) = *self {
id
} else {
Expand All @@ -37,24 +37,19 @@ impl CFGNodeData {

#[derive(Debug)]
pub struct CFGEdgeData {
pub exiting_scopes: Vec<hir::ItemLocalId>
pub(crate) exiting_scopes: Vec<hir::ItemLocalId>
}

pub type CFGIndex = graph::NodeIndex;
pub(crate) type CFGIndex = graph::NodeIndex;

pub type CFGGraph = graph::Graph<CFGNodeData, CFGEdgeData>;
pub(crate) type CFGGraph = graph::Graph<CFGNodeData, CFGEdgeData>;

pub type CFGNode = graph::Node<CFGNodeData>;
pub(crate) type CFGNode = graph::Node<CFGNodeData>;

pub type CFGEdge = graph::Edge<CFGEdgeData>;
pub(crate) type CFGEdge = graph::Edge<CFGEdgeData>;

impl CFG {
pub fn new(tcx: TyCtxt<'_>, body: &hir::Body) -> CFG {
construct::construct(tcx, body)
}

pub fn node_is_reachable(&self, id: hir::ItemLocalId) -> bool {
self.graph.depth_traverse(self.entry, graph::OUTGOING)
.any(|idx| self.graph.node_data(idx).id() == id)
}
}
5 changes: 2 additions & 3 deletions src/librustc_ast_borrowck/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
//! and thus uses bitvectors. Your job is simply to specify the so-called
//! GEN and KILL bits for each expression.

use rustc::cfg;
use rustc::cfg::CFGIndex;
use rustc::ty::TyCtxt;
use crate::cfg::{self, CFGIndex};
use std::mem;
use std::usize;
use log::debug;
Expand All @@ -16,6 +14,7 @@ use rustc::util::nodemap::FxHashMap;
use rustc::hir;
use rustc::hir::intravisit;
use rustc::hir::print as pprust;
use rustc::ty::TyCtxt;

#[derive(Copy, Clone, Debug)]
pub enum EntryOrExit {
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_ast_borrowck/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

pub use Variant::*;

pub use rustc::cfg::graphviz::{Node, Edge};
use rustc::cfg::graphviz as cfg_dot;

pub(crate) use crate::cfg::graphviz::{Node, Edge};
use crate::cfg::graphviz as cfg_dot;
use crate::cfg::CFGIndex;
use crate::borrowck::{self, BorrowckCtxt, LoanPath};
use crate::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit};
use log::debug;
use rustc::cfg::CFGIndex;
use std::rc::Rc;

#[derive(Debug, Copy, Clone)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc_ast_borrowck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ mod borrowck;
pub mod graphviz;

mod dataflow;
pub mod cfg;

pub use borrowck::provide;
35 changes: 32 additions & 3 deletions src/librustc_codegen_llvm/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, MirDebugScope, Variable

use libc::c_uint;
use std::cell::RefCell;
use std::ffi::CString;
use std::ffi::{CStr, CString};

use syntax_pos::{self, Span, Pos};
use syntax::ast;
Expand Down Expand Up @@ -224,8 +224,37 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
}

fn set_value_name(&mut self, value: &'ll Value, name: &str) {
let cname = SmallCStr::new(name);
fn set_var_name(&mut self, value: &'ll Value, name: impl ToString) {
// Avoid wasting time if LLVM value names aren't even enabled.
if self.sess().fewer_names() {
return;
}

// Only function parameters and instructions are local to a function,
// don't change the name of anything else (e.g. globals).
let param_or_inst = unsafe {
llvm::LLVMIsAArgument(value).is_some() ||
llvm::LLVMIsAInstruction(value).is_some()
};
if !param_or_inst {
return;
}

let old_name = unsafe {
CStr::from_ptr(llvm::LLVMGetValueName(value))
};
match old_name.to_str() {
Ok("") => {}
Ok(_) => {
// Avoid replacing the name if it already exists.
// While we could combine the names somehow, it'd
// get noisy quick, and the usefulness is dubious.
return;
}
Err(_) => return,
}

let cname = CString::new(name.to_string()).unwrap();
unsafe {
llvm::LLVMSetValueName(value, cname.as_ptr());
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ extern "C" {
pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);

// Operations on parameters
pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
pub fn LLVMCountParams(Fn: &Value) -> c_uint;
pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;

Expand All @@ -818,6 +819,7 @@ extern "C" {
pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);

// Operations on instructions
pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;

// Operations on call sites
Expand Down
Loading