Skip to content

Commit

Permalink
Auto merge of rust-lang#70936 - Dylan-DPC:rollup-2ng3e5h, r=Dylan-DPC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 9, 2020
2 parents 1edcfc8 + 5848209 commit d249d75
Show file tree
Hide file tree
Showing 38 changed files with 211 additions and 99 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ impl<T> VecDeque<T> {
/// assert_eq!(slice, &[3, 2, 1] as &[_]);
/// }
/// ```
#[unstable(feature = "deque_make_contiguous", issue = "none")]
#[unstable(feature = "deque_make_contiguous", issue = "70929")]
pub fn make_contiguous(&mut self) -> &mut [T] {
if self.is_contiguous() {
let tail = self.tail;
Expand Down
1 change: 1 addition & 0 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ mod hack {
use crate::string::ToString;
use crate::vec::Vec;

#[inline]
pub fn into_vec<T>(b: Box<[T]>) -> Vec<T> {
unsafe {
let len = b.len();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value

assert!(!instance.substs.needs_infer());
assert!(!instance.substs.has_escaping_bound_vars());
assert!(!instance.substs.has_param_types());
assert!(!instance.substs.has_param_types_or_consts());

if let Some(&llfn) = cx.instances.borrow().get(&instance) {
return llfn;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
visibility: Visibility,
symbol_name: &str,
) {
assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types());
assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types_or_consts());

let fn_abi = FnAbi::of_instance(self, instance, &[]);
let lldecl = self.declare_fn(symbol_name, &fn_abi);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
fn references_error(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_TY_ERR)
}
fn has_param_types(&self) -> bool {
fn has_param_types_or_consts(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_TY_PARAM | TypeFlags::HAS_CT_PARAM)
}
fn has_infer_types(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'tcx> Instance<'tcx> {
// There shouldn't be any params - if there are, then
// Instance.ty_env should have been used to provide the proper
// ParamEnv
if self.substs.has_param_types() {
if self.substs.has_param_types_or_consts() {
bug!("Instance.ty called for type {:?} with params in substs: {:?}", ty, self.substs);
}
tcx.subst_and_normalize_erasing_regions(self.substs, ty::ParamEnv::reveal_all(), &ty)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// Ignore layouts that are done with non-empty environments or
// non-monomorphic layouts, as the user only wants to see the stuff
// resulting from the final codegen session.
if layout.ty.has_param_types() || !self.param_env.caller_bounds.is_empty() {
if layout.ty.has_param_types_or_consts() || !self.param_env.caller_bounds.is_empty() {
return;
}

Expand Down Expand Up @@ -1754,7 +1754,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
match tail.kind {
ty::Param(_) | ty::Projection(_) => {
debug_assert!(tail.has_param_types());
debug_assert!(tail.has_param_types_or_consts());
Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(&tail) })
}
_ => bug!(
Expand Down
58 changes: 20 additions & 38 deletions src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,47 +760,26 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
(
Some(ref name),
BorrowExplanation::MustBeValidFor {
category: category @ ConstraintCategory::Return,
category:
category
@
(ConstraintCategory::Return
| ConstraintCategory::CallArgument
| ConstraintCategory::OpaqueType),
from_closure: false,
ref region_name,
span,
..
},
)
| (
Some(ref name),
BorrowExplanation::MustBeValidFor {
category: category @ ConstraintCategory::CallArgument,
from_closure: false,
ref region_name,
span,
..
},
) if borrow_spans.for_closure() => self.report_escaping_closure_capture(
borrow_spans,
borrow_span,
region_name,
category,
span,
&format!("`{}`", name),
),
(
Some(ref name),
BorrowExplanation::MustBeValidFor {
category: category @ ConstraintCategory::OpaqueType,
from_closure: false,
ref region_name,
) if borrow_spans.for_generator() | borrow_spans.for_closure() => self
.report_escaping_closure_capture(
borrow_spans,
borrow_span,
region_name,
category,
span,
..
},
) if borrow_spans.for_generator() => self.report_escaping_closure_capture(
borrow_spans,
borrow_span,
region_name,
category,
span,
&format!("`{}`", name),
),
&format!("`{}`", name),
),
(
ref name,
BorrowExplanation::MustBeValidFor {
Expand Down Expand Up @@ -1187,7 +1166,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
) -> DiagnosticBuilder<'cx> {
let tcx = self.infcx.tcx;
let args_span = use_span.args_or_use();
let mut err = self.cannot_capture_in_long_lived_closure(args_span, captured_var, var_span);

let suggestion = match tcx.sess.source_map().span_to_snippet(args_span) {
Ok(mut string) => {
Expand All @@ -1213,6 +1191,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
},
None => "closure",
};

let mut err =
self.cannot_capture_in_long_lived_closure(args_span, kind, captured_var, var_span);
err.span_suggestion(
args_span,
&format!(
Expand All @@ -1225,8 +1206,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);

let msg = match category {
ConstraintCategory::Return => "closure is returned here".to_string(),
ConstraintCategory::OpaqueType => "generator is returned here".to_string(),
ConstraintCategory::Return | ConstraintCategory::OpaqueType => {
format!("{} is returned here", kind)
}
ConstraintCategory::CallArgument => {
fr_name.highlight_region_name(&mut err);
format!("function requires argument type to outlive `{}`", fr_name)
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Rust MIR: a lowered representation of Rust.
#![feature(stmt_expr_attributes)]
#![feature(trait_alias)]
#![feature(option_expect_none)]
#![feature(or_patterns)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_mir/util/borrowck_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,16 +431,18 @@ impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> {
crate fn cannot_capture_in_long_lived_closure(
&self,
closure_span: Span,
closure_kind: &str,
borrowed_path: &str,
capture_span: Span,
) -> DiagnosticBuilder<'cx> {
let mut err = struct_span_err!(
self,
closure_span,
E0373,
"closure may outlive the current function, \
"{} may outlive the current function, \
but it borrows {}, \
which is owned by the current function",
closure_kind,
borrowed_path,
);
err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))
Expand Down
8 changes: 7 additions & 1 deletion src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
if !self.in_body {
// Avoid calling `hir_trait_to_predicates` in bodies, it will ICE.
// The traits' privacy in bodies is already checked as a part of trait object types.
let bounds = rustc_typeck::hir_trait_to_predicates(self.tcx, trait_ref);
let bounds = rustc_typeck::hir_trait_to_predicates(
self.tcx,
trait_ref,
// NOTE: This isn't really right, but the actual type doesn't matter here. It's
// just required by `ty::TraitRef`.
self.tcx.types.never,
);

for (trait_predicate, _, _) in bounds.trait_bounds {
if self.visit_trait(*trait_predicate.skip_binder()) {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_query_system/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ impl DepNodeColorMap {
DepNodeColorMap { values: (0..size).map(|_| AtomicU32::new(COMPRESSED_NONE)).collect() }
}

#[inline]
fn get(&self, index: SerializedDepNodeIndex) -> Option<DepNodeColor> {
match self.values[index].load(Ordering::Acquire) {
COMPRESSED_NONE => None,
Expand Down
1 change: 1 addition & 0 deletions src/librustc_query_system/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct QueryState<CTX: QueryContext, C: QueryCache> {
}

impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
#[inline]
pub(super) fn get_lookup<'tcx>(
&'tcx self,
key: &C::Key,
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2480,8 +2480,7 @@ impl<'a> Resolver<'a> {
let (span, found_use) = UsePlacementFinder::check(krate, node_id);
if !candidates.is_empty() {
diagnostics::show_candidates(&mut err, span, &candidates, better, found_use);
}
if let Some((span, msg, sugg, appl)) = suggestion {
} else if let Some((span, msg, sugg, appl)) = suggestion {
err.span_suggestion(span, msg, sugg, appl);
}
err.emit();
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,13 +706,13 @@ fn check_where_clauses<'tcx, 'fcx>(
return default_ty.into();
}
}
// Mark unwanted params as error.
fcx.tcx.types.err.into()

fcx.tcx.mk_param_from_def(param)
}

GenericParamDefKind::Const => {
// FIXME(const_generics:defaults)
fcx.tcx.consts.err.into()
fcx.tcx.mk_param_from_def(param)
}
}
});
Expand Down Expand Up @@ -750,7 +750,10 @@ fn check_where_clauses<'tcx, 'fcx>(
let substituted_pred = pred.subst(fcx.tcx, substs);
// Don't check non-defaulted params, dependent defaults (including lifetimes)
// or preds with multiple params.
if substituted_pred.references_error() || param_count.params.len() > 1 || has_region {
if substituted_pred.has_param_types_or_consts()
|| param_count.params.len() > 1
|| has_region
{
None
} else if predicates.predicates.iter().any(|&(p, _)| p == substituted_pred) {
// Avoid duplication of predicates that contain no parameters, for example.
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
pub fn hir_trait_to_predicates<'tcx>(
tcx: TyCtxt<'tcx>,
hir_trait: &hir::TraitRef<'_>,
self_ty: Ty<'tcx>,
) -> Bounds<'tcx> {
// In case there are any projections, etc., find the "environment"
// def-ID that will be used to determine the traits/predicates in
Expand All @@ -380,7 +381,7 @@ pub fn hir_trait_to_predicates<'tcx>(
hir_trait,
DUMMY_SP,
hir::Constness::NotConst,
tcx.types.err,
self_ty,
&mut bounds,
true,
);
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_typeck/variance/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,9 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
self.add_constraints_from_region(current, r, contra);

if let Some(poly_trait_ref) = data.principal() {
let poly_trait_ref =
poly_trait_ref.with_self_ty(self.tcx(), self.tcx().types.err);
self.add_constraints_from_trait_ref(
self.add_constraints_from_invariant_substs(
current,
*poly_trait_ref.skip_binder(),
poly_trait_ref.skip_binder().substs,
variance,
);
}
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,7 @@ impl Clean<Span> for rustc_span::Span {
let hi = sm.lookup_char_pos(self.hi());
Span {
filename,
cnum: lo.file.cnum,
loline: lo.line,
locol: lo.col.to_usize(),
hiline: hi.line,
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_ast::util::comments::strip_doc_comment_decoration;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc_hir::lang_items;
use rustc_hir::Mutability;
use rustc_index::vec::IndexVec;
Expand Down Expand Up @@ -1357,6 +1357,7 @@ pub enum VariantKind {
#[derive(Clone, Debug)]
pub struct Span {
pub filename: FileName,
pub cnum: CrateNum,
pub loline: usize,
pub locol: usize,
pub hiline: usize,
Expand All @@ -1368,6 +1369,7 @@ impl Span {
pub fn empty() -> Span {
Span {
filename: FileName::Anon(0),
cnum: LOCAL_CRATE,
loline: 0,
locol: 0,
hiline: 0,
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use rustc_data_structures::flock;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_feature::UnstableFeatures;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_hir::Mutability;
use rustc_middle::middle::privacy::AccessLevels;
use rustc_middle::middle::stability;
Expand Down Expand Up @@ -1623,14 +1623,14 @@ impl Context {
_ => return None,
};

let (krate, path) = if item.def_id.is_local() {
let (krate, path) = if item.source.cnum == LOCAL_CRATE {
if let Some(path) = self.shared.local_sources.get(file) {
(&self.shared.layout.krate, path)
} else {
return None;
}
} else {
let (krate, src_root) = match *self.cache.extern_locations.get(&item.def_id.krate)? {
let (krate, src_root) = match *self.cache.extern_locations.get(&item.source.cnum)? {
(ref name, ref src, Local) => (name, src),
(ref name, ref src, Remote(ref s)) => {
root = s.to_string();
Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/html/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::html::format::Buffer;
use crate::html::highlight;
use crate::html::layout;
use crate::html::render::{Error, SharedContext, BASIC_KEYWORDS};
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_span::source_map::FileName;
use std::ffi::OsStr;
use std::fs;
Expand Down Expand Up @@ -37,8 +38,8 @@ impl<'a> DocFolder for SourceCollector<'a> {
if self.scx.include_sources
// skip all synthetic "files"
&& item.source.filename.is_real()
// skip non-local items
&& item.def_id.is_local()
// skip non-local files
&& item.source.cnum == LOCAL_CRATE
{
// If it turns out that we couldn't read this file, then we probably
// can't read any of the files (generating html output from json or
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cfg_if::cfg_if! {
// If we're not documenting libstd then we just expose the main modules
// as we otherwise would.

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

Expand Down
Loading

0 comments on commit d249d75

Please sign in to comment.