Auto merge of #92062 - matthiaskrgr:rollup-en3p4sb, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #91439 (Mark defaulted `PartialEq`/`PartialOrd` methods as const) - #91516 (Improve suggestion to change struct field to &mut) - #91896 (Remove `in_band_lifetimes` for `rustc_passes`) - #91909 (⬆️ rust-analyzer) - #91922 (Remove `in_band_lifetimes` from `rustc_mir_dataflow`) - #92025 (Revert "socket ancillary data implementation for dragonflybsd.") - #92030 (Update stdlib to the 2021 edition) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
d3f300477b
41 changed files with 208 additions and 239 deletions
|
@ -229,15 +229,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
} => {
|
} => {
|
||||||
err.span_label(span, format!("cannot {ACT}", ACT = act));
|
err.span_label(span, format!("cannot {ACT}", ACT = act));
|
||||||
|
|
||||||
if let Some((span, message)) = annotate_struct_field(
|
if let Some(span) = get_mut_span_in_struct_field(
|
||||||
self.infcx.tcx,
|
self.infcx.tcx,
|
||||||
Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty,
|
Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty,
|
||||||
field,
|
field,
|
||||||
) {
|
) {
|
||||||
err.span_suggestion(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span,
|
||||||
"consider changing this to be mutable",
|
"consider changing this to be mutable",
|
||||||
message,
|
" mut ".into(),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1059,18 +1059,18 @@ fn is_closure_or_generator(ty: Ty<'_>) -> bool {
|
||||||
ty.is_closure() || ty.is_generator()
|
ty.is_closure() || ty.is_generator()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a suggestion to a struct definition given a field access to a local.
|
/// Given a field that needs to be mutable, returns a span where the " mut " could go.
|
||||||
/// This function expects the local to be a reference to a struct in order to produce a suggestion.
|
/// This function expects the local to be a reference to a struct in order to produce a span.
|
||||||
///
|
///
|
||||||
/// ```text
|
/// ```text
|
||||||
/// LL | s: &'a String
|
/// LL | s: &'a String
|
||||||
/// | ---------- use `&'a mut String` here to make mutable
|
/// | ^^^ returns a span taking up the space here
|
||||||
/// ```
|
/// ```
|
||||||
fn annotate_struct_field<'tcx>(
|
fn get_mut_span_in_struct_field<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
field: &mir::Field,
|
field: &mir::Field,
|
||||||
) -> Option<(Span, String)> {
|
) -> Option<Span> {
|
||||||
// Expect our local to be a reference to a struct of some kind.
|
// Expect our local to be a reference to a struct of some kind.
|
||||||
if let ty::Ref(_, ty, _) = ty.kind() {
|
if let ty::Ref(_, ty, _) = ty.kind() {
|
||||||
if let ty::Adt(def, _) = ty.kind() {
|
if let ty::Adt(def, _) = ty.kind() {
|
||||||
|
@ -1081,25 +1081,10 @@ fn annotate_struct_field<'tcx>(
|
||||||
// Now we're dealing with the actual struct that we're going to suggest a change to,
|
// Now we're dealing with the actual struct that we're going to suggest a change to,
|
||||||
// we can expect a field that is an immutable reference to a type.
|
// we can expect a field that is an immutable reference to a type.
|
||||||
if let hir::Node::Field(field) = node {
|
if let hir::Node::Field(field) = node {
|
||||||
if let hir::TyKind::Rptr(
|
if let hir::TyKind::Rptr(lifetime, hir::MutTy { mutbl: hir::Mutability::Not, ty }) =
|
||||||
lifetime,
|
field.ty.kind
|
||||||
hir::MutTy { mutbl: hir::Mutability::Not, ref ty },
|
|
||||||
) = field.ty.kind
|
|
||||||
{
|
{
|
||||||
// Get the snippets in two parts - the named lifetime (if there is one) and
|
return Some(lifetime.span.between(ty.span));
|
||||||
// type being referenced, that way we can reconstruct the snippet without loss
|
|
||||||
// of detail.
|
|
||||||
let type_snippet = tcx.sess.source_map().span_to_snippet(ty.span).ok()?;
|
|
||||||
let lifetime_snippet = if !lifetime.is_elided() {
|
|
||||||
format!("{} ", tcx.sess.source_map().span_to_snippet(lifetime.span).ok()?)
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
};
|
|
||||||
|
|
||||||
return Some((
|
|
||||||
field.ty.span,
|
|
||||||
format!("&{}mut {}", lifetime_snippet, &*type_snippet,),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub trait Direction {
|
||||||
/// Applies all effects between the given `EffectIndex`s.
|
/// Applies all effects between the given `EffectIndex`s.
|
||||||
///
|
///
|
||||||
/// `effects.start()` must precede or equal `effects.end()` in this direction.
|
/// `effects.start()` must precede or equal `effects.end()` in this direction.
|
||||||
fn apply_effects_in_range<A>(
|
fn apply_effects_in_range<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
state: &mut A::Domain,
|
state: &mut A::Domain,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -27,7 +27,7 @@ pub trait Direction {
|
||||||
) where
|
) where
|
||||||
A: Analysis<'tcx>;
|
A: Analysis<'tcx>;
|
||||||
|
|
||||||
fn apply_effects_in_block<A>(
|
fn apply_effects_in_block<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
state: &mut A::Domain,
|
state: &mut A::Domain,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -35,7 +35,7 @@ pub trait Direction {
|
||||||
) where
|
) where
|
||||||
A: Analysis<'tcx>;
|
A: Analysis<'tcx>;
|
||||||
|
|
||||||
fn gen_kill_effects_in_block<A>(
|
fn gen_kill_effects_in_block<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
trans: &mut GenKillSet<A::Idx>,
|
trans: &mut GenKillSet<A::Idx>,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -43,7 +43,7 @@ pub trait Direction {
|
||||||
) where
|
) where
|
||||||
A: GenKillAnalysis<'tcx>;
|
A: GenKillAnalysis<'tcx>;
|
||||||
|
|
||||||
fn visit_results_in_block<F, R>(
|
fn visit_results_in_block<'mir, 'tcx, F, R>(
|
||||||
state: &mut F,
|
state: &mut F,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||||
|
@ -52,7 +52,7 @@ pub trait Direction {
|
||||||
) where
|
) where
|
||||||
R: ResultsVisitable<'tcx, FlowState = F>;
|
R: ResultsVisitable<'tcx, FlowState = F>;
|
||||||
|
|
||||||
fn join_state_into_successors_of<A>(
|
fn join_state_into_successors_of<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
body: &mir::Body<'tcx>,
|
body: &mir::Body<'tcx>,
|
||||||
|
@ -72,7 +72,7 @@ impl Direction for Backward {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_effects_in_block<A>(
|
fn apply_effects_in_block<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
state: &mut A::Domain,
|
state: &mut A::Domain,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -92,7 +92,7 @@ impl Direction for Backward {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_kill_effects_in_block<A>(
|
fn gen_kill_effects_in_block<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
trans: &mut GenKillSet<A::Idx>,
|
trans: &mut GenKillSet<A::Idx>,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -112,7 +112,7 @@ impl Direction for Backward {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_effects_in_range<A>(
|
fn apply_effects_in_range<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
state: &mut A::Domain,
|
state: &mut A::Domain,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -189,7 +189,7 @@ impl Direction for Backward {
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_statement_effect(state, statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_results_in_block<F, R>(
|
fn visit_results_in_block<'mir, 'tcx, F, R>(
|
||||||
state: &mut F,
|
state: &mut F,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||||
|
@ -221,7 +221,7 @@ impl Direction for Backward {
|
||||||
vis.visit_block_start(state, block_data, block);
|
vis.visit_block_start(state, block_data, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn join_state_into_successors_of<A>(
|
fn join_state_into_successors_of<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
_tcx: TyCtxt<'tcx>,
|
_tcx: TyCtxt<'tcx>,
|
||||||
body: &mir::Body<'tcx>,
|
body: &mir::Body<'tcx>,
|
||||||
|
@ -294,7 +294,7 @@ impl Direction for Forward {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_effects_in_block<A>(
|
fn apply_effects_in_block<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
state: &mut A::Domain,
|
state: &mut A::Domain,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -314,7 +314,7 @@ impl Direction for Forward {
|
||||||
analysis.apply_terminator_effect(state, terminator, location);
|
analysis.apply_terminator_effect(state, terminator, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_kill_effects_in_block<A>(
|
fn gen_kill_effects_in_block<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
trans: &mut GenKillSet<A::Idx>,
|
trans: &mut GenKillSet<A::Idx>,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -334,7 +334,7 @@ impl Direction for Forward {
|
||||||
analysis.terminator_effect(trans, terminator, location);
|
analysis.terminator_effect(trans, terminator, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_effects_in_range<A>(
|
fn apply_effects_in_range<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
state: &mut A::Domain,
|
state: &mut A::Domain,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
|
@ -407,7 +407,7 @@ impl Direction for Forward {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_results_in_block<F, R>(
|
fn visit_results_in_block<'mir, 'tcx, F, R>(
|
||||||
state: &mut F,
|
state: &mut F,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||||
|
@ -438,7 +438,7 @@ impl Direction for Forward {
|
||||||
vis.visit_block_end(state, block_data, block);
|
vis.visit_block_end(state, block_data, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn join_state_into_successors_of<A>(
|
fn join_state_into_successors_of<'tcx, A>(
|
||||||
analysis: &A,
|
analysis: &A,
|
||||||
_tcx: TyCtxt<'tcx>,
|
_tcx: TyCtxt<'tcx>,
|
||||||
_body: &mir::Body<'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
|
// FIXME: Figure out how to express this using `Option::clone_from`, or maybe lift it into the
|
||||||
// standard library?
|
// standard library?
|
||||||
fn opt_clone_from_or_clone<T: Clone>(opt: &'a mut Option<T>, val: &T) -> &'a mut T {
|
fn opt_clone_from_or_clone<'a, T: Clone>(opt: &'a mut Option<T>, val: &T) -> &'a mut T {
|
||||||
if opt.is_some() {
|
if opt.is_some() {
|
||||||
let ret = opt.as_mut().unwrap();
|
let ret = opt.as_mut().unwrap();
|
||||||
ret.clone_from(val);
|
ret.clone_from(val);
|
||||||
|
|
|
@ -31,12 +31,15 @@ where
|
||||||
pub(super) entry_sets: IndexVec<BasicBlock, A::Domain>,
|
pub(super) entry_sets: IndexVec<BasicBlock, A::Domain>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> Results<'tcx, A>
|
impl<'tcx, A> Results<'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
{
|
{
|
||||||
/// Creates a `ResultsCursor` that can inspect these `Results`.
|
/// 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)
|
ResultsCursor::new(body, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +48,7 @@ where
|
||||||
&self.entry_sets[block]
|
&self.entry_sets[block]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visit_with(
|
pub fn visit_with<'mir>(
|
||||||
&self,
|
&self,
|
||||||
body: &'mir mir::Body<'tcx>,
|
body: &'mir mir::Body<'tcx>,
|
||||||
blocks: impl IntoIterator<Item = BasicBlock>,
|
blocks: impl IntoIterator<Item = BasicBlock>,
|
||||||
|
@ -54,7 +57,7 @@ where
|
||||||
visit_results(body, blocks, self, vis)
|
visit_results(body, blocks, self, vis)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visit_reachable_with(
|
pub fn visit_reachable_with<'mir>(
|
||||||
&self,
|
&self,
|
||||||
body: &'mir mir::Body<'tcx>,
|
body: &'mir mir::Body<'tcx>,
|
||||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>,
|
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>,
|
||||||
|
@ -85,7 +88,7 @@ where
|
||||||
apply_trans_for_block: Option<Box<dyn Fn(BasicBlock, &mut A::Domain)>>,
|
apply_trans_for_block: Option<Box<dyn Fn(BasicBlock, &mut A::Domain)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, D, T> Engine<'a, 'tcx, A>
|
impl<'a, 'tcx, A, D, T> Engine<'a, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: GenKillAnalysis<'tcx, Idx = T, Domain = D>,
|
A: GenKillAnalysis<'tcx, Idx = T, Domain = D>,
|
||||||
D: Clone + JoinSemiLattice + GenKill<T> + BorrowMut<BitSet<T>>,
|
D: Clone + JoinSemiLattice + GenKill<T> + BorrowMut<BitSet<T>>,
|
||||||
|
@ -119,7 +122,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, D> Engine<'a, 'tcx, A>
|
impl<'a, 'tcx, A, D> Engine<'a, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx, Domain = D>,
|
A: Analysis<'tcx, Domain = D>,
|
||||||
D: Clone + JoinSemiLattice,
|
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
|
/// Writes a DOT file containing the results of a dataflow analysis if the user requested it via
|
||||||
/// `rustc_mir` attributes.
|
/// `rustc_mir` attributes.
|
||||||
fn write_graphviz_results<A>(
|
fn write_graphviz_results<'tcx, A>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
body: &mir::Body<'tcx>,
|
body: &mir::Body<'tcx>,
|
||||||
results: &Results<'tcx, A>,
|
results: &Results<'tcx, A>,
|
||||||
|
@ -330,7 +333,7 @@ struct RustcMirAttrs {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RustcMirAttrs {
|
impl RustcMirAttrs {
|
||||||
fn parse(tcx: TyCtxt<'tcx>, def_id: DefId) -> Result<Self, ()> {
|
fn parse(tcx: TyCtxt<'_>, def_id: DefId) -> Result<Self, ()> {
|
||||||
let attrs = tcx.get_attrs(def_id);
|
let attrs = tcx.get_attrs(def_id);
|
||||||
|
|
||||||
let mut result = Ok(());
|
let mut result = Ok(());
|
||||||
|
@ -373,7 +376,7 @@ impl RustcMirAttrs {
|
||||||
|
|
||||||
fn set_field<T>(
|
fn set_field<T>(
|
||||||
field: &mut Option<T>,
|
field: &mut Option<T>,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'_>,
|
||||||
attr: &ast::NestedMetaItem,
|
attr: &ast::NestedMetaItem,
|
||||||
mapper: impl FnOnce(Symbol) -> Result<T, ()>,
|
mapper: impl FnOnce(Symbol) -> Result<T, ()>,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
|
|
|
@ -36,7 +36,7 @@ where
|
||||||
style: OutputStyle,
|
style: OutputStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> Formatter<'a, 'tcx, A>
|
impl<'a, 'tcx, A> Formatter<'a, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ pub struct CfgEdge {
|
||||||
index: usize,
|
index: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dataflow_successors(body: &Body<'tcx>, bb: BasicBlock) -> Vec<CfgEdge> {
|
fn dataflow_successors(body: &Body<'_>, bb: BasicBlock) -> Vec<CfgEdge> {
|
||||||
body[bb]
|
body[bb]
|
||||||
.terminator()
|
.terminator()
|
||||||
.successors()
|
.successors()
|
||||||
|
@ -61,7 +61,7 @@ fn dataflow_successors(body: &Body<'tcx>, bb: BasicBlock) -> Vec<CfgEdge> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> dot::Labeller<'_> for Formatter<'a, 'tcx, A>
|
impl<'tcx, A> dot::Labeller<'_> for Formatter<'_, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
A::Domain: DebugWithContext<A>,
|
A::Domain: DebugWithContext<A>,
|
||||||
|
@ -100,7 +100,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> dot::GraphWalk<'a> for Formatter<'a, 'tcx, A>
|
impl<'a, 'tcx, A> dot::GraphWalk<'a> for Formatter<'a, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -138,7 +138,7 @@ where
|
||||||
style: OutputStyle,
|
style: OutputStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> BlockFormatter<'a, 'tcx, A>
|
impl<'a, 'tcx, A> BlockFormatter<'a, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
A::Domain: DebugWithContext<A>,
|
A::Domain: DebugWithContext<A>,
|
||||||
|
@ -491,7 +491,7 @@ where
|
||||||
after: Vec<String>,
|
after: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> StateDiffCollector<'a, 'tcx, A>
|
impl<'a, 'tcx, A> StateDiffCollector<'a, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
A::Domain: DebugWithContext<A>,
|
A::Domain: DebugWithContext<A>,
|
||||||
|
@ -514,7 +514,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> ResultsVisitor<'a, 'tcx> for StateDiffCollector<'a, 'tcx, A>
|
impl<'a, 'tcx, A> ResultsVisitor<'a, 'tcx> for StateDiffCollector<'a, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
A::Domain: DebugWithContext<A>,
|
A::Domain: DebugWithContext<A>,
|
||||||
|
@ -524,7 +524,7 @@ where
|
||||||
fn visit_block_start(
|
fn visit_block_start(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &Self::FlowState,
|
state: &Self::FlowState,
|
||||||
_block_data: &'mir mir::BasicBlockData<'tcx>,
|
_block_data: &mir::BasicBlockData<'tcx>,
|
||||||
_block: BasicBlock,
|
_block: BasicBlock,
|
||||||
) {
|
) {
|
||||||
if A::Direction::is_forward() {
|
if A::Direction::is_forward() {
|
||||||
|
@ -535,7 +535,7 @@ where
|
||||||
fn visit_block_end(
|
fn visit_block_end(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &Self::FlowState,
|
state: &Self::FlowState,
|
||||||
_block_data: &'mir mir::BasicBlockData<'tcx>,
|
_block_data: &mir::BasicBlockData<'tcx>,
|
||||||
_block: BasicBlock,
|
_block: BasicBlock,
|
||||||
) {
|
) {
|
||||||
if A::Direction::is_backward() {
|
if A::Direction::is_backward() {
|
||||||
|
@ -546,7 +546,7 @@ where
|
||||||
fn visit_statement_before_primary_effect(
|
fn visit_statement_before_primary_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &Self::FlowState,
|
state: &Self::FlowState,
|
||||||
_statement: &'mir mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
_location: Location,
|
_location: Location,
|
||||||
) {
|
) {
|
||||||
if let Some(before) = self.before.as_mut() {
|
if let Some(before) = self.before.as_mut() {
|
||||||
|
@ -558,7 +558,7 @@ where
|
||||||
fn visit_statement_after_primary_effect(
|
fn visit_statement_after_primary_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &Self::FlowState,
|
state: &Self::FlowState,
|
||||||
_statement: &'mir mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
_location: Location,
|
_location: Location,
|
||||||
) {
|
) {
|
||||||
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));
|
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));
|
||||||
|
@ -568,7 +568,7 @@ where
|
||||||
fn visit_terminator_before_primary_effect(
|
fn visit_terminator_before_primary_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &Self::FlowState,
|
state: &Self::FlowState,
|
||||||
_terminator: &'mir mir::Terminator<'tcx>,
|
_terminator: &mir::Terminator<'tcx>,
|
||||||
_location: Location,
|
_location: Location,
|
||||||
) {
|
) {
|
||||||
if let Some(before) = self.before.as_mut() {
|
if let Some(before) = self.before.as_mut() {
|
||||||
|
@ -580,7 +580,7 @@ where
|
||||||
fn visit_terminator_after_primary_effect(
|
fn visit_terminator_after_primary_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &Self::FlowState,
|
state: &Self::FlowState,
|
||||||
_terminator: &'mir mir::Terminator<'tcx>,
|
_terminator: &mir::Terminator<'tcx>,
|
||||||
_location: Location,
|
_location: Location,
|
||||||
) {
|
) {
|
||||||
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));
|
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));
|
||||||
|
|
|
@ -214,7 +214,11 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
|
||||||
/// .iterate_to_fixpoint()
|
/// .iterate_to_fixpoint()
|
||||||
/// .into_results_cursor(body);
|
/// .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
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
|
@ -296,7 +300,7 @@ pub trait GenKillAnalysis<'tcx>: Analysis<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> Analysis<'tcx> for A
|
impl<'tcx, A> Analysis<'tcx> for A
|
||||||
where
|
where
|
||||||
A: GenKillAnalysis<'tcx>,
|
A: GenKillAnalysis<'tcx>,
|
||||||
A::Domain: GenKill<A::Idx> + BorrowMut<BitSet<A::Idx>>,
|
A::Domain: GenKill<A::Idx> + BorrowMut<BitSet<A::Idx>>,
|
||||||
|
@ -368,7 +372,11 @@ where
|
||||||
|
|
||||||
/* Extension methods */
|
/* 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
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct MockAnalysis<'tcx, D> {
|
||||||
dir: PhantomData<D>,
|
dir: PhantomData<D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Direction> MockAnalysis<'tcx, D> {
|
impl<D: Direction> MockAnalysis<'_, D> {
|
||||||
const BASIC_BLOCK_OFFSET: usize = 100;
|
const BASIC_BLOCK_OFFSET: usize = 100;
|
||||||
|
|
||||||
/// The entry set for each `BasicBlock` is the ID of that block offset by a fixed amount to
|
/// The entry set for each `BasicBlock` is the ID of that block offset by a fixed amount to
|
||||||
|
@ -160,7 +160,7 @@ impl<D: Direction> MockAnalysis<'tcx, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Direction> AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
|
impl<'tcx, D: Direction> AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
|
||||||
type Domain = BitSet<usize>;
|
type Domain = BitSet<usize>;
|
||||||
type Direction = D;
|
type Direction = D;
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<D: Direction> AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
|
impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
|
||||||
fn apply_statement_effect(
|
fn apply_statement_effect(
|
||||||
&self,
|
&self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
|
@ -260,7 +260,7 @@ impl SeekTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_cursor<D: Direction>(analysis: MockAnalysis<'tcx, D>) {
|
fn test_cursor<D: Direction>(analysis: MockAnalysis<'_, D>) {
|
||||||
let body = analysis.body;
|
let body = analysis.body;
|
||||||
|
|
||||||
let mut cursor =
|
let mut cursor =
|
||||||
|
|
|
@ -4,7 +4,7 @@ use super::{Analysis, Direction, Results};
|
||||||
|
|
||||||
/// Calls the corresponding method in `ResultsVisitor` for every location in a `mir::Body` with the
|
/// Calls the corresponding method in `ResultsVisitor` for every location in a `mir::Body` with the
|
||||||
/// dataflow state at that location.
|
/// dataflow state at that location.
|
||||||
pub fn visit_results<F, V>(
|
pub fn visit_results<'mir, 'tcx, F, V>(
|
||||||
body: &'mir mir::Body<'tcx>,
|
body: &'mir mir::Body<'tcx>,
|
||||||
blocks: impl IntoIterator<Item = BasicBlock>,
|
blocks: impl IntoIterator<Item = BasicBlock>,
|
||||||
results: &V,
|
results: &V,
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl MaybeBorrowedLocals {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AnalysisDomain<'tcx> for MaybeBorrowedLocals {
|
impl<'tcx> AnalysisDomain<'tcx> for MaybeBorrowedLocals {
|
||||||
type Domain = BitSet<Local>;
|
type Domain = BitSet<Local>;
|
||||||
const NAME: &'static str = "maybe_borrowed_locals";
|
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;
|
type Idx = Local;
|
||||||
|
|
||||||
fn statement_effect(
|
fn statement_effect(
|
||||||
|
@ -95,7 +95,7 @@ struct TransferFunction<'a, T> {
|
||||||
ignore_borrow_on_drop: bool,
|
ignore_borrow_on_drop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Visitor<'tcx> for TransferFunction<'a, T>
|
impl<'tcx, T> Visitor<'tcx> for TransferFunction<'_, T>
|
||||||
where
|
where
|
||||||
T: GenKill<Local>,
|
T: GenKill<Local>,
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ use rustc_middle::mir::{self, BasicBlock, Local, Location};
|
||||||
|
|
||||||
pub struct MaybeInitializedLocals;
|
pub struct MaybeInitializedLocals;
|
||||||
|
|
||||||
impl crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
|
impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
|
||||||
type Domain = BitSet<Local>;
|
type Domain = BitSet<Local>;
|
||||||
|
|
||||||
const NAME: &'static str = "maybe_init_locals";
|
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;
|
type Idx = Local;
|
||||||
|
|
||||||
fn statement_effect(
|
fn statement_effect(
|
||||||
|
@ -73,7 +73,7 @@ struct TransferFunction<'a, T> {
|
||||||
trans: &'a mut T,
|
trans: &'a mut T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Visitor<'tcx> for TransferFunction<'a, T>
|
impl<T> Visitor<'_> for TransferFunction<'_, T>
|
||||||
where
|
where
|
||||||
T: GenKill<Local>,
|
T: GenKill<Local>,
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,12 +48,12 @@ use crate::{AnalysisDomain, Backward, CallReturnPlaces, GenKill, GenKillAnalysis
|
||||||
pub struct MaybeLiveLocals;
|
pub struct MaybeLiveLocals;
|
||||||
|
|
||||||
impl MaybeLiveLocals {
|
impl MaybeLiveLocals {
|
||||||
fn transfer_function<T>(&self, trans: &'a mut T) -> TransferFunction<'a, T> {
|
fn transfer_function<'a, T>(&self, trans: &'a mut T) -> TransferFunction<'a, T> {
|
||||||
TransferFunction(trans)
|
TransferFunction(trans)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AnalysisDomain<'tcx> for MaybeLiveLocals {
|
impl<'tcx> AnalysisDomain<'tcx> for MaybeLiveLocals {
|
||||||
type Domain = BitSet<Local>;
|
type Domain = BitSet<Local>;
|
||||||
type Direction = Backward;
|
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;
|
type Idx = Local;
|
||||||
|
|
||||||
fn statement_effect(
|
fn statement_effect(
|
||||||
|
|
|
@ -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
|
/// 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.
|
/// 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>,
|
tcx: TyCtxt<'tcx>,
|
||||||
body: &'mir mir::Body<'tcx>,
|
body: &'mir mir::Body<'tcx>,
|
||||||
block: &'mir mir::BasicBlockData<'tcx>,
|
block: &'mir mir::BasicBlockData<'tcx>,
|
||||||
|
|
|
@ -17,7 +17,7 @@ impl MaybeStorageLive {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::AnalysisDomain<'tcx> for MaybeStorageLive {
|
impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeStorageLive {
|
||||||
type Domain = BitSet<Local>;
|
type Domain = BitSet<Local>;
|
||||||
|
|
||||||
const NAME: &'static str = "maybe_storage_live";
|
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;
|
type Idx = Local;
|
||||||
|
|
||||||
fn statement_effect(
|
fn statement_effect(
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(exact_size_is_empty)]
|
#![feature(exact_size_is_empty)]
|
||||||
#![feature(in_band_lifetimes)]
|
|
||||||
#![feature(let_else)]
|
#![feature(let_else)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(once_cell)]
|
#![feature(once_cell)]
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rustc_middle::mir::{self, Local};
|
||||||
pub struct AlwaysLiveLocals(BitSet<Local>);
|
pub struct AlwaysLiveLocals(BitSet<Local>);
|
||||||
|
|
||||||
impl AlwaysLiveLocals {
|
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()));
|
let mut always_live_locals = AlwaysLiveLocals(BitSet::new_filled(body.local_decls.len()));
|
||||||
|
|
||||||
for block in body.basic_blocks() {
|
for block in body.basic_blocks() {
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct CheckAttrVisitor<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckAttrVisitor<'tcx> {
|
impl CheckAttrVisitor<'_> {
|
||||||
/// Checks any attribute.
|
/// Checks any attribute.
|
||||||
fn check_attributes(
|
fn check_attributes(
|
||||||
&self,
|
&self,
|
||||||
|
@ -382,7 +382,7 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
&self,
|
&self,
|
||||||
hir_id: HirId,
|
hir_id: HirId,
|
||||||
attr_span: &Span,
|
attr_span: &Span,
|
||||||
attrs: &'hir [Attribute],
|
attrs: &[Attribute],
|
||||||
span: &Span,
|
span: &Span,
|
||||||
target: Target,
|
target: Target,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
@ -1481,7 +1481,7 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
/// Checks if the `#[repr]` attributes on `item` are valid.
|
/// Checks if the `#[repr]` attributes on `item` are valid.
|
||||||
fn check_repr(
|
fn check_repr(
|
||||||
&self,
|
&self,
|
||||||
attrs: &'hir [Attribute],
|
attrs: &[Attribute],
|
||||||
span: &Span,
|
span: &Span,
|
||||||
target: Target,
|
target: Target,
|
||||||
item: Option<ItemLike<'_>>,
|
item: Option<ItemLike<'_>>,
|
||||||
|
@ -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 {
|
for attr in attrs {
|
||||||
if attr.has_name(sym::used) && target != Target::Static {
|
if attr.has_name(sym::used) && target != Target::Static {
|
||||||
self.tcx
|
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>;
|
type Map = Map<'tcx>;
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl<'tcx> CheckConstTraitVisitor<'tcx> {
|
||||||
impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for 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
|
/// 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.
|
/// 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 {
|
let _: Option<_> = try {
|
||||||
if let hir::ItemKind::Impl(ref imp) = item.kind {
|
if let hir::ItemKind::Impl(ref imp) = item.kind {
|
||||||
if let hir::Constness::Const = imp.constness {
|
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)]
|
#[derive(Copy, Clone)]
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
||||||
|
|
||||||
#[allow(dead_code)] // FIXME(81658): should be used + lint reinstated after #83171 relands.
|
#[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(&mut self, assign: &'tcx hir::Expr<'tcx>) {
|
||||||
fn check_for_self_assign_helper(
|
fn check_for_self_assign_helper<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
typeck_results: &'tcx ty::TypeckResults<'tcx>,
|
typeck_results: &'tcx ty::TypeckResults<'tcx>,
|
||||||
lhs: &'tcx hir::Expr<'tcx>,
|
lhs: &'tcx hir::Expr<'tcx>,
|
||||||
|
@ -600,7 +600,7 @@ struct DeadVisitor<'tcx> {
|
||||||
live_symbols: FxHashSet<LocalDefId>,
|
live_symbols: FxHashSet<LocalDefId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeadVisitor<'tcx> {
|
impl<'tcx> DeadVisitor<'tcx> {
|
||||||
fn should_warn_about_item(&mut self, item: &hir::Item<'_>) -> bool {
|
fn should_warn_about_item(&mut self, item: &hir::Item<'_>) -> bool {
|
||||||
let should_warn = matches!(
|
let should_warn = matches!(
|
||||||
item.kind,
|
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>;
|
type Map = Map<'tcx>;
|
||||||
|
|
||||||
/// Walk nested items in place so that we don't report dead-code
|
/// Walk nested items in place so that we don't report dead-code
|
||||||
|
|
|
@ -62,7 +62,7 @@ fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
ty
|
ty
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExprVisitor<'tcx> {
|
impl<'tcx> ExprVisitor<'tcx> {
|
||||||
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
|
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
|
||||||
self.tcx.fn_sig(def_id).abi() == RustIntrinsic
|
self.tcx.fn_sig(def_id).abi() == RustIntrinsic
|
||||||
&& self.tcx.item_name(def_id) == sym::transmute
|
&& 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>;
|
type Map = intravisit::ErasedMap<'tcx>;
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||||
|
@ -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>;
|
type Map = intravisit::ErasedMap<'tcx>;
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct LanguageItemCollector<'tcx> {
|
||||||
tcx: TyCtxt<'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<'_>) {
|
fn visit_item(&mut self, item: &hir::Item<'_>) {
|
||||||
self.check_for_lang(Target::from_item(item), item.hir_id());
|
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<'_>) {}
|
fn visit_foreign_item(&mut self, _: &hir::ForeignItem<'_>) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LanguageItemCollector<'tcx> {
|
impl<'tcx> LanguageItemCollector<'tcx> {
|
||||||
fn new(tcx: TyCtxt<'tcx>) -> LanguageItemCollector<'tcx> {
|
fn new(tcx: TyCtxt<'tcx>) -> LanguageItemCollector<'tcx> {
|
||||||
LanguageItemCollector { tcx, items: LanguageItems::new() }
|
LanguageItemCollector { tcx, items: LanguageItems::new() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct LayoutTest<'tcx> {
|
||||||
tcx: TyCtxt<'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>) {
|
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ItemKind::TyAlias(..)
|
ItemKind::TyAlias(..)
|
||||||
|
@ -42,7 +42,7 @@ impl ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
|
||||||
fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem<'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) {
|
fn dump_layout_of(&self, item_def_id: LocalDefId, item: &hir::Item<'tcx>, attr: &Attribute) {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let param_env = self.tcx.param_env(item_def_id);
|
let param_env = self.tcx.param_env(item_def_id);
|
||||||
|
@ -114,7 +114,7 @@ struct UnwrapLayoutCx<'tcx> {
|
||||||
param_env: ParamEnv<'tcx>,
|
param_env: ParamEnv<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutOfHelpers<'tcx> for UnwrapLayoutCx<'tcx> {
|
impl<'tcx> LayoutOfHelpers<'tcx> for UnwrapLayoutCx<'tcx> {
|
||||||
type LayoutOfResult = TyAndLayout<'tcx>;
|
type LayoutOfResult = TyAndLayout<'tcx>;
|
||||||
|
|
||||||
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'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> {
|
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasParamEnv<'tcx> for UnwrapLayoutCx<'tcx> {
|
impl<'tcx> HasParamEnv<'tcx> for UnwrapLayoutCx<'tcx> {
|
||||||
fn param_env(&self) -> ParamEnv<'tcx> {
|
fn param_env(&self) -> ParamEnv<'tcx> {
|
||||||
self.param_env
|
self.param_env
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasDataLayout for UnwrapLayoutCx<'tcx> {
|
impl<'tcx> HasDataLayout for UnwrapLayoutCx<'tcx> {
|
||||||
fn data_layout(&self) -> &TargetDataLayout {
|
fn data_layout(&self) -> &TargetDataLayout {
|
||||||
self.tcx.data_layout()
|
self.tcx.data_layout()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(in_band_lifetimes)]
|
|
||||||
#![feature(map_try_insert)]
|
#![feature(map_try_insert)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub struct LibFeatureCollector<'tcx> {
|
||||||
lib_features: LibFeatures,
|
lib_features: LibFeatures,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LibFeatureCollector<'tcx> {
|
impl<'tcx> LibFeatureCollector<'tcx> {
|
||||||
fn new(tcx: TyCtxt<'tcx>) -> LibFeatureCollector<'tcx> {
|
fn new(tcx: TyCtxt<'tcx>) -> LibFeatureCollector<'tcx> {
|
||||||
LibFeatureCollector { tcx, lib_features: new_lib_features() }
|
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>;
|
type Map = Map<'tcx>;
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||||
|
|
|
@ -198,7 +198,7 @@ struct IrMaps<'tcx> {
|
||||||
lnks: IndexVec<LiveNode, LiveNodeKind>,
|
lnks: IndexVec<LiveNode, LiveNodeKind>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IrMaps<'tcx> {
|
impl<'tcx> IrMaps<'tcx> {
|
||||||
fn new(tcx: TyCtxt<'tcx>) -> IrMaps<'tcx> {
|
fn new(tcx: TyCtxt<'tcx>) -> IrMaps<'tcx> {
|
||||||
IrMaps {
|
IrMaps {
|
||||||
tcx,
|
tcx,
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl<'tcx> Visitor<'tcx> for CheckNakedFunctions<'tcx> {
|
||||||
|
|
||||||
fn visit_fn(
|
fn visit_fn(
|
||||||
&mut self,
|
&mut self,
|
||||||
fk: FnKind<'v>,
|
fk: FnKind<'_>,
|
||||||
_fd: &'tcx hir::FnDecl<'tcx>,
|
_fd: &'tcx hir::FnDecl<'tcx>,
|
||||||
body_id: hir::BodyId,
|
body_id: hir::BodyId,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
|
@ -22,7 +22,7 @@ use rustc_target::spec::abi::Abi;
|
||||||
// Returns true if the given item must be inlined because it may be
|
// Returns true if the given item must be inlined because it may be
|
||||||
// monomorphized or it was marked with `#[inline]`. This will only return
|
// monomorphized or it was marked with `#[inline]`. This will only return
|
||||||
// true for functions.
|
// 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() {
|
if attrs.requests_inline() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -655,7 +655,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
|
||||||
// stable (assuming they have not inherited instability from their parent).
|
// 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 =
|
let is_staged_api =
|
||||||
tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.features().staged_api;
|
tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.features().staged_api;
|
||||||
let mut staged_api = FxHashMap::default();
|
let mut staged_api = FxHashMap::default();
|
||||||
|
@ -737,7 +737,7 @@ struct Checker<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Visitor<'tcx> for Checker<'tcx> {
|
impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
|
||||||
type Map = Map<'tcx>;
|
type Map = Map<'tcx>;
|
||||||
|
|
||||||
/// Because stability levels are scoped lexically, we want to walk
|
/// Because stability levels are scoped lexically, we want to walk
|
||||||
|
@ -866,7 +866,7 @@ struct CheckTraitImplStable<'tcx> {
|
||||||
fully_stable: bool,
|
fully_stable: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Visitor<'tcx> for CheckTraitImplStable<'tcx> {
|
impl<'tcx> Visitor<'tcx> for CheckTraitImplStable<'tcx> {
|
||||||
type Map = Map<'tcx>;
|
type Map = Map<'tcx>;
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct LocalCollector {
|
||||||
locals: FxHashSet<HirId>,
|
locals: FxHashSet<HirId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Visitor<'tcx> for LocalCollector {
|
impl<'tcx> Visitor<'tcx> for LocalCollector {
|
||||||
type Map = intravisit::ErasedMap<'tcx>;
|
type Map = intravisit::ErasedMap<'tcx>;
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||||
|
@ -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>;
|
type Map = intravisit::ErasedMap<'tcx>;
|
||||||
|
|
||||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||||
|
|
|
@ -215,6 +215,7 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[default_method_body_is_const]
|
||||||
fn ne(&self, other: &Rhs) -> bool {
|
fn ne(&self, other: &Rhs) -> bool {
|
||||||
!self.eq(other)
|
!self.eq(other)
|
||||||
}
|
}
|
||||||
|
@ -1031,6 +1032,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[default_method_body_is_const]
|
||||||
fn lt(&self, other: &Rhs) -> bool {
|
fn lt(&self, other: &Rhs) -> bool {
|
||||||
matches!(self.partial_cmp(other), Some(Less))
|
matches!(self.partial_cmp(other), Some(Less))
|
||||||
}
|
}
|
||||||
|
@ -1050,6 +1052,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[default_method_body_is_const]
|
||||||
fn le(&self, other: &Rhs) -> bool {
|
fn le(&self, other: &Rhs) -> bool {
|
||||||
// Pattern `Some(Less | Eq)` optimizes worse than negating `None | Some(Greater)`.
|
// Pattern `Some(Less | Eq)` optimizes worse than negating `None | Some(Greater)`.
|
||||||
// FIXME: The root cause was fixed upstream in LLVM with:
|
// FIXME: The root cause was fixed upstream in LLVM with:
|
||||||
|
@ -1072,6 +1075,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[default_method_body_is_const]
|
||||||
fn gt(&self, other: &Rhs) -> bool {
|
fn gt(&self, other: &Rhs) -> bool {
|
||||||
matches!(self.partial_cmp(other), Some(Greater))
|
matches!(self.partial_cmp(other), Some(Greater))
|
||||||
}
|
}
|
||||||
|
@ -1091,6 +1095,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[default_method_body_is_const]
|
||||||
fn ge(&self, other: &Rhs) -> bool {
|
fn ge(&self, other: &Rhs) -> bool {
|
||||||
matches!(self.partial_cmp(other), Some(Greater | Equal))
|
matches!(self.partial_cmp(other), Some(Greater | Equal))
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,3 +203,36 @@ fn cmp_default() {
|
||||||
assert!(Fool(false) != Fool(false));
|
assert!(Fool(false) != Fool(false));
|
||||||
assert_eq!(Fool(false), Fool(true));
|
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<Ordering> {
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ version = "0.0.0"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/rust-lang/rust.git"
|
repository = "https://github.com/rust-lang/rust.git"
|
||||||
description = "The Rust Standard Library"
|
description = "The Rust Standard Library"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["dylib", "rlib"]
|
crate-type = ["dylib", "rlib"]
|
||||||
|
|
|
@ -38,10 +38,9 @@ macro_rules! error {
|
||||||
($e:expr, $s:expr) => {
|
($e:expr, $s:expr) => {
|
||||||
match $e {
|
match $e {
|
||||||
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
|
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
|
||||||
Err(ref err) => assert!(
|
Err(ref err) => {
|
||||||
err.raw_os_error() == Some($s),
|
assert!(err.raw_os_error() == Some($s), "`{}` did not have a code of `{}`", err, $s)
|
||||||
format!("`{}` did not have a code of `{}`", err, $s)
|
}
|
||||||
),
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -58,7 +57,7 @@ macro_rules! error_contains {
|
||||||
match $e {
|
match $e {
|
||||||
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
|
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
|
||||||
Err(ref err) => {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,8 +16,6 @@ mod libc {
|
||||||
pub use libc::c_int;
|
pub use libc::c_int;
|
||||||
pub struct ucred;
|
pub struct ucred;
|
||||||
pub struct cmsghdr;
|
pub struct cmsghdr;
|
||||||
#[cfg(target_os = "dragonfly")]
|
|
||||||
pub struct cmsgcred;
|
|
||||||
pub type pid_t = i32;
|
pub type pid_t = i32;
|
||||||
pub type gid_t = u32;
|
pub type gid_t = u32;
|
||||||
pub type uid_t = u32;
|
pub type uid_t = u32;
|
||||||
|
@ -185,11 +183,6 @@ impl<'a, T> Iterator for AncillaryDataIter<'a, T> {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SocketCred(libc::ucred);
|
pub struct SocketCred(libc::ucred);
|
||||||
|
|
||||||
#[cfg(target_os = "dragonfly")]
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct SocketCred(libc::cmsgcred);
|
|
||||||
|
|
||||||
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
|
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
|
||||||
impl SocketCred {
|
impl SocketCred {
|
||||||
/// Create a Unix credential struct.
|
/// Create a Unix credential struct.
|
||||||
|
@ -241,57 +234,6 @@ impl SocketCred {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "dragonfly")]
|
|
||||||
impl SocketCred {
|
|
||||||
/// Create a Unix credential struct.
|
|
||||||
///
|
|
||||||
/// PID, UID and GID is set to 0.
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
#[must_use]
|
|
||||||
pub fn new() -> SocketCred {
|
|
||||||
SocketCred(libc::cmsgcred { cmsgcred_pid: 0, cmsgcred_uid: 0, cmsgcred_gid: 0 })
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set the PID.
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
pub fn set_pid(&mut self, pid: libc::pid_t) {
|
|
||||||
self.0.cmsgcred_pid = pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the current PID.
|
|
||||||
#[must_use]
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
pub fn get_pid(&self) -> libc::pid_t {
|
|
||||||
self.0.cmsgcred_pid
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set the UID.
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
pub fn set_uid(&mut self, uid: libc::uid_t) {
|
|
||||||
self.0.cmsgcred_uid = uid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the current UID.
|
|
||||||
#[must_use]
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
pub fn get_uid(&self) -> libc::uid_t {
|
|
||||||
self.0.cmsgcred_uid
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set the GID.
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
pub fn set_gid(&mut self, gid: libc::gid_t) {
|
|
||||||
self.0.cmsgcred_gid = gid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the current GID.
|
|
||||||
#[must_use]
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
pub fn get_gid(&self) -> libc::gid_t {
|
|
||||||
self.0.cmsgcred_gid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This control message contains file descriptors.
|
/// This control message contains file descriptors.
|
||||||
///
|
///
|
||||||
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_RIGHTS`.
|
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_RIGHTS`.
|
||||||
|
@ -314,11 +256,7 @@ impl<'a> Iterator for ScmRights<'a> {
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
||||||
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::ucred>);
|
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::ucred>);
|
||||||
|
|
||||||
#[cfg(target_os = "dragonfly")]
|
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::cmsgcred>);
|
|
||||||
|
|
||||||
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly",))]
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
||||||
impl<'a> Iterator for ScmCredentials<'a> {
|
impl<'a> Iterator for ScmCredentials<'a> {
|
||||||
type Item = SocketCred;
|
type Item = SocketCred;
|
||||||
|
@ -362,7 +300,7 @@ impl<'a> AncillaryData<'a> {
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// `data` must contain a valid control message and the control message must be type of
|
/// `data` must contain a valid control message and the control message must be type of
|
||||||
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CREDS`.
|
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CREDENTIALS`.
|
||||||
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
|
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
|
||||||
unsafe fn as_credentials(data: &'a [u8]) -> Self {
|
unsafe fn as_credentials(data: &'a [u8]) -> Self {
|
||||||
let ancillary_data_iter = AncillaryDataIter::new(data);
|
let ancillary_data_iter = AncillaryDataIter::new(data);
|
||||||
|
@ -382,9 +320,6 @@ impl<'a> AncillaryData<'a> {
|
||||||
libc::SCM_RIGHTS => Ok(AncillaryData::as_rights(data)),
|
libc::SCM_RIGHTS => Ok(AncillaryData::as_rights(data)),
|
||||||
#[cfg(any(target_os = "android", target_os = "linux",))]
|
#[cfg(any(target_os = "android", target_os = "linux",))]
|
||||||
libc::SCM_CREDENTIALS => Ok(AncillaryData::as_credentials(data)),
|
libc::SCM_CREDENTIALS => Ok(AncillaryData::as_credentials(data)),
|
||||||
#[cfg(target_os = "dragonfly")]
|
|
||||||
libc::SCM_CREDS => Ok(AncillaryData::as_credentials(data)),
|
|
||||||
|
|
||||||
cmsg_type => {
|
cmsg_type => {
|
||||||
Err(AncillaryError::Unknown { cmsg_level: libc::SOL_SOCKET, cmsg_type })
|
Err(AncillaryError::Unknown { cmsg_level: libc::SOL_SOCKET, cmsg_type })
|
||||||
}
|
}
|
||||||
|
@ -609,19 +544,6 @@ impl<'a> SocketAncillary<'a> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "dragonfly")]
|
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
|
||||||
pub fn add_creds(&mut self, creds: &[SocketCred]) -> bool {
|
|
||||||
self.truncated = false;
|
|
||||||
add_to_ancillary_data(
|
|
||||||
&mut self.buffer,
|
|
||||||
&mut self.length,
|
|
||||||
creds,
|
|
||||||
libc::SOL_SOCKET,
|
|
||||||
libc::SCM_CREDS,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Clears the ancillary data, removing all values.
|
/// Clears the ancillary data, removing all values.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
|
|
|
@ -854,14 +854,8 @@ impl UnixDatagram {
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
#[cfg_attr(
|
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
|
||||||
any(target_os = "android", target_os = "linux", target_os = "dragonfly"),
|
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
|
||||||
doc = "```no_run"
|
|
||||||
)]
|
|
||||||
#[cfg_attr(
|
|
||||||
not(any(target_os = "android", target_os = "linux", target_os = "dragonfly")),
|
|
||||||
doc = "```ignore"
|
|
||||||
)]
|
|
||||||
/// #![feature(unix_socket_ancillary_data)]
|
/// #![feature(unix_socket_ancillary_data)]
|
||||||
/// use std::os::unix::net::UnixDatagram;
|
/// use std::os::unix::net::UnixDatagram;
|
||||||
///
|
///
|
||||||
|
@ -871,7 +865,7 @@ impl UnixDatagram {
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly",))]
|
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
||||||
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
|
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
|
||||||
self.0.set_passcred(passcred)
|
self.0.set_passcred(passcred)
|
||||||
|
@ -883,7 +877,7 @@ impl UnixDatagram {
|
||||||
/// Get the socket option `SO_PASSCRED`.
|
/// Get the socket option `SO_PASSCRED`.
|
||||||
///
|
///
|
||||||
/// [`set_passcred`]: UnixDatagram::set_passcred
|
/// [`set_passcred`]: UnixDatagram::set_passcred
|
||||||
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly",))]
|
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
|
||||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
||||||
pub fn passcred(&self) -> io::Result<bool> {
|
pub fn passcred(&self) -> io::Result<bool> {
|
||||||
self.0.passcred()
|
self.0.passcred()
|
||||||
|
|
|
@ -1600,7 +1600,6 @@ impl ExitStatusError {
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(exit_status_error)]
|
/// #![feature(exit_status_error)]
|
||||||
/// # if cfg!(unix) {
|
/// # if cfg!(unix) {
|
||||||
/// use std::convert::TryFrom;
|
|
||||||
/// use std::num::NonZeroI32;
|
/// use std::num::NonZeroI32;
|
||||||
/// use std::process::Command;
|
/// use std::process::Command;
|
||||||
///
|
///
|
||||||
|
|
|
@ -408,12 +408,12 @@ impl Socket {
|
||||||
Ok(raw != 0)
|
Ok(raw != 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonfly",))]
|
#[cfg(any(target_os = "android", target_os = "linux",))]
|
||||||
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
|
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
|
||||||
setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, passcred as libc::c_int)
|
setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, passcred as libc::c_int)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonfly",))]
|
#[cfg(any(target_os = "android", target_os = "linux",))]
|
||||||
pub fn passcred(&self) -> io::Result<bool> {
|
pub fn passcred(&self) -> io::Result<bool> {
|
||||||
let passcred: libc::c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED)?;
|
let passcred: libc::c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED)?;
|
||||||
Ok(passcred != 0)
|
Ok(passcred != 0)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use super::Builder;
|
use super::Builder;
|
||||||
use crate::any::Any;
|
use crate::any::Any;
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
|
use crate::panic::panic_any;
|
||||||
use crate::result;
|
use crate::result;
|
||||||
use crate::sync::{
|
use crate::sync::{
|
||||||
mpsc::{channel, Sender},
|
mpsc::{channel, Sender},
|
||||||
|
@ -183,7 +184,7 @@ fn test_simple_newsched_spawn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_try_panic_message_static_str() {
|
fn test_try_panic_message_string_literal() {
|
||||||
match thread::spawn(move || {
|
match thread::spawn(move || {
|
||||||
panic!("static string");
|
panic!("static string");
|
||||||
})
|
})
|
||||||
|
@ -199,9 +200,9 @@ fn test_try_panic_message_static_str() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_try_panic_message_owned_str() {
|
fn test_try_panic_any_message_owned_str() {
|
||||||
match thread::spawn(move || {
|
match thread::spawn(move || {
|
||||||
panic!("owned string".to_string());
|
panic_any("owned string".to_string());
|
||||||
})
|
})
|
||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
|
@ -215,9 +216,9 @@ fn test_try_panic_message_owned_str() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_try_panic_message_any() {
|
fn test_try_panic_any_message_any() {
|
||||||
match thread::spawn(move || {
|
match thread::spawn(move || {
|
||||||
panic!(box 413u16 as Box<dyn Any + Send>);
|
panic_any(box 413u16 as Box<dyn Any + Send>);
|
||||||
})
|
})
|
||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
|
@ -233,10 +234,10 @@ fn test_try_panic_message_any() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_try_panic_message_unit_struct() {
|
fn test_try_panic_any_message_unit_struct() {
|
||||||
struct Juju;
|
struct Juju;
|
||||||
|
|
||||||
match thread::spawn(move || panic!(Juju)).join() {
|
match thread::spawn(move || panic_any(Juju)).join() {
|
||||||
Err(ref e) if e.is::<Juju>() => {}
|
Err(ref e) if e.is::<Juju>() => {}
|
||||||
Err(_) | Ok(()) => panic!(),
|
Err(_) | Ok(()) => panic!(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
struct Bar<'a> {
|
struct Bar<'a> {
|
||||||
s: &'a String
|
s: &'a String,
|
||||||
|
// use wonky spaces to ensure we are creating the span correctly
|
||||||
|
longer_name: & 'a Vec<u8>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Bar<'a> {
|
impl<'a> Bar<'a> {
|
||||||
fn f(&mut self) {
|
fn f(&mut self) {
|
||||||
self.s.push('x');
|
self.s.push('x');
|
||||||
//~^ ERROR cannot borrow `*self.s` as mutable, as it is behind a `&` reference
|
//~^ ERROR cannot borrow `*self.s` as mutable, as it is behind a `&` reference
|
||||||
|
|
||||||
|
self.longer_name.push(13);
|
||||||
|
//~^ ERROR cannot borrow `*self.longer_name` as mutable, as it is behind a `&` reference
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,25 @@
|
||||||
error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/issue-38147-2.rs:7:9
|
--> $DIR/issue-38147-2.rs:9:9
|
||||||
|
|
|
|
||||||
LL | s: &'a String
|
|
||||||
| ---------- help: consider changing this to be mutable: `&'a mut String`
|
|
||||||
...
|
|
||||||
LL | self.s.push('x');
|
LL | self.s.push('x');
|
||||||
| ^^^^^^^^^^^^^^^^ cannot borrow as mutable
|
| ^^^^^^^^^^^^^^^^ cannot borrow as mutable
|
||||||
|
|
|
||||||
|
help: consider changing this to be mutable
|
||||||
|
|
|
||||||
|
LL | s: &'a mut String,
|
||||||
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0596]: cannot borrow `*self.longer_name` as mutable, as it is behind a `&` reference
|
||||||
|
--> $DIR/issue-38147-2.rs:12:9
|
||||||
|
|
|
||||||
|
LL | self.longer_name.push(13);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
|
||||||
|
|
|
||||||
|
help: consider changing this to be mutable
|
||||||
|
|
|
||||||
|
LL | longer_name: & 'a mut Vec<u8>
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0596`.
|
For more information about this error, try `rustc --explain E0596`.
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference
|
error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference
|
||||||
--> $DIR/issue-38147-3.rs:7:9
|
--> $DIR/issue-38147-3.rs:7:9
|
||||||
|
|
|
|
||||||
LL | s: &'a String
|
|
||||||
| ---------- help: consider changing this to be mutable: `&'a mut String`
|
|
||||||
...
|
|
||||||
LL | self.s.push('x');
|
LL | self.s.push('x');
|
||||||
| ^^^^^^^^^^^^^^^^ cannot borrow as mutable
|
| ^^^^^^^^^^^^^^^^ cannot borrow as mutable
|
||||||
|
|
|
||||||
|
help: consider changing this to be mutable
|
||||||
|
|
|
||||||
|
LL | s: &'a mut String
|
||||||
|
| +++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7d6fcbc0be2151bfa85ec146545b42d8be2fb28c
|
Subproject commit db2a7087b994e20f264f26ad6db75184282ad120
|
|
@ -23,8 +23,10 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Library crates are not yet ready to migrate to 2021.
|
// Not all library crates are ready to migrate to 2021.
|
||||||
if path.components().any(|c| c.as_os_str() == "library") {
|
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);
|
let has = contents.lines().any(is_edition_2018);
|
||||||
if !has {
|
if !has {
|
||||||
tidy_error!(
|
tidy_error!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue