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 8 pull requests #59387

Closed
wants to merge 20 commits into from
Closed
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
d189e6d
When moving out of a for loop head, suggest borrowing it
estebank Mar 14, 2019
fbc4326
Track changes to robots.txt
kornelski Mar 15, 2019
f4742f4
Add def getting methods to librustc/ty/context
Mar 15, 2019
b392c5e
use the identifier span for missing struct field
euclio Mar 16, 2019
32bcff1
SGX target: fix std unit tests
Mar 12, 2019
6430318
Use a valid name for graphviz graphs
matthewjasper Mar 17, 2019
830c98d
Fix undefined behavior in hint::spin_loop for x86 targets without SSE2
gnzlbg Mar 16, 2019
d1808aa
Remove track_errors from check_match
estebank Mar 15, 2019
936dec8
Continue running after `typeck_item_bodies` has failed
estebank Mar 15, 2019
c89872c
Do not `track_errors` in `register_plugins`
estebank Mar 15, 2019
afdc38d
address review comments
estebank Mar 18, 2019
5723632
Add note to address check_match errors
estebank Mar 23, 2019
d6fdbd7
Rollup merge of #59136 - jethrogb:jb/sgx-std-test, r=sanxiyn
Mark-Simulacrum Mar 23, 2019
d541e2b
Rollup merge of #59195 - estebank:for-loop-move, r=petrochenkov
Mark-Simulacrum Mar 23, 2019
c7b2345
Rollup merge of #59199 - estebank:untrack-errors, r=eddyb
Mark-Simulacrum Mar 23, 2019
485b34c
Rollup merge of #59213 - kornelski:robots, r=Mark-Simulacrum
Mark-Simulacrum Mar 23, 2019
7ec44cb
Rollup merge of #59216 - stepnivlk:type_dependent_defs-wrappers, r=ol…
Mark-Simulacrum Mar 23, 2019
d1344b3
Rollup merge of #59239 - gnzlbg:fix_spin_loop, r=nagisa
Mark-Simulacrum Mar 23, 2019
6f59f9a
Rollup merge of #59240 - euclio:struct-field-span, r=oli-obk
Mark-Simulacrum Mar 23, 2019
9f499f1
Rollup merge of #59251 - matthewjasper:fix-graphviz, r=petrochenkov
Mark-Simulacrum Mar 23, 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
19 changes: 19 additions & 0 deletions src/doc/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# NB: This file is not automatically deployed. After changes, it needs to be uploaded manually to doc.rust-lang.org
User-agent: *
Disallow: /0.3/
Disallow: /0.4/
Disallow: /0.5/
Disallow: /0.6/
Disallow: /0.7/
Disallow: /0.8/
Disallow: /0.9/
Disallow: /0.10/
Disallow: /0.11.0/
Disallow: /0.12.0/
Disallow: /1.0.0-alpha/
Disallow: /1.0.0-alpha.2/
Disallow: /1.0.0-beta/
Disallow: /1.0.0-beta.2/
Disallow: /1.0.0-beta.3/
Disallow: /1.0.0-beta.4/
Disallow: /1.0.0-beta.5/
31 changes: 25 additions & 6 deletions src/libcore/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,32 @@ pub unsafe fn unreachable_unchecked() -> ! {
#[inline]
#[unstable(feature = "renamed_spin_loop", issue = "55002")]
pub fn spin_loop() {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
unsafe {
asm!("pause" ::: "memory" : "volatile");
#[cfg(
all(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse2"
)
)] {
#[cfg(target_arch = "x86")] {
unsafe { crate::arch::x86::_mm_pause() };
}

#[cfg(target_arch = "x86_64")] {
unsafe { crate::arch::x86_64::_mm_pause() };
}
}

#[cfg(target_arch = "aarch64")]
unsafe {
asm!("yield" ::: "memory" : "volatile");
#[cfg(
any(
target_arch = "aarch64",
all(target_arch = "arm", target_feature = "v6")
)
)] {
#[cfg(target_arch = "aarch64")] {
unsafe { crate::arch::aarch64::__yield() };
}
#[cfg(target_arch = "arm")] {
unsafe { crate::arch::arm::__yield() };
}
}
}
3 changes: 2 additions & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4335,13 +4335,14 @@ impl<'a> LoweringContext<'a> {
// }

// expand <head>
let head = self.lower_expr(head);
let mut head = self.lower_expr(head);
let head_sp = head.span;
let desugared_span = self.mark_span_with_reason(
CompilerDesugaringKind::ForLoop,
head_sp,
None,
);
head.span = desugared_span;

let iter = self.str_to_ident("iter");

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}

