Skip to content

Commit 5535c25

Browse files
committed
Auto merge of #67495 - Centril:rollup-6aer3xg, r=Centril
Rollup of 7 pull requests Successful merges: - #67160 (Make GATs less ICE-prone.) - #67333 ([mir-opt] Fix `Inline` pass to handle inlining into `box` expressions) - #67420 (use _val to ignore parameter of any::type_name_of_val) - #67469 (Remove rustc-dev from the default nightly components) - #67489 (Drop petgraph dependency from bootstrap) - #67490 (Document privacy of RangeInclusive fields) - #67491 (use Result::map_or for bootstrap) Failed merges: r? @ghost
2 parents fc5deca + 7d29704 commit 5535c25

File tree

93 files changed

+1286
-728
lines changed

Some content is hidden

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

93 files changed

+1286
-728
lines changed

Diff for: Cargo.lock

-23
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ dependencies = [
195195
"lazy_static 1.3.0",
196196
"libc",
197197
"num_cpus",
198-
"petgraph",
199198
"pretty_assertions",
200199
"serde",
201200
"serde_json",
@@ -1081,12 +1080,6 @@ dependencies = [
10811080
"redox_syscall",
10821081
]
10831082

1084-
[[package]]
1085-
name = "fixedbitset"
1086-
version = "0.1.9"
1087-
source = "registry+https://github.com/rust-lang/crates.io-index"
1088-
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
1089-
10901083
[[package]]
10911084
name = "flate2"
10921085
version = "1.0.12"
@@ -2288,12 +2281,6 @@ dependencies = [
22882281
"vcpkg",
22892282
]
22902283

2291-
[[package]]
2292-
name = "ordermap"
2293-
version = "0.3.5"
2294-
source = "registry+https://github.com/rust-lang/crates.io-index"
2295-
checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
2296-
22972284
[[package]]
22982285
name = "ordslice"
22992286
version = "0.3.0"
@@ -2429,16 +2416,6 @@ dependencies = [
24292416
"sha-1",
24302417
]
24312418

2432-
[[package]]
2433-
name = "petgraph"
2434-
version = "0.4.13"
2435-
source = "registry+https://github.com/rust-lang/crates.io-index"
2436-
checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
2437-
dependencies = [
2438-
"fixedbitset",
2439-
"ordermap",
2440-
]
2441-
24422419
[[package]]
24432420
name = "phf"
24442421
version = "0.7.24"

Diff for: src/bootstrap/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ serde_json = "1.0.2"
4747
toml = "0.5"
4848
lazy_static = "1.3.0"
4949
time = "0.1"
50-
petgraph = "0.4.13"
5150

5251
[dev-dependencies]
5352
pretty_assertions = "0.5"

Diff for: src/bootstrap/builder.rs

+1-46
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::any::Any;
22
use std::cell::{Cell, RefCell};
33
use std::collections::BTreeSet;
4-
use std::collections::HashMap;
54
use std::env;
65
use std::ffi::OsStr;
76
use std::fmt::Debug;
@@ -29,9 +28,6 @@ use crate::{Build, DocTests, Mode, GitRepo};
2928

3029
pub use crate::Compiler;
3130

32-
use petgraph::graph::NodeIndex;
33-
use petgraph::Graph;
34-
3531
pub struct Builder<'a> {
3632
pub build: &'a Build,
3733
pub top_stage: u32,
@@ -40,9 +36,6 @@ pub struct Builder<'a> {
4036
stack: RefCell<Vec<Box<dyn Any>>>,
4137
time_spent_on_dependencies: Cell<Duration>,
4238
pub paths: Vec<PathBuf>,
43-
graph_nodes: RefCell<HashMap<String, NodeIndex>>,
44-
graph: RefCell<Graph<String, bool>>,
45-
parent: Cell<Option<NodeIndex>>,
4639
}
4740

