Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 16 pull requests #81545

Merged
merged 42 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8539425
Stabilize unsigned_abs
jhpratt Jan 13, 2021
edf2e37
Use unsigned_abs throughout repository
jhpratt Jan 13, 2021
0c8db16
Add `core::stream::Stream`
yoshuawuyts Nov 13, 2020
e94cf57
Make functional record update/struct update syntax works inside closu…
null-sleep Jan 23, 2021
a1b1132
Remove `Stream::next`
yoshuawuyts Jan 15, 2021
328abfb
Slight simplification of chars().count()
gilescope Jan 26, 2021
425a70a
Removing if so it's more like the previous implementation.
gilescope Jan 26, 2021
c07e558
Let's try the most idiomatic way.
gilescope Jan 26, 2021
a623ea5
Same instructions, but simpler.
gilescope Jan 26, 2021
d3c69a4
Warn write-only fields
sanxiyn Jan 28, 2021
899aae4
Simplify base_expr
sanxiyn Jan 28, 2021
85ad773
Add missing brace
oli-obk Jan 28, 2021
f620b5c
rustdoc: Remove unnecessary optional
camelid Jan 29, 2021
02094f9
Updated Vec::splice documentation
SOF3 Jan 29, 2021
5e983d7
Add a test for syntax like: ..t.s
null-sleep Jan 29, 2021
63714af
update rustfmt to v1.4.34
calebcartwright Jan 29, 2021
d8b5745
Treat nightlies for a version as complete
est31 Jan 28, 2021
dd18c48
Add tests
est31 Jan 28, 2021
c2c2e8d
`fn cold_path` doesn't need to be pub
henryboisdequin Jan 29, 2021
fd5fb86
fix typo
henryboisdequin Jan 29, 2021
08141a5
Add missiong variants in match binding
GuillaumeGomez Jan 29, 2021
13ffa43
rename raw_const/mut -> const/mut_addr_of, and stabilize them
RalfJung Jan 10, 2021
718398c
Fix typo in pat.rs
eltociear Jan 29, 2021
807b5f5
Don't print error output from rustup when detecting default build triple
jyn514 Jan 29, 2021
db115f1
Don't clone LLVM submodule when download-ci-llvm is set
jyn514 Jan 29, 2021
915a04e
Consider Scalar to be a bool only if its unsigned
nagisa Dec 31, 2020
ecd7cb1
Rollup merge of #79023 - yoshuawuyts:stream, r=KodrAus
JohnTitor Jan 30, 2021
a5c12ea
Rollup merge of #80562 - nagisa:nagisa/bools-are-unsigned, r=eddyb
JohnTitor Jan 30, 2021
b94d84d
Rollup merge of #80886 - RalfJung:stable-raw-ref-macros, r=m-ou-se
JohnTitor Jan 30, 2021
91ea1cb
Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-se
JohnTitor Jan 30, 2021
7fa991f
Rollup merge of #81291 - sexxi-goose:fix-struct-update-functional-rec…
JohnTitor Jan 30, 2021
c26dd4d
Rollup merge of #81409 - gilescope:chars_count, r=joshtriplett
JohnTitor Jan 30, 2021
fe27dea
Rollup merge of #81468 - est31:cfg_version, r=petrochenkov
JohnTitor Jan 30, 2021
774ba83
Rollup merge of #81473 - sanxiyn:write-only-field, r=oli-obk
JohnTitor Jan 30, 2021
b43c1d5
Rollup merge of #81495 - camelid:rustdoc-output_format-optional, r=Gu…
JohnTitor Jan 30, 2021
0f11a94
Rollup merge of #81499 - SOF3:patch-1, r=sanxiyn
JohnTitor Jan 30, 2021
6090c57
Rollup merge of #81501 - calebcartwright:update-rustfmt, r=sanxiyn
JohnTitor Jan 30, 2021
ba40cea
Rollup merge of #81505 - henryboisdequin:cold_path-not-pub, r=sanxiyn
JohnTitor Jan 30, 2021
596b394
Rollup merge of #81512 - GuillaumeGomez:cleanup-fixme-rustdoc, r=buga…
JohnTitor Jan 30, 2021
5df611c
Rollup merge of #81515 - eltociear:patch-7, r=jonas-schievink
JohnTitor Jan 30, 2021
e3905aa
Rollup merge of #81519 - jyn514:rustup-toolchain, r=Mark-Simulacrum
JohnTitor Jan 30, 2021
31e7634
Rollup merge of #81520 - jyn514:rustc2, r=Mark-Simulacrum
JohnTitor Jan 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4442,7 +4442,7 @@ dependencies = [

[[package]]
name = "rustfmt-nightly"
version = "1.4.32"
version = "1.4.34"
dependencies = [
"annotate-snippets 0.6.1",
"anyhow",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::slice;

#[inline(never)]
#[cold]
pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
f()
}

Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,14 @@ pub fn eval_condition(
return false;
}
};
let channel = env!("CFG_RELEASE_CHANNEL");
let nightly = channel == "nightly" || channel == "dev";
let rustc_version = parse_version(env!("CFG_RELEASE"), true).unwrap();

