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 6 pull requests #70672

Merged
merged 24 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a1e7495
Simplify `NodeItem`
jonas-schievink Mar 28, 2020
49ba323
spec. graph: track defining and finalizing impls
jonas-schievink Mar 28, 2020
103771c
Add a test
jonas-schievink Mar 29, 2020
e8910f5
Sync `Instance::resolve` with the projection code
jonas-schievink Mar 29, 2020
b00ba38
Use query instead of `impl_is_default` fn
jonas-schievink Mar 29, 2020
12d9f4e
Assert that the trait ref does not need inference
jonas-schievink Mar 29, 2020
2117817
Miri stacktrace: record span inside frame, not call-site span
RalfJung Mar 30, 2020
39e189d
bless tests
RalfJung Mar 30, 2020
fd8f818
Format
jonas-schievink Mar 30, 2020
abe143a
remove caller span from Miri stack frame
RalfJung Mar 30, 2020
a1a583b
stop unnecessarily passing around span argument for Miri function calls
RalfJung Mar 30, 2020
d8a0600
remove a dead parameter that everyone sets to None
RalfJung Mar 30, 2020
f259470
rustc_target::abi: rename FieldPlacement to FieldsShape.
anyska Mar 31, 2020
ad74480
avoid an unreachable fallback
RalfJung Mar 31, 2020
96deb95
const backtrace: do not skip first frame
RalfJung Mar 31, 2020
0110634
cargotest: remove webrender
pietroalbini Mar 31, 2020
3bcb3ef
clean up E0468 explanation
GuillaumeGomez Apr 1, 2020
f181778
compiletest: don't use `std::io::stdout()`, as it bypasses `set_print`.
eddyb Apr 1, 2020
0e0d84c
Rollup merge of #70535 - jonas-schievink:graph-refactor, r=nikomatsakis
Dylan-DPC Apr 1, 2020
b919df2
Rollup merge of #70590 - RalfJung:miri-backtrace, r=oli-obk
Dylan-DPC Apr 1, 2020
1b40067
Rollup merge of #70616 - anyska:fieldplacement-rename, r=oli-obk
Dylan-DPC Apr 1, 2020
0863e2c
Rollup merge of #70626 - pietroalbini:remove-webrender-cargotest, r=M…
Dylan-DPC Apr 1, 2020
37b2e3f
Rollup merge of #70649 - GuillaumeGomez:cleanup-e0468, r=Dylan-DPC
Dylan-DPC Apr 1, 2020
7d4d450
Rollup merge of #70662 - eddyb:compiletest-stdout-fix, r=Mark-Simulacrum
Dylan-DPC Apr 1, 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
12 changes: 6 additions & 6 deletions src/librustc_codegen_llvm/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn uncached_llvm_type<'a, 'tcx>(
};