4841
impl<'a> Deref for Builder<'a> {
@@ -490,9 +483,6 @@ impl<'a> Builder<'a> {
490483
stack: RefCell::new(Vec::new()),
491484
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
492485
paths: vec![],
493-
graph_nodes: RefCell::new(HashMap::new()),
494-
graph: RefCell::new(Graph::new()),
495-
parent: Cell::new(None),
496486
};
497487

498488
let builder = &builder;
@@ -535,17 +525,13 @@ impl<'a> Builder<'a> {
535525
stack: RefCell::new(Vec::new()),
536526
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
537527
paths: paths.to_owned(),
538-
graph_nodes: RefCell::new(HashMap::new()),
539-
graph: RefCell::new(Graph::new()),
540-
parent: Cell::new(None),
541528
};
542529

543530
builder
544531
}
545532

546-
pub fn execute_cli(&self) -> Graph<String, bool> {
533+
pub fn execute_cli(&self) {
547534
self.run_step_descriptions(&Builder::get_step_descriptions(self.kind), &self.paths);
548-
self.graph.borrow().clone()
549535
}
550536

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

1263-
{
1264-
let mut graph = self.graph.borrow_mut();
1265-
let parent = self.parent.get();
1266-
let us = *self
1267-
.graph_nodes
1268-
.borrow_mut()
1269-
.entry(format!("{:?}", step))
1270-
.or_insert_with(|| graph.add_node(format!("{:?}", step)));
1271-
if let Some(parent) = parent {
1272-
graph.add_edge(parent, us, false);
1273-
}
1274-
}
1275-
12761249
return out;
12771250
}
12781251
self.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step));
12791252
stack.push(Box::new(step.clone()));
12801253
}
12811254

