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 7 pull requests #67495

Merged
merged 22 commits into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
db6d0b1
Check associated type implementations for generic mismatches
matthewjasper Dec 8, 2019
c5028f6
Resolve names in the generics of impl associated types
matthewjasper Dec 8, 2019
4b164f6
Correctly lower paths to generic associated types
matthewjasper Dec 8, 2019
6394032
Correctly lower bounds on GATs
matthewjasper Dec 8, 2019
cd3ead1
Use `delay_span_bug` less often
matthewjasper Dec 8, 2019
0a5c91c
Generate correct `Deref` predicate
matthewjasper Dec 9, 2019
2206218
Remove rustc-dev from the default nightly components
cuviper Dec 20, 2019
bec4fc1
[mir-opt] Fix `Inline` pass to handle inlining into `box` expressions
wesleywiser Dec 15, 2019
f1325a7
Move the rest of the mir-opt inline tests into a folder
wesleywiser Dec 15, 2019
c268798
Update tests for GATs
matthewjasper Dec 8, 2019
e7b8bfe
Fix rustdoc
matthewjasper Dec 8, 2019
28af652
Drop petgraph dependency from bootstrap
Mark-Simulacrum Dec 21, 2019
519fc84
Document privacy of RangeInclusive fields
Mark-Simulacrum Dec 21, 2019
c93198f
use _val to ignore parameter of any::type_name_of_val
tesuji Dec 21, 2019
f3d7e03
use Result::map_or for bootstrap
tesuji Dec 21, 2019
b50c3b7
Rollup merge of #67160 - matthewjasper:gat-generics, r=nikomatsakis
Centril Dec 21, 2019
ac6dbff
Rollup merge of #67333 - wesleywiser:fix_inline_into_box_place, r=oli…
Centril Dec 21, 2019
9fa2046
Rollup merge of #67420 - lzutao:_val, r=Centril
Centril Dec 21, 2019
b9a6d74
Rollup merge of #67469 - cuviper:no-default-rustc-dev, r=Mark-Simulacrum
Centril Dec 21, 2019
2135cc4
Rollup merge of #67489 - Mark-Simulacrum:drop-petgraph, r=Centril
Centril Dec 21, 2019
5a0f17e
Rollup merge of #67490 - Mark-Simulacrum:i-67371, r=Dylan-DPC
Centril Dec 21, 2019
7d29704
Rollup merge of #67491 - lzutao:res-map-or, r=Mark-Simulacrum
Centril Dec 21, 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
23 changes: 0 additions & 23 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ dependencies = [
"lazy_static 1.3.0",
"libc",
"num_cpus",
"petgraph",
"pretty_assertions",
"serde",
"serde_json",
Expand Down Expand Up @@ -1081,12 +1080,6 @@ dependencies = [
"redox_syscall",
]

[[package]]
name = "fixedbitset"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"

[[package]]
name = "flate2"
version = "1.0.12"
Expand Down Expand Up @@ -2288,12 +2281,6 @@ dependencies = [
"vcpkg",
]

[[package]]
name = "ordermap"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"

[[package]]
name = "ordslice"
version = "0.3.0"
Expand Down Expand Up @@ -2429,16 +2416,6 @@ dependencies = [
"sha-1",
]

[[package]]
name = "petgraph"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
dependencies = [
"fixedbitset",
"ordermap",
]

[[package]]
name = "phf"
version = "0.7.24"
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ serde_json = "1.0.2"
toml = "0.5"
lazy_static = "1.3.0"
time = "0.1"
petgraph = "0.4.13"

[dev-dependencies]
pretty_assertions = "0.5"
47 changes: 1 addition & 46 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::any::Any;
use std::cell::{Cell, RefCell};
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::env;
use std::ffi::OsStr;
use std::fmt::Debug;
Expand Down Expand Up @@ -29,9 +28,6 @@ use crate::{Build, DocTests, Mode, GitRepo};

pub use crate::Compiler;

use petgraph::graph::NodeIndex;
use petgraph::Graph;

pub struct Builder<'a> {
pub build: &'a Build,
pub top_stage: u32,
Expand All @@ -40,9 +36,6 @@ pub struct Builder<'a> {
stack: RefCell<Vec<Box<dyn Any>>>,
time_spent_on_dependencies: Cell<Duration>,
pub paths: Vec<PathBuf>,
graph_nodes: RefCell<HashMap<String, NodeIndex>>,
graph: RefCell<Graph<String, bool>>,
parent: Cell<Option<NodeIndex>>,
}

impl<'a> Deref for Builder<'a> {
Expand Down Expand Up @@ -490,9 +483,6 @@ impl<'a> Builder<'a> {
stack: RefCell::new(Vec::new()),
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
paths: vec![],
graph_nodes: RefCell::new(HashMap::new()),
graph: RefCell::new(Graph::new()),
parent: Cell::new(None),
};

let builder = &builder;
Expand Down Expand Up @@ -535,17 +525,13 @@ impl<'a> Builder<'a> {
stack: RefCell::new(Vec::new()),
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
paths: paths.to_owned(),
graph_nodes: RefCell::new(HashMap::new()),
graph: RefCell::new(Graph::new()),
parent: Cell::new(None),
};

builder
}

