Skip to content

Commit d249d75

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

File tree

38 files changed

+211
-99
lines changed

38 files changed

+211
-99
lines changed

src/liballoc/collections/vec_deque.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 20 additions & 38 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 1 deletion
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))

0 commit comments

Comments
 (0)