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 #64826

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c015927
Fix ICE in rustdoc when merging generic and where bounds in the case …
Nashenas88 Aug 27, 2019
09f6b44
Simplify some code in rustdoc's simplify
Nashenas88 Aug 27, 2019
143b83a
Add regression test for issue, apply suggestion to convert to assert_eq
Nashenas88 Aug 28, 2019
612ef5f
add new tests for re_rebalance_coherence
nikomatsakis Sep 12, 2019
e69d1b6
change to check-pass
nikomatsakis Sep 13, 2019
3f004a1
Fix re-rebalance coherence implementation for fundamental types
weiznich Sep 17, 2019
a9c38d9
Add more tests
weiznich Sep 18, 2019
31b3012
Split line to fix tidy
weiznich Sep 18, 2019
3ee2920
Fix some unused variable warnings
weiznich Sep 22, 2019
d2762ac
Differentiate AArch64 bare-metal targets between hf and non-hf.
andre-richter Sep 18, 2019
2666ae5
Remove whitespace from testname
weiznich Sep 23, 2019
9249a73
More path name fixes
weiznich Sep 24, 2019
5122091
Turn `walk_parent_nodes` method into an iterator
estebank Sep 26, 2019
0ec4513
Fix format macro expansions spans to be macro-generated
rinon Sep 25, 2019
dd38a0f
update rtpSpawn's parameters type(It's prototype has been updated in …
bpangWR Sep 26, 2019
ab86cec
Account for tail expressions when pointing at return type
estebank Sep 26, 2019
7f318f6
[const-prop] Replace `eval_place()` with use of `InterpCx`
wesleywiser Sep 4, 2019
1a78e66
[const-prop] Replace `Use` handling with use of `InterpCx`
wesleywiser Sep 6, 2019
570748d
[const-prop] Replace `Cast` handling with use of `InterpCx`
wesleywiser Sep 6, 2019
243f99e
[const-prop] Replace `NullaryOp` handling with use of `InterpCx`
wesleywiser Sep 6, 2019
0162021
[const-prop] Replace most `UnaryOp` handling with use of `InterpCx`
wesleywiser Sep 6, 2019
233925d
[const-prop] Replace `CheckedBinaryOp` handling with use of `InterpCx`
wesleywiser Sep 9, 2019
bf770f9
[const-prop] Replace some `Binaryp` handling with use of `InterpCx`
wesleywiser Sep 10, 2019
82f38c4
[const-prop] Replace `Ref` handling with use of `InterpCx`
wesleywiser Sep 11, 2019
0d09424
Don't run the ConstProp MIR pass on generators
wesleywiser Sep 13, 2019
0cf9c5b
Respond to code review feedback and fix tidy
wesleywiser Sep 13, 2019
59f2e13
Move Ref-from-arg checking from `step.rs` to `const_prop.rs`
wesleywiser Sep 14, 2019
c8336f3
Work around for #64506
wesleywiser Sep 17, 2019
9b4fae7
Introduce a `ConstPropMachine`
wesleywiser Sep 25, 2019
737fb99
Allow reading non-mutable statics in const prop
wesleywiser Sep 25, 2019
377a70d
Fix div_duration() marked as stable by mistake
JMS55 Sep 26, 2019
c81d359
Merge pull request #30 from Wind-River/update
n-salim Sep 26, 2019
e9aa0e7
Use existing Handler to print query stack
Aaron1011 Sep 26, 2019
97906bc
Add note about global state in try_print_query_stack
Aaron1011 Sep 26, 2019
fdeb4ca
review comments
estebank Sep 26, 2019
821ff46
Include message on tests that should panic
kungfukennyg Sep 24, 2019
65af1ff
Rollup merge of #63937 - Nashenas88:rustdoc_57180, r=GuillaumeGomez
Centril Sep 27, 2019
931b795
Rollup merge of #64419 - wesleywiser:const_prop_use_ecx, r=oli-obk
Centril Sep 27, 2019
0286ed0
Rollup merge of #64546 - weiznich:bugfix/rfc-2451-rerebalance-tests, …
Centril Sep 27, 2019
daa632b
Rollup merge of #64589 - andre-richter:aarch64_bare_metal, r=Amanieu
Centril Sep 27, 2019
9c1b008
Rollup merge of #64745 - kennethbgoodin:should-panic-msg, r=varkor
Centril Sep 27, 2019
b0bfef1
Rollup merge of #64793 - immunant:format_spans, r=matthewjasper
Centril Sep 27, 2019
19f99b8
Rollup merge of #64799 - Aaron1011:fix/double-panic, r=Mark-Simulacrum
Centril Sep 27, 2019
ea31935
Rollup merge of #64802 - estebank:walk-parents-iterator, r=matthewjasper
Centril Sep 27, 2019
c02e798
Rollup merge of #64815 - JMS55:patch-1, r=jonas-schievink
Centril Sep 27, 2019
51f7b2b
Rollup merge of #64818 - Wind-River:master, r=alexcrichton
Centril Sep 27, 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
4 changes: 0 additions & 4 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ Stabilized APIs
- [`<*mut T>::cast`]
- [`Duration::as_secs_f32`]
- [`Duration::as_secs_f64`]
- [`Duration::div_duration_f32`]
- [`Duration::div_duration_f64`]
- [`Duration::div_f32`]
- [`Duration::div_f64`]
- [`Duration::from_secs_f32`]
Expand Down Expand Up @@ -100,8 +98,6 @@ Compatibility Notes
[`<*mut T>::cast`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.cast
[`Duration::as_secs_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f32
[`Duration::as_secs_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f64
[`Duration::div_duration_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_duration_f32
[`Duration::div_duration_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_duration_f64
[`Duration::div_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_f32
[`Duration::div_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_f64
[`Duration::from_secs_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.from_secs_f32
Expand Down
235 changes: 127 additions & 108 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use syntax::source_map::Spanned;
use syntax::ext::base::MacroKind;
use syntax_pos::{Span, DUMMY_SP};

use std::result::Result::Err;

pub mod blocks;
mod collector;
mod def_collector;
Expand Down Expand Up @@ -183,6 +181,44 @@ pub struct Map<'hir> {
hir_to_node_id: FxHashMap<HirId, NodeId>,
}

struct ParentHirIterator<'map> {
current_id: HirId,
map: &'map Map<'map>,
}

impl<'map> ParentHirIterator<'map> {
fn new(current_id: HirId, map: &'map Map<'map>) -> ParentHirIterator<'map> {
ParentHirIterator {
current_id,
map,
}
}
}

impl<'map> Iterator for ParentHirIterator<'map> {
type Item = (HirId, Node<'map>);

fn next(&mut self) -> Option<Self::Item> {
if self.current_id == CRATE_HIR_ID {
return None;
}
loop { // There are nodes that do not have entries, so we need to skip them.
let parent_id = self.map.get_parent_node(self.current_id);

if parent_id == self.current_id {
self.current_id = CRATE_HIR_ID;
return None;
}

self.current_id = parent_id;
if let Some(entry) = self.map.find_entry(parent_id) {
return Some((parent_id, entry.node));
}
// If this `HirId` doesn't have an `Entry`, skip it and look for its `parent_id`.
}
}
}

impl<'hir> Map<'hir> {
#[inline]
fn lookup(&self, id: HirId) -> Option<&Entry<'hir>> {
Expand Down Expand Up @@ -682,45 +718,6 @@ impl<'hir> Map<'hir> {
}
}


/// If there is some error when walking the parents (e.g., a node does not
/// have a parent in the map or a node can't be found), then we return the
/// last good `HirId` we found. Note that reaching the crate root (`id == 0`),
/// is not an error, since items in the crate module have the crate root as
/// parent.
fn walk_parent_nodes<F, F2>(&self,
start_id: HirId,
found: F,
bail_early: F2)
-> Result<HirId, HirId>
where F: Fn(&Node<'hir>) -> bool, F2: Fn(&Node<'hir>) -> bool
{
let mut id = start_id;
loop {
let parent_id = self.get_parent_node(id);
if parent_id == CRATE_HIR_ID {
return Ok(CRATE_HIR_ID);
}
if parent_id == id {
return Err(id);
}

if let Some(entry) = self.find_entry(parent_id) {
if let Node::Crate = entry.node {
return Err(id);
}
if found(&entry.node) {
return Ok(parent_id);
} else if bail_early(&entry.node) {
return Err(parent_id);
}
id = parent_id;
} else {
return Err(id);
}
}
}

/// Retrieves the `HirId` for `id`'s enclosing method, unless there's a
/// `while` or `loop` before reaching it, as block tail returns are not
/// available in them.
Expand All @@ -744,46 +741,64 @@ impl<'hir> Map<'hir> {
/// }
/// ```
pub fn get_return_block(&self, id: HirId) -> Option<HirId> {
let match_fn = |node: &Node<'_>| {
match *node {
let mut iter = ParentHirIterator::new(id, &self).peekable();
let mut ignore_tail = false;
if let Some(entry) = self.find_entry(id) {
if let Node::Expr(Expr { node: ExprKind::Ret(_), .. }) = entry.node {
// When dealing with `return` statements, we don't care about climbing only tail
// expressions.
ignore_tail = true;
}
}
while let Some((hir_id, node)) = iter.next() {
if let (Some((_, next_node)), false) = (iter.peek(), ignore_tail) {
match next_node {
Node::Block(Block { expr: None, .. }) => return None,
Node::Block(Block { expr: Some(expr), .. }) => {
if hir_id != expr.hir_id {
// The current node is not the tail expression of its parent.
return None;
}
}
_ => {}
}
}
match node {
Node::Item(_) |
Node::ForeignItem(_) |
Node::TraitItem(_) |
Node::Expr(Expr { node: ExprKind::Closure(..), ..}) |
Node::ImplItem(_) => true,
_ => false,
}
};
let match_non_returning_block = |node: &Node<'_>| {
match *node {
Node::ImplItem(_) => return Some(hir_id),
Node::Expr(ref expr) => {
match expr.node {
ExprKind::Loop(..) | ExprKind::Ret(..) => true,
_ => false,
// Ignore `return`s on the first iteration
ExprKind::Ret(..) | ExprKind::Loop(..) => return None,
_ => {}
}
}
_ => false,
Node::Local(_) => return None,
_ => {}
}
};

self.walk_parent_nodes(id, match_fn, match_non_returning_block).ok()
}
None
}

/// Retrieves the `HirId` for `id`'s parent item, or `id` itself if no
/// parent item is in this map. The "parent item" is the closest parent node
/// in the HIR which is recorded by the map and is an item, either an item
/// in a module, trait, or impl.
pub fn get_parent_item(&self, hir_id: HirId) -> HirId {
match self.walk_parent_nodes(hir_id, |node| match *node {
Node::Item(_) |
Node::ForeignItem(_) |
Node::TraitItem(_) |
Node::ImplItem(_) => true,
_ => false,
}, |_| false) {
Ok(id) => id,
Err(id) => id,
for (hir_id, node) in ParentHirIterator::new(hir_id, &self) {
match node {
Node::Crate |
Node::Item(_) |
Node::ForeignItem(_) |
Node::TraitItem(_) |
Node::ImplItem(_) => return hir_id,
_ => {}
}
}
hir_id
}

/// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
Expand All @@ -795,60 +810,64 @@ impl<'hir> Map<'hir> {
/// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no
/// module parent is in this map.
pub fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
match self.walk_parent_nodes(hir_id, |node| match *node {
Node::Item(&Item { node: ItemKind::Mod(_), .. }) => true,
_ => false,
}, |_| false) {
Ok(id) => id,
Err(id) => id,
for (hir_id, node) in ParentHirIterator::new(hir_id, &self) {
if let Node::Item(&Item { node: ItemKind::Mod(_), .. }) = node {
return hir_id;
}
}
CRATE_HIR_ID
}

/// Returns the nearest enclosing scope. A scope is roughly an item or block.
pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option<HirId> {
self.walk_parent_nodes(hir_id, |node| match *node {
Node::Item(i) => {
match i.node {
ItemKind::Fn(..)
| ItemKind::Mod(..)
| ItemKind::Enum(..)
| ItemKind::Struct(..)
| ItemKind::Union(..)
| ItemKind::Trait(..)
| ItemKind::Impl(..) => true,
_ => false,
}
},
Node::ForeignItem(fi) => {
match fi.node {
ForeignItemKind::Fn(..) => true,
_ => false,
}
},
Node::TraitItem(ti) => {
match ti.node {
TraitItemKind::Method(..) => true,
_ => false,
}
},
Node::ImplItem(ii) => {
match ii.node {
ImplItemKind::Method(..) => true,
_ => false,
}
},
Node::Block(_) => true,
_ => false,
}, |_| false).ok()
for (hir_id, node) in ParentHirIterator::new(hir_id, &self) {
if match node {
Node::Item(i) => {
match i.node {
ItemKind::Fn(..)
| ItemKind::Mod(..)
| ItemKind::Enum(..)
| ItemKind::Struct(..)
| ItemKind::Union(..)
| ItemKind::Trait(..)
| ItemKind::Impl(..) => true,
_ => false,
}
},
Node::ForeignItem(fi) => {
match fi.node {
ForeignItemKind::Fn(..) => true,
_ => false,
}
},
Node::TraitItem(ti) => {
match ti.node {
TraitItemKind::Method(..) => true,
_ => false,
}
},
Node::ImplItem(ii) => {
match ii.node {
ImplItemKind::Method(..) => true,
_ => false,
}
},
Node::Block(_) => true,
_ => false,
} {
return Some(hir_id);
}
}
None
}

/// Returns the defining scope for an opaque type definition.
pub fn get_defining_scope(&self, id: HirId) -> Option<HirId> {
pub fn get_defining_scope(&self, id: HirId) -> HirId {
let mut scope = id;
loop {
scope = self.get_enclosing_scope(scope)?;
scope = self.get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID);
if scope == CRATE_HIR_ID {
return Some(CRATE_HIR_ID);
return CRATE_HIR_ID;
}
match self.get(scope) {
Node::Item(i) => {
Expand All @@ -861,7 +880,7 @@ impl<'hir> Map<'hir> {
_ => break,
}
}
Some(scope)
scope
}

pub fn get_parent_did(&self, id: HirId) -> DefId {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ pub enum ExprKind {
/// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
/// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, [x, a, b, c, d])`.
MethodCall(P<PathSegment>, Span, HirVec<Expr>),
/// A tuple (e.g., `(a, b, c ,d)`).
/// A tuple (e.g., `(a, b, c, d)`).
Tup(HirVec<Expr>),
/// A binary operation (e.g., `a + b`, `a * b`).
Binary(BinOp, P<Expr>, P<Expr>),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ pub fn may_define_opaque_type(
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();

// Named opaque types can be defined by any siblings or children of siblings.
let scope = tcx.hir().get_defining_scope(opaque_hir_id).expect("could not get defining scope");
let scope = tcx.hir().get_defining_scope(opaque_hir_id);
// We walk up the node tree until we hit the root or the scope of the opaque type.
while hir_id != scope && hir_id != hir::CRATE_HIR_ID {
hir_id = tcx.hir().get_parent_item(hir_id);
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ pub enum UnsupportedOpInfo<'tcx> {
/// Free-form case. Only for errors that are never caught!
Unsupported(String),

/// FIXME(#64506) Error used to work around accessing projections of
/// uninhabited types.
UninhabitedValue,

// -- Everything below is not categorized yet --
FunctionAbiMismatch(Abi, Abi),
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
Expand Down Expand Up @@ -552,6 +556,8 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
not a power of two"),
Unsupported(ref msg) =>
write!(f, "{}", msg),
UninhabitedValue =>
write!(f, "tried to use an uninhabited value"),
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/librustc/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,15 @@ fn orphan_check_trait_ref<'tcx>(
// Let Ti be the first such type.
// - No uncovered type parameters P1..=Pn may appear in T0..Ti (excluding Ti)
//
for input_ty in trait_ref.input_types() {
fn uncover_fundamental_ty(ty: Ty<'_>) -> Vec<Ty<'_>> {
if fundamental_ty(ty) {
ty.walk_shallow().flat_map(|ty| uncover_fundamental_ty(ty)).collect()
} else {
vec![ty]
}
}

for input_ty in trait_ref.input_types().flat_map(uncover_fundamental_ty) {
debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty);
if ty_is_local(tcx, input_ty, in_crate) {
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
Expand Down
Loading