Skip to content

Commit 9f2abad

Browse files
committed
Auto merge of #41373 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests - Successful merges: #40290, #41353, #41356, #41360, #41361, #41364 - Failed merges:
2 parents c398efc + 20718c8 commit 9f2abad

File tree

36 files changed

+151
-296
lines changed

36 files changed

+151
-296
lines changed

src/bootstrap/bootstrap.py

-8
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,6 @@ def build_triple(self):
404404
raise Exception(err)
405405
sys.exit(err)
406406

407-
# Darwin's `uname -s` lies and always returns i386. We have to use
408-
# sysctl instead.
409-
if ostype == 'Darwin' and cputype == 'i686':
410-
args = ['sysctl', 'hw.optional.x86_64']
411-
sysctl = subprocess.check_output(args).decode(default_encoding)
412-
if ': 1' in sysctl:
413-
cputype = 'x86_64'
414-
415407
# The goal here is to come up with the same triple as LLVM would,
416408
# at least for the subset of platforms we're willing to target.
417409
if ostype == 'Linux':

src/doc/unstable-book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
- [fmt_internals](fmt-internals.md)
8080
- [fn_traits](fn-traits.md)
8181
- [fnbox](fnbox.md)
82+
- [from_utf8_error_as_bytes](from_utf8_error_as_bytes.md)
8283
- [fundamental](fundamental.md)
8384
- [fused](fused.md)
8485
- [future_atomic_orderings](future-atomic-orderings.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `from_utf8_error_as_bytes`
2+
3+
The tracking issue for this feature is: [#40895]
4+
5+
[#40895]: https://github.com/rust-lang/rust/issues/40895
6+
7+
------------------------

src/libcollections/string.rs

+20
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,26 @@ impl String {
14031403
}
14041404

14051405
impl FromUtf8Error {
1406+
/// Returns a slice of [`u8`]s bytes that were attempted to convert to a `String`.
1407+
///
1408+
/// # Examples
1409+
///
1410+
/// Basic usage:
1411+
///
1412+
/// ```
1413+
/// #![feature(from_utf8_error_as_bytes)]
1414+
/// // some invalid bytes, in a vector
1415+
/// let bytes = vec![0, 159];
1416+
///
1417+
/// let value = String::from_utf8(bytes);
1418+
///
1419+
/// assert_eq!(&[0, 159], value.unwrap_err().as_bytes());
1420+
/// ```
1421+
#[unstable(feature = "from_utf8_error_as_bytes", reason = "recently added", issue = "40895")]
1422+
pub fn as_bytes(&self) -> &[u8] {
1423+
&self.bytes[..]
1424+
}
1425+
14061426
/// Returns the bytes that were attempted to convert to a `String`.
14071427
///
14081428
/// This method is carefully constructed to avoid allocation. It will

src/librustc/dep_graph/dep_node.rs

-40
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,15 @@ pub enum DepNode<D: Clone + Debug> {
5656
WorkProduct(Arc<WorkProductId>),
5757

5858
// Represents different phases in the compiler.
59-
CollectLanguageItems,
60-
ResolveLifetimes,
6159
RegionResolveCrate,
62-
PluginRegistrar,
63-
StabilityIndex,
64-
CollectItem(D),
65-
CollectItemSig(D),
6660
Coherence,
6761
Resolve,
68-
EntryPoint,
69-
CheckEntryFn,
7062
CoherenceCheckTrait(D),
7163
CoherenceCheckImpl(D),
7264
CoherenceOverlapCheck(D),
7365
CoherenceOverlapCheckSpecial(D),
74-
CoherenceOrphanCheck(D),
7566
Variance,
76-
WfCheck(D),
77-
TypeckItemType(D),
78-
UnusedTraitCheck,
79-
CheckConst(D),
8067
PrivacyAccessLevels(CrateNum),
81-
IntrinsicCheck(D),
82-
MatchCheck(D),
8368

8469
// Represents the MIR for a fn; also used as the task node for
8570
// things read/modify that MIR.
@@ -91,14 +76,10 @@ pub enum DepNode<D: Clone + Debug> {
9176
BorrowCheck(D),
9277
RvalueCheck(D),
9378
Reachability,
94-
DeadCheck,
95-
StabilityCheck(D),
9679
LateLintCheck,
97-
TransCrate,
9880
TransCrateItem(D),
9981
TransInlinedItem(D),
10082
TransWriteMetadata,
101-
LinkBinary,
10283

10384
// Nodes representing bits of computed IR in the tcx. Each shared
10485
// table in the tcx (or elsewhere) maps to one of these
@@ -184,12 +165,10 @@ impl<D: Clone + Debug> DepNode<D> {
184165
}
185166

186167
check! {
187-
CollectItem,
188168
BorrowCheck,
189169
Hir,
190170
HirBody,
191171
TransCrateItem,
192-
TypeckItemType,
193172
AssociatedItems,
194173
ItemSignature,
195174
AssociatedItemDefIds,
@@ -211,24 +190,14 @@ impl<D: Clone + Debug> DepNode<D> {
211190
BorrowCheckKrate => Some(BorrowCheckKrate),
212191
MirKrate => Some(MirKrate),
213192
TypeckBodiesKrate => Some(TypeckBodiesKrate),
214-
CollectLanguageItems => Some(CollectLanguageItems),
215-
ResolveLifetimes => Some(ResolveLifetimes),
216193
RegionResolveCrate => Some(RegionResolveCrate),
217-
PluginRegistrar => Some(PluginRegistrar),
218-
StabilityIndex => Some(StabilityIndex),
219194
Coherence => Some(Coherence),
220195
Resolve => Some(Resolve),
221-
EntryPoint => Some(EntryPoint),
222-
CheckEntryFn => Some(CheckEntryFn),
223196
Variance => Some(Variance),
224-
UnusedTraitCheck => Some(UnusedTraitCheck),
225197
PrivacyAccessLevels(k) => Some(PrivacyAccessLevels(k)),
226198
Reachability => Some(Reachability),
227-
DeadCheck => Some(DeadCheck),
228199
LateLintCheck => Some(LateLintCheck),
229-
TransCrate => Some(TransCrate),
230200
TransWriteMetadata => Some(TransWriteMetadata),
231-
LinkBinary => Some(LinkBinary),
232201

233202
// work product names do not need to be mapped, because
234203
// they are always absolute.
@@ -237,26 +206,17 @@ impl<D: Clone + Debug> DepNode<D> {
237206
Hir(ref d) => op(d).map(Hir),
238207
HirBody(ref d) => op(d).map(HirBody),
239208
MetaData(ref d) => op(d).map(MetaData),
240-
CollectItem(ref d) => op(d).map(CollectItem),
241-
CollectItemSig(ref d) => op(d).map(CollectItemSig),
242209
CoherenceCheckTrait(ref d) => op(d).map(CoherenceCheckTrait),
243210
CoherenceCheckImpl(ref d) => op(d).map(CoherenceCheckImpl),
244211
CoherenceOverlapCheck(ref d) => op(d).map(CoherenceOverlapCheck),
245212
CoherenceOverlapCheckSpecial(ref d) => op(d).map(CoherenceOverlapCheckSpecial),
246-
CoherenceOrphanCheck(ref d) => op(d).map(CoherenceOrphanCheck),
247-
WfCheck(ref d) => op(d).map(WfCheck),
248-
TypeckItemType(ref d) => op(d).map(TypeckItemType),
249-
CheckConst(ref d) => op(d).map(CheckConst),
250-
IntrinsicCheck(ref d) => op(d).map(IntrinsicCheck),
251-
MatchCheck(ref d) => op(d).map(MatchCheck),
252213
Mir(ref d) => op(d).map(Mir),
253214
MirShim(ref def_ids) => {
254215
let def_ids: Option<Vec<E>> = def_ids.iter().map(op).collect();
255216
def_ids.map(MirShim)
256217
}
257218
BorrowCheck(ref d) => op(d).map(BorrowCheck),
258219
RvalueCheck(ref d) => op(d).map(RvalueCheck),
259-
StabilityCheck(ref d) => op(d).map(StabilityCheck),
260220
TransCrateItem(ref d) => op(d).map(TransCrateItem),
261221
TransInlinedItem(ref d) => op(d).map(TransInlinedItem),
262222
AssociatedItems(ref d) => op(d).map(AssociatedItems),

src/librustc/middle/dead.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// closely. The idea is that all reachable symbols are live, codes called
1313
// from live codes are live, and everything else is dead.
1414

15-
use dep_graph::DepNode;
1615
use hir::map as hir_map;
1716
use hir::{self, PatKind};
1817
use hir::intravisit::{self, Visitor, NestedVisitorMap};
@@ -594,7 +593,6 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
594593
}
595594

596595
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
597-
let _task = tcx.dep_graph.in_task(DepNode::DeadCheck);
598596
let access_levels = &ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE);
599597
let krate = tcx.hir.krate();
600598
let live_symbols = find_live(tcx, access_levels, krate);

src/librustc/middle/entry.rs

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111

12-
use dep_graph::DepNode;
1312
use hir::map as hir_map;
1413
use hir::def_id::{CRATE_DEF_INDEX};
1514
use session::{config, Session};
@@ -57,8 +56,6 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
5756
}
5857

5958
pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) {
60-
let _task = hir_map.dep_graph.in_task(DepNode::EntryPoint);
61-
6259
let any_exe = session.crate_types.borrow().iter().any(|ty| {
6360
*ty == config::CrateTypeExecutable
6461
});

src/librustc/middle/intrinsicck.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use dep_graph::DepNode;
1211
use hir::def::Def;
1312
use hir::def_id::DefId;
1413
use infer::InferCtxt;
@@ -25,7 +24,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
2524
let mut visitor = ItemVisitor {
2625
tcx: tcx
2726
};
28-
tcx.visit_all_item_likes_in_krate(DepNode::IntrinsicCheck, &mut visitor.as_deep_visitor());
27+
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
2928
}
3029

3130
struct ItemVisitor<'a, 'tcx: 'a> {

src/librustc/middle/lang_items.rs

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
pub use self::LangItem::*;
2323

24-
use dep_graph::DepNode;
2524
use hir::map as hir_map;
2625
use session::Session;
2726
use hir::def_id::DefId;
@@ -236,7 +235,6 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<Symbol> {
236235
pub fn collect_language_items(session: &Session,
237236
map: &hir_map::Map)
238237
-> LanguageItems {
239-
let _task = map.dep_graph.in_task(DepNode::CollectLanguageItems);
240238
let krate: &hir::Crate = map.krate();
241239
let mut collector = LanguageItemCollector::new(session, map);
242240
collector.collect(krate);

src/librustc/middle/resolve_lifetime.rs

-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
//! used between functions, and they operate in a purely top-down
1616
//! way. Therefore we break lifetime name resolution into a separate pass.
1717
18-
use dep_graph::DepNode;
1918
use hir::map::Map;
2019
use session::Session;
2120
use hir::def::Def;
@@ -259,7 +258,6 @@ const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root;
259258
pub fn krate(sess: &Session,
260259
hir_map: &Map)
261260
-> Result<NamedRegionMap, usize> {
262-
let _task = hir_map.dep_graph.in_task(DepNode::ResolveLifetimes);
263261
let krate = hir_map.krate();
264262
let mut map = NamedRegionMap {
265263
defs: NodeMap(),

src/librustc/middle/stability.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
1414
pub use self::StabilityLevel::*;
1515

16-
use dep_graph::DepNode;
1716
use hir::map as hir_map;
1817
use lint;
1918
use hir::def::Def;
@@ -383,7 +382,6 @@ impl<'a, 'tcx> Index<'tcx> {
383382
// Put the active features into a map for quick lookup
384383
self.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect();
385384

386-
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
387385
let krate = tcx.hir.krate();
388386
let mut annotator = Annotator {
389387
tcx: tcx,
@@ -397,7 +395,6 @@ impl<'a, 'tcx> Index<'tcx> {
397395
}
398396

399397
pub fn new(hir_map: &hir_map::Map) -> Index<'tcx> {
400-
let _task = hir_map.dep_graph.in_task(DepNode::StabilityIndex);
401398
let krate = hir_map.krate();
402399

403400
let mut is_staged_api = false;
@@ -424,7 +421,7 @@ impl<'a, 'tcx> Index<'tcx> {
424421
/// features and possibly prints errors.
425422
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
426423
let mut checker = Checker { tcx: tcx };
427-
tcx.visit_all_item_likes_in_krate(DepNode::StabilityCheck, &mut checker.as_deep_visitor());
424+
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
428425
}
429426

430427
struct Checker<'a, 'tcx: 'a> {
@@ -662,7 +659,6 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
662659
let access_levels = &ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE);
663660

664661
if tcx.stability.borrow().staged_api[&LOCAL_CRATE] && tcx.sess.features.borrow().staged_api {
665-
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
666662
let krate = tcx.hir.krate();
667663
let mut missing = MissingStabilityAnnotations {
668664
tcx: tcx,

src/librustc_const_eval/check_match.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ use _match::WitnessPreference::*;
1414

1515
use pattern::{Pattern, PatternContext, PatternError, PatternKind};
1616

17-
use rustc::dep_graph::DepNode;
18-
1917
use rustc::middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor};
2018
use rustc::middle::expr_use_visitor::{LoanCause, MutateMode};
2119
use rustc::middle::expr_use_visitor as euv;
@@ -56,8 +54,7 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
5654
}
5755

5856
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
59-
tcx.visit_all_item_likes_in_krate(DepNode::MatchCheck,
60-
&mut OuterVisitor { tcx: tcx }.as_deep_visitor());
57+
tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx: tcx }.as_deep_visitor());
6158
tcx.sess.abort_if_errors();
6259
}
6360

src/librustc_driver/derive_registrar.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::dep_graph::DepNode;
1211
use rustc::hir::itemlikevisit::ItemLikeVisitor;
1312
use rustc::hir::map::Map;
1413
use rustc::hir;
1514
use syntax::ast;
1615
use syntax::attr;
1716

1817
pub fn find(hir_map: &Map) -> Option<ast::NodeId> {
19-
let _task = hir_map.dep_graph.in_task(DepNode::PluginRegistrar);
2018
let krate = hir_map.krate();
2119

2220
let mut finder = Finder { registrar: None };

src/librustc_mir/build/expr/as_temp.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
3838
debug!("expr_as_temp(block={:?}, expr={:?})", block, expr);
3939
let this = self;
4040

41-
if let ExprKind::Scope { .. } = expr.kind {
42-
span_bug!(expr.span, "unexpected scope expression in as_temp: {:?}",
43-
expr);
41+
if let ExprKind::Scope { extent, value } = expr.kind {
42+
return this.in_scope(extent, block, |this| {
43+
this.as_temp(block, temp_lifetime, value)
44+
});
4445
}
4546

4647
let expr_ty = expr.ty.clone();

0 commit comments

Comments
 (0)