Skip to content

Commit ef54f57

Browse files
committed
Auto merge of #64246 - Centril:rollup-zey4o09, r=Centril
Rollup of 10 pull requests Successful merges: - #63919 (Use hygiene for AST passes) - #63927 (Filter linkcheck spurious failure) - #64149 (rustc_codegen_llvm: give names to non-alloca variable values.) - #64192 (Bail out when encountering likely missing turbofish in parser) - #64231 (Move the HIR CFG to `rustc_ast_borrowck`) - #64233 (Correct pluralisation of various diagnostic messages) - #64236 (reduce visibility) - #64240 (Include compiler-rt in the source tarball) - #64241 ([doc] Added more prereqs and note about default directory) - #64243 (Move injection of attributes from command line to `libsyntax_ext`) Failed merges: r? @ghost
2 parents da13f06 + 3d4cb50 commit ef54f57

File tree

90 files changed

+857
-749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+857
-749
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ or reading the [rustc guide][rustcguidebuild].
3232
* `cmake` 3.4.3 or later
3333
* `curl`
3434
* `git`
35+
* `ssl` which comes in `libssl-dev` or `openssl-devel`
3536

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

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

60+
Create install directory if you are not installing in default directory
61+
5962
4. Build and install:
6063

6164
```sh

src/bootstrap/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
808808
"llvm-project/lld", "llvm-project\\lld",
809809
"llvm-project/lldb", "llvm-project\\lldb",
810810
"llvm-project/llvm", "llvm-project\\llvm",
811+
"llvm-project/compiler-rt", "llvm-project\\compiler-rt",
811812
];
812813
if spath.contains("llvm-project") && !spath.ends_with("llvm-project")
813814
&& !LLVM_PROJECTS.iter().any(|path| spath.contains(path))

src/librustc/ich/impls_syntax.rs

+8
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,17 @@ impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData {
390390
impl_stable_hash_for!(enum ::syntax_pos::hygiene::ExpnKind {
391391
Root,
392392
Macro(kind, descr),
393+
AstPass(kind),
393394
Desugaring(kind)
394395
});
395396

397+
impl_stable_hash_for!(enum ::syntax_pos::hygiene::AstPass {
398+
StdImports,
399+
TestHarness,
400+
ProcMacroHarness,
401+
PluginMacroDefs,
402+
});
403+
396404
impl_stable_hash_for!(enum ::syntax_pos::hygiene::DesugaringKind {
397405
CondTemporary,
398406
Async,

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ pub mod query;
9797

9898
#[macro_use]
9999
pub mod arena;
100-
pub mod cfg;
101100
pub mod dep_graph;
102101
pub mod hir;
103102
pub mod ich;

src/librustc/lint/mod.rs

+25-21
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,30 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
646646
(Level::Forbid, None) => sess.struct_err(msg),
647647
};
648648

649+
// Check for future incompatibility lints and issue a stronger warning.
650+
let lints = sess.lint_store.borrow();
651+
let lint_id = LintId::of(lint);
652+
let future_incompatible = lints.future_incompatible(lint_id);
653+
654+
// If this code originates in a foreign macro, aka something that this crate
655+
// did not itself author, then it's likely that there's nothing this crate
656+
// can do about it. We probably want to skip the lint entirely.
657+
if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
658+
// Any suggestions made here are likely to be incorrect, so anything we
659+
// emit shouldn't be automatically fixed by rustfix.
660+
err.allow_suggestions(false);
661+
662+
// If this is a future incompatible lint it'll become a hard error, so
663+
// we have to emit *something*. Also allow lints to whitelist themselves
664+
// on a case-by-case basis for emission in a foreign macro.
665+
if future_incompatible.is_none() && !lint.report_in_external_macro {
666+
err.cancel();
667+
// Don't continue further, since we don't want to have
668+
// `diag_span_note_once` called for a diagnostic that isn't emitted.
669+
return err;
670+
}
671+
}
672+
649673
let name = lint.name_lower();
650674
match src {
651675
LintSource::Default => {
@@ -695,10 +719,6 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
695719

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

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

726-
// If this code originates in a foreign macro, aka something that this crate
727-
// did not itself author, then it's likely that there's nothing this crate
728-
// can do about it. We probably want to skip the lint entirely.
729-
if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
730-
// Any suggestions made here are likely to be incorrect, so anything we
731-
// emit shouldn't be automatically fixed by rustfix.
732-
err.allow_suggestions(false);
733-
734-
// If this is a future incompatible lint it'll become a hard error, so
735-
// we have to emit *something*. Also allow lints to whitelist themselves
736-
// on a case-by-case basis for emission in a foreign macro.
737-
if future_incompatible.is_none() && !lint.report_in_external_macro {
738-
err.cancel()
739-
}
740-
}
741-
742746
return err
743747
}
744748

@@ -868,7 +872,7 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
868872
let expn_data = span.ctxt().outer_expn_data();
869873
match expn_data.kind {
870874
ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop) => false,
871-
ExpnKind::Desugaring(_) => true, // well, it's "external"
875+
ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external"
872876
ExpnKind::Macro(MacroKind::Bang, _) => {
873877
if expn_data.def_site.is_dummy() {
874878
// dummy span for the def_site means it's an external macro

src/librustc/ty/error.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ impl<'tcx> ty::TyS<'tcx> {
200200
ty::Array(_, n) => {
201201
let n = tcx.lift_to_global(&n).unwrap();
202202
match n.try_eval_usize(tcx, ty::ParamEnv::empty()) {
203-
Some(n) => format!("array of {} elements", n).into(),
203+
Some(n) => {
204+
format!("array of {} element{}", n, if n != 1 { "s" } else { "" }).into()
205+
}
204206
None => "array".into(),
205207
}
206208
}

src/librustc_ast_borrowck/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use InteriorKind::*;
99

1010
use rustc::hir::HirId;
1111
use rustc::hir::Node;
12-
use rustc::cfg;
1312
use rustc::middle::borrowck::{BorrowCheckResult, SignalledError};
1413
use rustc::hir::def_id::{DefId, LocalDefId};
1514
use rustc::middle::mem_categorization as mc;
@@ -28,6 +27,7 @@ use log::debug;
2827

2928
use rustc::hir;
3029

30+
use crate::cfg;
3131
use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
3232

3333
pub mod check_loans;

src/librustc_ast_borrowck/borrowck/move_data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
55

66
use crate::borrowck::*;
7-
use rustc::cfg;
7+
use crate::cfg;
88
use rustc::ty::{self, TyCtxt};
99
use rustc::util::nodemap::FxHashMap;
1010

src/librustc/cfg/construct.rs src/librustc_ast_borrowck/cfg/construct.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::cfg::*;
2-
use crate::middle::region;
32
use rustc_data_structures::graph::implementation as graph;
4-
use crate::ty::{self, TyCtxt};
3+
use rustc::middle::region;
4+
use rustc::ty::{self, TyCtxt};
55

6-
use crate::hir::{self, PatKind};
7-
use crate::hir::def_id::DefId;
8-
use crate::hir::ptr::P;
6+
use rustc::hir::{self, PatKind};
7+
use rustc::hir::def_id::DefId;
8+
use rustc::hir::ptr::P;
99

1010
struct CFGBuilder<'a, 'tcx> {
1111
tcx: TyCtxt<'tcx>,
@@ -30,7 +30,7 @@ struct LoopScope {
3030
break_index: CFGIndex, // where to go on a `break`
3131
}
3232

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

src/librustc/cfg/graphviz.rs src/librustc_ast_borrowck/cfg/graphviz.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
/// This module provides linkage between rustc::middle::graph and
22
/// libgraphviz traits.
33
4-
// For clarity, rename the graphviz crate locally to dot.
5-
use graphviz as dot;
6-
74
use crate::cfg;
8-
use crate::hir;
9-
use crate::ty::TyCtxt;
5+
use rustc::hir;
6+
use rustc::ty::TyCtxt;
107

11-
pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
12-
pub type Edge<'a> = &'a cfg::CFGEdge;
8+
pub(crate) type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
9+
pub(crate) type Edge<'a> = &'a cfg::CFGEdge;
1310

1411
pub struct LabelledCFG<'a, 'tcx> {
1512
pub tcx: TyCtxt<'tcx>,

src/librustc/cfg/mod.rs src/librustc_ast_borrowck/cfg/mod.rs

+13-18
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
//! Uses `Graph` as the underlying representation.
33
44
use rustc_data_structures::graph::implementation as graph;
5-
use crate::ty::TyCtxt;
6-
use crate::hir;
7-
use crate::hir::def_id::DefId;
5+
use rustc::ty::TyCtxt;
6+
use rustc::hir;
7+
use rustc::hir::def_id::DefId;
88

99
mod construct;
1010
pub mod graphviz;
1111

1212
pub struct CFG {
13-
pub owner_def_id: DefId,
14-
pub graph: CFGGraph,
15-
pub entry: CFGIndex,
16-
pub exit: CFGIndex,
13+
owner_def_id: DefId,
14+
pub(crate) graph: CFGGraph,
15+
pub(crate) entry: CFGIndex,
16+
exit: CFGIndex,
1717
}
1818

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

2828
impl CFGNodeData {
29-
pub fn id(&self) -> hir::ItemLocalId {
29+
pub(crate) fn id(&self) -> hir::ItemLocalId {
3030
if let CFGNodeData::AST(id) = *self {
3131
id
3232
} else {
@@ -37,24 +37,19 @@ impl CFGNodeData {
3737

3838
#[derive(Debug)]
3939
pub struct CFGEdgeData {
40-
pub exiting_scopes: Vec<hir::ItemLocalId>
40+
pub(crate) exiting_scopes: Vec<hir::ItemLocalId>
4141
}
4242

43-
pub type CFGIndex = graph::NodeIndex;
43+
pub(crate) type CFGIndex = graph::NodeIndex;
4444

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

47-
pub type CFGNode = graph::Node<CFGNodeData>;
47+
pub(crate) type CFGNode = graph::Node<CFGNodeData>;
4848

49-
pub type CFGEdge = graph::Edge<CFGEdgeData>;
49+
pub(crate) type CFGEdge = graph::Edge<CFGEdgeData>;
5050

5151
impl CFG {
5252
pub fn new(tcx: TyCtxt<'_>, body: &hir::Body) -> CFG {
5353
construct::construct(tcx, body)
5454
}
55-
56-
pub fn node_is_reachable(&self, id: hir::ItemLocalId) -> bool {
57-
self.graph.depth_traverse(self.entry, graph::OUTGOING)
58-
.any(|idx| self.graph.node_data(idx).id() == id)
59-
}
6055
}

src/librustc_ast_borrowck/dataflow.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
//! and thus uses bitvectors. Your job is simply to specify the so-called
44
//! GEN and KILL bits for each expression.
55
6-
use rustc::cfg;
7-
use rustc::cfg::CFGIndex;
8-
use rustc::ty::TyCtxt;
6+
use crate::cfg::{self, CFGIndex};
97
use std::mem;
108
use std::usize;
119
use log::debug;
@@ -16,6 +14,7 @@ use rustc::util::nodemap::FxHashMap;
1614
use rustc::hir;
1715
use rustc::hir::intravisit;
1816
use rustc::hir::print as pprust;
17+
use rustc::ty::TyCtxt;
1918

2019
#[derive(Copy, Clone, Debug)]
2120
pub enum EntryOrExit {

src/librustc_ast_borrowck/graphviz.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
55
pub use Variant::*;
66

7-
pub use rustc::cfg::graphviz::{Node, Edge};
8-
use rustc::cfg::graphviz as cfg_dot;
9-
7+
pub(crate) use crate::cfg::graphviz::{Node, Edge};
8+
use crate::cfg::graphviz as cfg_dot;
9+
use crate::cfg::CFGIndex;
1010
use crate::borrowck::{self, BorrowckCtxt, LoanPath};
1111
use crate::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit};
1212
use log::debug;
13-
use rustc::cfg::CFGIndex;
1413
use std::rc::Rc;
1514

1615
#[derive(Debug, Copy, Clone)]

src/librustc_ast_borrowck/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ mod borrowck;
1818
pub mod graphviz;
1919

2020
mod dataflow;
21+
pub mod cfg;
2122

2223
pub use borrowck::provide;

src/librustc_codegen_llvm/debuginfo/mod.rs

+32-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, MirDebugScope, Variable
3232

3333
use libc::c_uint;
3434
use std::cell::RefCell;
35-
use std::ffi::CString;
35+
use std::ffi::{CStr, CString};
3636

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

227-
fn set_value_name(&mut self, value: &'ll Value, name: &str) {
228-
let cname = SmallCStr::new(name);
227+
fn set_var_name(&mut self, value: &'ll Value, name: impl ToString) {
228+
// Avoid wasting time if LLVM value names aren't even enabled.
229+
if self.sess().fewer_names() {
230+
return;
231+
}
232+
233+
// Only function parameters and instructions are local to a function,
234+
// don't change the name of anything else (e.g. globals).
235+
let param_or_inst = unsafe {
236+
llvm::LLVMIsAArgument(value).is_some() ||
237+
llvm::LLVMIsAInstruction(value).is_some()
238+
};
239+
if !param_or_inst {
240+
return;
241+
}
242+
243+
let old_name = unsafe {
244+
CStr::from_ptr(llvm::LLVMGetValueName(value))
245+
};
246+
match old_name.to_str() {
247+
Ok("") => {}
248+
Ok(_) => {
249+
// Avoid replacing the name if it already exists.
250+
// While we could combine the names somehow, it'd
251+
// get noisy quick, and the usefulness is dubious.
252+
return;
253+
}
254+
Err(_) => return,
255+
}
256+
257+
let cname = CString::new(name.to_string()).unwrap();
229258
unsafe {
230259
llvm::LLVMSetValueName(value, cname.as_ptr());
231260
}

src/librustc_codegen_llvm/llvm/ffi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ extern "C" {
806806
pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
807807

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

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

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

823825
// Operations on call sites

0 commit comments

Comments
 (0)