diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs
index 1df5540e3b840..2269fdf481471 100644
--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs
+++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs
@@ -257,9 +257,9 @@ pub fn create_compressed_metadata_file(
return compressed.to_vec();
};
let section = file.add_section(
- file.segment_name(StandardSegment::Data).to_vec(),
+ file.segment_name(StandardSegment::Debug).to_vec(),
b".rustc".to_vec(),
- SectionKind::Data,
+ SectionKind::Debug,
);
let offset = file.append_section_data(section, &compressed, 1);
diff --git a/compiler/rustc_mir_dataflow/src/framework/direction.rs b/compiler/rustc_mir_dataflow/src/framework/direction.rs
index 6131ee7981829..102e74397724a 100644
--- a/compiler/rustc_mir_dataflow/src/framework/direction.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/direction.rs
@@ -18,7 +18,7 @@ pub trait Direction {
/// Applies all effects between the given `EffectIndex`s.
///
/// `effects.start()` must precede or equal `effects.end()` in this direction.
- fn apply_effects_in_range(
+ fn apply_effects_in_range<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@@ -27,7 +27,7 @@ pub trait Direction {
) where
A: Analysis<'tcx>;
- fn apply_effects_in_block(
+ fn apply_effects_in_block<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@@ -35,7 +35,7 @@ pub trait Direction {
) where
A: Analysis<'tcx>;
- fn gen_kill_effects_in_block(
+ fn gen_kill_effects_in_block<'tcx, A>(
analysis: &A,
trans: &mut GenKillSet,
block: BasicBlock,
@@ -43,7 +43,7 @@ pub trait Direction {
) where
A: GenKillAnalysis<'tcx>;
- fn visit_results_in_block(
+ fn visit_results_in_block<'mir, 'tcx, F, R>(
state: &mut F,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
@@ -52,7 +52,7 @@ pub trait Direction {
) where
R: ResultsVisitable<'tcx, FlowState = F>;
- fn join_state_into_successors_of(
+ fn join_state_into_successors_of<'tcx, A>(
analysis: &A,
tcx: TyCtxt<'tcx>,
body: &mir::Body<'tcx>,
@@ -72,7 +72,7 @@ impl Direction for Backward {
false
}
- fn apply_effects_in_block(
+ fn apply_effects_in_block<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@@ -92,7 +92,7 @@ impl Direction for Backward {
}
}
- fn gen_kill_effects_in_block(
+ fn gen_kill_effects_in_block<'tcx, A>(
analysis: &A,
trans: &mut GenKillSet,
block: BasicBlock,
@@ -112,7 +112,7 @@ impl Direction for Backward {
}
}
- fn apply_effects_in_range(
+ fn apply_effects_in_range<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@@ -189,7 +189,7 @@ impl Direction for Backward {
analysis.apply_statement_effect(state, statement, location);
}
- fn visit_results_in_block(
+ fn visit_results_in_block<'mir, 'tcx, F, R>(
state: &mut F,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
@@ -221,7 +221,7 @@ impl Direction for Backward {
vis.visit_block_start(state, block_data, block);
}
- fn join_state_into_successors_of(
+ fn join_state_into_successors_of<'tcx, A>(
analysis: &A,
_tcx: TyCtxt<'tcx>,
body: &mir::Body<'tcx>,
@@ -294,7 +294,7 @@ impl Direction for Forward {
true
}
- fn apply_effects_in_block(
+ fn apply_effects_in_block<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@@ -314,7 +314,7 @@ impl Direction for Forward {
analysis.apply_terminator_effect(state, terminator, location);
}
- fn gen_kill_effects_in_block(
+ fn gen_kill_effects_in_block<'tcx, A>(
analysis: &A,
trans: &mut GenKillSet,
block: BasicBlock,
@@ -334,7 +334,7 @@ impl Direction for Forward {
analysis.terminator_effect(trans, terminator, location);
}
- fn apply_effects_in_range(
+ fn apply_effects_in_range<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@@ -407,7 +407,7 @@ impl Direction for Forward {
}
}
- fn visit_results_in_block(
+ fn visit_results_in_block<'mir, 'tcx, F, R>(
state: &mut F,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
@@ -438,7 +438,7 @@ impl Direction for Forward {
vis.visit_block_end(state, block_data, block);
}
- fn join_state_into_successors_of(
+ fn join_state_into_successors_of<'tcx, A>(
analysis: &A,
_tcx: TyCtxt<'tcx>,
_body: &mir::Body<'tcx>,
@@ -591,7 +591,7 @@ where
//
// FIXME: Figure out how to express this using `Option::clone_from`, or maybe lift it into the
// standard library?
-fn opt_clone_from_or_clone(opt: &'a mut Option, val: &T) -> &'a mut T {
+fn opt_clone_from_or_clone<'a, T: Clone>(opt: &'a mut Option, val: &T) -> &'a mut T {
if opt.is_some() {
let ret = opt.as_mut().unwrap();
ret.clone_from(val);
diff --git a/compiler/rustc_mir_dataflow/src/framework/engine.rs b/compiler/rustc_mir_dataflow/src/framework/engine.rs
index 804abc3b42b53..e8a6d8dad439e 100644
--- a/compiler/rustc_mir_dataflow/src/framework/engine.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/engine.rs
@@ -31,12 +31,15 @@ where
pub(super) entry_sets: IndexVec,
}
-impl Results<'tcx, A>
+impl<'tcx, A> Results<'tcx, A>
where
A: Analysis<'tcx>,
{
/// Creates a `ResultsCursor` that can inspect these `Results`.
- pub fn into_results_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'mir, 'tcx, A> {
+ pub fn into_results_cursor<'mir>(
+ self,
+ body: &'mir mir::Body<'tcx>,
+ ) -> ResultsCursor<'mir, 'tcx, A> {
ResultsCursor::new(body, self)
}
@@ -45,7 +48,7 @@ where
&self.entry_sets[block]
}
- pub fn visit_with(
+ pub fn visit_with<'mir>(
&self,
body: &'mir mir::Body<'tcx>,
blocks: impl IntoIterator- ,
@@ -54,7 +57,7 @@ where
visit_results(body, blocks, self, vis)
}
- pub fn visit_reachable_with(
+ pub fn visit_reachable_with<'mir>(
&self,
body: &'mir mir::Body<'tcx>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>,
@@ -85,7 +88,7 @@ where
apply_trans_for_block: Option>,
}
-impl Engine<'a, 'tcx, A>
+impl<'a, 'tcx, A, D, T> Engine<'a, 'tcx, A>
where
A: GenKillAnalysis<'tcx, Idx = T, Domain = D>,
D: Clone + JoinSemiLattice + GenKill + BorrowMut>,
@@ -119,7 +122,7 @@ where
}
}
-impl Engine<'a, 'tcx, A>
+impl<'a, 'tcx, A, D> Engine<'a, 'tcx, A>
where
A: Analysis<'tcx, Domain = D>,
D: Clone + JoinSemiLattice,
@@ -257,7 +260,7 @@ where
/// Writes a DOT file containing the results of a dataflow analysis if the user requested it via
/// `rustc_mir` attributes.
-fn write_graphviz_results(
+fn write_graphviz_results<'tcx, A>(
tcx: TyCtxt<'tcx>,
body: &mir::Body<'tcx>,
results: &Results<'tcx, A>,
@@ -330,7 +333,7 @@ struct RustcMirAttrs {
}
impl RustcMirAttrs {
- fn parse(tcx: TyCtxt<'tcx>, def_id: DefId) -> Result {
+ fn parse(tcx: TyCtxt<'_>, def_id: DefId) -> Result {
let attrs = tcx.get_attrs(def_id);
let mut result = Ok(());
@@ -373,7 +376,7 @@ impl RustcMirAttrs {
fn set_field(
field: &mut Option,
- tcx: TyCtxt<'tcx>,
+ tcx: TyCtxt<'_>,
attr: &ast::NestedMetaItem,
mapper: impl FnOnce(Symbol) -> Result,
) -> Result<(), ()> {
diff --git a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs
index 517bc086ef683..34bc157a744a7 100644
--- a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs
@@ -36,7 +36,7 @@ where
style: OutputStyle,
}
-impl Formatter<'a, 'tcx, A>
+impl<'a, 'tcx, A> Formatter<'a, 'tcx, A>
where
A: Analysis<'tcx>,
{
@@ -52,7 +52,7 @@ pub struct CfgEdge {
index: usize,
}
-fn dataflow_successors(body: &Body<'tcx>, bb: BasicBlock) -> Vec {
+fn dataflow_successors(body: &Body<'_>, bb: BasicBlock) -> Vec {
body[bb]
.terminator()
.successors()
@@ -61,7 +61,7 @@ fn dataflow_successors(body: &Body<'tcx>, bb: BasicBlock) -> Vec {
.collect()
}
-impl dot::Labeller<'_> for Formatter<'a, 'tcx, A>
+impl<'tcx, A> dot::Labeller<'_> for Formatter<'_, 'tcx, A>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext,
@@ -100,7 +100,7 @@ where
}
}
-impl dot::GraphWalk<'a> for Formatter<'a, 'tcx, A>
+impl<'a, 'tcx, A> dot::GraphWalk<'a> for Formatter<'a, 'tcx, A>
where
A: Analysis<'tcx>,
{
@@ -138,7 +138,7 @@ where
style: OutputStyle,
}
-impl BlockFormatter<'a, 'tcx, A>
+impl<'a, 'tcx, A> BlockFormatter<'a, 'tcx, A>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext,
@@ -491,7 +491,7 @@ where
after: Vec,
}
-impl StateDiffCollector<'a, 'tcx, A>
+impl<'a, 'tcx, A> StateDiffCollector<'a, 'tcx, A>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext,
@@ -514,7 +514,7 @@ where
}
}
-impl ResultsVisitor<'a, 'tcx> for StateDiffCollector<'a, 'tcx, A>
+impl<'a, 'tcx, A> ResultsVisitor<'a, 'tcx> for StateDiffCollector<'a, 'tcx, A>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext,
@@ -524,7 +524,7 @@ where
fn visit_block_start(
&mut self,
state: &Self::FlowState,
- _block_data: &'mir mir::BasicBlockData<'tcx>,
+ _block_data: &mir::BasicBlockData<'tcx>,
_block: BasicBlock,
) {
if A::Direction::is_forward() {
@@ -535,7 +535,7 @@ where
fn visit_block_end(
&mut self,
state: &Self::FlowState,
- _block_data: &'mir mir::BasicBlockData<'tcx>,
+ _block_data: &mir::BasicBlockData<'tcx>,
_block: BasicBlock,
) {
if A::Direction::is_backward() {
@@ -546,7 +546,7 @@ where
fn visit_statement_before_primary_effect(
&mut self,
state: &Self::FlowState,
- _statement: &'mir mir::Statement<'tcx>,
+ _statement: &mir::Statement<'tcx>,
_location: Location,
) {
if let Some(before) = self.before.as_mut() {
@@ -558,7 +558,7 @@ where
fn visit_statement_after_primary_effect(
&mut self,
state: &Self::FlowState,
- _statement: &'mir mir::Statement<'tcx>,
+ _statement: &mir::Statement<'tcx>,
_location: Location,
) {
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));
@@ -568,7 +568,7 @@ where
fn visit_terminator_before_primary_effect(
&mut self,
state: &Self::FlowState,
- _terminator: &'mir mir::Terminator<'tcx>,
+ _terminator: &mir::Terminator<'tcx>,
_location: Location,
) {
if let Some(before) = self.before.as_mut() {
@@ -580,7 +580,7 @@ where
fn visit_terminator_after_primary_effect(
&mut self,
state: &Self::FlowState,
- _terminator: &'mir mir::Terminator<'tcx>,
+ _terminator: &mir::Terminator<'tcx>,
_location: Location,
) {
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));
diff --git a/compiler/rustc_mir_dataflow/src/framework/mod.rs b/compiler/rustc_mir_dataflow/src/framework/mod.rs
index 500fba8b1142c..dac6720a6e543 100644
--- a/compiler/rustc_mir_dataflow/src/framework/mod.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/mod.rs
@@ -214,7 +214,11 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
/// .iterate_to_fixpoint()
/// .into_results_cursor(body);
/// ```
- fn into_engine(self, tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>) -> Engine<'mir, 'tcx, Self>
+ fn into_engine<'mir>(
+ self,
+ tcx: TyCtxt<'tcx>,
+ body: &'mir mir::Body<'tcx>,
+ ) -> Engine<'mir, 'tcx, Self>
where
Self: Sized,
{
@@ -296,7 +300,7 @@ pub trait GenKillAnalysis<'tcx>: Analysis<'tcx> {
}
}
-impl Analysis<'tcx> for A
+impl<'tcx, A> Analysis<'tcx> for A
where
A: GenKillAnalysis<'tcx>,
A::Domain: GenKill + BorrowMut>,
@@ -368,7 +372,11 @@ where
/* Extension methods */
- fn into_engine(self, tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>) -> Engine<'mir, 'tcx, Self>
+ fn into_engine<'mir>(
+ self,
+ tcx: TyCtxt<'tcx>,
+ body: &'mir mir::Body<'tcx>,
+ ) -> Engine<'mir, 'tcx, Self>
where
Self: Sized,
{
diff --git a/compiler/rustc_mir_dataflow/src/framework/tests.rs b/compiler/rustc_mir_dataflow/src/framework/tests.rs
index 01ca8ca9258fb..3cc8d30259c0e 100644
--- a/compiler/rustc_mir_dataflow/src/framework/tests.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/tests.rs
@@ -85,7 +85,7 @@ struct MockAnalysis<'tcx, D> {
dir: PhantomData,
}
-impl MockAnalysis<'tcx, D> {
+impl MockAnalysis<'_, D> {
const BASIC_BLOCK_OFFSET: usize = 100;
/// The entry set for each `BasicBlock` is the ID of that block offset by a fixed amount to
@@ -160,7 +160,7 @@ impl MockAnalysis<'tcx, D> {
}
}
-impl AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
+impl<'tcx, D: Direction> AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
type Domain = BitSet;
type Direction = D;
@@ -175,7 +175,7 @@ impl AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
}
}
-impl Analysis<'tcx> for MockAnalysis<'tcx, D> {
+impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
fn apply_statement_effect(
&self,
state: &mut Self::Domain,
@@ -260,7 +260,7 @@ impl SeekTarget {
}
}
-fn test_cursor(analysis: MockAnalysis<'tcx, D>) {
+fn test_cursor(analysis: MockAnalysis<'_, D>) {
let body = analysis.body;
let mut cursor =
diff --git a/compiler/rustc_mir_dataflow/src/framework/visitor.rs b/compiler/rustc_mir_dataflow/src/framework/visitor.rs
index 84136c4d78cf1..75b4e150a8a33 100644
--- a/compiler/rustc_mir_dataflow/src/framework/visitor.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/visitor.rs
@@ -4,7 +4,7 @@ use super::{Analysis, Direction, Results};
/// Calls the corresponding method in `ResultsVisitor` for every location in a `mir::Body` with the
/// dataflow state at that location.
-pub fn visit_results(
+pub fn visit_results<'mir, 'tcx, F, V>(
body: &'mir mir::Body<'tcx>,
blocks: impl IntoIterator
- ,
results: &V,
diff --git a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs
index 6df2c8df3cea0..bb9755e4f48dd 100644
--- a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs
+++ b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs
@@ -45,7 +45,7 @@ impl MaybeBorrowedLocals {
}
}
-impl AnalysisDomain<'tcx> for MaybeBorrowedLocals {
+impl<'tcx> AnalysisDomain<'tcx> for MaybeBorrowedLocals {
type Domain = BitSet;
const NAME: &'static str = "maybe_borrowed_locals";
@@ -59,7 +59,7 @@ impl AnalysisDomain<'tcx> for MaybeBorrowedLocals {
}
}
-impl GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
+impl<'tcx> GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
type Idx = Local;
fn statement_effect(
@@ -95,7 +95,7 @@ struct TransferFunction<'a, T> {
ignore_borrow_on_drop: bool,
}
-impl Visitor<'tcx> for TransferFunction<'a, T>
+impl<'tcx, T> Visitor<'tcx> for TransferFunction<'_, T>
where
T: GenKill,
{
diff --git a/compiler/rustc_mir_dataflow/src/impls/init_locals.rs b/compiler/rustc_mir_dataflow/src/impls/init_locals.rs
index df13b5c33940a..b355871d64f6f 100644
--- a/compiler/rustc_mir_dataflow/src/impls/init_locals.rs
+++ b/compiler/rustc_mir_dataflow/src/impls/init_locals.rs
@@ -10,7 +10,7 @@ use rustc_middle::mir::{self, BasicBlock, Local, Location};
pub struct MaybeInitializedLocals;
-impl crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
+impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
type Domain = BitSet;
const NAME: &'static str = "maybe_init_locals";
@@ -28,7 +28,7 @@ impl crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
}
}
-impl crate::GenKillAnalysis<'tcx> for MaybeInitializedLocals {
+impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeInitializedLocals {
type Idx = Local;
fn statement_effect(
@@ -73,7 +73,7 @@ struct TransferFunction<'a, T> {
trans: &'a mut T,
}
-impl Visitor<'tcx> for TransferFunction<'a, T>
+impl Visitor<'_> for TransferFunction<'_, T>
where
T: GenKill,
{
diff --git a/compiler/rustc_mir_dataflow/src/impls/liveness.rs b/compiler/rustc_mir_dataflow/src/impls/liveness.rs
index 5be9df6c452a2..65c388f8124a3 100644
--- a/compiler/rustc_mir_dataflow/src/impls/liveness.rs
+++ b/compiler/rustc_mir_dataflow/src/impls/liveness.rs
@@ -48,12 +48,12 @@ use crate::{AnalysisDomain, Backward, CallReturnPlaces, GenKill, GenKillAnalysis
pub struct MaybeLiveLocals;
impl MaybeLiveLocals {
- fn transfer_function(&self, trans: &'a mut T) -> TransferFunction<'a, T> {
+ fn transfer_function<'a, T>(&self, trans: &'a mut T) -> TransferFunction<'a, T> {
TransferFunction(trans)
}
}
-impl AnalysisDomain<'tcx> for MaybeLiveLocals {
+impl<'tcx> AnalysisDomain<'tcx> for MaybeLiveLocals {
type Domain = BitSet;
type Direction = Backward;
@@ -69,7 +69,7 @@ impl AnalysisDomain<'tcx> for MaybeLiveLocals {
}
}
-impl GenKillAnalysis<'tcx> for MaybeLiveLocals {
+impl<'tcx> GenKillAnalysis<'tcx> for MaybeLiveLocals {
type Idx = Local;
fn statement_effect(
diff --git a/compiler/rustc_mir_dataflow/src/impls/mod.rs b/compiler/rustc_mir_dataflow/src/impls/mod.rs
index 5659fd2dc7075..5dc8a003b4778 100644
--- a/compiler/rustc_mir_dataflow/src/impls/mod.rs
+++ b/compiler/rustc_mir_dataflow/src/impls/mod.rs
@@ -704,7 +704,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
///
/// If the basic block matches this pattern, this function returns the place corresponding to the
/// enum (`_1` in the example above) as well as the `AdtDef` of that enum.
-fn switch_on_enum_discriminant(
+fn switch_on_enum_discriminant<'mir, 'tcx>(
tcx: TyCtxt<'tcx>,
body: &'mir mir::Body<'tcx>,
block: &'mir mir::BasicBlockData<'tcx>,
diff --git a/compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs b/compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs
index 108357abc0de0..896377f2bc307 100644
--- a/compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs
+++ b/compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs
@@ -17,7 +17,7 @@ impl MaybeStorageLive {
}
}
-impl crate::AnalysisDomain<'tcx> for MaybeStorageLive {
+impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeStorageLive {
type Domain = BitSet;
const NAME: &'static str = "maybe_storage_live";
@@ -39,7 +39,7 @@ impl crate::AnalysisDomain<'tcx> for MaybeStorageLive {
}
}
-impl crate::GenKillAnalysis<'tcx> for MaybeStorageLive {
+impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeStorageLive {
type Idx = Local;
fn statement_effect(
diff --git a/compiler/rustc_mir_dataflow/src/lib.rs b/compiler/rustc_mir_dataflow/src/lib.rs
index 8fdd0a39f250a..6c2d1b85646b1 100644
--- a/compiler/rustc_mir_dataflow/src/lib.rs
+++ b/compiler/rustc_mir_dataflow/src/lib.rs
@@ -3,7 +3,6 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(exact_size_is_empty)]
-#![feature(in_band_lifetimes)]
#![feature(let_else)]
#![feature(min_specialization)]
#![feature(once_cell)]
diff --git a/compiler/rustc_mir_dataflow/src/storage.rs b/compiler/rustc_mir_dataflow/src/storage.rs
index 18b8ef557d671..218d4557215fb 100644
--- a/compiler/rustc_mir_dataflow/src/storage.rs
+++ b/compiler/rustc_mir_dataflow/src/storage.rs
@@ -11,7 +11,7 @@ use rustc_middle::mir::{self, Local};
pub struct AlwaysLiveLocals(BitSet);
impl AlwaysLiveLocals {
- pub fn new(body: &mir::Body<'tcx>) -> Self {
+ pub fn new(body: &mir::Body<'_>) -> Self {
let mut always_live_locals = AlwaysLiveLocals(BitSet::new_filled(body.local_decls.len()));
for block in body.basic_blocks() {
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index 49e6a7df10301..38ad8283f4df0 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -58,7 +58,7 @@ struct CheckAttrVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
}
-impl CheckAttrVisitor<'tcx> {
+impl CheckAttrVisitor<'_> {
/// Checks any attribute.
fn check_attributes(
&self,
@@ -382,7 +382,7 @@ impl CheckAttrVisitor<'tcx> {
&self,
hir_id: HirId,
attr_span: &Span,
- attrs: &'hir [Attribute],
+ attrs: &[Attribute],
span: &Span,
target: Target,
) -> bool {
@@ -1481,7 +1481,7 @@ impl CheckAttrVisitor<'tcx> {
/// Checks if the `#[repr]` attributes on `item` are valid.
fn check_repr(
&self,
- attrs: &'hir [Attribute],
+ attrs: &[Attribute],
span: &Span,
target: Target,
item: Option>,
@@ -1663,7 +1663,7 @@ impl CheckAttrVisitor<'tcx> {
}
}
- fn check_used(&self, attrs: &'hir [Attribute], target: Target) {
+ fn check_used(&self, attrs: &[Attribute], target: Target) {
for attr in attrs {
if attr.has_name(sym::used) && target != Target::Static {
self.tcx
@@ -1842,7 +1842,7 @@ impl CheckAttrVisitor<'tcx> {
}
}
-impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
+impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map(&mut self) -> NestedVisitorMap {
diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs
index 9ccf76b5700c2..a5a65740707e6 100644
--- a/compiler/rustc_passes/src/check_const.rs
+++ b/compiler/rustc_passes/src/check_const.rs
@@ -78,7 +78,7 @@ impl<'tcx> CheckConstTraitVisitor<'tcx> {
impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for CheckConstTraitVisitor<'tcx> {
/// check for const trait impls, and errors if the impl uses provided/default functions
/// of the trait being implemented; as those provided functions can be non-const.
- fn visit_item(&mut self, item: &'hir hir::Item<'hir>) {
+ fn visit_item<'hir>(&mut self, item: &'hir hir::Item<'hir>) {
let _: Option<_> = try {
if let hir::ItemKind::Impl(ref imp) = item.kind {
if let hir::Constness::Const = imp.constness {
@@ -134,11 +134,11 @@ impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for CheckConstTraitVisitor<
};
}
- fn visit_trait_item(&mut self, _: &'hir hir::TraitItem<'hir>) {}
+ fn visit_trait_item<'hir>(&mut self, _: &'hir hir::TraitItem<'hir>) {}
- fn visit_impl_item(&mut self, _: &'hir hir::ImplItem<'hir>) {}
+ fn visit_impl_item<'hir>(&mut self, _: &'hir hir::ImplItem<'hir>) {}
- fn visit_foreign_item(&mut self, _: &'hir hir::ForeignItem<'hir>) {}
+ fn visit_foreign_item<'hir>(&mut self, _: &'hir hir::ForeignItem<'hir>) {}
}
#[derive(Copy, Clone)]
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index 772791324019a..3b15332c678fd 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -150,7 +150,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
#[allow(dead_code)] // FIXME(81658): should be used + lint reinstated after #83171 relands.
fn check_for_self_assign(&mut self, assign: &'tcx hir::Expr<'tcx>) {
- fn check_for_self_assign_helper(
+ fn check_for_self_assign_helper<'tcx>(
tcx: TyCtxt<'tcx>,
typeck_results: &'tcx ty::TypeckResults<'tcx>,
lhs: &'tcx hir::Expr<'tcx>,
@@ -600,7 +600,7 @@ struct DeadVisitor<'tcx> {
live_symbols: FxHashSet,
}
-impl DeadVisitor<'tcx> {
+impl<'tcx> DeadVisitor<'tcx> {
fn should_warn_about_item(&mut self, item: &hir::Item<'_>) -> bool {
let should_warn = matches!(
item.kind,
@@ -672,7 +672,7 @@ impl DeadVisitor<'tcx> {
}
}
-impl Visitor<'tcx> for DeadVisitor<'tcx> {
+impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> {
type Map = Map<'tcx>;
/// Walk nested items in place so that we don't report dead-code
diff --git a/compiler/rustc_passes/src/intrinsicck.rs b/compiler/rustc_passes/src/intrinsicck.rs
index 008b856ebf2fa..064c469662842 100644
--- a/compiler/rustc_passes/src/intrinsicck.rs
+++ b/compiler/rustc_passes/src/intrinsicck.rs
@@ -62,7 +62,7 @@ fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
ty
}
-impl ExprVisitor<'tcx> {
+impl<'tcx> ExprVisitor<'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
self.tcx.fn_sig(def_id).abi() == RustIntrinsic
&& self.tcx.item_name(def_id) == sym::transmute
@@ -487,7 +487,7 @@ impl ExprVisitor<'tcx> {
}
}
-impl Visitor<'tcx> for ItemVisitor<'tcx> {
+impl<'tcx> Visitor<'tcx> for ItemVisitor<'tcx> {
type Map = intravisit::ErasedMap<'tcx>;
fn nested_visit_map(&mut self) -> NestedVisitorMap {
@@ -504,7 +504,7 @@ impl Visitor<'tcx> for ItemVisitor<'tcx> {
}
}
-impl Visitor<'tcx> for ExprVisitor<'tcx> {
+impl<'tcx> Visitor<'tcx> for ExprVisitor<'tcx> {
type Map = intravisit::ErasedMap<'tcx>;
fn nested_visit_map(&mut self) -> NestedVisitorMap {
diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs
index 388c33917c64f..a808d6c8348a7 100644
--- a/compiler/rustc_passes/src/lang_items.rs
+++ b/compiler/rustc_passes/src/lang_items.rs
@@ -28,7 +28,7 @@ struct LanguageItemCollector<'tcx> {
tcx: TyCtxt<'tcx>,
}
-impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
+impl<'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
fn visit_item(&mut self, item: &hir::Item<'_>) {
self.check_for_lang(Target::from_item(item), item.hir_id());
@@ -50,7 +50,7 @@ impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
fn visit_foreign_item(&mut self, _: &hir::ForeignItem<'_>) {}
}
-impl LanguageItemCollector<'tcx> {
+impl<'tcx> LanguageItemCollector<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> LanguageItemCollector<'tcx> {
LanguageItemCollector { tcx, items: LanguageItems::new() }
}
diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs
index 558d8958b1358..00e8eb5eb2b38 100644
--- a/compiler/rustc_passes/src/layout_test.rs
+++ b/compiler/rustc_passes/src/layout_test.rs
@@ -20,7 +20,7 @@ struct LayoutTest<'tcx> {
tcx: TyCtxt<'tcx>,
}
-impl ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
+impl<'tcx> ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
match item.kind {
ItemKind::TyAlias(..)
@@ -42,7 +42,7 @@ impl ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem<'tcx>) {}
}
-impl LayoutTest<'tcx> {
+impl<'tcx> LayoutTest<'tcx> {
fn dump_layout_of(&self, item_def_id: LocalDefId, item: &hir::Item<'tcx>, attr: &Attribute) {
let tcx = self.tcx;
let param_env = self.tcx.param_env(item_def_id);
@@ -114,7 +114,7 @@ struct UnwrapLayoutCx<'tcx> {
param_env: ParamEnv<'tcx>,
}
-impl LayoutOfHelpers<'tcx> for UnwrapLayoutCx<'tcx> {
+impl<'tcx> LayoutOfHelpers<'tcx> for UnwrapLayoutCx<'tcx> {
type LayoutOfResult = TyAndLayout<'tcx>;
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
@@ -127,19 +127,19 @@ impl LayoutOfHelpers<'tcx> for UnwrapLayoutCx<'tcx> {
}
}
-impl HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> {
+impl<'tcx> HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}
}
-impl HasParamEnv<'tcx> for UnwrapLayoutCx<'tcx> {
+impl<'tcx> HasParamEnv<'tcx> for UnwrapLayoutCx<'tcx> {
fn param_env(&self) -> ParamEnv<'tcx> {
self.param_env
}
}
-impl HasDataLayout for UnwrapLayoutCx<'tcx> {
+impl<'tcx> HasDataLayout for UnwrapLayoutCx<'tcx> {
fn data_layout(&self) -> &TargetDataLayout {
self.tcx.data_layout()
}
diff --git a/compiler/rustc_passes/src/lib.rs b/compiler/rustc_passes/src/lib.rs
index d6528364e9806..8a411f01d6ee2 100644
--- a/compiler/rustc_passes/src/lib.rs
+++ b/compiler/rustc_passes/src/lib.rs
@@ -6,7 +6,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(crate_visibility_modifier)]
-#![feature(in_band_lifetimes)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
#![feature(nll)]
diff --git a/compiler/rustc_passes/src/lib_features.rs b/compiler/rustc_passes/src/lib_features.rs
index 10b8c3104fcad..55ae808dc3089 100644
--- a/compiler/rustc_passes/src/lib_features.rs
+++ b/compiler/rustc_passes/src/lib_features.rs
@@ -23,7 +23,7 @@ pub struct LibFeatureCollector<'tcx> {
lib_features: LibFeatures,
}
-impl LibFeatureCollector<'tcx> {
+impl<'tcx> LibFeatureCollector<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> LibFeatureCollector<'tcx> {
LibFeatureCollector { tcx, lib_features: new_lib_features() }
}
@@ -110,7 +110,7 @@ impl LibFeatureCollector<'tcx> {
}
}
-impl Visitor<'tcx> for LibFeatureCollector<'tcx> {
+impl<'tcx> Visitor<'tcx> for LibFeatureCollector<'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map(&mut self) -> NestedVisitorMap {
diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs
index 3d7a215754aca..8bd08913e90d4 100644
--- a/compiler/rustc_passes/src/liveness.rs
+++ b/compiler/rustc_passes/src/liveness.rs
@@ -198,7 +198,7 @@ struct IrMaps<'tcx> {
lnks: IndexVec,
}
-impl IrMaps<'tcx> {
+impl<'tcx> IrMaps<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> IrMaps<'tcx> {
IrMaps {
tcx,
diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs
index d3ecd18a93c5a..07cb165d79670 100644
--- a/compiler/rustc_passes/src/naked_functions.rs
+++ b/compiler/rustc_passes/src/naked_functions.rs
@@ -37,7 +37,7 @@ impl<'tcx> Visitor<'tcx> for CheckNakedFunctions<'tcx> {
fn visit_fn(
&mut self,
- fk: FnKind<'v>,
+ fk: FnKind<'_>,
_fd: &'tcx hir::FnDecl<'tcx>,
body_id: hir::BodyId,
span: Span,
diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs
index fc56a339215be..707e6b123daa2 100644
--- a/compiler/rustc_passes/src/reachable.rs
+++ b/compiler/rustc_passes/src/reachable.rs
@@ -22,7 +22,7 @@ use rustc_target::spec::abi::Abi;
// Returns true if the given item must be inlined because it may be
// monomorphized or it was marked with `#[inline]`. This will only return
// true for functions.
-fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item<'_>, attrs: &CodegenFnAttrs) -> bool {
+fn item_might_be_inlined(tcx: TyCtxt<'_>, item: &hir::Item<'_>, attrs: &CodegenFnAttrs) -> bool {
if attrs.requests_inline() {
return true;
}
diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs
index 92911c3cd2455..5f19991f9c78b 100644
--- a/compiler/rustc_passes/src/stability.rs
+++ b/compiler/rustc_passes/src/stability.rs
@@ -655,7 +655,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
// stable (assuming they have not inherited instability from their parent).
}
-fn stability_index(tcx: TyCtxt<'tcx>, (): ()) -> Index<'tcx> {
+fn stability_index<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> Index<'tcx> {
let is_staged_api =
tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.features().staged_api;
let mut staged_api = FxHashMap::default();
@@ -737,7 +737,7 @@ struct Checker<'tcx> {
tcx: TyCtxt<'tcx>,
}
-impl Visitor<'tcx> for Checker<'tcx> {
+impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
type Map = Map<'tcx>;
/// Because stability levels are scoped lexically, we want to walk
@@ -866,7 +866,7 @@ struct CheckTraitImplStable<'tcx> {
fully_stable: bool,
}
-impl Visitor<'tcx> for CheckTraitImplStable<'tcx> {
+impl<'tcx> Visitor<'tcx> for CheckTraitImplStable<'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map(&mut self) -> NestedVisitorMap {
diff --git a/compiler/rustc_passes/src/upvars.rs b/compiler/rustc_passes/src/upvars.rs
index 91b8ae07637df..2d84c8caada80 100644
--- a/compiler/rustc_passes/src/upvars.rs
+++ b/compiler/rustc_passes/src/upvars.rs
@@ -42,7 +42,7 @@ struct LocalCollector {
locals: FxHashSet,
}
-impl Visitor<'tcx> for LocalCollector {
+impl<'tcx> Visitor<'tcx> for LocalCollector {
type Map = intravisit::ErasedMap<'tcx>;
fn nested_visit_map(&mut self) -> NestedVisitorMap {
@@ -71,7 +71,7 @@ impl CaptureCollector<'_, '_> {
}
}
-impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
+impl<'tcx> Visitor<'tcx> for CaptureCollector<'_, 'tcx> {
type Map = intravisit::ErasedMap<'tcx>;
fn nested_visit_map(&mut self) -> NestedVisitorMap {
diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs
index 7456f886ea5d8..deed9901cc9e4 100644
--- a/library/core/src/cmp.rs
+++ b/library/core/src/cmp.rs
@@ -215,6 +215,7 @@ pub trait PartialEq {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
+ #[default_method_body_is_const]
fn ne(&self, other: &Rhs) -> bool {
!self.eq(other)
}
@@ -1031,6 +1032,7 @@ pub trait PartialOrd: PartialEq {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
+ #[default_method_body_is_const]
fn lt(&self, other: &Rhs) -> bool {
matches!(self.partial_cmp(other), Some(Less))
}
@@ -1050,6 +1052,7 @@ pub trait PartialOrd: PartialEq {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
+ #[default_method_body_is_const]
fn le(&self, other: &Rhs) -> bool {
// Pattern `Some(Less | Eq)` optimizes worse than negating `None | Some(Greater)`.
// FIXME: The root cause was fixed upstream in LLVM with:
@@ -1072,6 +1075,7 @@ pub trait PartialOrd: PartialEq {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
+ #[default_method_body_is_const]
fn gt(&self, other: &Rhs) -> bool {
matches!(self.partial_cmp(other), Some(Greater))
}
@@ -1091,6 +1095,7 @@ pub trait PartialOrd: PartialEq {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
+ #[default_method_body_is_const]
fn ge(&self, other: &Rhs) -> bool {
matches!(self.partial_cmp(other), Some(Greater | Equal))
}
diff --git a/library/core/tests/cmp.rs b/library/core/tests/cmp.rs
index 11cf7add07ada..58fee19ca7490 100644
--- a/library/core/tests/cmp.rs
+++ b/library/core/tests/cmp.rs
@@ -203,3 +203,36 @@ fn cmp_default() {
assert!(Fool(false) != Fool(false));
assert_eq!(Fool(false), Fool(true));
}
+
+#[cfg(not(bootstrap))]
+mod const_cmp {
+ use super::*;
+
+ struct S(i32);
+
+ impl const PartialEq for S {
+ fn eq(&self, other: &Self) -> bool {
+ self.0 == other.0
+ }
+ }
+
+ impl const PartialOrd for S {
+ fn partial_cmp(&self, other: &Self) -> Option {
+ let ret = match (self.0, other.0) {
+ (a, b) if a > b => Ordering::Greater,
+ (a, b) if a < b => Ordering::Less,
+ _ => Ordering::Equal,
+ };
+
+ Some(ret)
+ }
+ }
+
+ const _: () = assert!(S(1) == S(1));
+ const _: () = assert!(S(0) != S(1));
+
+ const _: () = assert!(S(1) <= S(1));
+ const _: () = assert!(S(1) >= S(1));
+ const _: () = assert!(S(0) < S(1));
+ const _: () = assert!(S(1) > S(0));
+}
diff --git a/library/portable-simd/crates/core_simd/src/masks/bitmask.rs b/library/portable-simd/crates/core_simd/src/masks/bitmask.rs
index 4c964cb52e196..b4217dc87ba9c 100644
--- a/library/portable-simd/crates/core_simd/src/masks/bitmask.rs
+++ b/library/portable-simd/crates/core_simd/src/masks/bitmask.rs
@@ -105,18 +105,14 @@ where
#[must_use = "method returns a new vector and does not mutate the original value"]
pub fn to_int(self) -> Simd {
unsafe {
- crate::intrinsics::simd_select_bitmask(
- self.0,
- Simd::splat(T::TRUE),
- Simd::splat(T::FALSE),
- )
+ intrinsics::simd_select_bitmask(self.0, Simd::splat(T::TRUE), Simd::splat(T::FALSE))
}
}
#[inline]
#[must_use = "method returns a new mask and does not mutate the original value"]
pub unsafe fn from_int_unchecked(value: Simd) -> Self {
- unsafe { Self(crate::intrinsics::simd_bitmask(value), PhantomData) }
+ unsafe { Self(intrinsics::simd_bitmask(value), PhantomData) }
}
#[cfg(feature = "generic_const_exprs")]
diff --git a/library/portable-simd/crates/core_simd/src/masks/full_masks.rs b/library/portable-simd/crates/core_simd/src/masks/full_masks.rs
index 5421ccbe3d8f5..e5bb784bb910f 100644
--- a/library/portable-simd/crates/core_simd/src/masks/full_masks.rs
+++ b/library/portable-simd/crates/core_simd/src/masks/full_masks.rs
@@ -115,7 +115,7 @@ where
pub fn to_bitmask(self) -> [u8; LaneCount::::BITMASK_LEN] {
unsafe {
let mut bitmask: [u8; LaneCount::::BITMASK_LEN] =
- crate::intrinsics::simd_bitmask(self.0);
+ intrinsics::simd_bitmask(self.0);
// There is a bug where LLVM appears to implement this operation with the wrong
// bit order.
@@ -144,7 +144,7 @@ where
}
}
- Self::from_int_unchecked(crate::intrinsics::simd_select_bitmask(
+ Self::from_int_unchecked(intrinsics::simd_select_bitmask(
bitmask,
Self::splat(true).to_int(),
Self::splat(false).to_int(),
diff --git a/library/portable-simd/crates/core_simd/src/mod.rs b/library/portable-simd/crates/core_simd/src/mod.rs
index ec874a22389d4..85026265956a2 100644
--- a/library/portable-simd/crates/core_simd/src/mod.rs
+++ b/library/portable-simd/crates/core_simd/src/mod.rs
@@ -27,7 +27,6 @@ pub mod simd {
pub use crate::core_simd::lane_count::{LaneCount, SupportedLaneCount};
pub use crate::core_simd::masks::*;
- pub use crate::core_simd::select::Select;
pub use crate::core_simd::swizzle::*;
pub use crate::core_simd::vector::*;
}
diff --git a/library/portable-simd/crates/core_simd/src/select.rs b/library/portable-simd/crates/core_simd/src/select.rs
index 5d696ebf76ec2..8d521057fbd3e 100644
--- a/library/portable-simd/crates/core_simd/src/select.rs
+++ b/library/portable-simd/crates/core_simd/src/select.rs
@@ -1,54 +1,6 @@
use crate::simd::intrinsics;
use crate::simd::{LaneCount, Mask, MaskElement, Simd, SimdElement, SupportedLaneCount};
-mod sealed {
- pub trait Sealed {
- fn select(mask: Mask, true_values: Self, false_values: Self) -> Self;
- }
-}
-use sealed::Sealed;
-
-/// Supporting trait for vector `select` function
-pub trait Select: Sealed {}
-
-impl Sealed> for Simd
-where
- T: SimdElement,
- LaneCount: SupportedLaneCount,
-{
- #[inline]
- #[must_use = "method returns a new vector and does not mutate the original inputs"]
- fn select(mask: Mask, true_values: Self, false_values: Self) -> Self {
- unsafe { intrinsics::simd_select(mask.to_int(), true_values, false_values) }
- }
-}
-
-impl Select> for Simd
-where
- T: SimdElement,
- LaneCount: SupportedLaneCount,
-{
-}
-
-impl Sealed for Mask
-where
- T: MaskElement,
- LaneCount: SupportedLaneCount,
-{
- #[inline]
- #[must_use = "method returns a new vector and does not mutate the original inputs"]
- fn select(mask: Self, true_values: Self, false_values: Self) -> Self {
- mask & true_values | !mask & false_values
- }
-}
-
-impl Select for Mask
-where
- T: MaskElement,
- LaneCount: SupportedLaneCount,
-{
-}
-
impl Mask
where
T: MaskElement,
@@ -69,8 +21,24 @@ where
/// let c = mask.select(a, b);
/// assert_eq!(c.to_array(), [0, 5, 6, 3]);
/// ```
+ #[inline]
+ #[must_use = "method returns a new vector and does not mutate the original inputs"]
+ pub fn select(
+ self,
+ true_values: Simd,
+ false_values: Simd,
+ ) -> Simd
+ where
+ U: SimdElement,
+ {
+ unsafe { intrinsics::simd_select(self.to_int(), true_values, false_values) }
+ }
+
+ /// Choose lanes from two masks.
+ ///
+ /// For each lane in the mask, choose the corresponding lane from `true_values` if
+ /// that lane mask is true, and `false_values` if that lane mask is false.
///
- /// `select` can also be used on masks:
/// ```
/// # #![feature(portable_simd)]
/// # #[cfg(feature = "std")] use core_simd::Mask;
@@ -78,12 +46,12 @@ where
/// let a = Mask::::from_array([true, true, false, false]);
/// let b = Mask::::from_array([false, false, true, true]);
/// let mask = Mask::::from_array([true, false, false, true]);
- /// let c = mask.select(a, b);
+ /// let c = mask.select_mask(a, b);
/// assert_eq!(c.to_array(), [true, false, true, false]);
/// ```
#[inline]
- #[must_use = "method returns a new vector and does not mutate the original inputs"]
- pub fn select>(self, true_values: S, false_values: S) -> S {
- S::select(self, true_values, false_values)
+ #[must_use = "method returns a new mask and does not mutate the original inputs"]
+ pub fn select_mask(self, true_values: Self, false_values: Self) -> Self {
+ self & true_values | !self & false_values
}
}
diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
index b7a4512152521..232ccdf39d456 100644
--- a/library/std/Cargo.toml
+++ b/library/std/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
description = "The Rust Standard Library"
-edition = "2018"
+edition = "2021"
[lib]
crate-type = ["dylib", "rlib"]
diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs
index 2293fb6b55812..749d51d4981c3 100644
--- a/library/std/src/fs/tests.rs
+++ b/library/std/src/fs/tests.rs
@@ -38,10 +38,9 @@ macro_rules! error {
($e:expr, $s:expr) => {
match $e {
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
- Err(ref err) => assert!(
- err.raw_os_error() == Some($s),
- format!("`{}` did not have a code of `{}`", err, $s)
- ),
+ Err(ref err) => {
+ assert!(err.raw_os_error() == Some($s), "`{}` did not have a code of `{}`", err, $s)
+ }
}
};
}
@@ -58,7 +57,7 @@ macro_rules! error_contains {
match $e {
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
Err(ref err) => {
- assert!(err.to_string().contains($s), format!("`{}` did not contain `{}`", err, $s))
+ assert!(err.to_string().contains($s), "`{}` did not contain `{}`", err, $s)
}
}
};
diff --git a/library/std/src/process.rs b/library/std/src/process.rs
index bf35d71bc4f05..e012594dd4648 100644
--- a/library/std/src/process.rs
+++ b/library/std/src/process.rs
@@ -1600,7 +1600,6 @@ impl ExitStatusError {
/// ```
/// #![feature(exit_status_error)]
/// # if cfg!(unix) {
- /// use std::convert::TryFrom;
/// use std::num::NonZeroI32;
/// use std::process::Command;
///
diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs
index ca0d88135a5d8..4f2c81731a335 100644
--- a/library/std/src/thread/tests.rs
+++ b/library/std/src/thread/tests.rs
@@ -1,6 +1,7 @@
use super::Builder;
use crate::any::Any;
use crate::mem;
+use crate::panic::panic_any;
use crate::result;
use crate::sync::{
mpsc::{channel, Sender},
@@ -183,7 +184,7 @@ fn test_simple_newsched_spawn() {
}
#[test]
-fn test_try_panic_message_static_str() {
+fn test_try_panic_message_string_literal() {
match thread::spawn(move || {
panic!("static string");
})
@@ -199,9 +200,9 @@ fn test_try_panic_message_static_str() {
}
#[test]
-fn test_try_panic_message_owned_str() {
+fn test_try_panic_any_message_owned_str() {
match thread::spawn(move || {
- panic!("owned string".to_string());
+ panic_any("owned string".to_string());
})
.join()
{
@@ -215,9 +216,9 @@ fn test_try_panic_message_owned_str() {
}
#[test]
-fn test_try_panic_message_any() {
+fn test_try_panic_any_message_any() {
match thread::spawn(move || {
- panic!(box 413u16 as Box);
+ panic_any(box 413u16 as Box);
})
.join()
{
@@ -233,10 +234,10 @@ fn test_try_panic_message_any() {
}
#[test]
-fn test_try_panic_message_unit_struct() {
+fn test_try_panic_any_message_unit_struct() {
struct Juju;
- match thread::spawn(move || panic!(Juju)).join() {
+ match thread::spawn(move || panic_any(Juju)).join() {
Err(ref e) if e.is::() => {}
Err(_) | Ok(()) => panic!(),
}
diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer
index 7d6fcbc0be215..db2a7087b994e 160000
--- a/src/tools/rust-analyzer
+++ b/src/tools/rust-analyzer
@@ -1 +1 @@
-Subproject commit 7d6fcbc0be2151bfa85ec146545b42d8be2fb28c
+Subproject commit db2a7087b994e20f264f26ad6db75184282ad120
diff --git a/src/tools/tidy/src/edition.rs b/src/tools/tidy/src/edition.rs
index 3f59fefd041eb..f610dbd806aea 100644
--- a/src/tools/tidy/src/edition.rs
+++ b/src/tools/tidy/src/edition.rs
@@ -23,8 +23,10 @@ pub fn check(path: &Path, bad: &mut bool) {
return;
}
- // Library crates are not yet ready to migrate to 2021.
- if path.components().any(|c| c.as_os_str() == "library") {
+ // Not all library crates are ready to migrate to 2021.
+ if file.components().any(|c| c.as_os_str() == "library")
+ && file.components().all(|c| c.as_os_str() != "std")
+ {
let has = contents.lines().any(is_edition_2018);
if !has {
tidy_error!(