// See https://github.com/rust-lang/rust/issues/64796#issuecomment-625474439 for details
if nightly { rustc_version > min_version } else { rustc_version >= min_version }
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
if sess.assume_incomplete_release {
rustc_version > min_version
} else {
rustc_version >= min_version
}
}
ast::MetaItemKind::List(ref mis) => {
for mi in mis.iter() {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ fn test_debugging_options_tracking_hash() {
// This list is in alphabetical order.
tracked!(allow_features, Some(vec![String::from("lang_items")]));
tracked!(always_encode_mir, true);
tracked!(assume_incomplete_release, true);
tracked!(asm_comments, true);
tracked!(binary_dep_depinfo, true);
tracked!(chalk, true);
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_middle/src/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,3 @@ pub fn read_target_uint(endianness: Endian, mut source: &[u8]) -> Result<u128, i
debug_assert!(source.len() == 0); // We should have consumed the source buffer.
uint
}

/// Computes the unsigned absolute value without wrapping or panicking.
#[inline]
pub fn uabs(value: i64) -> u64 {
// The only tricky part here is if value == i64::MIN. In that case,
// wrapping_abs() returns i64::MIN == -2^63. Casting this value to a u64
// gives 2^63, the correct value.
value.wrapping_abs() as u64
}
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{uabs, AllocId, InterpResult};
use super::{AllocId, InterpResult};

use rustc_macros::HashStable;
use rustc_target::abi::{HasDataLayout, Size};
Expand Down Expand Up @@ -57,7 +57,7 @@ pub trait PointerArithmetic: HasDataLayout {
#[inline]
fn overflowing_signed_offset(&self, val: u64, i: i64) -> (u64, bool) {
// We need to make sure that i fits in a machine isize.
let n = uabs(i);
let n = i.unsigned_abs();
if i >= 0 {
let (val, over) = self.overflowing_offset(val, n);
(val, over || i > self.machine_isize_max())
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::convert::TryFrom;
use rustc_hir::def_id::DefId;
use rustc_middle::mir::{
self,
interpret::{uabs, ConstValue, GlobalId, InterpResult, Scalar},
interpret::{ConstValue, GlobalId, InterpResult, Scalar},
BinOp,
};
use rustc_middle::ty;
Expand Down Expand Up @@ -542,7 +542,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// memory between these pointers must be accessible. Note that we do not require the
// pointers to be properly aligned (unlike a read/write operation).
let min_ptr = if offset_bytes >= 0 { ptr } else { offset_ptr };
let size: u64 = uabs(offset_bytes);
let size = offset_bytes.unsigned_abs();
// This call handles checking for integer/NULL pointers.
self.memory.check_ptr_access_align(
min_ptr,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl<'tcx> PlaceBuilder<'tcx> {
self.base
}

fn field(self, f: Field, ty: Ty<'tcx>) -> Self {
crate fn field(self, f: Field, ty: Ty<'tcx>) -> Self {
self.project(PlaceElem::Field(f, ty))
}

Expand Down
13 changes: 9 additions & 4 deletions compiler/rustc_mir_build/src/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let field_names = this.hir.all_fields(adt_def, variant_index);

let fields: Vec<_> = if let Some(FruInfo { base, field_types }) = base {
let base = unpack!(block = this.as_place(block, base));
let place_builder = unpack!(block = this.as_place_builder(block, base));

// MIR does not natively support FRU, so for each
// base-supplied field, generate an operand that
Expand All @@ -306,9 +306,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.zip(field_types.into_iter())
.map(|(n, ty)| match fields_map.get(&n) {
Some(v) => v.clone(),
None => this.consume_by_copy_or_move(
this.hir.tcx().mk_place_field(base, n, ty),
),
None => {
let place_builder = place_builder.clone();
this.consume_by_copy_or_move(
place_builder
.field(n, ty)
.into_place(this.hir.tcx(), this.hir.typeck_results()),
)
},
})
.collect()
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl<'a> Parser<'a> {
Err(err)
}

/// Parse and throw away a parentesized comma separated
/// Parse and throw away a parenthesized comma separated
/// sequence of patterns until `)` is reached.
fn skip_pat_list(&mut self) -> PResult<'a, ()> {
while !self.check(&token::CloseDelim(token::Paren)) {
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ fn should_explore(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
)
}

fn base_expr<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
loop {
match expr.kind {
hir::ExprKind::Field(base, ..) => expr = base,
_ => return expr,
}
}
}

struct MarkSymbolVisitor<'tcx> {
worklist: Vec<hir::HirId>,
tcx: TyCtxt<'tcx>,
Expand Down Expand Up @@ -263,6 +272,12 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
hir::ExprKind::MethodCall(..) => {
self.lookup_and_handle_method(expr.hir_id);
}
hir::ExprKind::Assign(ref left, ref right, ..) => {
// Ignore write to field
self.visit_expr(base_expr(left));
self.visit_expr(right);
return;
}
hir::ExprKind::Field(ref lhs, ..) => {
self.handle_field_access(&lhs, expr.hir_id);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ impl<'a> Resolver<'a> {
});
if let Some(def_span) = def_span {
if span.overlaps(def_span) {
// Don't suggest typo suggestion for itself like in the followoing:
// Don't suggest typo suggestion for itself like in the following:
// error[E0423]: expected function, tuple struct or tuple variant, found struct `X`
// --> $DIR/issue-64792-bad-unicode-ctor.rs:3:14
// |
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"only allow the listed language features to be enabled in code (space separated)"),
always_encode_mir: bool = (false, parse_bool, [TRACKED],
"encode MIR of all functions into the crate metadata (default: no)"),
assume_incomplete_release: bool = (false, parse_bool, [TRACKED],
"make cfg(version) treat the current version as incomplete (default: no)"),
asm_comments: bool = (false, parse_bool, [TRACKED],
"generate comments into the assembly (may change behavior) (default: no)"),
ast_json: bool = (false, parse_bool, [UNTRACKED],
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_session/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ pub struct ParseSess {
pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>,
/// All the type ascriptions expressions that have had a suggestion for likely path typo.
pub type_ascription_path_suggestions: Lock<FxHashSet<Span>>,
/// Whether cfg(version) should treat the current release as incomplete
pub assume_incomplete_release: bool,
}

impl ParseSess {
Expand All @@ -164,6 +166,7 @@ impl ParseSess {
reached_eof: Lock::new(false),
env_depinfo: Default::default(),
type_ascription_path_suggestions: Default::default(),
assume_incomplete_release: false,
}
}

Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,8 @@ pub fn build_session(
None
};

let parse_sess = ParseSess::with_span_handler(span_diagnostic, source_map);
let mut parse_sess = ParseSess::with_span_handler(span_diagnostic, source_map);
parse_sess.assume_incomplete_release = sopts.debugging_opts.assume_incomplete_release;
let sysroot = match &sopts.maybe_sysroot {
Some(sysroot) => sysroot.clone(),
None => filesearch::get_or_default_sysroot(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_symbol_mangling/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
if val < 0 {
neg = true;
}
Some(val.wrapping_abs() as u128)
Some(val.unsigned_abs())
})
}
_ => {
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_target/src/abi/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ impl ArgAttributes {
}

pub fn ext(&mut self, ext: ArgExtension) -> &mut Self {
assert!(self.arg_ext == ArgExtension::None || self.arg_ext == ext);
assert!(
self.arg_ext == ArgExtension::None || self.arg_ext == ext,
"cannot set {:?} when {:?} is already set",
ext,
self.arg_ext
);
self.arg_ext = ext;
self
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ pub struct Scalar {

impl Scalar {
pub fn is_bool(&self) -> bool {
if let Int(I8, _) = self.value { self.valid_range == (0..=1) } else { false }
matches!(self.value, Int(I8, false)) && self.valid_range == (0..=1)
}

/// Returns the valid range as a `x..y` range.
Expand Down
14 changes: 14 additions & 0 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ use core::ops::{
};
use core::pin::Pin;
use core::ptr::{self, Unique};
use core::stream::Stream;
use core::task::{Context, Poll};

use crate::alloc::{handle_alloc_error, AllocError, Allocator, Global, Layout, WriteCloneIntoRaw};
Expand Down Expand Up @@ -1621,3 +1622,16 @@ where
F::poll(Pin::new(&mut *self), cx)
}
}

#[unstable(feature = "async_stream", issue = "79024")]
impl<S: ?Sized + Stream + Unpin> Stream for Box<S> {
type Item = S::Item;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Pin::new(&mut **self).poll_next(cx)
}

fn size_hint(&self) -> (usize, Option<usize>) {
(**self).size_hint()
}
}
4 changes: 2 additions & 2 deletions library/alloc/src/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ impl<'a, K, V, Type> NodeRef<marker::ValMut<'a>, K, V, Type> {
// to avoid aliasing with outstanding references to other elements,
// in particular, those returned to the caller in earlier iterations.
let leaf = Self::as_leaf_ptr(&mut self);
let keys = unsafe { &raw const (*leaf).keys };
let vals = unsafe { &raw mut (*leaf).vals };
let keys = unsafe { ptr::addr_of!((*leaf).keys) };
let vals = unsafe { ptr::addr_of_mut!((*leaf).vals) };
// We must coerce to unsized array pointers because of Rust issue #74679.
let keys: *const [_] = keys;
let vals: *mut [_] = vals;
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#![feature(array_windows)]
#![feature(allow_internal_unstable)]
#![feature(arbitrary_self_types)]
#![feature(async_stream)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(cfg_sanitize)]
Expand Down Expand Up @@ -115,7 +116,6 @@
#![feature(pattern)]
#![feature(ptr_internals)]
#![feature(range_bounds_assert_len)]
#![feature(raw_ref_op)]
#![feature(rustc_attrs)]
#![feature(receiver_trait)]
#![cfg_attr(bootstrap, feature(min_const_generics))]
Expand Down
6 changes: 3 additions & 3 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ impl<T> Rc<T> {

unsafe {
let inner = init_ptr.as_ptr();
ptr::write(&raw mut (*inner).value, data);
ptr::write(ptr::addr_of_mut!((*inner).value), data);

let prev_value = (*inner).strong.get();
debug_assert_eq!(prev_value, 0, "No prior strong references should exist");
Expand Down Expand Up @@ -804,7 +804,7 @@ impl<T: ?Sized> Rc<T> {
// SAFETY: This cannot go through Deref::deref or Rc::inner because
// this is required to retain raw/mut provenance such that e.g. `get_mut` can
// write through the pointer after the Rc is recovered through `from_raw`.
unsafe { &raw const (*ptr).value }
unsafe { ptr::addr_of_mut!((*ptr).value) }
}

/// Constructs an `Rc<T>` from a raw pointer.
Expand Down Expand Up @@ -1917,7 +1917,7 @@ impl<T: ?Sized> Weak<T> {
// SAFETY: if is_dangling returns false, then the pointer is dereferencable.
// The payload may be dropped at this point, and we have to maintain provenance,
// so use raw pointer manipulation.
unsafe { &raw const (*ptr).value }
unsafe { ptr::addr_of_mut!((*ptr).value) }
}
}

Expand Down
6 changes: 3 additions & 3 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl<T> Arc<T> {
// reference into a strong reference.
unsafe {
let inner = init_ptr.as_ptr();
ptr::write(&raw mut (*inner).data, data);
ptr::write(ptr::addr_of_mut!((*inner).data), data);

// The above write to the data field must be visible to any threads which
// observe a non-zero strong count. Therefore we need at least "Release" ordering
Expand Down Expand Up @@ -800,7 +800,7 @@ impl<T: ?Sized> Arc<T> {
// SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner because
// this is required to retain raw/mut provenance such that e.g. `get_mut` can
// write through the pointer after the Rc is recovered through `from_raw`.
unsafe { &raw const (*ptr).data }
unsafe { ptr::addr_of_mut!((*ptr).data) }
}

/// Constructs an `Arc<T>` from a raw pointer.
Expand Down Expand Up @@ -1677,7 +1677,7 @@ impl<T: ?Sized> Weak<T> {
// SAFETY: if is_dangling returns false, then the pointer is dereferencable.
// The payload may be dropped at this point, and we have to maintain provenance,
// so use raw pointer manipulation.
unsafe { &raw mut (*ptr).data }
unsafe { ptr::addr_of_mut!((*ptr).data) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ impl<T, A: Allocator> Vec<T, A> {
/// This is optimal if:
///
/// * The tail (elements in the vector after `range`) is empty,
/// * or `replace_with` yields fewer elements than `range`’s length
/// * or `replace_with` yields fewer or equal elements than `range`’s length
/// * or the lower bound of its `size_hint()` is exact.
///
/// Otherwise, a temporary vector is allocated and the tail is moved twice.
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
#![feature(auto_traits)]
#![feature(or_patterns)]
#![feature(prelude_import)]
#![feature(raw_ref_macros)]
#![feature(repr_simd, platform_intrinsics)]
#![feature(rustc_attrs)]
#![feature(simd_ffi)]
Expand Down Expand Up @@ -254,6 +253,8 @@ pub mod panicking;
pub mod pin;
pub mod raw;
pub mod result;
#[unstable(feature = "async_stream", issue = "79024")]
pub mod stream;
pub mod sync;

pub mod fmt;
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/dec2flt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn bound_intermediate_digits(decimal: &Decimal<'_>, e: i64) -> u64 {
// It tries to find a positive number k such that `f << k / 10^e` is an in-range
// significand. This will result in about `2^53 * f * 10^e` < `10^17 * f * 10^e`.
// One input that triggers this is 0.33...33 (375 x 3).
f_len + (e.abs() as u64) + 17
f_len + e.unsigned_abs() + 17
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,12 +1158,12 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// #![feature(unsigned_abs)]
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".unsigned_abs(), 100", stringify!($UnsignedT), ");")]
#[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").unsigned_abs(), 100", stringify!($UnsignedT), ");")]
/// assert_eq!((-128i8).unsigned_abs(), 128u8);
/// ```
#[unstable(feature = "unsigned_abs", issue = "74913")]
#[stable(feature = "unsigned_abs", since = "1.51.0")]
#[rustc_const_stable(feature = "unsigned_abs", since = "1.51.0")]
#[inline]
pub const fn unsigned_abs(self) -> $UnsignedT {
self.wrapping_abs() as $UnsignedT
Expand Down
Loading