match layout.fields {
layout::FieldPlacement::Union(_) => {
layout::FieldsShape::Union(_) => {
let fill = cx.type_padding_filler(layout.size, layout.align.abi);
let packed = false;
match name {
Expand All @@ -91,10 +91,10 @@ fn uncached_llvm_type<'a, 'tcx>(
}
}
}
layout::FieldPlacement::Array { count, .. } => {
layout::FieldsShape::Array { count, .. } => {
cx.type_array(layout.field(cx, 0).llvm_type(cx), count)
}
layout::FieldPlacement::Arbitrary { .. } => match name {
layout::FieldsShape::Arbitrary { .. } => match name {
None => {
let (llfields, packed) = struct_llfields(cx, layout);
cx.type_struct(&llfields, packed)
Expand Down Expand Up @@ -371,13 +371,13 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
_ => {}
}
match self.fields {
layout::FieldPlacement::Union(_) => {
layout::FieldsShape::Union(_) => {
bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self)
}

layout::FieldPlacement::Array { .. } => index as u64,
layout::FieldsShape::Array { .. } => index as u64,

layout::FieldPlacement::Arbitrary { .. } => {
layout::FieldsShape::Arbitrary { .. } => {
1 + (self.fields.memory_index(index) as u64) * 2
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
}

pub fn len<Cx: ConstMethods<'tcx, Value = V>>(&self, cx: &Cx) -> V {
if let layout::FieldPlacement::Array { count, .. } = self.layout.fields {
if let layout::FieldsShape::Array { count, .. } = self.layout.fields {
if self.layout.is_unsized() {
assert_eq!(count, 0);
self.llextra.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_error_codes/error_codes/E0468.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A non-root module attempts to import macros from another crate.
A non-root module tried to import macros from another crate.

Example of erroneous code:

Expand All @@ -17,7 +17,7 @@ Either move the macro import to crate root or do without the foreign macros.
This will work:

```
#[macro_use(debug_assert)]
#[macro_use(debug_assert)] // ok!
extern crate core;

mod foo {
Expand Down
22 changes: 9 additions & 13 deletions src/librustc_middle/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ pub struct ConstEvalErr<'tcx> {

#[derive(Debug)]
pub struct FrameInfo<'tcx> {
/// This span is in the caller.
pub call_site: Span,
pub instance: ty::Instance<'tcx>,
pub span: Span,
pub lint_root: Option<hir::HirId>,
}

Expand All @@ -65,12 +64,12 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
if tcx.def_key(self.instance.def_id()).disambiguated_data.data
== DefPathData::ClosureExpr
{
write!(f, "inside call to closure")?;
write!(f, "inside closure")?;
} else {
write!(f, "inside call to `{}`", self.instance)?;
write!(f, "inside `{}`", self.instance)?;
}
if !self.call_site.is_dummy() {
let lo = tcx.sess.source_map().lookup_char_pos(self.call_site.lo());
if !self.span.is_dummy() {
let lo = tcx.sess.source_map().lookup_char_pos(self.span.lo());
write!(f, " at {}:{}:{}", lo.file.name, lo.line, lo.col.to_usize() + 1)?;
}
Ok(())
Expand Down Expand Up @@ -168,13 +167,10 @@ impl<'tcx> ConstEvalErr<'tcx> {
if let Some(span_msg) = span_msg {
err.span_label(self.span, span_msg);
}
// Add spans for the stacktrace.
// Skip the last, which is just the environment of the constant. The stacktrace
// is sometimes empty because we create "fake" eval contexts in CTFE to do work
// on constant values.
if !self.stacktrace.is_empty() {
for frame_info in &self.stacktrace[..self.stacktrace.len() - 1] {
err.span_label(frame_info.call_site, frame_info.to_string());
// Add spans for the stacktrace. Don't print a single-line backtrace though.
if self.stacktrace.len() > 1 {
for frame_info in &self.stacktrace {
err.span_label(frame_info.span, frame_info.to_string());
}
}
// Let the caller finish the job.
Expand Down
70 changes: 59 additions & 11 deletions src/librustc_middle/traits/specialization_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,44 @@ impl Iterator for Ancestors<'_> {
}
}

pub struct NodeItem<T> {
pub node: Node,
pub item: T,
/// Information about the most specialized definition of an associated item.
pub struct LeafDef {
/// The associated item described by this `LeafDef`.
pub item: ty::AssocItem,

/// The node in the specialization graph containing the definition of `item`.
pub defining_node: Node,

/// The "top-most" (ie. least specialized) specialization graph node that finalized the
/// definition of `item`.
///
/// Example:
///
/// ```
/// trait Tr {
/// fn assoc(&self);
/// }
///
/// impl<T> Tr for T {
/// default fn assoc(&self) {}
/// }
///
/// impl Tr for u8 {}
/// ```
///
/// If we start the leaf definition search at `impl Tr for u8`, that impl will be the
/// `finalizing_node`, while `defining_node` will be the generic impl.
///
/// If the leaf definition search is started at the generic impl, `finalizing_node` will be
/// `None`, since the most specialized impl we found still allows overriding the method
/// (doesn't finalize it).
pub finalizing_node: Option<Node>,
}

impl<T> NodeItem<T> {
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> NodeItem<U> {
NodeItem { node: self.node, item: f(self.item) }
impl LeafDef {
/// Returns whether this definition is known to not be further specializable.
pub fn is_final(&self) -> bool {
self.finalizing_node.is_some()
}
}

Expand All @@ -173,18 +203,36 @@ impl<'tcx> Ancestors<'tcx> {
tcx: TyCtxt<'tcx>,
trait_item_name: Ident,
trait_item_kind: ty::AssocKind,
) -> Option<NodeItem<ty::AssocItem>> {
) -> Option<LeafDef> {
let trait_def_id = self.trait_def_id;
let mut finalizing_node = None;

self.find_map(|node| {
node.item(tcx, trait_item_name, trait_item_kind, trait_def_id)
.map(|item| NodeItem { node, item })
if let Some(item) = node.item(tcx, trait_item_name, trait_item_kind, trait_def_id) {
if finalizing_node.is_none() {
let is_specializable = item.defaultness.is_default()
|| tcx.impl_defaultness(node.def_id()).is_default();

if !is_specializable {
finalizing_node = Some(node);
}
}

Some(LeafDef { item, defining_node: node, finalizing_node })
} else {
// Item not mentioned. This "finalizes" any defaulted item provided by an ancestor.
finalizing_node = Some(node);
None
}
})
}
}

/// Walk up the specialization ancestors of a given impl, starting with that
/// impl itself. Returns `None` if an error was reported while building the
/// specialization graph.
/// impl itself.
///
/// Returns `Err` if an error was reported while building the specialization
/// graph.
pub fn ancestors(
tcx: TyCtxt<'tcx>,
trait_def_id: DefId,
Expand Down
Loading