pub fn execute_cli(&self) -> Graph<String, bool> {
pub fn execute_cli(&self) {
self.run_step_descriptions(&Builder::get_step_descriptions(self.kind), &self.paths);
self.graph.borrow().clone()
}

pub fn default_doc(&self, paths: Option<&[PathBuf]>) {
Expand Down Expand Up @@ -1260,41 +1246,12 @@ impl<'a> Builder<'a> {
if let Some(out) = self.cache.get(&step) {
self.verbose(&format!("{}c {:?}", " ".repeat(stack.len()), step));

{
let mut graph = self.graph.borrow_mut();
let parent = self.parent.get();
let us = *self
.graph_nodes
.borrow_mut()
.entry(format!("{:?}", step))
.or_insert_with(|| graph.add_node(format!("{:?}", step)));
if let Some(parent) = parent {
graph.add_edge(parent, us, false);
}
}

return out;
}
self.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step));
stack.push(Box::new(step.clone()));
}

let prev_parent = self.parent.get();

{
let mut graph = self.graph.borrow_mut();
let parent = self.parent.get();
let us = *self
.graph_nodes
.borrow_mut()
.entry(format!("{:?}", step))
.or_insert_with(|| graph.add_node(format!("{:?}", step)));
self.parent.set(Some(us));
if let Some(parent) = parent {
graph.add_edge(parent, us, true);
}
}

