Skip to content

Commit d249d75

Browse files
committed
Auto merge of rust-lang#70936 - Dylan-DPC:rollup-2ng3e5h, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - rust-lang#70134 (add basic support of OsStrExt for HermitCore) - rust-lang#70565 (Add inline attributes for functions used in the query system) - rust-lang#70828 (rustdoc: Don't try to load source files from external crates) - rust-lang#70870 (Fix abuses of tykind::err) - rust-lang#70906 (Suggest move for closures and async blocks in more cases.) - rust-lang#70912 (Do not suggest adding type param when `use` is already suggested) - rust-lang#70930 (add tracking issue to `VecDeque::make_contiguous`) Failed merges: r? @ghost
2 parents 1edcfc8 + 5848209 commit d249d75

38 files changed

+211
-99
lines changed

src/liballoc/collections/vec_deque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,7 @@ impl<T> VecDeque<T> {
21042104
/// assert_eq!(slice, &[3, 2, 1] as &[_]);
21052105
/// }
21062106
/// ```
2107-
#[unstable(feature = "deque_make_contiguous", issue = "none")]
2107+
#[unstable(feature = "deque_make_contiguous", issue = "70929")]
21082108
pub fn make_contiguous(&mut self) -> &mut [T] {
21092109
if self.is_contiguous() {
21102110
let tail = self.tail;

src/liballoc/slice.rs

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ mod hack {
140140
use crate::string::ToString;
141141
use crate::vec::Vec;
142142

143+
#[inline]
143144
pub fn into_vec<T>(b: Box<[T]>) -> Vec<T> {
144145
unsafe {
145146
let len = b.len();

src/librustc_codegen_llvm/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
2929

3030
assert!(!instance.substs.needs_infer());
3131
assert!(!instance.substs.has_escaping_bound_vars());
32-
assert!(!instance.substs.has_param_types());
32+
assert!(!instance.substs.has_param_types_or_consts());
3333

3434
if let Some(&llfn) = cx.instances.borrow().get(&instance) {
3535
return llfn;

src/librustc_codegen_llvm/mono_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
4747
visibility: Visibility,
4848
symbol_name: &str,
4949
) {
50-
assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types());
50+
assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types_or_consts());
5151

5252
let fn_abi = FnAbi::of_instance(self, instance, &[]);
5353
let lldecl = self.declare_fn(symbol_name, &fn_abi);

src/librustc_middle/ty/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
8484
fn references_error(&self) -> bool {
8585
self.has_type_flags(TypeFlags::HAS_TY_ERR)
8686
}
87-
fn has_param_types(&self) -> bool {
87+
fn has_param_types_or_consts(&self) -> bool {
8888
self.has_type_flags(TypeFlags::HAS_TY_PARAM | TypeFlags::HAS_CT_PARAM)
8989
}
9090
fn has_infer_types(&self) -> bool {

src/librustc_middle/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'tcx> Instance<'tcx> {
9191
// There shouldn't be any params - if there are, then
9292
// Instance.ty_env should have been used to provide the proper
9393
// ParamEnv
94-
if self.substs.has_param_types() {
94+
if self.substs.has_param_types_or_consts() {
9595
bug!("Instance.ty called for type {:?} with params in substs: {:?}", ty, self.substs);
9696
}
9797
tcx.subst_and_normalize_erasing_regions(self.substs, ty::ParamEnv::reveal_all(), &ty)

src/librustc_middle/ty/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
15851585
// Ignore layouts that are done with non-empty environments or
15861586
// non-monomorphic layouts, as the user only wants to see the stuff
15871587
// resulting from the final codegen session.
1588-
if layout.ty.has_param_types() || !self.param_env.caller_bounds.is_empty() {
1588+
if layout.ty.has_param_types_or_consts() || !self.param_env.caller_bounds.is_empty() {
15891589
return;
15901590
}
15911591

@@ -1754,7 +1754,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
17541754
let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
17551755
match tail.kind {
17561756
ty::Param(_) | ty::Projection(_) => {
1757-
debug_assert!(tail.has_param_types());
1757+
debug_assert!(tail.has_param_types_or_consts());
17581758
Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(&tail) })
17591759
}
17601760
_ => bug!(

src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs

+20-38
Original file line numberDiff line numberDiff line change
@@ -760,47 +760,26 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
760760
(
761761
Some(ref name),
762762
BorrowExplanation::MustBeValidFor {
763-
category: category @ ConstraintCategory::Return,
763+
category:
764+
category
765+
@
766+
(ConstraintCategory::Return
767+
| ConstraintCategory::CallArgument
768+
| ConstraintCategory::OpaqueType),
764769
from_closure: false,
765770
ref region_name,
766771
span,
767772
..
768773
},
769-
)
770-
| (
771-
Some(ref name),
772-
BorrowExplanation::MustBeValidFor {
773-
category: category @ ConstraintCategory::CallArgument,
774-
from_closure: false,
775-
ref region_name,
776-
span,
777-
..
778-
},
779-
) if borrow_spans.for_closure() => self.report_escaping_closure_capture(
780-
borrow_spans,
781-
borrow_span,
782-
region_name,
783-
category,
784-
span,
785-
&format!("`{}`", name),
786-
),
787-
(
788-
Some(ref name),
789-
BorrowExplanation::MustBeValidFor {
790-
category: category @ ConstraintCategory::OpaqueType,
791-
from_closure: false,
792-
ref region_name,
774+
) if borrow_spans.for_generator() | borrow_spans.for_closure() => self
775+
.report_escaping_closure_capture(
776+
borrow_spans,
777+
borrow_span,
778+
region_name,
779+
category,
793780
span,
794-
..
795-
},
796-
) if borrow_spans.for_generator() => self.report_escaping_closure_capture(
797-
borrow_spans,
798-
borrow_span,
799-
region_name,
800-
category,
801-
span,
802-
&format!("`{}`", name),
803-
),
781+
&format!("`{}`", name),
782+
),
804783
(
805784
ref name,
806785
BorrowExplanation::MustBeValidFor {
@@ -1187,7 +1166,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11871166
) -> DiagnosticBuilder<'cx> {
11881167
let tcx = self.infcx.tcx;
11891168
let args_span = use_span.args_or_use();
1190-
let mut err = self.cannot_capture_in_long_lived_closure(args_span, captured_var, var_span);
11911169

11921170
let suggestion = match tcx.sess.source_map().span_to_snippet(args_span) {
11931171
Ok(mut string) => {
@@ -1213,6 +1191,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12131191
},
12141192
None => "closure",
12151193
};
1194+
1195+
let mut err =
1196+
self.cannot_capture_in_long_lived_closure(args_span, kind, captured_var, var_span);
12161197
err.span_suggestion(
12171198
args_span,
12181199
&format!(
@@ -1225,8 +1206,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12251206
);
12261207

12271208
let msg = match category {
1228-
ConstraintCategory::Return => "closure is returned here".to_string(),
1229-
ConstraintCategory::OpaqueType => "generator is returned here".to_string(),
1209+
ConstraintCategory::Return | ConstraintCategory::OpaqueType => {
1210+
format!("{} is returned here", kind)
1211+
}
12301212
ConstraintCategory::CallArgument => {
12311213
fr_name.highlight_region_name(&mut err);
12321214
format!("function requires argument type to outlive `{}`", fr_name)

src/librustc_mir/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Rust MIR: a lowered representation of Rust.
2525
#![feature(stmt_expr_attributes)]
2626
#![feature(trait_alias)]
2727
#![feature(option_expect_none)]
28+
#![feature(or_patterns)]
2829
#![recursion_limit = "256"]
2930

3031
#[macro_use]

src/librustc_mir/util/borrowck_errors.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -431,16 +431,18 @@ impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> {
431431
crate fn cannot_capture_in_long_lived_closure(
432432
&self,
433433
closure_span: Span,
434+
closure_kind: &str,
434435
borrowed_path: &str,
435436
capture_span: Span,
436437
) -> DiagnosticBuilder<'cx> {
437438
let mut err = struct_span_err!(
438439
self,
439440
closure_span,
440441
E0373,
441-
"closure may outlive the current function, \
442+
"{} may outlive the current function, \
442443
but it borrows {}, \
443444
which is owned by the current function",
445+
closure_kind,
444446
borrowed_path,
445447
);
446448
err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))

src/librustc_privacy/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
12381238
if !self.in_body {
12391239
// Avoid calling `hir_trait_to_predicates` in bodies, it will ICE.
12401240
// The traits' privacy in bodies is already checked as a part of trait object types.
1241-
let bounds = rustc_typeck::hir_trait_to_predicates(self.tcx, trait_ref);
1241+
let bounds = rustc_typeck::hir_trait_to_predicates(
1242+
self.tcx,
1243+
trait_ref,
1244+
// NOTE: This isn't really right, but the actual type doesn't matter here. It's
1245+
// just required by `ty::TraitRef`.
1246+
self.tcx.types.never,
1247+
);
12421248

12431249
for (trait_predicate, _, _) in bounds.trait_bounds {
12441250
if self.visit_trait(*trait_predicate.skip_binder()) {

src/librustc_query_system/dep_graph/graph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ impl DepNodeColorMap {
11121112
DepNodeColorMap { values: (0..size).map(|_| AtomicU32::new(COMPRESSED_NONE)).collect() }
11131113
}
11141114

1115+
#[inline]
11151116
fn get(&self, index: SerializedDepNodeIndex) -> Option<DepNodeColor> {
11161117
match self.values[index].load(Ordering::Acquire) {
11171118
COMPRESSED_NONE => None,

src/librustc_query_system/query/plumbing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub struct QueryState<CTX: QueryContext, C: QueryCache> {
5151
}
5252

5353
impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
54+
#[inline]
5455
pub(super) fn get_lookup<'tcx>(
5556
&'tcx self,
5657
key: &C::Key,

src/librustc_resolve/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2480,8 +2480,7 @@ impl<'a> Resolver<'a> {
24802480
let (span, found_use) = UsePlacementFinder::check(krate, node_id);
24812481
if !candidates.is_empty() {
24822482
diagnostics::show_candidates(&mut err, span, &candidates, better, found_use);
2483-
}
2484-
if let Some((span, msg, sugg, appl)) = suggestion {
2483+
} else if let Some((span, msg, sugg, appl)) = suggestion {
24852484
err.span_suggestion(span, msg, sugg, appl);
24862485
}
24872486
err.emit();

src/librustc_typeck/check/wfcheck.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -706,13 +706,13 @@ fn check_where_clauses<'tcx, 'fcx>(
706706
return default_ty.into();
707707
}
708708
}
709-
// Mark unwanted params as error.
710-
fcx.tcx.types.err.into()
709+
710+
fcx.tcx.mk_param_from_def(param)
711711
}
712712

713713
GenericParamDefKind::Const => {
714714
// FIXME(const_generics:defaults)
715-
fcx.tcx.consts.err.into()
715+
fcx.tcx.mk_param_from_def(param)
716716
}
717717
}
718718
});
@@ -750,7 +750,10 @@ fn check_where_clauses<'tcx, 'fcx>(
750750
let substituted_pred = pred.subst(fcx.tcx, substs);
751751
// Don't check non-defaulted params, dependent defaults (including lifetimes)
752752
// or preds with multiple params.
753-
if substituted_pred.references_error() || param_count.params.len() > 1 || has_region {
753+
if substituted_pred.has_param_types_or_consts()
754+
|| param_count.params.len() > 1
755+
|| has_region
756+
{
754757
None
755758
} else if predicates.predicates.iter().any(|&(p, _)| p == substituted_pred) {
756759
// Avoid duplication of predicates that contain no parameters, for example.

src/librustc_typeck/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
367367
pub fn hir_trait_to_predicates<'tcx>(
368368
tcx: TyCtxt<'tcx>,
369369
hir_trait: &hir::TraitRef<'_>,
370+
self_ty: Ty<'tcx>,
370371
) -> Bounds<'tcx> {
371372
// In case there are any projections, etc., find the "environment"
372373
// def-ID that will be used to determine the traits/predicates in
@@ -380,7 +381,7 @@ pub fn hir_trait_to_predicates<'tcx>(
380381
hir_trait,
381382
DUMMY_SP,
382383
hir::Constness::NotConst,
383-
tcx.types.err,
384+
self_ty,
384385
&mut bounds,
385386
true,
386387
);

src/librustc_typeck/variance/constraints.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,9 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
315315
self.add_constraints_from_region(current, r, contra);
316316

317317
if let Some(poly_trait_ref) = data.principal() {
318-
let poly_trait_ref =
319-
poly_trait_ref.with_self_ty(self.tcx(), self.tcx().types.err);
320-
self.add_constraints_from_trait_ref(
318+
self.add_constraints_from_invariant_substs(
321319
current,
322-
*poly_trait_ref.skip_binder(),
320+
poly_trait_ref.skip_binder().substs,
323321
variance,
324322
);
325323
}

src/librustdoc/clean/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,7 @@ impl Clean<Span> for rustc_span::Span {
19361936
let hi = sm.lookup_char_pos(self.hi());
19371937
Span {
19381938
filename,
1939+
cnum: lo.file.cnum,
19391940
loline: lo.line,
19401941
locol: lo.col.to_usize(),
19411942
hiline: hi.line,

src/librustdoc/clean/types.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_ast::util::comments::strip_doc_comment_decoration;
1414
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1515
use rustc_hir as hir;
1616
use rustc_hir::def::Res;
17-
use rustc_hir::def_id::{CrateNum, DefId};
17+
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
1818
use rustc_hir::lang_items;
1919
use rustc_hir::Mutability;
2020
use rustc_index::vec::IndexVec;
@@ -1357,6 +1357,7 @@ pub enum VariantKind {
13571357
#[derive(Clone, Debug)]
13581358
pub struct Span {
13591359
pub filename: FileName,
1360+
pub cnum: CrateNum,
13601361
pub loline: usize,
13611362
pub locol: usize,
13621363
pub hiline: usize,
@@ -1368,6 +1369,7 @@ impl Span {
13681369
pub fn empty() -> Span {
13691370
Span {
13701371
filename: FileName::Anon(0),
1372+
cnum: LOCAL_CRATE,
13711373
loline: 0,
13721374
locol: 0,
13731375
hiline: 0,

src/librustdoc/html/render.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use rustc_data_structures::flock;
4747
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
4848
use rustc_feature::UnstableFeatures;
4949
use rustc_hir as hir;
50-
use rustc_hir::def_id::DefId;
50+
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
5151
use rustc_hir::Mutability;
5252
use rustc_middle::middle::privacy::AccessLevels;
5353
use rustc_middle::middle::stability;
@@ -1623,14 +1623,14 @@ impl Context {
16231623
_ => return None,
16241624
};
16251625

1626-
let (krate, path) = if item.def_id.is_local() {
1626+
let (krate, path) = if item.source.cnum == LOCAL_CRATE {
16271627
if let Some(path) = self.shared.local_sources.get(file) {
16281628
(&self.shared.layout.krate, path)
16291629
} else {
16301630
return None;
16311631
}
16321632
} else {
1633-
let (krate, src_root) = match *self.cache.extern_locations.get(&item.def_id.krate)? {
1633+
let (krate, src_root) = match *self.cache.extern_locations.get(&item.source.cnum)? {
16341634
(ref name, ref src, Local) => (name, src),
16351635
(ref name, ref src, Remote(ref s)) => {
16361636
root = s.to_string();

src/librustdoc/html/sources.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::html::format::Buffer;
55
use crate::html::highlight;
66
use crate::html::layout;
77
use crate::html::render::{Error, SharedContext, BASIC_KEYWORDS};
8+
use rustc_hir::def_id::LOCAL_CRATE;
89
use rustc_span::source_map::FileName;
910
use std::ffi::OsStr;
1011
use std::fs;
@@ -37,8 +38,8 @@ impl<'a> DocFolder for SourceCollector<'a> {
3738
if self.scx.include_sources
3839
// skip all synthetic "files"
3940
&& item.source.filename.is_real()
40-
// skip non-local items
41-
&& item.def_id.is_local()
41+
// skip non-local files
42+
&& item.source.cnum == LOCAL_CRATE
4243
{
4344
// If it turns out that we couldn't read this file, then we probably
4445
// can't read any of the files (generating html output from json or

src/libstd/os/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ cfg_if::cfg_if! {
2424
// If we're not documenting libstd then we just expose the main modules
2525
// as we otherwise would.
2626

27-
#[cfg(any(target_os = "redox", unix, target_os = "vxworks"))]
27+
#[cfg(any(target_os = "redox", unix, target_os = "vxworks", target_os = "hermit"))]
2828
#[stable(feature = "rust1", since = "1.0.0")]
2929
pub use crate::sys::ext as unix;
3030

0 commit comments

Comments
 (0)