Skip to content

Commit 28847e5

Browse files
committed
Merge branch 'master' into fix-doc-links
2 parents 547219c + 66f7a5d commit 28847e5

File tree

110 files changed

+804
-819
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

+804
-819
lines changed

src/libcore/alloc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::ptr::{self, NonNull};
1818
/// something wrong when combining the given input arguments with this
1919
/// allocator.
2020
#[unstable(feature = "allocator_api", issue = "32838")]
21-
#[derive(Clone, PartialEq, Eq, Debug)]
21+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
2222
pub struct AllocErr;
2323

2424
// (we need this for downstream impl of trait Error)

src/libcore/marker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
709709
/// So this, for example, can only be done on types implementing `Unpin`:
710710
///
711711
/// ```rust
712+
/// # #![allow(unused_must_use)]
712713
/// use std::mem;
713714
/// use std::pin::Pin;
714715
///

src/libcore/mem/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ pub fn take<T: Default>(dest: &mut T) -> T {
808808
/// [`Clone`]: ../../std/clone/trait.Clone.html
809809
#[inline]
810810
#[stable(feature = "rust1", since = "1.0.0")]
811+
#[must_use = "if you don't need the old value, you can just assign the new value directly"]
811812
pub fn replace<T>(dest: &mut T, mut src: T) -> T {
812813
swap(dest, &mut src);
813814
src

src/libproc_macro/bridge/client.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ impl BridgeState<'_> {
290290
}
291291

292292
impl Bridge<'_> {
293+
pub(crate) fn is_available() -> bool {
294+
BridgeState::with(|state| match state {
295+
BridgeState::Connected(_) | BridgeState::InUse => true,
296+
BridgeState::NotConnected => false,
297+
})
298+
}
299+
293300
fn enter<R>(self, f: impl FnOnce() -> R) -> R {
294301
// Hide the default panic output within `proc_macro` expansions.
295302
// NB. the server can't do this because it may use a different libstd.

src/libproc_macro/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ use std::path::PathBuf;
4545
use std::str::FromStr;
4646
use std::{error, fmt, iter, mem};
4747

48+
/// Determines whether proc_macro has been made accessible to the currently
49+
/// running program.
50+
///
51+
/// The proc_macro crate is only intended for use inside the implementation of
52+
/// procedural macros. All the functions in this crate panic if invoked from
53+
/// outside of a procedural macro, such as from a build script or unit test or
54+
/// ordinary Rust binary.
55+
///
56+
/// With consideration for Rust libraries that are designed to support both
57+
/// macro and non-macro use cases, `proc_macro::is_available()` provides a
58+
/// non-panicking way to detect whether the infrastructure required to use the
59+
/// API of proc_macro is presently available. Returns true if invoked from
60+
/// inside of a procedural macro, false if invoked from any other binary.
61+
#[unstable(feature = "proc_macro_is_available", issue = "71436")]
62+
pub fn is_available() -> bool {
63+
bridge::Bridge::is_available()
64+
}
65+
4866
/// The main type provided by this crate, representing an abstract stream of
4967
/// tokens, or, more specifically, a sequence of token trees.
5068
/// The type provide interfaces for iterating over those token trees and, conversely,

src/librustc_codegen_ssa/mir/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
120120
};
121121
if is_consume {
122122
let base_ty =
123-
mir::Place::ty_from(place_ref.local, proj_base, *self.fx.mir, cx.tcx());
123+
mir::Place::ty_from(place_ref.local, proj_base, self.fx.mir, cx.tcx());
124124
let base_ty = self.fx.monomorphize(&base_ty);
125125

126126
// ZSTs don't require any actual memory access.

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
152152
// a loop.
153153
fn maybe_sideeffect<Bx: BuilderMethods<'a, 'tcx>>(
154154
&self,
155-
mir: mir::ReadOnlyBodyAndCache<'tcx, 'tcx>,
155+
mir: &'tcx mir::Body<'tcx>,
156156
bx: &mut Bx,
157157
targets: &[mir::BasicBlock],
158158
) {
@@ -306,7 +306,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
306306
target: mir::BasicBlock,
307307
unwind: Option<mir::BasicBlock>,
308308
) {
309-
let ty = location.ty(*self.mir, bx.tcx()).ty;
309+
let ty = location.ty(self.mir, bx.tcx()).ty;
310310
let ty = self.monomorphize(&ty);
311311
let drop_fn = Instance::resolve_drop_in_place(bx.tcx(), ty);
312312

@@ -572,7 +572,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
572572
let extra_args = extra_args
573573
.iter()
574574
.map(|op_arg| {
575-
let op_ty = op_arg.ty(*self.mir, bx.tcx());
575+
let op_ty = op_arg.ty(self.mir, bx.tcx());
576576
self.monomorphize(&op_ty)
577577
})
578578
.collect::<Vec<_>>();

src/librustc_codegen_ssa/mir/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use self::operand::{OperandRef, OperandValue};
2121
pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
2222
instance: Instance<'tcx>,
2323

24-
mir: mir::ReadOnlyBodyAndCache<'tcx, 'tcx>,
24+
mir: &'tcx mir::Body<'tcx>,
2525

2626
debug_context: Option<FunctionDebugContext<Bx::DIScope>>,
2727

@@ -169,7 +169,6 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
169169
.collect();
170170

171171
let (landing_pads, funclets) = create_funclets(&mir, &mut bx, &cleanup_kinds, &block_bxs);
172-
let mir_body: &mir::Body<'_> = *mir;
173172
let mut fx = FunctionCx {
174173
instance,
175174
mir,
@@ -197,7 +196,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
197196
let args = arg_local_refs(&mut bx, &mut fx, &memory_locals);
198197

199198
let mut allocate_local = |local| {
200-
let decl = &mir_body.local_decls[local];
199+
let decl = &mir.local_decls[local];
201200
let layout = bx.layout_of(fx.monomorphize(&decl.ty));
202201
assert!(!layout.ty.has_erasable_regions());
203202

@@ -223,7 +222,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
223222
let retptr = allocate_local(mir::RETURN_PLACE);
224223
iter::once(retptr)
225224
.chain(args.into_iter())
226-
.chain(mir_body.vars_and_temps_iter().map(allocate_local))
225+
.chain(mir.vars_and_temps_iter().map(allocate_local))
227226
.collect()
228227
};
229228

@@ -235,8 +234,8 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
235234
bx.br(fx.blocks[mir::START_BLOCK]);
236235
}
237236

238-
let rpo = traversal::reverse_postorder(&mir_body);
239-
let mut visited = BitSet::new_empty(mir_body.basic_blocks().len());
237+
let rpo = traversal::reverse_postorder(&mir);
238+
let mut visited = BitSet::new_empty(mir.basic_blocks().len());
240239

241240
// Codegen the body of each block using reverse postorder
242241
for (bb, _) in rpo {
@@ -246,7 +245,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
246245

247246
// Remove blocks that haven't been visited, or have no
248247
// predecessors.
249-
for bb in mir_body.basic_blocks().indices() {
248+
for bb in mir.basic_blocks().indices() {
250249
// Unreachable block
251250
if !visited.contains(bb.index()) {
252251
debug!("codegen_mir: block {:?} was not visited", bb);

src/librustc_codegen_ssa/mir/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
497497

498498
pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx>) -> Ty<'tcx> {
499499
let tcx = self.cx.tcx();
500-
let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx);
500+
let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, self.mir, tcx);
501501
self.monomorphize(&place_ty.ty)
502502
}
503503
}

src/librustc_codegen_ssa/mir/rvalue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
473473
}
474474

475475
mir::Rvalue::Discriminant(ref place) => {
476-
let discr_ty = rvalue.ty(*self.mir, bx.tcx());
476+
let discr_ty = rvalue.ty(self.mir, bx.tcx());
477477
let discr = self
478478
.codegen_place(&mut bx, place.as_ref())
479479
.codegen_get_discr(&mut bx, discr_ty);
@@ -529,7 +529,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
529529
mir::Rvalue::Repeat(..) | mir::Rvalue::Aggregate(..) => {
530530
// According to `rvalue_creates_operand`, only ZST
531531
// aggregate rvalues are allowed to be operands.
532-
let ty = rvalue.ty(*self.mir, self.cx.tcx());
532+
let ty = rvalue.ty(self.mir, self.cx.tcx());
533533
let operand =
534534
OperandRef::new_zst(&mut bx, self.cx.layout_of(self.monomorphize(&ty)));
535535
(bx, operand)
@@ -749,7 +749,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
749749
true,
750750
mir::Rvalue::Repeat(..) |
751751
mir::Rvalue::Aggregate(..) => {
752-
let ty = rvalue.ty(*self.mir, self.cx.tcx());
752+
let ty = rvalue.ty(self.mir, self.cx.tcx());
753753
let ty = self.monomorphize(&ty);
754754
self.cx.spanned_layout_of(ty, span).is_zst()
755755
}

0 commit comments

Comments
 (0)