let (out, dur) = {
let start = Instant::now();
let zero = Duration::new(0, 0);
Expand All @@ -1305,8 +1262,6 @@ impl<'a> Builder<'a> {
(out, dur - deps)
};

self.parent.set(prev_parent);

if self.config.print_step_timings && dur > Duration::from_millis(100) {
println!(
"[TIMING] {:?} -- {}.{:03}",
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ pub enum CiEnv {
impl CiEnv {
/// Obtains the current CI environment.
pub fn current() -> CiEnv {
if env::var("TF_BUILD").ok().map_or(false, |e| &*e == "True") {
if env::var("TF_BUILD").map_or(false, |e| e == "True") {
CiEnv::AzurePipelines
} else if env::var("GITHUB_ACTIONS").ok().map_or(false, |e| &*e == "true") {
} else if env::var("GITHUB_ACTIONS").map_or(false, |e| e == "true") {
CiEnv::GitHubActions
} else {
CiEnv::None
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ pub const fn type_name<T: ?Sized>() -> &'static str {
/// ```
#[unstable(feature = "type_name_of_val", issue = "66359")]
#[rustc_const_unstable(feature = "const_type_name", issue = "63084")]
pub const fn type_name_of_val<T: ?Sized>(val: &T) -> &'static str {
let _ = val;
pub const fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str {
type_name::<T>()
}
5 changes: 5 additions & 0 deletions src/libcore/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
#[derive(Clone)] // not Copy -- see #27186
#[stable(feature = "inclusive_range", since = "1.26.0")]
pub struct RangeInclusive<Idx> {
// Note that the fields here are not public to allow changing the
// representation in the future; in particular, while we could plausibly
// expose start/end, modifying them without changing (future/current)
// private fields may lead to incorrect behavior, so we don't want to
// support that mode.
pub(crate) start: Idx,
pub(crate) end: Idx,
pub(crate) is_empty: Option<bool>,
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,7 @@ impl<'tcx> ObligationCause<'tcx> {
use crate::traits::ObligationCauseCode::*;
match self.code {
CompareImplMethodObligation { .. } => Error0308("method not compatible with trait"),
CompareImplTypeObligation { .. } => Error0308("type not compatible with trait"),
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) =>
Error0308(match source {
hir::MatchSource::IfLetDesugar { .. } =>
Expand Down Expand Up @@ -1948,6 +1949,7 @@ impl<'tcx> ObligationCause<'tcx> {
use crate::traits::ObligationCauseCode::*;
match self.code {
CompareImplMethodObligation { .. } => "method type is compatible with trait",
CompareImplTypeObligation { .. } => "associated type is compatible with trait",
ExprAssignable => "expression is assignable",
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
Expand Down
8 changes: 8 additions & 0 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
SelectionError::Unimplemented => {
if let ObligationCauseCode::CompareImplMethodObligation {
item_name, impl_item_def_id, trait_item_def_id,
} | ObligationCauseCode::CompareImplTypeObligation {
item_name, impl_item_def_id, trait_item_def_id,
} = obligation.cause.code {
self.report_extra_impl_obligation(
span,
Expand Down Expand Up @@ -2631,6 +2633,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
but not on the corresponding trait method",
predicate));
}
ObligationCauseCode::CompareImplTypeObligation { .. } => {
err.note(&format!(
"the requirement `{}` appears on the associated impl type\
but not on the corresponding associated trait type",
predicate));
}
ObligationCauseCode::ReturnType |
ObligationCauseCode::ReturnValue(_) |
ObligationCauseCode::BlockTailExpression(_) => (),
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ pub enum ObligationCauseCode<'tcx> {
trait_item_def_id: DefId,
},

/// Error derived when matching traits/impls; see ObligationCause for more details
CompareImplTypeObligation {
item_name: ast::Name,
impl_item_def_id: DefId,
trait_item_def_id: DefId,
},

/// Checking that this expression can be assigned where it needs to be
// FIXME(eddyb) #11161 is the original Expr required?
ExprAssignable,
Expand Down
26 changes: 21 additions & 5 deletions src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::ty::subst::{Subst, InternalSubsts};
use crate::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
use crate::ty::fold::{TypeFoldable, TypeFolder};
use crate::util::common::FN_OUTPUT_NAME;
use syntax_pos::DUMMY_SP;

/// Depending on the stage of compilation, we want projection to be
/// more or less conservative.
Expand Down Expand Up @@ -1437,11 +1438,14 @@ fn confirm_impl_candidate<'cx, 'tcx>(
obligation: &ProjectionTyObligation<'tcx>,
impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let tcx = selcx.tcx();

let VtableImplData { impl_def_id, substs, nested } = impl_vtable;
let assoc_item_id = obligation.predicate.item_def_id;
let trait_def_id = tcx.trait_id_of_impl(impl_def_id).unwrap();

let tcx = selcx.tcx();
let param_env = obligation.param_env;
let assoc_ty = assoc_ty_def(selcx, impl_def_id, obligation.predicate.item_def_id);
let assoc_ty = assoc_ty_def(selcx, impl_def_id, assoc_item_id);

if !assoc_ty.item.defaultness.has_value() {
// This means that the impl is missing a definition for the
Expand All @@ -1456,16 +1460,28 @@ fn confirm_impl_candidate<'cx, 'tcx>(
obligations: nested,
};
}
let substs = obligation.predicate.substs.rebase_onto(tcx, trait_def_id, substs);
let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
let ty = if let ty::AssocKind::OpaqueTy = assoc_ty.item.kind {
let item_substs = InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
tcx.mk_opaque(assoc_ty.item.def_id, item_substs)
} else {
tcx.type_of(assoc_ty.item.def_id)
};
Progress {
ty: ty.subst(tcx, substs),
obligations: nested,
if substs.len() != tcx.generics_of(assoc_ty.item.def_id).count() {
tcx.sess.delay_span_bug(
DUMMY_SP,
"impl item and trait item have different parameter counts",
);
Progress {
ty: tcx.types.err,
obligations: nested,
}
} else {
Progress {
ty: ty.subst(tcx, substs),
obligations: nested,
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,15 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
impl_item_def_id,
trait_item_def_id,
}),
super::CompareImplTypeObligation {
item_name,
impl_item_def_id,
trait_item_def_id,
} => Some(super::CompareImplTypeObligation {
item_name,
impl_item_def_id,
trait_item_def_id,
}),
super::ExprAssignable => Some(super::ExprAssignable),
super::MatchExpressionArm(box super::MatchExpressionArmCause {
arm_span,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
}

#[inline]
pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'_>) -> PolyTraitRef<'tcx> {
pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'tcx>) -> PolyTraitRef<'tcx> {
// Note: unlike with `TraitRef::to_poly_trait_ref()`,
// `self.0.trait_ref` is permitted to have escaping regions.
// This is because here `self` has a `Binder` and so does our
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,11 +1026,11 @@ impl<'tcx> ProjectionTy<'tcx> {
/// Extracts the underlying trait reference from this projection.
/// For example, if this is a projection of `<T as Iterator>::Item`,
/// then this function would return a `T: Iterator` trait reference.
pub fn trait_ref(&self, tcx: TyCtxt<'_>) -> ty::TraitRef<'tcx> {
pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> {
let def_id = tcx.associated_item(self.item_def_id).container.id();
ty::TraitRef {
def_id,
substs: self.substs,
substs: self.substs.truncate_to(tcx, tcx.generics_of(def_id)),
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/librustc/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> {
ty::GenericParamDefKind::Const => {
tcx.mk_const(ty::Const {
val: ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from(param.index)),
ty: tcx.type_of(def_id),
ty: tcx.type_of(param.def_id),
}).into()
}
}
Expand Down Expand Up @@ -533,8 +533,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
data.name,
self.root_ty,
data.index);
self.tcx.sess.delay_span_bug(span, &msg);
r
span_bug!(span, "{}", msg);
}
}
}
Expand Down
Loading