Skip to content

Commit 4fac5c9

Browse files
committed
Auto merge of #59590 - Centril:rollup, r=Centril
Rollup of 7 pull requests Successful merges: - #58805 (Lint for redundant imports) - #59506 (Use platform dependent mcount function) - #59519 (rustc_target: factor out common fields of non-Single Variants.) - #59580 (Allow closure to unsafe fn coercion) - #59581 (Stabilize refcell_replace_swap feature) - #59583 (match match match match match) - #59587 (Remove #[doc(hidden)] from Error::type_id) Failed merges: r? @ghost
2 parents a89c03a + 3445445 commit 4fac5c9

File tree

110 files changed

+599
-251
lines changed

Some content is hidden

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

110 files changed

+599
-251
lines changed

src/liballoc/borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<T> ToOwned for T
135135
/// Another example showing how to keep `Cow` in a struct:
136136
///
137137
/// ```
138-
/// use std::borrow::{Cow, ToOwned};
138+
/// use std::borrow::Cow;
139139
///
140140
/// struct Items<'a, X: 'a> where [X]: ToOwned<Owned = Vec<X>> {
141141
/// values: Cow<'a, [X]>,

src/libcore/cell.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,24 +702,21 @@ impl<T> RefCell<T> {
702702
/// Replaces the wrapped value with a new one computed from `f`, returning
703703
/// the old value, without deinitializing either one.
704704
///
705-
/// This function corresponds to [`std::mem::replace`](../mem/fn.replace.html).
706-
///
707705
/// # Panics
708706
///
709707
/// Panics if the value is currently borrowed.
710708
///
711709
/// # Examples
712710
///
713711
/// ```
714-
/// #![feature(refcell_replace_swap)]
715712
/// use std::cell::RefCell;
716713
/// let cell = RefCell::new(5);
717714
/// let old_value = cell.replace_with(|&mut old| old + 1);
718715
/// assert_eq!(old_value, 5);
719716
/// assert_eq!(cell, RefCell::new(6));
720717
/// ```
721718
#[inline]
722-
#[unstable(feature = "refcell_replace_swap", issue="43570")]
719+
#[stable(feature = "refcell_replace_swap", since="1.35.0")]
723720
pub fn replace_with<F: FnOnce(&mut T) -> T>(&self, f: F) -> T {
724721
let mut_borrow = &mut *self.borrow_mut();
725722
let replacement = f(mut_borrow);
@@ -1421,7 +1418,6 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
14211418
///
14221419
/// ```
14231420
/// use std::cell::UnsafeCell;
1424-
/// use std::marker::Sync;
14251421
///
14261422
/// # #[allow(dead_code)]
14271423
/// struct NotThreadSafe<T> {

src/libcore/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(pattern)]
1717
#![feature(range_is_empty)]
1818
#![feature(raw)]
19-
#![feature(refcell_replace_swap)]
2019
#![feature(slice_patterns)]
2120
#![feature(sort_internals)]
2221
#![feature(specialization)]

src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#![feature(proc_macro_internals)]
4646
#![feature(optin_builtin_traits)]
4747
#![feature(range_is_empty)]
48-
#![feature(refcell_replace_swap)]
4948
#![feature(rustc_diagnostic_macros)]
5049
#![feature(rustc_attrs)]
5150
#![feature(slice_patterns)]

src/librustc/lint/builtin.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ pub enum BuiltinLintDiagnostics {
483483
UnknownCrateTypes(Span, String, String),
484484
UnusedImports(String, Vec<(Span, String)>),
485485
NestedImplTrait { outer_impl_trait_span: Span, inner_impl_trait_span: Span },
486+
RedundantImport(Vec<(Span, bool)>, ast::Ident),
486487
}
487488

488489
impl BuiltinLintDiagnostics {
@@ -579,6 +580,15 @@ impl BuiltinLintDiagnostics {
579580
db.span_label(outer_impl_trait_span, "outer `impl Trait`");
580581
db.span_label(inner_impl_trait_span, "nested `impl Trait` here");
581582
}
583+
BuiltinLintDiagnostics::RedundantImport(spans, ident) => {
584+
for (span, is_imported) in spans {
585+
let introduced = if is_imported { "imported" } else { "defined" };
586+
db.span_label(
587+
span,
588+
format!("the item `{}` is already {} here", ident, introduced)
589+
);
590+
}
591+
}
582592
}
583593
}
584594
}

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
707707
adjustment::Adjust::NeverToAny |
708708
adjustment::Adjust::ReifyFnPointer |
709709
adjustment::Adjust::UnsafeFnPointer |
710-
adjustment::Adjust::ClosureFnPointer |
710+
adjustment::Adjust::ClosureFnPointer(_) |
711711
adjustment::Adjust::MutToConstPointer |
712712
adjustment::Adjust::Unsize => {
713713
// Creating a closure/fn-pointer or unsizing consumes

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
621621
adjustment::Adjust::NeverToAny |
622622
adjustment::Adjust::ReifyFnPointer |
623623
adjustment::Adjust::UnsafeFnPointer |
624-
adjustment::Adjust::ClosureFnPointer |
624+
adjustment::Adjust::ClosureFnPointer(_) |
625625
adjustment::Adjust::MutToConstPointer |
626626
adjustment::Adjust::Borrow(_) |
627627
adjustment::Adjust::Unsize => {

src/librustc/mir/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,8 +2247,9 @@ pub enum CastKind {
22472247
/// Converts unique, zero-sized type for a fn to fn()
22482248
ReifyFnPointer,
22492249

2250-
/// Converts non capturing closure to fn()
2251-
ClosureFnPointer,
2250+
/// Converts non capturing closure to fn() or unsafe fn().
2251+
/// It cannot convert a closure that requires unsafe.
2252+
ClosureFnPointer(hir::Unsafety),
22522253

22532254
/// Converts safe fn() to unsafe fn()
22542255
UnsafeFnPointer,

src/librustc/ty/adjustment.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ pub enum Adjust<'tcx> {
6262
/// Go from a safe fn pointer to an unsafe fn pointer.
6363
UnsafeFnPointer,
6464

65-
/// Go from a non-capturing closure to an fn pointer.
66-
ClosureFnPointer,
65+
/// Go from a non-capturing closure to an fn pointer or an unsafe fn pointer.
66+
/// It cannot convert a closure that requires unsafe.
67+
ClosureFnPointer(hir::Unsafety),
6768

6869
/// Go from a mut raw pointer to a const raw pointer.
6970
MutToConstPointer,

src/librustc/ty/context.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24412441
/// type with the same signature. Detuples and so forth -- so
24422442
/// e.g., if we have a sig with `Fn<(u32, i32)>` then you would get
24432443
/// a `fn(u32, i32)`.
2444-
pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> {
2444+
/// `unsafety` determines the unsafety of the `fn` type. If you pass
2445+
/// `hir::Unsafety::Unsafe` in the previous example, then you would get
2446+
/// an `unsafe fn (u32, i32)`.
2447+
/// It cannot convert a closure that requires unsafe.
2448+
pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>, unsafety: hir::Unsafety) -> Ty<'tcx> {
24452449
let converted_sig = sig.map_bound(|s| {
24462450
let params_iter = match s.inputs()[0].sty {
24472451
ty::Tuple(params) => {
@@ -2453,7 +2457,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24532457
params_iter,
24542458
s.output(),
24552459
s.c_variadic,
2456-
hir::Unsafety::Normal,
2460+
unsafety,
24572461
abi::Abi::Rust,
24582462
)
24592463
});

0 commit comments

Comments
 (0)