1282-
let prev_parent = self.parent.get();
1283-
1284-
{
1285-
let mut graph = self.graph.borrow_mut();
1286-
let parent = self.parent.get();
1287-
let us = *self
1288-
.graph_nodes
1289-
.borrow_mut()
1290-
.entry(format!("{:?}", step))
1291-
.or_insert_with(|| graph.add_node(format!("{:?}", step)));
1292-
self.parent.set(Some(us));
1293-
if let Some(parent) = parent {
1294-
graph.add_edge(parent, us, true);
1295-
}
1296-
}
1297-
12981255
let (out, dur) = {
12991256
let start = Instant::now();
13001257
let zero = Duration::new(0, 0);
@@ -1305,8 +1262,6 @@ impl<'a> Builder<'a> {
13051262
(out, dur - deps)
13061263
};
13071264

1308-
self.parent.set(prev_parent);
1309-
13101265
if self.config.print_step_timings && dur > Duration::from_millis(100) {
13111266
println!(
13121267
"[TIMING] {:?} -- {}.{:03}",

Diff for: src/bootstrap/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ pub enum CiEnv {
270270
impl CiEnv {
271271
/// Obtains the current CI environment.
272272
pub fn current() -> CiEnv {
273-
if env::var("TF_BUILD").ok().map_or(false, |e| &*e == "True") {
273+
if env::var("TF_BUILD").map_or(false, |e| e == "True") {
274274
CiEnv::AzurePipelines
275-
} else if env::var("GITHUB_ACTIONS").ok().map_or(false, |e| &*e == "true") {
275+
} else if env::var("GITHUB_ACTIONS").map_or(false, |e| e == "true") {
276276
CiEnv::GitHubActions
277277
} else {
278278
CiEnv::None

Diff for: src/libcore/any.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@ pub const fn type_name<T: ?Sized>() -> &'static str {
496496
/// ```
497497
#[unstable(feature = "type_name_of_val", issue = "66359")]
498498
#[rustc_const_unstable(feature = "const_type_name", issue = "63084")]
499-
pub const fn type_name_of_val<T: ?Sized>(val: &T) -> &'static str {
500-
let _ = val;
499+
pub const fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str {
501500
type_name::<T>()
502501
}

Diff for: src/libcore/ops/range.rs

+5
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
333333
#[derive(Clone)] // not Copy -- see #27186
334334
#[stable(feature = "inclusive_range", since = "1.26.0")]
335335
pub struct RangeInclusive<Idx> {
336+
// Note that the fields here are not public to allow changing the
337+
// representation in the future; in particular, while we could plausibly
338+
// expose start/end, modifying them without changing (future/current)
339+
// private fields may lead to incorrect behavior, so we don't want to
340+
// support that mode.
336341
pub(crate) start: Idx,
337342
pub(crate) end: Idx,
338343
pub(crate) is_empty: Option<bool>,

Diff for: src/librustc/infer/error_reporting/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,7 @@ impl<'tcx> ObligationCause<'tcx> {
19121912
use crate::traits::ObligationCauseCode::*;
19131913
match self.code {
19141914
CompareImplMethodObligation { .. } => Error0308("method not compatible with trait"),
1915+
CompareImplTypeObligation { .. } => Error0308("type not compatible with trait"),
19151916
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) =>
19161917
Error0308(match source {
19171918
hir::MatchSource::IfLetDesugar { .. } =>
@@ -1948,6 +1949,7 @@ impl<'tcx> ObligationCause<'tcx> {
19481949
use crate::traits::ObligationCauseCode::*;
19491950
match self.code {
19501951
CompareImplMethodObligation { .. } => "method type is compatible with trait",
1952+
CompareImplTypeObligation { .. } => "associated type is compatible with trait",
19511953
ExprAssignable => "expression is assignable",
19521954
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
19531955
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",

Diff for: src/librustc/traits/error_reporting.rs

+8
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
702702
SelectionError::Unimplemented => {
703703
if let ObligationCauseCode::CompareImplMethodObligation {
704704
item_name, impl_item_def_id, trait_item_def_id,
705+
} | ObligationCauseCode::CompareImplTypeObligation {
706+
item_name, impl_item_def_id, trait_item_def_id,
705707
} = obligation.cause.code {
706708
self.report_extra_impl_obligation(
707709
span,
@@ -2631,6 +2633,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
26312633
but not on the corresponding trait method",
26322634
predicate));
26332635
}
2636+
ObligationCauseCode::CompareImplTypeObligation { .. } => {
2637+
err.note(&format!(
2638+
"the requirement `{}` appears on the associated impl type\
2639+
but not on the corresponding associated trait type",
2640+
predicate));
2641+
}
26342642
ObligationCauseCode::ReturnType |
26352643
ObligationCauseCode::ReturnValue(_) |
26362644
ObligationCauseCode::BlockTailExpression(_) => (),

Diff for: src/librustc/traits/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ pub enum ObligationCauseCode<'tcx> {
230230
trait_item_def_id: DefId,
231231
},
232232

233+
/// Error derived when matching traits/impls; see ObligationCause for more details
234+
CompareImplTypeObligation {
235+
item_name: ast::Name,
236+
impl_item_def_id: DefId,
237+
trait_item_def_id: DefId,
238+
},
239+
233240
/// Checking that this expression can be assigned where it needs to be
234241
// FIXME(eddyb) #11161 is the original Expr required?
235242
ExprAssignable,

Diff for: src/librustc/traits/project.rs

+21-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::ty::subst::{Subst, InternalSubsts};
2323
use crate::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
2424
use crate::ty::fold::{TypeFoldable, TypeFolder};
2525
use crate::util::common::FN_OUTPUT_NAME;
26+
use syntax_pos::DUMMY_SP;
2627

2728
/// Depending on the stage of compilation, we want projection to be
2829
/// more or less conservative.
@@ -1437,11 +1438,14 @@ fn confirm_impl_candidate<'cx, 'tcx>(
14371438
obligation: &ProjectionTyObligation<'tcx>,
14381439
impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>,
14391440
) -> Progress<'tcx> {
1441+
let tcx = selcx.tcx();
1442+
14401443
let VtableImplData { impl_def_id, substs, nested } = impl_vtable;
1444+
let assoc_item_id = obligation.predicate.item_def_id;
1445+
let trait_def_id = tcx.trait_id_of_impl(impl_def_id).unwrap();
14411446

1442-
let tcx = selcx.tcx();
14431447
let param_env = obligation.param_env;
1444-
let assoc_ty = assoc_ty_def(selcx, impl_def_id, obligation.predicate.item_def_id);
1448+
let assoc_ty = assoc_ty_def(selcx, impl_def_id, assoc_item_id);
14451449

14461450
if !assoc_ty.item.defaultness.has_value() {
14471451
// This means that the impl is missing a definition for the
@@ -1456,16 +1460,28 @@ fn confirm_impl_candidate<'cx, 'tcx>(
14561460
obligations: nested,
14571461
};
14581462
}
1463+
let substs = obligation.predicate.substs.rebase_onto(tcx, trait_def_id, substs);
14591464
let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
14601465
let ty = if let ty::AssocKind::OpaqueTy = assoc_ty.item.kind {
14611466
let item_substs = InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
14621467
tcx.mk_opaque(assoc_ty.item.def_id, item_substs)
14631468
} else {
14641469
tcx.type_of(assoc_ty.item.def_id)
14651470
};
1466-
Progress {
1467-
ty: ty.subst(tcx, substs),
1468-
obligations: nested,
1471+
if substs.len() != tcx.generics_of(assoc_ty.item.def_id).count() {
1472+
tcx.sess.delay_span_bug(
1473+
DUMMY_SP,
1474+
"impl item and trait item have different parameter counts",
1475+
);
1476+
Progress {
1477+
ty: tcx.types.err,
1478+
obligations: nested,
1479+
}
1480+
} else {
1481+
Progress {
1482+
ty: ty.subst(tcx, substs),
1483+
obligations: nested,
1484+
}
14691485
}
14701486
}
14711487

Diff for: src/librustc/traits/structural_impls.rs

+9
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,15 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
514514
impl_item_def_id,
515515
trait_item_def_id,
516516
}),
517+
super::CompareImplTypeObligation {
518+
item_name,
519+
impl_item_def_id,
520+
trait_item_def_id,
521+
} => Some(super::CompareImplTypeObligation {
522+
item_name,
523+
impl_item_def_id,
524+
trait_item_def_id,
525+
}),
517526
super::ExprAssignable => Some(super::ExprAssignable),
518527
super::MatchExpressionArm(box super::MatchExpressionArmCause {
519528
arm_span,

Diff for: src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
13051305
}
13061306

13071307
#[inline]
1308-
pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'_>) -> PolyTraitRef<'tcx> {
1308+
pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'tcx>) -> PolyTraitRef<'tcx> {
13091309
// Note: unlike with `TraitRef::to_poly_trait_ref()`,
13101310
// `self.0.trait_ref` is permitted to have escaping regions.
13111311
// This is because here `self` has a `Binder` and so does our

Diff for: src/librustc/ty/sty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1026,11 +1026,11 @@ impl<'tcx> ProjectionTy<'tcx> {
10261026
/// Extracts the underlying trait reference from this projection.
10271027
/// For example, if this is a projection of `<T as Iterator>::Item`,
10281028
/// then this function would return a `T: Iterator` trait reference.
1029-
pub fn trait_ref(&self, tcx: TyCtxt<'_>) -> ty::TraitRef<'tcx> {
1029+
pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> {
10301030
let def_id = tcx.associated_item(self.item_def_id).container.id();
10311031
ty::TraitRef {
10321032
def_id,
1033-
substs: self.substs,
1033+
substs: self.substs.truncate_to(tcx, tcx.generics_of(def_id)),
10341034
}
10351035
}
10361036

Diff for: src/librustc/ty/subst.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> {
234234
ty::GenericParamDefKind::Const => {
235235
tcx.mk_const(ty::Const {
236236
val: ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from(param.index)),
237-
ty: tcx.type_of(def_id),
237+
ty: tcx.type_of(param.def_id),
238238
}).into()
239239
}
240240
}
@@ -533,8 +533,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
533533
data.name,
534534
self.root_ty,
535535
data.index);
536-
self.tcx.sess.delay_span_bug(span, &msg);
537-
r
536+
span_bug!(span, "{}", msg);
538537
}
539538
}
540539
}

0 commit comments

Comments
 (0)