fn lookup_and_handle_method(&mut self, id: hir::HirId) {
if let Some(def) = self.tables.type_dependent_defs().get(id) {
self.check_def_id(def.def_id());
if let Some(def_id) = self.tables.type_dependent_def_id(id) {
self.check_def_id(def_id);
} else {
bug!("no type-dependent def for method");
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
}
ty::Error => { }
_ => {
if let Some(def) = self.mc.tables.type_dependent_defs().get(call.hir_id) {
let def_id = def.def_id();
if let Some(def_id) = self.mc.tables.type_dependent_def_id(call.hir_id) {
let call_scope = region::Scope {
id: call.hir_id.local_id,
data: region::ScopeData::Node
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
Some(self.tables.qpath_def(qpath, expr.hir_id))
}
hir::ExprKind::MethodCall(..) => {
self.tables.type_dependent_defs().get(expr.hir_id).cloned()
self.tables.type_dependent_def(expr.hir_id)
}
_ => None
};
Expand Down
9 changes: 9 additions & 0 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,15 @@ impl<'tcx> TypeckTables<'tcx> {
}
}

pub fn type_dependent_def(&self, id: HirId) -> Option<Def> {
validate_hir_id_for_typeck_tables(self.local_id_root, id, false);
self.type_dependent_defs.get(&id.local_id).cloned()
}

pub fn type_dependent_def_id(&self, id: HirId) -> Option<DefId> {
self.type_dependent_def(id).map(|def| def.def_id())
}

pub fn type_dependent_defs_mut(&mut self) -> LocalTableInContextMut<'_, Def> {
LocalTableInContextMut {
local_id_root: self.local_id_root,
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/ty/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ rustc_query_append! { [define_queries!][ <'tcx>

TypeChecking {
[] fn typeck_item_bodies:
typeck_item_bodies_dep_node(CrateNum) -> Result<(), ErrorReported>,
typeck_item_bodies_dep_node(CrateNum) -> (),

[] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
},
Expand Down Expand Up @@ -325,8 +325,7 @@ rustc_query_append! { [define_queries!][ <'tcx>
},

TypeChecking {
[] fn check_match: CheckMatch(DefId)
-> Result<(), ErrorReported>,
[] fn check_match: CheckMatch(DefId) -> (),

/// Performs part of the privacy check and computes "access levels".
[] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,
Expand Down
14 changes: 14 additions & 0 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use std::rc::Rc;
use rustc_data_structures::sync::Lrc;
use std::hash::{Hash, Hasher};
use syntax::ast;
use syntax::source_map::CompilerDesugaringKind;
use syntax_pos::{MultiSpan, Span};
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
use log::debug;
Expand Down Expand Up @@ -746,6 +747,19 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
},
moved_lp.ty));
}
if let (Some(CompilerDesugaringKind::ForLoop), Ok(snippet)) = (
move_span.compiler_desugaring_kind(),
self.tcx.sess.source_map().span_to_snippet(move_span),
) {
if !snippet.starts_with("&") {
err.span_suggestion(
move_span,
"consider borrowing this to avoid moving it into the for loop",
format!("&{}", snippet),
Applicability::MaybeIncorrect,
);
}
}

// Note: we used to suggest adding a `ref binding` or calling
// `clone` but those suggestions have been removed because
Expand Down
12 changes: 11 additions & 1 deletion src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,20 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
let body = tcx.hir().body(body_id);
let cfg = cfg::CFG::new(tcx, &body);
let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges;
let hir_id = code.id();
// We have to disassemble the hir_id because name must be ASCII
// alphanumeric. This does not appear in the rendered graph, so it does not
// have to be user friendly.
let name = format!(
"hir_id_{}_{}_{}",
hir_id.owner.address_space().index(),
hir_id.owner.as_array_index(),
hir_id.local_id.index(),
);
let lcfg = LabelledCFG {
tcx,
cfg: &cfg,
name: format!("node_{}", code.id()),
name,
labelled_edges,
};

Expand Down
26 changes: 12 additions & 14 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,22 +323,20 @@ pub fn register_plugins<'a>(
..
} = registry;

sess.track_errors(|| {
let mut ls = sess.lint_store.borrow_mut();
for pass in early_lint_passes {
ls.register_early_pass(Some(sess), true, false, pass);
}
for pass in late_lint_passes {
ls.register_late_pass(Some(sess), true, pass);
}
let mut ls = sess.lint_store.borrow_mut();
for pass in early_lint_passes {
ls.register_early_pass(Some(sess), true, false, pass);
}
for pass in late_lint_passes {
ls.register_late_pass(Some(sess), true, pass);
}

for (name, (to, deprecated_name)) in lint_groups {
ls.register_group(Some(sess), true, name, deprecated_name, to);
}
for (name, (to, deprecated_name)) in lint_groups {
ls.register_group(Some(sess), true, name, deprecated_name, to);
}

*sess.plugin_llvm_passes.borrow_mut() = llvm_passes;
*sess.plugin_attributes.borrow_mut() = attributes.clone();
})?;
*sess.plugin_llvm_passes.borrow_mut() = llvm_passes;
*sess.plugin_attributes.borrow_mut() = attributes.clone();

Ok((krate, PluginInfo {
syntax_exts,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
}
},
hir::ExprKind::MethodCall(..) => {
cx.tables.type_dependent_defs().get(expr.hir_id).cloned()
cx.tables.type_dependent_def(expr.hir_id)
},
_ => None
};
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
let mut flow_inits = FlowAtLocation::new(do_dataflow(
tcx,
mir,
id,
def_id,
&attributes,
&dead_unwinds,
MaybeInitializedPlaces::new(tcx, mir, &mdpe),
Expand Down Expand Up @@ -191,7 +191,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
let flow_borrows = FlowAtLocation::new(do_dataflow(
tcx,
mir,
id,
def_id,
&attributes,
&dead_unwinds,
Borrows::new(tcx, mir, regioncx.clone(), &borrow_set),
Expand All @@ -200,7 +200,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
let flow_uninits = FlowAtLocation::new(do_dataflow(
tcx,
mir,
id,
def_id,
&attributes,
&dead_unwinds,
MaybeUninitializedPlaces::new(tcx, mir, &mdpe),
Expand All @@ -209,7 +209,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
let flow_ever_inits = FlowAtLocation::new(do_dataflow(
tcx,
mir,
id,
def_id,
&attributes,
&dead_unwinds,
EverInitializedPlaces::new(tcx, mir, &mdpe),
Expand Down
14 changes: 10 additions & 4 deletions src/librustc_mir/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,17 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
self.simplify_candidate(&mut candidate);

if !candidate.match_pairs.is_empty() {
span_bug!(
// ICE if no other errors have been emitted. This used to be a hard error that wouldn't
// be reached because `hair::pattern::check_match::check_match` wouldn't have let the
// compiler continue. In our tests this is only ever hit by
// `ui/consts/const-match-check.rs` with `--cfg eval1`, and that file already generates
// a different error before hand.
self.hir.tcx().sess.delay_span_bug(
candidate.match_pairs[0].pattern.span,
"match pairs {:?} remaining after simplifying \
irrefutable pattern",
candidate.match_pairs
&format!(
"match pairs {:?} remaining after simplifying irrefutable pattern",
candidate.match_pairs,
),
);
}

Expand Down
6 changes: 2 additions & 4 deletions src/librustc_mir/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use rustc::ty::layout::{self, LayoutOf, VariantIdx};
use rustc::ty::subst::Subst;
use rustc::traits::Reveal;
use rustc_data_structures::fx::FxHashMap;
use rustc::util::common::ErrorReported;

use syntax::ast::Mutability;
use syntax::source_map::{Span, DUMMY_SP};
Expand Down Expand Up @@ -619,9 +618,8 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
let tables = tcx.typeck_tables_of(def_id);

// Do match-check before building MIR
if let Err(ErrorReported) = tcx.check_match(def_id) {
return Err(ErrorHandled::Reported)
}
// FIXME(#59378) check_match may have errored but we're not checking for that anymore
tcx.check_match(def_id);

if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind_by_hir_id(id) {
tcx.mir_const_qualif(def_id);
Expand Down
17 changes: 9 additions & 8 deletions src/librustc_mir/dataflow/graphviz.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
//! Hook into libgraphviz for rendering dataflow graphs for MIR.

use rustc::hir::HirId;
use rustc::hir::def_id::DefId;
use rustc::mir::{BasicBlock, Mir};

use std::fs;
use std::io;
use std::marker::PhantomData;
use std::path::Path;

use crate::util::graphviz_safe_def_name;

use super::{BitDenotation, DataflowState};
use super::DataflowBuilder;
use super::DebugFormatted;

pub trait MirWithFlowState<'tcx> {
type BD: BitDenotation<'tcx>;
fn hir_id(&self) -> HirId;
fn def_id(&self) -> DefId;
fn mir(&self) -> &Mir<'tcx>;
fn flow_state(&self) -> &DataflowState<'tcx, Self::BD>;
}
Expand All @@ -23,7 +25,7 @@ impl<'a, 'tcx, BD> MirWithFlowState<'tcx> for DataflowBuilder<'a, 'tcx, BD>
where BD: BitDenotation<'tcx>
{
type BD = BD;
fn hir_id(&self) -> HirId { self.hir_id }
fn def_id(&self) -> DefId { self.def_id }
fn mir(&self) -> &Mir<'tcx> { self.flow_state.mir() }
fn flow_state(&self) -> &DataflowState<'tcx, Self::BD> { &self.flow_state.flow_state }
}
Expand All @@ -47,8 +49,8 @@ pub(crate) fn print_borrowck_graph_to<'a, 'tcx, BD, P>(
let g = Graph { mbcx, phantom: PhantomData, render_idx };
let mut v = Vec::new();
dot::render(&g, &mut v)?;
debug!("print_borrowck_graph_to path: {} hir_id: {}",
path.display(), mbcx.hir_id);
debug!("print_borrowck_graph_to path: {} def_id: {:?}",
path.display(), mbcx.def_id);
fs::write(path, v)
}

Expand All @@ -69,9 +71,8 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P>
type Node = Node;
type Edge = Edge;
fn graph_id(&self) -> dot::Id<'_> {
dot::Id::new(format!("graph_for_node_{}",
self.mbcx.hir_id()))
.unwrap()
let name = graphviz_safe_def_name(self.mbcx.def_id());
dot::Id::new(format!("graph_for_def_id_{}", name)).unwrap()
}

fn node_id(&self, n: &Node) -> dot::Id<'_> {
Expand Down
Loading