mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Auto merge of #77172 - jonas-schievink:rollup-a041rou, r=jonas-schievink
Rollup of 15 pull requests Successful merges: - #75438 (Use adaptive SVG favicon for rustdoc like other rust sites) - #76304 (Make delegation methods of `std::net::IpAddr` unstably const) - #76724 (Allow a unique name to be assigned to dataflow graphviz output) - #76978 (Documented From impls in std/sync/mpsc/mod.rs) - #77044 (Liballoc bench vec use mem take not replace) - #77050 (Typo fix: "satsify" -> "satisfy") - #77074 (add array::from_ref) - #77078 (Don't use an if guard to check equality with a constant) - #77079 (Use `Self` in docs when possible) - #77081 (Merge two almost identical match arms) - #77121 (Updated html_root_url for compiler crates) - #77136 (Suggest `const_mut_refs`, not `const_fn` for mutable references in `const fn`) - #77160 (Suggest `const_fn_transmute`, not `const_fn`) - #77164 (Remove workaround for deref issue that no longer exists.) - #77165 (Followup to #76673) Failed merges: r? `@ghost`
This commit is contained in:
commit
5bfeee5fe0
@ -30,7 +30,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![no_std]
|
||||
#![forbid(unsafe_code)]
|
||||
#![feature(nll)]
|
||||
|
@ -8,7 +8,7 @@
|
||||
//! This crate implements several kinds of arena.
|
||||
|
||||
#![doc(
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/",
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||
test(no_crate_inject, attr(deny(warnings)))
|
||||
)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
|
@ -4,7 +4,10 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
|
||||
#![doc(
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||
test(attr(deny(warnings)))
|
||||
)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(const_fn)] // For the `transmute` in `P::new`
|
||||
#![feature(const_fn_transmute)]
|
||||
|
@ -301,7 +301,7 @@ where
|
||||
.emit();
|
||||
};
|
||||
match issue.parse() {
|
||||
Ok(num) if num == 0 => {
|
||||
Ok(0) => {
|
||||
emit_diag(
|
||||
"`issue` must not be \"0\", \
|
||||
use \"none\" instead",
|
||||
|
@ -518,8 +518,7 @@ pub mod printf {
|
||||
.and_then(|end| end.at_next_cp())
|
||||
.map(|end| (next.slice_between(end).unwrap(), end));
|
||||
let end = match end {
|
||||
Some(("32", end)) => end,
|
||||
Some(("64", end)) => end,
|
||||
Some(("32" | "64", end)) => end,
|
||||
_ => next,
|
||||
};
|
||||
state = Type;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! This crate contains implementations of built-in macros and other code generating facilities
|
||||
//! injecting code into the crate before it is lowered to HIR.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(decl_macro)]
|
||||
|
@ -4,7 +4,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(const_cstr_unchecked)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(option_expect_none)]
|
||||
#![feature(box_patterns)]
|
||||
|
@ -6,7 +6,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(array_windows)]
|
||||
#![feature(control_flow_enum)]
|
||||
|
@ -4,7 +4,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(nll)]
|
||||
#![feature(once_cell)]
|
||||
#![recursion_limit = "256"]
|
||||
|
@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! This module contains the code for creating and emitting diagnostics.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(backtrace)]
|
||||
#![feature(nll)]
|
||||
|
@ -272,7 +272,7 @@
|
||||
//! * [DOT language](http://www.graphviz.org/doc/info/lang.html)
|
||||
|
||||
#![doc(
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/",
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||
test(attr(allow(unused_variables), deny(warnings)))
|
||||
)]
|
||||
#![feature(nll)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Support for serializing the dep-graph and reloading it.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(nll)]
|
||||
#![recursion_limit = "256"]
|
||||
|
@ -12,7 +12,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
|
@ -25,7 +25,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
#![feature(array_windows)]
|
||||
#![feature(bool_to_option)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![feature(nll)]
|
||||
#![feature(static_nobundle)]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
|
||||
// NOTE: This crate only exists to allow linking on mingw targets.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
@ -22,7 +22,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(array_windows)]
|
||||
#![feature(backtrace)]
|
||||
#![feature(bool_to_option)]
|
||||
|
@ -96,6 +96,8 @@ pub enum TerminatorKind<'tcx> {
|
||||
/// P <- V
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Note that DropAndReplace is eliminated as part of the `ElaborateDrops` pass.
|
||||
DropAndReplace {
|
||||
place: Place<'tcx>,
|
||||
value: Operand<'tcx>,
|
||||
|
@ -205,6 +205,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||
|
||||
let mut flow_inits = MaybeInitializedPlaces::new(tcx, &body, &mdpe)
|
||||
.into_engine(tcx, &body, def.did.to_def_id())
|
||||
.pass_name("borrowck")
|
||||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(&body);
|
||||
|
||||
@ -264,12 +265,15 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||
|
||||
let flow_borrows = Borrows::new(tcx, &body, regioncx.clone(), &borrow_set)
|
||||
.into_engine(tcx, &body, def.did.to_def_id())
|
||||
.pass_name("borrowck")
|
||||
.iterate_to_fixpoint();
|
||||
let flow_uninits = MaybeUninitializedPlaces::new(tcx, &body, &mdpe)
|
||||
.into_engine(tcx, &body, def.did.to_def_id())
|
||||
.pass_name("borrowck")
|
||||
.iterate_to_fixpoint();
|
||||
let flow_ever_inits = EverInitializedPlaces::new(tcx, &body, &mdpe)
|
||||
.into_engine(tcx, &body, def.did.to_def_id())
|
||||
.pass_name("borrowck")
|
||||
.iterate_to_fixpoint();
|
||||
|
||||
let movable_generator = match tcx.hir().get(id) {
|
||||
|
@ -84,6 +84,7 @@ where
|
||||
def_id: DefId,
|
||||
dead_unwinds: Option<&'a BitSet<BasicBlock>>,
|
||||
entry_sets: IndexVec<BasicBlock, A::Domain>,
|
||||
pass_name: Option<&'static str>,
|
||||
analysis: A,
|
||||
|
||||
/// Cached, cumulative transfer functions for each block.
|
||||
@ -174,6 +175,7 @@ where
|
||||
body,
|
||||
def_id,
|
||||
dead_unwinds: None,
|
||||
pass_name: None,
|
||||
entry_sets,
|
||||
apply_trans_for_block,
|
||||
}
|
||||
@ -189,6 +191,15 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
/// Adds an identifier to the graphviz output for this particular run of a dataflow analysis.
|
||||
///
|
||||
/// Some analyses are run multiple times in the compilation pipeline. Give them a `pass_name`
|
||||
/// to differentiate them. Otherwise, only the results for the latest run will be saved.
|
||||
pub fn pass_name(mut self, name: &'static str) -> Self {
|
||||
self.pass_name = Some(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Computes the fixpoint for this dataflow problem and returns it.
|
||||
pub fn iterate_to_fixpoint(self) -> Results<'tcx, A>
|
||||
where
|
||||
@ -202,6 +213,7 @@ where
|
||||
mut entry_sets,
|
||||
tcx,
|
||||
apply_trans_for_block,
|
||||
pass_name,
|
||||
..
|
||||
} = self;
|
||||
|
||||
@ -249,7 +261,7 @@ where
|
||||
|
||||
let results = Results { analysis, entry_sets };
|
||||
|
||||
let res = write_graphviz_results(tcx, def_id, &body, &results);
|
||||
let res = write_graphviz_results(tcx, def_id, &body, &results, pass_name);
|
||||
if let Err(e) = res {
|
||||
warn!("Failed to write graphviz dataflow results: {}", e);
|
||||
}
|
||||
@ -267,6 +279,7 @@ fn write_graphviz_results<A>(
|
||||
def_id: DefId,
|
||||
body: &mir::Body<'tcx>,
|
||||
results: &Results<'tcx, A>,
|
||||
pass_name: Option<&'static str>,
|
||||
) -> std::io::Result<()>
|
||||
where
|
||||
A: Analysis<'tcx>,
|
||||
@ -285,12 +298,17 @@ where
|
||||
None if tcx.sess.opts.debugging_opts.dump_mir_dataflow
|
||||
&& dump_enabled(tcx, A::NAME, def_id) =>
|
||||
{
|
||||
// FIXME: Use some variant of `pretty::dump_path` for this
|
||||
let mut path = PathBuf::from(&tcx.sess.opts.debugging_opts.dump_mir_dir);
|
||||
|
||||
let crate_name = tcx.crate_name(def_id.krate);
|
||||
let item_name = ty::print::with_forced_impl_filename_line(|| {
|
||||
tcx.def_path(def_id).to_filename_friendly_no_crate()
|
||||
});
|
||||
path.push(format!("rustc.{}.{}.dot", item_name, A::NAME));
|
||||
|
||||
let pass_name = pass_name.map(|s| format!(".{}", s)).unwrap_or_default();
|
||||
|
||||
path.push(format!("{}.{}.{}{}.dot", crate_name, item_name, A::NAME, pass_name));
|
||||
path
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,14 @@ impl NonConstOp for Transmute {
|
||||
}
|
||||
|
||||
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
|
||||
mcf_emit_error(ccx, span, "can only call `transmute` from const items, not `const fn`");
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_fn_transmute,
|
||||
span,
|
||||
&format!("`transmute` is not allowed in {}s", ccx.const_kind()),
|
||||
)
|
||||
.note("`transmute` is only allowed in constants and statics for now")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
@ -535,6 +542,7 @@ impl NonConstOp for UnsizingCast {
|
||||
}
|
||||
}
|
||||
|
||||
// Types that cannot appear in the signature or locals of a `const fn`.
|
||||
pub mod ty {
|
||||
use super::*;
|
||||
|
||||
@ -548,7 +556,13 @@ pub mod ty {
|
||||
}
|
||||
|
||||
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
|
||||
mcf_emit_error(ccx, span, "mutable references in const fn are unstable");
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_mut_refs,
|
||||
span,
|
||||
&format!("mutable references are not allowed in {}s", ccx.const_kind()),
|
||||
)
|
||||
.emit()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,7 @@ impl Qualifs<'mir, 'tcx> {
|
||||
MaybeMutBorrowedLocals::mut_borrows_only(tcx, &body, param_env)
|
||||
.unsound_ignore_borrow_on_drop()
|
||||
.into_engine(tcx, &body, def_id.to_def_id())
|
||||
.pass_name("const_qualification")
|
||||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(&body)
|
||||
});
|
||||
|
@ -44,6 +44,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
|
||||
let inits = MaybeInitializedPlaces::new(tcx, body, &env)
|
||||
.into_engine(tcx, body, def_id)
|
||||
.dead_unwinds(&dead_unwinds)
|
||||
.pass_name("elaborate_drops")
|
||||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(body);
|
||||
|
||||
@ -51,6 +52,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
|
||||
.mark_inactive_variants_as_uninit()
|
||||
.into_engine(tcx, body, def_id)
|
||||
.dead_unwinds(&dead_unwinds)
|
||||
.pass_name("elaborate_drops")
|
||||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(body);
|
||||
|
||||
@ -83,6 +85,7 @@ fn find_dead_unwinds<'tcx>(
|
||||
let mut dead_unwinds = BitSet::new_empty(body.basic_blocks().len());
|
||||
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &env)
|
||||
.into_engine(tcx, body, def_id)
|
||||
.pass_name("find_dead_unwinds")
|
||||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(body);
|
||||
for (bb, bb_data) in body.basic_blocks().iter_enumerated() {
|
||||
|
@ -467,8 +467,10 @@ fn locals_live_across_suspend_points(
|
||||
|
||||
// Calculate the MIR locals which have been previously
|
||||
// borrowed (even if they are still active).
|
||||
let borrowed_locals_results =
|
||||
MaybeBorrowedLocals::all_borrows().into_engine(tcx, body_ref, def_id).iterate_to_fixpoint();
|
||||
let borrowed_locals_results = MaybeBorrowedLocals::all_borrows()
|
||||
.into_engine(tcx, body_ref, def_id)
|
||||
.pass_name("generator")
|
||||
.iterate_to_fixpoint();
|
||||
|
||||
let mut borrowed_locals_cursor =
|
||||
dataflow::ResultsCursor::new(body_ref, &borrowed_locals_results);
|
||||
@ -484,6 +486,7 @@ fn locals_live_across_suspend_points(
|
||||
// Calculate the liveness of MIR locals ignoring borrows.
|
||||
let mut liveness = MaybeLiveLocals
|
||||
.into_engine(tcx, body_ref, def_id)
|
||||
.pass_name("generator")
|
||||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(body_ref);
|
||||
|
||||
|
@ -38,8 +38,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for RemoveUnneededDropsOptimizationFinder<'a, 'tcx> {
|
||||
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
|
||||
match terminator.kind {
|
||||
TerminatorKind::Drop { place, target, .. }
|
||||
| TerminatorKind::DropAndReplace { place, target, .. } => {
|
||||
TerminatorKind::Drop { place, target, .. } => {
|
||||
let ty = place.ty(self.body, self.tcx);
|
||||
let needs_drop = ty.ty.needs_drop(self.tcx, self.tcx.param_env(self.def_id));
|
||||
if !needs_drop {
|
||||
|
@ -5,7 +5,7 @@
|
||||
//! generated instead.
|
||||
|
||||
#![doc(
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/",
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||
html_playground_url = "https://play.rust-lang.org/",
|
||||
test(attr(deny(warnings)))
|
||||
)]
|
||||
|
@ -4,7 +4,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(nll)]
|
||||
#![feature(or_patterns)]
|
||||
|
@ -6,7 +6,7 @@
|
||||
//! feature](https://doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html)
|
||||
//! of the Unstable Book for some examples.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(nll)]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(nll)]
|
||||
#![recursion_limit = "256"]
|
||||
|
@ -8,7 +8,7 @@
|
||||
//!
|
||||
//! Type-relative name resolution (methods, fields, associated items) happens in `librustc_typeck`.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(nll)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(nll)]
|
||||
#![feature(or_patterns)]
|
||||
#![recursion_limit = "256"]
|
||||
|
@ -5,7 +5,7 @@ Core encoding and decoding interfaces.
|
||||
*/
|
||||
|
||||
#![doc(
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/",
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||
html_playground_url = "https://play.rust-lang.org/",
|
||||
test(attr(allow(unused_variables), deny(warnings)))
|
||||
)]
|
||||
|
@ -4,7 +4,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(array_windows)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(const_fn)]
|
||||
|
@ -87,7 +87,7 @@
|
||||
//! virtually impossible. Thus, symbol hash generation exclusively relies on
|
||||
//! DefPaths which are much more robust in the face of changes to the code base.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(never_type)]
|
||||
#![feature(nll)]
|
||||
#![feature(or_patterns)]
|
||||
|
@ -7,7 +7,7 @@
|
||||
//! more 'stuff' here in the future. It does not have a dependency on
|
||||
//! LLVM.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(const_panic)]
|
||||
|
@ -10,7 +10,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(drain_filter)]
|
||||
|
@ -4,7 +4,7 @@
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(nll)]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
|
@ -55,7 +55,7 @@ This API is completely unstable and subject to change.
|
||||
|
||||
*/
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(box_syntax)]
|
||||
|
@ -241,7 +241,7 @@ fn bench_extend_recycle(b: &mut Bencher) {
|
||||
let mut data = vec![0; 1000];
|
||||
|
||||
b.iter(|| {
|
||||
let tmp = std::mem::replace(&mut data, Vec::new());
|
||||
let tmp = std::mem::take(&mut data);
|
||||
let mut to_extend = black_box(Vec::new());
|
||||
to_extend.extend(tmp.into_iter());
|
||||
data = black_box(to_extend);
|
||||
@ -500,7 +500,7 @@ fn bench_in_place_recycle(b: &mut Bencher) {
|
||||
let mut data = vec![0; 1000];
|
||||
|
||||
b.iter(|| {
|
||||
let tmp = std::mem::replace(&mut data, Vec::new());
|
||||
let tmp = std::mem::take(&mut data);
|
||||
data = black_box(
|
||||
tmp.into_iter()
|
||||
.enumerate()
|
||||
@ -520,7 +520,7 @@ fn bench_in_place_zip_recycle(b: &mut Bencher) {
|
||||
rng.fill_bytes(&mut subst[..]);
|
||||
|
||||
b.iter(|| {
|
||||
let tmp = std::mem::replace(&mut data, Vec::new());
|
||||
let tmp = std::mem::take(&mut data);
|
||||
let mangled = tmp
|
||||
.into_iter()
|
||||
.zip(subst.iter().copied())
|
||||
|
@ -30,7 +30,7 @@
|
||||
//! // Explicitly implement the trait so the queue becomes a min-heap
|
||||
//! // instead of a max-heap.
|
||||
//! impl Ord for State {
|
||||
//! fn cmp(&self, other: &State) -> Ordering {
|
||||
//! fn cmp(&self, other: &Self) -> Ordering {
|
||||
//! // Notice that the we flip the ordering on costs.
|
||||
//! // In case of a tie we compare positions - this step is necessary
|
||||
//! // to make implementations of `PartialEq` and `Ord` consistent.
|
||||
@ -41,7 +41,7 @@
|
||||
//!
|
||||
//! // `PartialOrd` needs to be implemented as well.
|
||||
//! impl PartialOrd for State {
|
||||
//! fn partial_cmp(&self, other: &State) -> Option<Ordering> {
|
||||
//! fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
//! Some(self.cmp(other))
|
||||
//! }
|
||||
//! }
|
||||
|
@ -412,7 +412,7 @@ impl<T> Vec<T> {
|
||||
/// (at least, it's highly likely to be incorrect if it wasn't).
|
||||
/// * `T` needs to have the same size and alignment as what `ptr` was allocated with.
|
||||
/// (`T` having a less strict alignment is not sufficient, the alignment really
|
||||
/// needs to be equal to satsify the [`dealloc`] requirement that memory must be
|
||||
/// needs to be equal to satisfy the [`dealloc`] requirement that memory must be
|
||||
/// allocated and deallocated with the same layout.)
|
||||
/// * `length` needs to be less than or equal to `capacity`.
|
||||
/// * `capacity` needs to be the capacity that the pointer was allocated with.
|
||||
|
@ -19,6 +19,20 @@ mod iter;
|
||||
#[unstable(feature = "array_value_iter", issue = "65798")]
|
||||
pub use iter::IntoIter;
|
||||
|
||||
/// Converts a reference to `T` into a reference to an array of length 1 (without copying).
|
||||
#[unstable(feature = "array_from_ref", issue = "77101")]
|
||||
pub fn from_ref<T>(s: &T) -> &[T; 1] {
|
||||
// SAFETY: Converting `&T` to `&[T; 1]` is sound.
|
||||
unsafe { &*(s as *const T).cast::<[T; 1]>() }
|
||||
}
|
||||
|
||||
/// Converts a mutable reference to `T` into a mutable reference to an array of length 1 (without copying).
|
||||
#[unstable(feature = "array_from_ref", issue = "77101")]
|
||||
pub fn from_mut<T>(s: &mut T) -> &mut [T; 1] {
|
||||
// SAFETY: Converting `&mut T` to `&mut [T; 1]` is sound.
|
||||
unsafe { &mut *(s as *mut T).cast::<[T; 1]>() }
|
||||
}
|
||||
|
||||
/// Utility trait implemented only on arrays of fixed size
|
||||
///
|
||||
/// This trait can be used to implement other traits on fixed-size arrays
|
||||
|
@ -726,19 +726,19 @@ impl PartialOrd for Ordering {
|
||||
/// }
|
||||
///
|
||||
/// impl PartialOrd for Person {
|
||||
/// fn partial_cmp(&self, other: &Person) -> Option<Ordering> {
|
||||
/// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
/// Some(self.cmp(other))
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl Ord for Person {
|
||||
/// fn cmp(&self, other: &Person) -> Ordering {
|
||||
/// fn cmp(&self, other: &Self) -> Ordering {
|
||||
/// self.height.cmp(&other.height)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl PartialEq for Person {
|
||||
/// fn eq(&self, other: &Person) -> bool {
|
||||
/// fn eq(&self, other: &Self) -> bool {
|
||||
/// self.height == other.height
|
||||
/// }
|
||||
/// }
|
||||
|
@ -643,9 +643,9 @@ macro_rules! impls {
|
||||
/// }
|
||||
///
|
||||
/// impl<R: ResType> ExternalResource<R> {
|
||||
/// fn new() -> ExternalResource<R> {
|
||||
/// fn new() -> Self {
|
||||
/// let size_of_res = mem::size_of::<R>();
|
||||
/// ExternalResource {
|
||||
/// Self {
|
||||
/// resource_handle: foreign_lib::new(size_of_res),
|
||||
/// resource_type: PhantomData,
|
||||
/// }
|
||||
|
@ -128,10 +128,10 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
/// }
|
||||
///
|
||||
/// impl Sub for Point {
|
||||
/// type Output = Point;
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn sub(self, other: Point) -> Point {
|
||||
/// Point {
|
||||
/// fn sub(self, other: Self) -> Self::Output {
|
||||
/// Self {
|
||||
/// x: self.x - other.x,
|
||||
/// y: self.y - other.y,
|
||||
/// }
|
||||
@ -241,7 +241,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
/// // Reduce to lowest terms by dividing by the greatest common
|
||||
/// // divisor.
|
||||
/// let gcd = gcd(numerator, denominator);
|
||||
/// Rational {
|
||||
/// Self {
|
||||
/// numerator: numerator / gcd,
|
||||
/// denominator: denominator / gcd,
|
||||
/// }
|
||||
@ -255,7 +255,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
/// fn mul(self, rhs: Self) -> Self {
|
||||
/// let numerator = self.numerator * rhs.numerator;
|
||||
/// let denominator = self.denominator * rhs.denominator;
|
||||
/// Rational::new(numerator, denominator)
|
||||
/// Self::new(numerator, denominator)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -291,7 +291,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn mul(self, rhs: Scalar) -> Self::Output {
|
||||
/// Vector { value: self.value.iter().map(|v| v * rhs.value).collect() }
|
||||
/// Self { value: self.value.iter().map(|v| v * rhs.value).collect() }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -369,7 +369,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
/// // Reduce to lowest terms by dividing by the greatest common
|
||||
/// // divisor.
|
||||
/// let gcd = gcd(numerator, denominator);
|
||||
/// Rational {
|
||||
/// Self {
|
||||
/// numerator: numerator / gcd,
|
||||
/// denominator: denominator / gcd,
|
||||
/// }
|
||||
@ -387,7 +387,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
///
|
||||
/// let numerator = self.numerator * rhs.denominator;
|
||||
/// let denominator = self.denominator * rhs.numerator;
|
||||
/// Rational::new(numerator, denominator)
|
||||
/// Self::new(numerator, denominator)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -423,7 +423,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn div(self, rhs: Scalar) -> Self::Output {
|
||||
/// Vector { value: self.value.iter().map(|v| v / rhs.value).collect() }
|
||||
/// Self { value: self.value.iter().map(|v| v / rhs.value).collect() }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -515,7 +515,7 @@ div_impl_float! { f32 f64 }
|
||||
/// let len = self.slice.len();
|
||||
/// let rem = len % modulus;
|
||||
/// let start = len - rem;
|
||||
/// SplitSlice {slice: &self.slice[start..]}
|
||||
/// Self {slice: &self.slice[start..]}
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -615,7 +615,7 @@ rem_impl_float! { f32 f64 }
|
||||
/// }
|
||||
///
|
||||
/// impl Neg for Sign {
|
||||
/// type Output = Sign;
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn neg(self) -> Self::Output {
|
||||
/// match self {
|
||||
|
@ -15,7 +15,7 @@
|
||||
/// }
|
||||
///
|
||||
/// impl Not for Answer {
|
||||
/// type Output = Answer;
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn not(self) -> Self::Output {
|
||||
/// match self {
|
||||
@ -85,7 +85,7 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
///
|
||||
/// // rhs is the "right-hand side" of the expression `a & b`
|
||||
/// fn bitand(self, rhs: Self) -> Self::Output {
|
||||
/// Scalar(self.0 & rhs.0)
|
||||
/// Self(self.0 & rhs.0)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -106,10 +106,13 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
/// impl BitAnd for BooleanVector {
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn bitand(self, BooleanVector(rhs): Self) -> Self::Output {
|
||||
/// let BooleanVector(lhs) = self;
|
||||
/// fn bitand(self, Self(rhs): Self) -> Self::Output {
|
||||
/// let Self(lhs) = self;
|
||||
/// assert_eq!(lhs.len(), rhs.len());
|
||||
/// BooleanVector(lhs.iter().zip(rhs.iter()).map(|(x, y)| *x && *y).collect())
|
||||
/// Self(lhs.iter()
|
||||
/// .zip(rhs.iter())
|
||||
/// .map(|(x, y)| *x && *y)
|
||||
/// .collect())
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -179,8 +182,8 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// // rhs is the "right-hand side" of the expression `a | b`
|
||||
/// fn bitor(self, rhs: Self) -> Self {
|
||||
/// Scalar(self.0 | rhs.0)
|
||||
/// fn bitor(self, rhs: Self) -> Self::Output {
|
||||
/// Self(self.0 | rhs.0)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -201,10 +204,10 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
/// impl BitOr for BooleanVector {
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn bitor(self, BooleanVector(rhs): Self) -> Self::Output {
|
||||
/// let BooleanVector(lhs) = self;
|
||||
/// fn bitor(self, Self(rhs): Self) -> Self::Output {
|
||||
/// let Self(lhs) = self;
|
||||
/// assert_eq!(lhs.len(), rhs.len());
|
||||
/// BooleanVector(lhs.iter().zip(rhs.iter()).map(|(x, y)| *x || *y).collect())
|
||||
/// Self(lhs.iter().zip(rhs.iter()).map(|(x, y)| *x || *y).collect())
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -275,7 +278,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
///
|
||||
/// // rhs is the "right-hand side" of the expression `a ^ b`
|
||||
/// fn bitxor(self, rhs: Self) -> Self::Output {
|
||||
/// Scalar(self.0 ^ rhs.0)
|
||||
/// Self(self.0 ^ rhs.0)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -296,13 +299,13 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
/// impl BitXor for BooleanVector {
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn bitxor(self, BooleanVector(rhs): Self) -> Self::Output {
|
||||
/// let BooleanVector(lhs) = self;
|
||||
/// fn bitxor(self, Self(rhs): Self) -> Self::Output {
|
||||
/// let Self(lhs) = self;
|
||||
/// assert_eq!(lhs.len(), rhs.len());
|
||||
/// BooleanVector(lhs.iter()
|
||||
/// .zip(rhs.iter())
|
||||
/// .map(|(x, y)| (*x || *y) && !(*x && *y))
|
||||
/// .collect())
|
||||
/// Self(lhs.iter()
|
||||
/// .zip(rhs.iter())
|
||||
/// .map(|(x, y)| (*x || *y) && !(*x && *y))
|
||||
/// .collect())
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -375,9 +378,9 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
/// impl Shl<Scalar> for Scalar {
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn shl(self, Scalar(rhs): Self) -> Scalar {
|
||||
/// let Scalar(lhs) = self;
|
||||
/// Scalar(lhs << rhs)
|
||||
/// fn shl(self, Self(rhs): Self) -> Self::Output {
|
||||
/// let Self(lhs) = self;
|
||||
/// Self(lhs << rhs)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -400,10 +403,10 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
/// fn shl(self, rhs: usize) -> Self::Output {
|
||||
/// // Rotate the vector by `rhs` places.
|
||||
/// let (a, b) = self.vec.split_at(rhs);
|
||||
/// let mut spun_vector: Vec<T> = vec![];
|
||||
/// let mut spun_vector = vec![];
|
||||
/// spun_vector.extend_from_slice(b);
|
||||
/// spun_vector.extend_from_slice(a);
|
||||
/// SpinVector { vec: spun_vector }
|
||||
/// Self { vec: spun_vector }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -493,9 +496,9 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 }
|
||||
/// impl Shr<Scalar> for Scalar {
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn shr(self, Scalar(rhs): Self) -> Scalar {
|
||||
/// let Scalar(lhs) = self;
|
||||
/// Scalar(lhs >> rhs)
|
||||
/// fn shr(self, Self(rhs): Self) -> Self::Output {
|
||||
/// let Self(lhs) = self;
|
||||
/// Self(lhs >> rhs)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -518,10 +521,10 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 }
|
||||
/// fn shr(self, rhs: usize) -> Self::Output {
|
||||
/// // Rotate the vector by `rhs` places.
|
||||
/// let (a, b) = self.vec.split_at(self.vec.len() - rhs);
|
||||
/// let mut spun_vector: Vec<T> = vec![];
|
||||
/// let mut spun_vector = vec![];
|
||||
/// spun_vector.extend_from_slice(b);
|
||||
/// spun_vector.extend_from_slice(a);
|
||||
/// SpinVector { vec: spun_vector }
|
||||
/// Self { vec: spun_vector }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -606,7 +609,7 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
|
||||
/// impl BitAndAssign for Scalar {
|
||||
/// // rhs is the "right-hand side" of the expression `a &= b`
|
||||
/// fn bitand_assign(&mut self, rhs: Self) {
|
||||
/// *self = Scalar(self.0 & rhs.0)
|
||||
/// *self = Self(self.0 & rhs.0)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
@ -640,11 +643,11 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
|
||||
/// // `rhs` is the "right-hand side" of the expression `a &= b`.
|
||||
/// fn bitand_assign(&mut self, rhs: Self) {
|
||||
/// assert_eq!(self.0.len(), rhs.0.len());
|
||||
/// *self = BooleanVector(self.0
|
||||
/// .iter()
|
||||
/// .zip(rhs.0.iter())
|
||||
/// .map(|(x, y)| *x && *y)
|
||||
/// .collect());
|
||||
/// *self = Self(self.0
|
||||
/// .iter()
|
||||
/// .zip(rhs.0.iter())
|
||||
/// .map(|(x, y)| *x && *y)
|
||||
/// .collect());
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
|
@ -49,18 +49,18 @@
|
||||
//! }
|
||||
//!
|
||||
//! impl Add for Point {
|
||||
//! type Output = Point;
|
||||
//! type Output = Self;
|
||||
//!
|
||||
//! fn add(self, other: Point) -> Point {
|
||||
//! Point {x: self.x + other.x, y: self.y + other.y}
|
||||
//! fn add(self, other: Self) -> Self {
|
||||
//! Self {x: self.x + other.x, y: self.y + other.y}
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! impl Sub for Point {
|
||||
//! type Output = Point;
|
||||
//! type Output = Self;
|
||||
//!
|
||||
//! fn sub(self, other: Point) -> Point {
|
||||
//! Point {x: self.x - other.x, y: self.y - other.y}
|
||||
//! fn sub(self, other: Self) -> Self {
|
||||
//! Self {x: self.x - other.x, y: self.y - other.y}
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
|
@ -1,5 +1,6 @@
|
||||
//! Free functions to create `&[T]` and `&mut [T]`.
|
||||
|
||||
use crate::array;
|
||||
use crate::intrinsics::is_aligned_and_not_null;
|
||||
use crate::mem;
|
||||
use crate::ptr;
|
||||
@ -140,19 +141,11 @@ pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T]
|
||||
/// Converts a reference to T into a slice of length 1 (without copying).
|
||||
#[stable(feature = "from_ref", since = "1.28.0")]
|
||||
pub fn from_ref<T>(s: &T) -> &[T] {
|
||||
// SAFETY: a reference is guaranteed to be valid for reads. The returned
|
||||
// reference cannot be mutated as it is an immutable reference.
|
||||
// `mem::size_of::<T>()` cannot be larger than `isize::MAX`.
|
||||
// Thus the call to `from_raw_parts` is safe.
|
||||
unsafe { from_raw_parts(s, 1) }
|
||||
array::from_ref(s)
|
||||
}
|
||||
|
||||
/// Converts a reference to T into a slice of length 1 (without copying).
|
||||
#[stable(feature = "from_ref", since = "1.28.0")]
|
||||
pub fn from_mut<T>(s: &mut T) -> &mut [T] {
|
||||
// SAFETY: a mutable reference is guaranteed to be valid for writes.
|
||||
// The reference cannot be accessed by another pointer as it is an mutable reference.
|
||||
// `mem::size_of::<T>()` cannot be larger than `isize::MAX`.
|
||||
// Thus the call to `from_raw_parts_mut` is safe.
|
||||
unsafe { from_raw_parts_mut(s, 1) }
|
||||
array::from_mut(s)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use core::array::{FixedSizeArray, IntoIter};
|
||||
use core::array::{self, FixedSizeArray, IntoIter};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
#[test]
|
||||
@ -19,6 +19,21 @@ fn fixed_size_array() {
|
||||
assert_eq!(FixedSizeArray::as_mut_slice(&mut empty_zero_sized).len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_from_ref() {
|
||||
let value: String = "Hello World!".into();
|
||||
let arr: &[String; 1] = array::from_ref(&value);
|
||||
assert_eq!(&[value.clone()], arr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_from_mut() {
|
||||
let mut value: String = "Hello World".into();
|
||||
let arr: &mut [String; 1] = array::from_mut(&mut value);
|
||||
arr[0].push_str("!");
|
||||
assert_eq!(&value, "Hello World!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_try_from() {
|
||||
macro_rules! test {
|
||||
|
@ -1,5 +1,6 @@
|
||||
#![feature(alloc_layout_extra)]
|
||||
#![feature(array_chunks)]
|
||||
#![feature(array_from_ref)]
|
||||
#![feature(array_methods)]
|
||||
#![feature(array_map)]
|
||||
#![feature(array_windows)]
|
||||
|
@ -238,6 +238,7 @@
|
||||
#![feature(const_cstr_unchecked)]
|
||||
#![feature(const_fn_transmute)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(const_ip)]
|
||||
#![feature(const_ipv6)]
|
||||
#![feature(const_raw_ptr_deref)]
|
||||
#![feature(const_ipv4)]
|
||||
|
@ -148,8 +148,9 @@ impl IpAddr {
|
||||
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)).is_unspecified(), true);
|
||||
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)).is_unspecified(), true);
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
|
||||
#[stable(feature = "ip_shared", since = "1.12.0")]
|
||||
pub fn is_unspecified(&self) -> bool {
|
||||
pub const fn is_unspecified(&self) -> bool {
|
||||
match self {
|
||||
IpAddr::V4(ip) => ip.is_unspecified(),
|
||||
IpAddr::V6(ip) => ip.is_unspecified(),
|
||||
@ -169,8 +170,9 @@ impl IpAddr {
|
||||
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)).is_loopback(), true);
|
||||
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0x1)).is_loopback(), true);
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
|
||||
#[stable(feature = "ip_shared", since = "1.12.0")]
|
||||
pub fn is_loopback(&self) -> bool {
|
||||
pub const fn is_loopback(&self) -> bool {
|
||||
match self {
|
||||
IpAddr::V4(ip) => ip.is_loopback(),
|
||||
IpAddr::V6(ip) => ip.is_loopback(),
|
||||
@ -192,7 +194,8 @@ impl IpAddr {
|
||||
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(80, 9, 12, 3)).is_global(), true);
|
||||
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1)).is_global(), true);
|
||||
/// ```
|
||||
pub fn is_global(&self) -> bool {
|
||||
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
|
||||
pub const fn is_global(&self) -> bool {
|
||||
match self {
|
||||
IpAddr::V4(ip) => ip.is_global(),
|
||||
IpAddr::V6(ip) => ip.is_global(),
|
||||
@ -212,8 +215,9 @@ impl IpAddr {
|
||||
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(224, 254, 0, 0)).is_multicast(), true);
|
||||
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0)).is_multicast(), true);
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
|
||||
#[stable(feature = "ip_shared", since = "1.12.0")]
|
||||
pub fn is_multicast(&self) -> bool {
|
||||
pub const fn is_multicast(&self) -> bool {
|
||||
match self {
|
||||
IpAddr::V4(ip) => ip.is_multicast(),
|
||||
IpAddr::V6(ip) => ip.is_multicast(),
|
||||
@ -238,7 +242,8 @@ impl IpAddr {
|
||||
/// true
|
||||
/// );
|
||||
/// ```
|
||||
pub fn is_documentation(&self) -> bool {
|
||||
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
|
||||
pub const fn is_documentation(&self) -> bool {
|
||||
match self {
|
||||
IpAddr::V4(ip) => ip.is_documentation(),
|
||||
IpAddr::V6(ip) => ip.is_documentation(),
|
||||
|
@ -918,3 +918,22 @@ fn ipv6_const() {
|
||||
const IP_V4: Option<Ipv4Addr> = IP_ADDRESS.to_ipv4();
|
||||
assert_eq!(IP_V4.unwrap(), Ipv4Addr::new(0, 0, 0, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ip_const() {
|
||||
// test that the methods of `IpAddr` are usable in a const context
|
||||
|
||||
const IP_ADDRESS: IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
|
||||
|
||||
const IS_UNSPECIFIED: bool = IP_ADDRESS.is_unspecified();
|
||||
assert!(!IS_UNSPECIFIED);
|
||||
|
||||
const IS_LOOPBACK: bool = IP_ADDRESS.is_loopback();
|
||||
assert!(IS_LOOPBACK);
|
||||
|
||||
const IS_GLOBAL: bool = IP_ADDRESS.is_global();
|
||||
assert!(!IS_GLOBAL);
|
||||
|
||||
const IS_MULTICAST: bool = IP_ADDRESS.is_multicast();
|
||||
assert!(!IS_MULTICAST);
|
||||
}
|
||||
|
@ -1531,6 +1531,11 @@ impl<T: Send> error::Error for TrySendError<T> {
|
||||
|
||||
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
|
||||
impl<T> From<SendError<T>> for TrySendError<T> {
|
||||
/// Converts a `SendError<T>` into a `TrySendError<T>`.
|
||||
///
|
||||
/// This conversion always returns a `TrySendError::Disconnected` containing the data in the `SendError<T>`.
|
||||
///
|
||||
/// No data is allocated on the heap.
|
||||
fn from(err: SendError<T>) -> TrySendError<T> {
|
||||
match err {
|
||||
SendError(t) => TrySendError::Disconnected(t),
|
||||
@ -1576,6 +1581,11 @@ impl error::Error for TryRecvError {
|
||||
|
||||
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
|
||||
impl From<RecvError> for TryRecvError {
|
||||
/// Converts a `RecvError` into a `TryRecvError`.
|
||||
///
|
||||
/// This conversion always returns `TryRecvError::Disconnected`.
|
||||
///
|
||||
/// No data is allocated on the heap.
|
||||
fn from(err: RecvError) -> TryRecvError {
|
||||
match err {
|
||||
RecvError => TryRecvError::Disconnected,
|
||||
@ -1606,6 +1616,11 @@ impl error::Error for RecvTimeoutError {
|
||||
|
||||
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
|
||||
impl From<RecvError> for RecvTimeoutError {
|
||||
/// Converts a `RecvError` into a `RecvTimeoutError`.
|
||||
///
|
||||
/// This conversion always returns `RecvTimeoutError::Disconnected`.
|
||||
///
|
||||
/// No data is allocated on the heap.
|
||||
fn from(err: RecvError) -> RecvTimeoutError {
|
||||
match err {
|
||||
RecvError => RecvTimeoutError::Disconnected,
|
||||
|
@ -37,9 +37,7 @@ impl<T> RefUnwindSafe for ReentrantMutex<T> {}
|
||||
/// guarded data.
|
||||
#[must_use = "if unused the ReentrantMutex will immediately unlock"]
|
||||
pub struct ReentrantMutexGuard<'a, T: 'a> {
|
||||
// funny underscores due to how Deref currently works (it disregards field
|
||||
// privacy).
|
||||
__lock: &'a ReentrantMutex<T>,
|
||||
lock: &'a ReentrantMutex<T>,
|
||||
}
|
||||
|
||||
impl<T> !marker::Send for ReentrantMutexGuard<'_, T> {}
|
||||
@ -129,7 +127,7 @@ impl<T: fmt::Debug + 'static> fmt::Debug for ReentrantMutex<T> {
|
||||
|
||||
impl<'mutex, T> ReentrantMutexGuard<'mutex, T> {
|
||||
fn new(lock: &'mutex ReentrantMutex<T>) -> ReentrantMutexGuard<'mutex, T> {
|
||||
ReentrantMutexGuard { __lock: lock }
|
||||
ReentrantMutexGuard { lock }
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,7 +135,7 @@ impl<T> Deref for ReentrantMutexGuard<'_, T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T {
|
||||
&self.__lock.data
|
||||
&self.lock.data
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +143,7 @@ impl<T> Drop for ReentrantMutexGuard<'_, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
self.__lock.inner.unlock();
|
||||
self.lock.inner.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,9 @@ pub fn render<T: Print, S: Print>(
|
||||
keywords = page.keywords,
|
||||
favicon = if layout.favicon.is_empty() {
|
||||
format!(
|
||||
r#"<link rel="shortcut icon" href="{static_root_path}favicon{suffix}.ico">"#,
|
||||
r##"<link rel="icon" type="image/svg+xml" href="{static_root_path}favicon{suffix}.svg">
|
||||
<link rel="alternate icon" type="image/png" href="{static_root_path}favicon-16x16{suffix}.png">
|
||||
<link rel="alternate icon" type="image/png" href="{static_root_path}favicon-32x32{suffix}.png">"##,
|
||||
static_root_path = static_root_path,
|
||||
suffix = page.resource_suffix
|
||||
)
|
||||
|
@ -754,7 +754,9 @@ fn write_shared(
|
||||
write(cx.path("rust-logo.png"), static_files::RUST_LOGO)?;
|
||||
}
|
||||
if (*cx.shared).layout.favicon.is_empty() {
|
||||
write(cx.path("favicon.ico"), static_files::RUST_FAVICON)?;
|
||||
write(cx.path("favicon.svg"), static_files::RUST_FAVICON_SVG)?;
|
||||
write(cx.path("favicon-16x16.png"), static_files::RUST_FAVICON_PNG_16)?;
|
||||
write(cx.path("favicon-32x32.png"), static_files::RUST_FAVICON_PNG_32)?;
|
||||
}
|
||||
write(cx.path("brush.svg"), static_files::BRUSH_SVG)?;
|
||||
write(cx.path("wheel.svg"), static_files::WHEEL_SVG)?;
|
||||
|
BIN
src/librustdoc/html/static/favicon-16x16.png
Normal file
BIN
src/librustdoc/html/static/favicon-16x16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
src/librustdoc/html/static/favicon-32x32.png
Normal file
BIN
src/librustdoc/html/static/favicon-32x32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 23 KiB |
24
src/librustdoc/html/static/favicon.svg
Normal file
24
src/librustdoc/html/static/favicon.svg
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
|
||||
<defs>
|
||||
<style type="text/css"><![CDATA[
|
||||
#logo {
|
||||
fill-rule: nonzero;
|
||||
}
|
||||
#logo-teeth {
|
||||
stroke: #000000;
|
||||
stroke-width: 0.92px;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
#logo {
|
||||
fill: #FFFFFF;
|
||||
fill-rule: nonzero;
|
||||
}
|
||||
#logo-teeth {
|
||||
fill: #FFFFFF;
|
||||
stroke: #FFFFFF;
|
||||
stroke-width: 0.92px;
|
||||
}
|
||||
}
|
||||
]]></style>
|
||||
</defs>
|
||||
<path id="logo" d="M15.993,1.54c-7.972,0 -14.461,6.492 -14.461,14.462c0,7.969 6.492,14.461 14.461,14.461c7.97,0 14.462,-6.492 14.462,-14.461c0,-7.97 -6.492,-14.462 -14.462,-14.462Zm-0.021,1.285c0.511,0.013 0.924,0.439 0.924,0.951c0,0.522 -0.43,0.952 -0.952,0.952c-0.522,0 -0.951,-0.43 -0.951,-0.952c0,0 0,0 0,0c0,-0.522 0.429,-0.952 0.951,-0.952c0.01,0 0.019,0.001 0.028,0.001Zm2.178,1.566c3.379,0.633 6.313,2.723 8.016,5.709l-1.123,2.533c-0.193,0.438 0.006,0.952 0.44,1.147l2.16,0.958c0.067,0.675 0.076,1.355 0.025,2.031l-1.202,0c-0.12,0 -0.169,0.08 -0.169,0.196l0,0.551c0,1.297 -0.731,1.582 -1.373,1.652c-0.612,0.07 -1.288,-0.257 -1.374,-0.63c-0.361,-2.029 -0.961,-2.46 -1.909,-3.21c1.178,-0.746 2.401,-1.85 2.401,-3.325c0,-1.594 -1.092,-2.597 -1.835,-3.09c-1.046,-0.688 -2.203,-0.826 -2.515,-0.826l-12.421,0c1.717,-1.918 4.02,-3.218 6.55,-3.696l1.466,1.536c0.33,0.346 0.878,0.361 1.223,0.028l1.64,-1.564Zm-13.522,7.043c0.511,0.015 0.924,0.44 0.924,0.951c0,0.522 -0.43,0.952 -0.952,0.952c-0.522,0 -0.951,-0.43 -0.951,-0.952c0,0 0,0 0,0c0,-0.522 0.429,-0.951 0.951,-0.951c0.009,0 0.019,0 0.028,0Zm22.685,0.043c0.511,0.015 0.924,0.44 0.924,0.951c0,0.522 -0.43,0.952 -0.952,0.952c-0.522,0 -0.951,-0.43 -0.951,-0.952c0,0 0,0 0,0c0,-0.522 0.429,-0.952 0.951,-0.952c0.01,0 0.019,0 0.028,0.001Zm-20.892,0.153l1.658,0l0,7.477l-3.347,0c-0.414,-1.452 -0.542,-2.97 -0.38,-4.47l2.05,-0.912c0.438,-0.195 0.637,-0.706 0.441,-1.144l-0.422,-0.951Zm6.92,0.079l3.949,0c0.205,0 1.441,0.236 1.441,1.163c0,0.768 -0.948,1.043 -1.728,1.043l-3.665,0l0.003,-2.206Zm0,5.373l3.026,0c0.275,0 1.477,0.079 1.86,1.615c0.119,0.471 0.385,2.007 0.566,2.499c0.18,0.551 0.911,1.652 1.691,1.652l4.938,0c-0.331,0.444 -0.693,0.863 -1.083,1.255l-2.01,-0.432c-0.468,-0.101 -0.93,0.199 -1.031,0.667l-0.477,2.228c-3.104,1.406 -6.672,1.389 -9.762,-0.046l-0.478,-2.228c-0.101,-0.468 -0.56,-0.767 -1.028,-0.667l-1.967,0.423c-0.365,-0.377 -0.704,-0.778 -1.016,-1.2l9.567,0c0.107,0 0.181,-0.018 0.181,-0.119l0,-3.384c0,-0.097 -0.074,-0.119 -0.181,-0.119l-2.799,0l0.003,-2.144Zm-4.415,7.749c0.512,0.015 0.924,0.44 0.924,0.951c0,0.522 -0.429,0.952 -0.951,0.952c-0.522,0 -0.952,-0.43 -0.952,-0.952c0,0 0,0 0,0c0,-0.522 0.43,-0.952 0.952,-0.952c0.009,0 0.018,0.001 0.027,0.001Zm14.089,0.043c0.511,0.015 0.924,0.439 0.923,0.951c0,0.522 -0.429,0.952 -0.951,0.952c-0.522,0 -0.951,-0.43 -0.951,-0.952c0,0 0,0 0,0c0,-0.522 0.429,-0.952 0.951,-0.952c0.009,0 0.018,0 0.028,0.001Z"/><path id="logo-teeth" d="M29.647,16.002c0,7.49 -6.163,13.653 -13.654,13.653c-7.49,0 -13.654,-6.163 -13.654,-13.653c0,-7.491 6.164,-13.654 13.654,-13.654c7.491,0 13.654,6.163 13.654,13.654Zm-0.257,-1.319l2.13,1.319l-2.13,1.318l1.83,1.71l-2.344,0.878l1.463,2.035l-2.475,0.404l1.04,2.282l-2.506,-0.089l0.575,2.442l-2.441,-0.576l0.089,2.506l-2.283,-1.04l-0.403,2.475l-2.035,-1.462l-0.878,2.343l-1.71,-1.829l-1.319,2.129l-1.318,-2.129l-1.71,1.829l-0.878,-2.343l-2.035,1.462l-0.404,-2.475l-2.282,1.04l0.089,-2.506l-2.442,0.576l0.575,-2.442l-2.505,0.089l1.04,-2.282l-2.475,-0.404l1.462,-2.035l-2.343,-0.878l1.829,-1.71l-2.129,-1.318l2.129,-1.319l-1.829,-1.71l2.343,-0.878l-1.462,-2.035l2.475,-0.404l-1.04,-2.282l2.505,0.089l-0.575,-2.441l2.442,0.575l-0.089,-2.506l2.282,1.04l0.404,-2.475l2.035,1.463l0.878,-2.344l1.71,1.83l1.318,-2.13l1.319,2.13l1.71,-1.83l0.878,2.344l2.035,-1.463l0.403,2.475l2.283,-1.04l-0.089,2.506l2.441,-0.575l-0.575,2.441l2.506,-0.089l-1.04,2.282l2.475,0.404l-1.463,2.035l2.344,0.878l-1.83,1.71Z"/></svg>
|
After Width: | Height: | Size: 4.2 KiB |
@ -53,8 +53,10 @@ pub static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");
|
||||
|
||||
/// The contents of `rust-logo.png`, the default icon of the documentation.
|
||||
pub static RUST_LOGO: &[u8] = include_bytes!("static/rust-logo.png");
|
||||
/// The contents of `favicon.ico`, the default favicon of the documentation.
|
||||
pub static RUST_FAVICON: &[u8] = include_bytes!("static/favicon.ico");
|
||||
/// The default documentation favicons (SVG and PNG fallbacks)
|
||||
pub static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/favicon.svg");
|
||||
pub static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/favicon-16x16.png");
|
||||
pub static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/favicon-32x32.png");
|
||||
|
||||
/// The built-in themes given to every documentation site.
|
||||
pub mod themes {
|
||||
|
@ -2,7 +2,7 @@ fn main() {
|
||||
foo(&mut 5);
|
||||
}
|
||||
|
||||
const fn foo(x: &mut i32) -> i32 { //~ ERROR mutable references in const fn
|
||||
const fn foo(x: &mut i32) -> i32 { //~ ERROR mutable references
|
||||
*x + 1
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_mut_refs.rs:5:14
|
||||
|
|
||||
LL | const fn foo(x: &mut i32) -> i32 {
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0723`.
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/const_let_assign3.rs:8:18
|
||||
|
|
||||
LL | const fn foo(&mut self, x: u32) {
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0764]: mutable references are not allowed in constants
|
||||
--> $DIR/const_let_assign3.rs:16:5
|
||||
@ -29,5 +29,5 @@ LL | *y = 42;
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0019, E0723, E0764.
|
||||
Some errors have detailed explanations: E0019, E0658, E0764.
|
||||
For more information about an error, try `rustc --explain E0019`.
|
||||
|
@ -37,26 +37,26 @@ impl<T> Foo<T> {
|
||||
const fn into_inner(self) -> T { self.0 } //~ destructors cannot be evaluated
|
||||
const fn get(&self) -> &T { &self.0 }
|
||||
const fn get_mut(&mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references in const fn are unstable
|
||||
//~^ mutable references
|
||||
}
|
||||
impl<'a, T> Foo<T> {
|
||||
const fn new_lt(t: T) -> Self { Foo(t) }
|
||||
const fn into_inner_lt(self) -> T { self.0 } //~ destructors cannot be evaluated
|
||||
const fn get_lt(&'a self) -> &T { &self.0 }
|
||||
const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references in const fn are unstable
|
||||
//~^ mutable references
|
||||
}
|
||||
impl<T: Sized> Foo<T> {
|
||||
const fn new_s(t: T) -> Self { Foo(t) }
|
||||
const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructors
|
||||
const fn get_s(&self) -> &T { &self.0 }
|
||||
const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references in const fn are unstable
|
||||
//~^ mutable references
|
||||
}
|
||||
impl<T: ?Sized> Foo<T> {
|
||||
const fn get_sq(&self) -> &T { &self.0 }
|
||||
const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references in const fn are unstable
|
||||
//~^ mutable references
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
|
||||
//~^ ERROR casting pointers to integers
|
||||
const fn foo30_6() -> bool { let x = true; x }
|
||||
const fn inc(x: &mut i32) { *x += 1 }
|
||||
//~^ ERROR mutable references in const fn are unstable
|
||||
//~^ ERROR mutable references
|
||||
|
||||
// ok
|
||||
const fn foo36(a: bool, b: bool) -> bool { a && b }
|
||||
|
@ -6,14 +6,14 @@ LL | const fn into_inner(self) -> T { self.0 }
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:39:36
|
||||
|
|
||||
LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:44:28
|
||||
@ -23,14 +23,14 @@ LL | const fn into_inner_lt(self) -> T { self.0 }
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:46:42
|
||||
|
|
||||
LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:51:27
|
||||
@ -40,23 +40,23 @@ LL | const fn into_inner_s(self) -> T { self.0 }
|
||||
| |
|
||||
| constant functions cannot evaluate destructors
|
||||
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:53:38
|
||||
|
|
||||
LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:58:39
|
||||
|
|
||||
LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:76:16
|
||||
@ -164,14 +164,14 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize }
|
||||
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
|
||||
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
|
||||
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:101:14
|
||||
|
|
||||
LL | const fn inc(x: &mut i32) { *x += 1 }
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:110:6
|
||||
|
@ -1,6 +1,6 @@
|
||||
const fn mutable_ref_in_const() -> u8 {
|
||||
let mut a = 0;
|
||||
let b = &mut a; //~ ERROR mutable references in const fn
|
||||
let b = &mut a; //~ ERROR mutable references
|
||||
*b
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ struct X;
|
||||
impl X {
|
||||
const fn inherent_mutable_ref_in_const() -> u8 {
|
||||
let mut a = 0;
|
||||
let b = &mut a; //~ ERROR mutable references in const fn
|
||||
let b = &mut a; //~ ERROR mutable references
|
||||
*b
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/mutable_borrow.rs:3:9
|
||||
|
|
||||
LL | let b = &mut a;
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/mutable_borrow.rs:12:13
|
||||
|
|
||||
LL | let b = &mut a;
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0723`.
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -6,33 +6,33 @@ struct Foo(u32);
|
||||
const TRANSMUTED_U32: u32 = unsafe { mem::transmute(Foo(3)) };
|
||||
|
||||
const fn transmute_fn() -> u32 { unsafe { mem::transmute(Foo(3)) } }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
|
||||
const fn transmute_fn_intrinsic() -> u32 { unsafe { std::intrinsics::transmute(Foo(3)) } }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
|
||||
const fn transmute_fn_core_intrinsic() -> u32 { unsafe { core::intrinsics::transmute(Foo(3)) } }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
|
||||
const unsafe fn unsafe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
|
||||
const unsafe fn unsafe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
|
||||
const unsafe fn unsafe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
|
||||
const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
//~| ERROR call to unsafe function is unsafe and requires unsafe function or block
|
||||
|
||||
const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
//~| ERROR call to unsafe function is unsafe and requires unsafe function or block
|
||||
|
||||
const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||
//~^ ERROR `transmute`
|
||||
//~| ERROR call to unsafe function is unsafe and requires unsafe function or block
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,83 +1,92 @@
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:8:43
|
||||
|
|
||||
LL | const fn transmute_fn() -> u32 { unsafe { mem::transmute(Foo(3)) } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:11:53
|
||||
|
|
||||
LL | const fn transmute_fn_intrinsic() -> u32 { unsafe { std::intrinsics::transmute(Foo(3)) } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:14:58
|
||||
|
|
||||
LL | const fn transmute_fn_core_intrinsic() -> u32 { unsafe { core::intrinsics::transmute(Foo(3)) } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:17:48
|
||||
|
|
||||
LL | const unsafe fn unsafe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:20:58
|
||||
|
|
||||
LL | const unsafe fn unsafe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:23:63
|
||||
|
|
||||
LL | const unsafe fn unsafe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:26:39
|
||||
|
|
||||
LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:30:49
|
||||
|
|
||||
LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:34:54
|
||||
|
|
||||
LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
||||
--> $DIR/feature-gate-const_fn_transmute.rs:26:39
|
||||
@ -105,5 +114,5 @@ LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::tran
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0133, E0723.
|
||||
Some errors have detailed explanations: E0133, E0658.
|
||||
For more information about an error, try `rustc --explain E0133`.
|
||||
|
@ -8,7 +8,7 @@
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const fn foo() -> i32 {
|
||||
unsafe { std::mem::transmute(4u32) } //~ ERROR can only call `transmute` from const items
|
||||
unsafe { std::mem::transmute(4u32) } //~ ERROR `transmute`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,12 +1,13 @@
|
||||
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||
error[E0658]: `transmute` is not allowed in constant functions
|
||||
--> $DIR/internal-unstable-const.rs:11:14
|
||||
|
|
||||
LL | unsafe { std::mem::transmute(4u32) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
|
||||
= help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
|
||||
= note: `transmute` is only allowed in constants and statics for now
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0723`.
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -1,20 +1,20 @@
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/ranged_ints2_const.rs:11:9
|
||||
|
|
||||
LL | let y = &mut x.0;
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/ranged_ints2_const.rs:18:9
|
||||
|
|
||||
LL | let y = unsafe { &mut x.0 };
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0133]: mutation of layout constrained field is unsafe and requires unsafe function or block
|
||||
--> $DIR/ranged_ints2_const.rs:11:13
|
||||
@ -26,5 +26,5 @@ LL | let y = &mut x.0;
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0133, E0723.
|
||||
Some errors have detailed explanations: E0133, E0658.
|
||||
For more information about an error, try `rustc --explain E0133`.
|
||||
|
@ -87,6 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
|
||||
|
||||
let maybe_storage_live_result = MaybeStorageLive
|
||||
.into_engine(cx.tcx, mir, def_id.to_def_id())
|
||||
.pass_name("redundant_clone")
|
||||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(mir);
|
||||
let mut possible_borrower = {
|
||||
|
Loading…
Reference in New Issue
Block a user