Rollup merge of #127729 - compiler-errors:ed-2024-gen, r=oli-obk
Stop using the `gen` identifier in the compiler In preparation for edition 2024, this PR previews the fallout of removing usages of `gen` since it's being reserved as a keyword. There are two notable changes here: 1. Had to rename `fn gen(..)` in gen/kill analysis to `gen_`. Not certain there's a better name than that. 2. There are (false?[^1]) positives in `rustc_macros` when using synstructure, which uses `gen impl` to mark an implementation. We could suppress this in a one-off way, or perhaps just ignore `gen` in macros altogether, since if an identifier ends up in expanded code then it'll get properly denied anyways. Not relevant to the compiler, but it's gonna be really annoying to change `rand`'s `gen` fn in the library and miri... [^1]: I haven't looked at the synstructure proc macro code itself so I'm not certain if it'll start to fail when converted to ed2024 (or, e.g., when syn starts parsing `gen` as a kw).
This commit is contained in:
commit
3f13562acd
17 changed files with 79 additions and 68 deletions
|
@ -553,7 +553,7 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, '_, 'tcx> {
|
||||||
panic!("could not find BorrowIndex for location {location:?}");
|
panic!("could not find BorrowIndex for location {location:?}");
|
||||||
});
|
});
|
||||||
|
|
||||||
trans.gen(index);
|
trans.gen_(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure there are no remaining borrows for variables
|
// Make sure there are no remaining borrows for variables
|
||||||
|
|
|
@ -3218,10 +3218,10 @@ impl<'hir> Item<'hir> {
|
||||||
ItemKind::Static(ty, mutbl, body), (ty, *mutbl, *body);
|
ItemKind::Static(ty, mutbl, body), (ty, *mutbl, *body);
|
||||||
|
|
||||||
expect_const, (&'hir Ty<'hir>, &'hir Generics<'hir>, BodyId),
|
expect_const, (&'hir Ty<'hir>, &'hir Generics<'hir>, BodyId),
|
||||||
ItemKind::Const(ty, gen, body), (ty, gen, *body);
|
ItemKind::Const(ty, generics, body), (ty, generics, *body);
|
||||||
|
|
||||||
expect_fn, (&FnSig<'hir>, &'hir Generics<'hir>, BodyId),
|
expect_fn, (&FnSig<'hir>, &'hir Generics<'hir>, BodyId),
|
||||||
ItemKind::Fn(sig, gen, body), (sig, gen, *body);
|
ItemKind::Fn(sig, generics, body), (sig, generics, *body);
|
||||||
|
|
||||||
expect_macro, (&ast::MacroDef, MacroKind), ItemKind::Macro(def, mk), (def, *mk);
|
expect_macro, (&ast::MacroDef, MacroKind), ItemKind::Macro(def, mk), (def, *mk);
|
||||||
|
|
||||||
|
@ -3233,25 +3233,25 @@ impl<'hir> Item<'hir> {
|
||||||
expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm(asm), asm;
|
expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm(asm), asm;
|
||||||
|
|
||||||
expect_ty_alias, (&'hir Ty<'hir>, &'hir Generics<'hir>),
|
expect_ty_alias, (&'hir Ty<'hir>, &'hir Generics<'hir>),
|
||||||
ItemKind::TyAlias(ty, gen), (ty, gen);
|
ItemKind::TyAlias(ty, generics), (ty, generics);
|
||||||
|
|
||||||
expect_opaque_ty, &OpaqueTy<'hir>, ItemKind::OpaqueTy(ty), ty;
|
expect_opaque_ty, &OpaqueTy<'hir>, ItemKind::OpaqueTy(ty), ty;
|
||||||
|
|
||||||
expect_enum, (&EnumDef<'hir>, &'hir Generics<'hir>), ItemKind::Enum(def, gen), (def, gen);
|
expect_enum, (&EnumDef<'hir>, &'hir Generics<'hir>), ItemKind::Enum(def, generics), (def, generics);
|
||||||
|
|
||||||
expect_struct, (&VariantData<'hir>, &'hir Generics<'hir>),
|
expect_struct, (&VariantData<'hir>, &'hir Generics<'hir>),
|
||||||
ItemKind::Struct(data, gen), (data, gen);
|
ItemKind::Struct(data, generics), (data, generics);
|
||||||
|
|
||||||
expect_union, (&VariantData<'hir>, &'hir Generics<'hir>),
|
expect_union, (&VariantData<'hir>, &'hir Generics<'hir>),
|
||||||
ItemKind::Union(data, gen), (data, gen);
|
ItemKind::Union(data, generics), (data, generics);
|
||||||
|
|
||||||
expect_trait,
|
expect_trait,
|
||||||
(IsAuto, Safety, &'hir Generics<'hir>, GenericBounds<'hir>, &'hir [TraitItemRef]),
|
(IsAuto, Safety, &'hir Generics<'hir>, GenericBounds<'hir>, &'hir [TraitItemRef]),
|
||||||
ItemKind::Trait(is_auto, safety, gen, bounds, items),
|
ItemKind::Trait(is_auto, safety, generics, bounds, items),
|
||||||
(*is_auto, *safety, gen, bounds, items);
|
(*is_auto, *safety, generics, bounds, items);
|
||||||
|
|
||||||
expect_trait_alias, (&'hir Generics<'hir>, GenericBounds<'hir>),
|
expect_trait_alias, (&'hir Generics<'hir>, GenericBounds<'hir>),
|
||||||
ItemKind::TraitAlias(gen, bounds), (gen, bounds);
|
ItemKind::TraitAlias(generics, bounds), (generics, bounds);
|
||||||
|
|
||||||
expect_impl, &'hir Impl<'hir>, ItemKind::Impl(imp), imp;
|
expect_impl, &'hir Impl<'hir>, ItemKind::Impl(imp), imp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2554,7 +2554,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.and_then(|node| node.generics())
|
.and_then(|node| node.generics())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|generics| generics.params)
|
.flat_map(|generics| generics.params)
|
||||||
.find(|gen| &gen.def_id.to_def_id() == res_def_id)
|
.find(|param| ¶m.def_id.to_def_id() == res_def_id)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,8 @@ impl<'a> DiagnosticDerive<'a> {
|
||||||
});
|
});
|
||||||
|
|
||||||
// A lifetime of `'a` causes conflicts, but `_sess` is fine.
|
// A lifetime of `'a` causes conflicts, but `_sess` is fine.
|
||||||
|
// FIXME(edition_2024): Fix the `keyword_idents_2024` lint to not trigger here?
|
||||||
|
#[allow(keyword_idents_2024)]
|
||||||
let mut imp = structure.gen_impl(quote! {
|
let mut imp = structure.gen_impl(quote! {
|
||||||
gen impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for @Self
|
gen impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for @Self
|
||||||
where G: rustc_errors::EmissionGuarantee
|
where G: rustc_errors::EmissionGuarantee
|
||||||
|
@ -148,6 +150,8 @@ impl<'a> LintDiagnosticDerive<'a> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// FIXME(edition_2024): Fix the `keyword_idents_2024` lint to not trigger here?
|
||||||
|
#[allow(keyword_idents_2024)]
|
||||||
let mut imp = structure.gen_impl(quote! {
|
let mut imp = structure.gen_impl(quote! {
|
||||||
gen impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for @Self {
|
gen impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for @Self {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
|
|
@ -86,6 +86,9 @@ impl SubdiagnosticDerive {
|
||||||
|
|
||||||
let diag = &self.diag;
|
let diag = &self.diag;
|
||||||
let f = &self.f;
|
let f = &self.f;
|
||||||
|
|
||||||
|
// FIXME(edition_2024): Fix the `keyword_idents_2024` lint to not trigger here?
|
||||||
|
#[allow(keyword_idents_2024)]
|
||||||
let ret = structure.gen_impl(quote! {
|
let ret = structure.gen_impl(quote! {
|
||||||
gen impl rustc_errors::Subdiagnostic for @Self {
|
gen impl rustc_errors::Subdiagnostic for @Self {
|
||||||
fn add_to_diag_with<__G, __F>(
|
fn add_to_diag_with<__G, __F>(
|
||||||
|
@ -100,6 +103,7 @@ impl SubdiagnosticDerive {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1016,14 +1016,14 @@ macro_rules! extra_body_methods {
|
||||||
macro_rules! super_body {
|
macro_rules! super_body {
|
||||||
($self:ident, $body:ident, $($mutability:ident, $invalidate:tt)?) => {
|
($self:ident, $body:ident, $($mutability:ident, $invalidate:tt)?) => {
|
||||||
let span = $body.span;
|
let span = $body.span;
|
||||||
if let Some(gen) = &$($mutability)? $body.coroutine {
|
if let Some(coroutine) = &$($mutability)? $body.coroutine {
|
||||||
if let Some(yield_ty) = $(& $mutability)? gen.yield_ty {
|
if let Some(yield_ty) = $(& $mutability)? coroutine.yield_ty {
|
||||||
$self.visit_ty(
|
$self.visit_ty(
|
||||||
yield_ty,
|
yield_ty,
|
||||||
TyContext::YieldTy(SourceInfo::outermost(span))
|
TyContext::YieldTy(SourceInfo::outermost(span))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let Some(resume_ty) = $(& $mutability)? gen.resume_ty {
|
if let Some(resume_ty) = $(& $mutability)? coroutine.resume_ty {
|
||||||
$self.visit_ty(
|
$self.visit_ty(
|
||||||
resume_ty,
|
resume_ty,
|
||||||
TyContext::ResumeTy(SourceInfo::outermost(span))
|
TyContext::ResumeTy(SourceInfo::outermost(span))
|
||||||
|
|
|
@ -402,7 +402,7 @@ where
|
||||||
/// building up a `GenKillSet` and then throwing it away.
|
/// building up a `GenKillSet` and then throwing it away.
|
||||||
pub trait GenKill<T> {
|
pub trait GenKill<T> {
|
||||||
/// Inserts `elem` into the state vector.
|
/// Inserts `elem` into the state vector.
|
||||||
fn gen(&mut self, elem: T);
|
fn gen_(&mut self, elem: T);
|
||||||
|
|
||||||
/// Removes `elem` from the state vector.
|
/// Removes `elem` from the state vector.
|
||||||
fn kill(&mut self, elem: T);
|
fn kill(&mut self, elem: T);
|
||||||
|
@ -410,7 +410,7 @@ pub trait GenKill<T> {
|
||||||
/// Calls `gen` for each element in `elems`.
|
/// Calls `gen` for each element in `elems`.
|
||||||
fn gen_all(&mut self, elems: impl IntoIterator<Item = T>) {
|
fn gen_all(&mut self, elems: impl IntoIterator<Item = T>) {
|
||||||
for elem in elems {
|
for elem in elems {
|
||||||
self.gen(elem);
|
self.gen_(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,12 +424,12 @@ pub trait GenKill<T> {
|
||||||
|
|
||||||
/// Stores a transfer function for a gen/kill problem.
|
/// Stores a transfer function for a gen/kill problem.
|
||||||
///
|
///
|
||||||
/// Calling `gen`/`kill` on a `GenKillSet` will "build up" a transfer function so that it can be
|
/// Calling `gen_`/`kill` on a `GenKillSet` will "build up" a transfer function so that it can be
|
||||||
/// applied multiple times efficiently. When there are multiple calls to `gen` and/or `kill` for
|
/// applied multiple times efficiently. When there are multiple calls to `gen_` and/or `kill` for
|
||||||
/// the same element, the most recent one takes precedence.
|
/// the same element, the most recent one takes precedence.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct GenKillSet<T> {
|
pub struct GenKillSet<T> {
|
||||||
gen: HybridBitSet<T>,
|
gen_: HybridBitSet<T>,
|
||||||
kill: HybridBitSet<T>,
|
kill: HybridBitSet<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,31 +437,31 @@ impl<T: Idx> GenKillSet<T> {
|
||||||
/// Creates a new transfer function that will leave the dataflow state unchanged.
|
/// Creates a new transfer function that will leave the dataflow state unchanged.
|
||||||
pub fn identity(universe: usize) -> Self {
|
pub fn identity(universe: usize) -> Self {
|
||||||
GenKillSet {
|
GenKillSet {
|
||||||
gen: HybridBitSet::new_empty(universe),
|
gen_: HybridBitSet::new_empty(universe),
|
||||||
kill: HybridBitSet::new_empty(universe),
|
kill: HybridBitSet::new_empty(universe),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply(&self, state: &mut impl BitSetExt<T>) {
|
pub fn apply(&self, state: &mut impl BitSetExt<T>) {
|
||||||
state.union(&self.gen);
|
state.union(&self.gen_);
|
||||||
state.subtract(&self.kill);
|
state.subtract(&self.kill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Idx> GenKill<T> for GenKillSet<T> {
|
impl<T: Idx> GenKill<T> for GenKillSet<T> {
|
||||||
fn gen(&mut self, elem: T) {
|
fn gen_(&mut self, elem: T) {
|
||||||
self.gen.insert(elem);
|
self.gen_.insert(elem);
|
||||||
self.kill.remove(elem);
|
self.kill.remove(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kill(&mut self, elem: T) {
|
fn kill(&mut self, elem: T) {
|
||||||
self.kill.insert(elem);
|
self.kill.insert(elem);
|
||||||
self.gen.remove(elem);
|
self.gen_.remove(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Idx> GenKill<T> for BitSet<T> {
|
impl<T: Idx> GenKill<T> for BitSet<T> {
|
||||||
fn gen(&mut self, elem: T) {
|
fn gen_(&mut self, elem: T) {
|
||||||
self.insert(elem);
|
self.insert(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ impl<T: Idx> GenKill<T> for BitSet<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Idx> GenKill<T> for ChunkedBitSet<T> {
|
impl<T: Idx> GenKill<T> for ChunkedBitSet<T> {
|
||||||
fn gen(&mut self, elem: T) {
|
fn gen_(&mut self, elem: T) {
|
||||||
self.insert(elem);
|
self.insert(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,11 +481,11 @@ impl<T: Idx> GenKill<T> for ChunkedBitSet<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S: GenKill<T>> GenKill<T> for MaybeReachable<S> {
|
impl<T, S: GenKill<T>> GenKill<T> for MaybeReachable<S> {
|
||||||
fn gen(&mut self, elem: T) {
|
fn gen_(&mut self, elem: T) {
|
||||||
match self {
|
match self {
|
||||||
// If the state is not reachable, adding an element does nothing.
|
// If the state is not reachable, adding an element does nothing.
|
||||||
MaybeReachable::Unreachable => {}
|
MaybeReachable::Unreachable => {}
|
||||||
MaybeReachable::Reachable(set) => set.gen(elem),
|
MaybeReachable::Reachable(set) => set.gen_(elem),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ impl<T, S: GenKill<T>> GenKill<T> for MaybeReachable<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Idx> GenKill<T> for lattice::Dual<BitSet<T>> {
|
impl<T: Idx> GenKill<T> for lattice::Dual<BitSet<T>> {
|
||||||
fn gen(&mut self, elem: T) {
|
fn gen_(&mut self, elem: T) {
|
||||||
self.0.insert(elem);
|
self.0.insert(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ where
|
||||||
Rvalue::AddressOf(_, borrowed_place)
|
Rvalue::AddressOf(_, borrowed_place)
|
||||||
| Rvalue::Ref(_, BorrowKind::Mut { .. } | BorrowKind::Shared, borrowed_place) => {
|
| Rvalue::Ref(_, BorrowKind::Mut { .. } | BorrowKind::Shared, borrowed_place) => {
|
||||||
if !borrowed_place.is_indirect() {
|
if !borrowed_place.is_indirect() {
|
||||||
self.trans.gen(borrowed_place.local);
|
self.trans.gen_(borrowed_place.local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ where
|
||||||
//
|
//
|
||||||
// [#61069]: https://github.com/rust-lang/rust/pull/61069
|
// [#61069]: https://github.com/rust-lang/rust/pull/61069
|
||||||
if !dropped_place.is_indirect() {
|
if !dropped_place.is_indirect() {
|
||||||
self.trans.gen(dropped_place.local);
|
self.trans.gen_(dropped_place.local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,8 +159,8 @@ pub fn borrowed_locals(body: &Body<'_>) -> BitSet<Local> {
|
||||||
|
|
||||||
impl GenKill<Local> for Borrowed {
|
impl GenKill<Local> for Borrowed {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn gen(&mut self, elem: Local) {
|
fn gen_(&mut self, elem: Local) {
|
||||||
self.0.gen(elem)
|
self.0.gen_(elem)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn kill(&mut self, _: Local) {
|
fn kill(&mut self, _: Local) {
|
||||||
|
|
|
@ -283,7 +283,7 @@ impl<'a, 'mir, 'tcx> MaybeInitializedPlaces<'a, 'mir, 'tcx> {
|
||||||
) {
|
) {
|
||||||
match state {
|
match state {
|
||||||
DropFlagState::Absent => trans.kill(path),
|
DropFlagState::Absent => trans.kill(path),
|
||||||
DropFlagState::Present => trans.gen(path),
|
DropFlagState::Present => trans.gen_(path),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ impl<'a, 'tcx> MaybeUninitializedPlaces<'a, '_, 'tcx> {
|
||||||
state: DropFlagState,
|
state: DropFlagState,
|
||||||
) {
|
) {
|
||||||
match state {
|
match state {
|
||||||
DropFlagState::Absent => trans.gen(path),
|
DropFlagState::Absent => trans.gen_(path),
|
||||||
DropFlagState::Present => trans.kill(path),
|
DropFlagState::Present => trans.kill(path),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
|
||||||
) {
|
) {
|
||||||
match state {
|
match state {
|
||||||
DropFlagState::Absent => trans.kill(path),
|
DropFlagState::Absent => trans.kill(path),
|
||||||
DropFlagState::Present => trans.gen(path),
|
DropFlagState::Present => trans.gen_(path),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
|
||||||
MaybeReachable::Reachable(ChunkedBitSet::new_empty(self.move_data().move_paths.len()));
|
MaybeReachable::Reachable(ChunkedBitSet::new_empty(self.move_data().move_paths.len()));
|
||||||
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
|
drop_flag_effects_for_function_entry(self.body, self.mdpe, |path, s| {
|
||||||
assert!(s == DropFlagState::Present);
|
assert!(s == DropFlagState::Present);
|
||||||
state.gen(path);
|
state.gen_(path);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
|
||||||
&& let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref())
|
&& let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref())
|
||||||
{
|
{
|
||||||
on_all_children_bits(self.move_data(), mpi, |child| {
|
on_all_children_bits(self.move_data(), mpi, |child| {
|
||||||
trans.gen(child);
|
trans.gen_(child);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
|
||||||
self.move_data(),
|
self.move_data(),
|
||||||
self.move_data().rev_lookup.find(place.as_ref()),
|
self.move_data().rev_lookup.find(place.as_ref()),
|
||||||
|mpi| {
|
|mpi| {
|
||||||
trans.gen(mpi);
|
trans.gen_(mpi);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -572,7 +572,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> {
|
||||||
self.move_data(),
|
self.move_data(),
|
||||||
enum_place,
|
enum_place,
|
||||||
variant,
|
variant,
|
||||||
|mpi| trans.gen(mpi),
|
|mpi| trans.gen_(mpi),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -643,7 +643,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
|
||||||
self.move_data(),
|
self.move_data(),
|
||||||
self.move_data().rev_lookup.find(place.as_ref()),
|
self.move_data().rev_lookup.find(place.as_ref()),
|
||||||
|mpi| {
|
|mpi| {
|
||||||
trans.gen(mpi);
|
trans.gen_(mpi);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -738,7 +738,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, '_, 'tcx> {
|
||||||
|
|
||||||
let call_loc = self.body.terminator_loc(block);
|
let call_loc = self.body.terminator_loc(block);
|
||||||
for init_index in &init_loc_map[call_loc] {
|
for init_index in &init_loc_map[call_loc] {
|
||||||
trans.gen(*init_index);
|
trans.gen_(*init_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ where
|
||||||
self.0.kill(place.local);
|
self.0.kill(place.local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(DefUse::Use) => self.0.gen(place.local),
|
Some(DefUse::Use) => self.0.gen_(place.local),
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ impl DefUse {
|
||||||
fn apply(trans: &mut impl GenKill<Local>, place: Place<'_>, context: PlaceContext) {
|
fn apply(trans: &mut impl GenKill<Local>, place: Place<'_>, context: PlaceContext) {
|
||||||
match DefUse::for_place(place, context) {
|
match DefUse::for_place(place, context) {
|
||||||
Some(DefUse::Def) => trans.kill(place.local),
|
Some(DefUse::Def) => trans.kill(place.local),
|
||||||
Some(DefUse::Use) => trans.gen(place.local),
|
Some(DefUse::Use) => trans.gen_(place.local),
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ impl<'tcx, 'a> crate::GenKillAnalysis<'tcx> for MaybeStorageLive<'a> {
|
||||||
_: Location,
|
_: Location,
|
||||||
) {
|
) {
|
||||||
match stmt.kind {
|
match stmt.kind {
|
||||||
StatementKind::StorageLive(l) => trans.gen(l),
|
StatementKind::StorageLive(l) => trans.gen_(l),
|
||||||
StatementKind::StorageDead(l) => trans.kill(l),
|
StatementKind::StorageDead(l) => trans.kill(l),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ impl<'tcx, 'a> crate::GenKillAnalysis<'tcx> for MaybeStorageDead<'a> {
|
||||||
) {
|
) {
|
||||||
match stmt.kind {
|
match stmt.kind {
|
||||||
StatementKind::StorageLive(l) => trans.kill(l),
|
StatementKind::StorageLive(l) => trans.kill(l),
|
||||||
StatementKind::StorageDead(l) => trans.gen(l),
|
StatementKind::StorageDead(l) => trans.gen_(l),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
|
||||||
StatementKind::Assign(box (place, _))
|
StatementKind::Assign(box (place, _))
|
||||||
| StatementKind::SetDiscriminant { box place, .. }
|
| StatementKind::SetDiscriminant { box place, .. }
|
||||||
| StatementKind::Deinit(box place) => {
|
| StatementKind::Deinit(box place) => {
|
||||||
trans.gen(place.local);
|
trans.gen_(place.local);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing to do for these. Match exhaustively so this fails to compile when new
|
// Nothing to do for these. Match exhaustively so this fails to compile when new
|
||||||
|
@ -250,7 +250,7 @@ impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
|
||||||
|
|
||||||
match &terminator.kind {
|
match &terminator.kind {
|
||||||
TerminatorKind::Call { destination, .. } => {
|
TerminatorKind::Call { destination, .. } => {
|
||||||
trans.gen(destination.local);
|
trans.gen_(destination.local);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that we do *not* gen the `resume_arg` of `Yield` terminators. The reason for
|
// Note that we do *not* gen the `resume_arg` of `Yield` terminators. The reason for
|
||||||
|
@ -265,7 +265,7 @@ impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
|
||||||
InlineAsmOperand::Out { place, .. }
|
InlineAsmOperand::Out { place, .. }
|
||||||
| InlineAsmOperand::InOut { out_place: place, .. } => {
|
| InlineAsmOperand::InOut { out_place: place, .. } => {
|
||||||
if let Some(place) = place {
|
if let Some(place) = place {
|
||||||
trans.gen(place.local);
|
trans.gen_(place.local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InlineAsmOperand::In { .. }
|
InlineAsmOperand::In { .. }
|
||||||
|
@ -341,7 +341,7 @@ impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
|
||||||
_block: BasicBlock,
|
_block: BasicBlock,
|
||||||
return_places: CallReturnPlaces<'_, 'tcx>,
|
return_places: CallReturnPlaces<'_, 'tcx>,
|
||||||
) {
|
) {
|
||||||
return_places.for_each(|place| trans.gen(place.local));
|
return_places.for_each(|place| trans.gen_(place.local));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1998,6 +1998,9 @@ impl<'a> Builder<'a> {
|
||||||
if mode == Mode::Rustc {
|
if mode == Mode::Rustc {
|
||||||
rustflags.arg("-Zunstable-options");
|
rustflags.arg("-Zunstable-options");
|
||||||
rustflags.arg("-Wrustc::internal");
|
rustflags.arg("-Wrustc::internal");
|
||||||
|
// FIXME(edition_2024): Change this to `-Wrust_2024_idioms` when all
|
||||||
|
// of the individual lints are satisfied.
|
||||||
|
rustflags.arg("-Wkeyword_idents_2024");
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.config.rust_frame_pointers {
|
if self.config.rust_frame_pointers {
|
||||||
|
|
|
@ -1052,12 +1052,12 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib
|
||||||
for (pos, literal) in meta_item_list.iter().filter_map(|meta| meta.lit()).enumerate() {
|
for (pos, literal) in meta_item_list.iter().filter_map(|meta| meta.lit()).enumerate() {
|
||||||
match literal.kind {
|
match literal.kind {
|
||||||
ast::LitKind::Int(a, _) => {
|
ast::LitKind::Int(a, _) => {
|
||||||
let gen = func.generics.params.remove(0);
|
let param = func.generics.params.remove(0);
|
||||||
if let GenericParamDef {
|
if let GenericParamDef {
|
||||||
name,
|
name,
|
||||||
kind: GenericParamDefKind::Const { ty, .. },
|
kind: GenericParamDefKind::Const { ty, .. },
|
||||||
..
|
..
|
||||||
} = gen
|
} = param
|
||||||
{
|
{
|
||||||
func.decl
|
func.decl
|
||||||
.inputs
|
.inputs
|
||||||
|
|
|
@ -1051,7 +1051,7 @@ fn simplify_fn_type<'tcx, 'a>(
|
||||||
let mut ty_generics = Vec::new();
|
let mut ty_generics = Vec::new();
|
||||||
let mut ty_constraints = Vec::new();
|
let mut ty_constraints = Vec::new();
|
||||||
if let Some(arg_generics) = arg.generic_args() {
|
if let Some(arg_generics) = arg.generic_args() {
|
||||||
for ty in arg_generics.into_iter().filter_map(|gen| match gen {
|
for ty in arg_generics.into_iter().filter_map(|param| match param {
|
||||||
clean::GenericArg::Type(ty) => Some(ty),
|
clean::GenericArg::Type(ty) => Some(ty),
|
||||||
_ => None,
|
_ => None,
|
||||||
}) {
|
}) {
|
||||||
|
@ -1172,8 +1172,8 @@ fn simplify_fn_constraint<'tcx, 'a>(
|
||||||
) {
|
) {
|
||||||
let mut ty_constraints = Vec::new();
|
let mut ty_constraints = Vec::new();
|
||||||
let ty_constrained_assoc = RenderTypeId::AssociatedType(constraint.assoc.name);
|
let ty_constrained_assoc = RenderTypeId::AssociatedType(constraint.assoc.name);
|
||||||
for gen in &constraint.assoc.args {
|
for param in &constraint.assoc.args {
|
||||||
match gen {
|
match param {
|
||||||
clean::GenericArg::Type(arg) => simplify_fn_type(
|
clean::GenericArg::Type(arg) => simplify_fn_type(
|
||||||
self_,
|
self_,
|
||||||
generics,
|
generics,
|
||||||
|
|
|
@ -364,8 +364,8 @@ declare_lint_pass!(MiscEarlyLints => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
impl EarlyLintPass for MiscEarlyLints {
|
impl EarlyLintPass for MiscEarlyLints {
|
||||||
fn check_generics(&mut self, cx: &EarlyContext<'_>, gen: &Generics) {
|
fn check_generics(&mut self, cx: &EarlyContext<'_>, generics: &Generics) {
|
||||||
for param in &gen.params {
|
for param in &generics.params {
|
||||||
builtin_type_shadow::check(cx, param);
|
builtin_type_shadow::check(cx, param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,9 +102,9 @@ impl TraitBounds {
|
||||||
impl_lint_pass!(TraitBounds => [TYPE_REPETITION_IN_BOUNDS, TRAIT_DUPLICATION_IN_BOUNDS]);
|
impl_lint_pass!(TraitBounds => [TYPE_REPETITION_IN_BOUNDS, TRAIT_DUPLICATION_IN_BOUNDS]);
|
||||||
|
|
||||||
impl<'tcx> LateLintPass<'tcx> for TraitBounds {
|
impl<'tcx> LateLintPass<'tcx> for TraitBounds {
|
||||||
fn check_generics(&mut self, cx: &LateContext<'tcx>, gen: &'tcx Generics<'_>) {
|
fn check_generics(&mut self, cx: &LateContext<'tcx>, generics: &'tcx Generics<'_>) {
|
||||||
self.check_type_repetition(cx, gen);
|
self.check_type_repetition(cx, generics);
|
||||||
check_trait_bound_duplication(cx, gen);
|
check_trait_bound_duplication(cx, generics);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||||
|
@ -238,7 +238,7 @@ impl TraitBounds {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::mutable_key_type)]
|
#[allow(clippy::mutable_key_type)]
|
||||||
fn check_type_repetition<'tcx>(&self, cx: &LateContext<'tcx>, gen: &'tcx Generics<'_>) {
|
fn check_type_repetition<'tcx>(&self, cx: &LateContext<'tcx>, generics: &'tcx Generics<'_>) {
|
||||||
struct SpanlessTy<'cx, 'tcx> {
|
struct SpanlessTy<'cx, 'tcx> {
|
||||||
ty: &'tcx Ty<'tcx>,
|
ty: &'tcx Ty<'tcx>,
|
||||||
cx: &'cx LateContext<'tcx>,
|
cx: &'cx LateContext<'tcx>,
|
||||||
|
@ -258,12 +258,12 @@ impl TraitBounds {
|
||||||
}
|
}
|
||||||
impl Eq for SpanlessTy<'_, '_> {}
|
impl Eq for SpanlessTy<'_, '_> {}
|
||||||
|
|
||||||
if gen.span.from_expansion() {
|
if generics.span.from_expansion() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut map: UnhashMap<SpanlessTy<'_, '_>, Vec<&GenericBound<'_>>> = UnhashMap::default();
|
let mut map: UnhashMap<SpanlessTy<'_, '_>, Vec<&GenericBound<'_>>> = UnhashMap::default();
|
||||||
let mut applicability = Applicability::MaybeIncorrect;
|
let mut applicability = Applicability::MaybeIncorrect;
|
||||||
for bound in gen.predicates {
|
for bound in generics.predicates {
|
||||||
if let WherePredicate::BoundPredicate(ref p) = bound
|
if let WherePredicate::BoundPredicate(ref p) = bound
|
||||||
&& p.origin != PredicateOrigin::ImplTrait
|
&& p.origin != PredicateOrigin::ImplTrait
|
||||||
&& p.bounds.len() as u64 <= self.max_trait_bounds
|
&& p.bounds.len() as u64 <= self.max_trait_bounds
|
||||||
|
@ -301,8 +301,8 @@ impl TraitBounds {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
|
fn check_trait_bound_duplication(cx: &LateContext<'_>, generics: &'_ Generics<'_>) {
|
||||||
if gen.span.from_expansion() {
|
if generics.span.from_expansion() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
|
||||||
// |
|
// |
|
||||||
// collects each of these where clauses into a set keyed by generic name and comparable trait
|
// collects each of these where clauses into a set keyed by generic name and comparable trait
|
||||||
// eg. (T, Clone)
|
// eg. (T, Clone)
|
||||||
let where_predicates = gen
|
let where_predicates = generics
|
||||||
.predicates
|
.predicates
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|pred| {
|
.filter_map(|pred| {
|
||||||
|
@ -342,7 +342,7 @@ fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
|
||||||
// |
|
// |
|
||||||
// compare trait bounds keyed by generic name and comparable trait to collected where
|
// compare trait bounds keyed by generic name and comparable trait to collected where
|
||||||
// predicates eg. (T, Clone)
|
// predicates eg. (T, Clone)
|
||||||
for predicate in gen.predicates.iter().filter(|pred| !pred.in_where_clause()) {
|
for predicate in generics.predicates.iter().filter(|pred| !pred.in_where_clause()) {
|
||||||
if let WherePredicate::BoundPredicate(bound_predicate) = predicate
|
if let WherePredicate::BoundPredicate(bound_predicate) = predicate
|
||||||
&& bound_predicate.origin != PredicateOrigin::ImplTrait
|
&& bound_predicate.origin != PredicateOrigin::ImplTrait
|
||||||
&& !bound_predicate.span.from_expansion()
|
&& !bound_predicate.span.from_expansion()
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
|
||||||
bound
|
bound
|
||||||
.bound_generic_params
|
.bound_generic_params
|
||||||
.iter()
|
.iter()
|
||||||
.any(|gen| matches!(gen.kind, GenericParamKind::Lifetime { .. }))
|
.any(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
|
||||||
});
|
});
|
||||||
if has_lifetime_parameters {
|
if has_lifetime_parameters {
|
||||||
// complex trait bounds like A<'a, 'b>
|
// complex trait bounds like A<'a, 'b>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue