Skip to content

Commit de1ad34

Browse files
authored
Enable impl-trait-overcaptures 2024 transition lint (bytecodealliance#9965)
* Enable `impl-trait-overcaptures` 2024 transition lint This lint detects cases where returning `impl Trait` will work differently in 2024 than in the current 2021 edition. Ambiguities are resolved with `use<..>` syntax stabilized in Rust 1.82.0 to mean the same thing in both editions. * Fix some more `impl Trait` returns * Tighten bounds on settings `iter` * Fix build on 1.82.0 * Fix another capture on MSRV
1 parent e4b7637 commit de1ad34

File tree

24 files changed

+33
-28
lines changed

24 files changed

+33
-28
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ rust-2024-guarded-string-incompatible-syntax = 'warn'
189189
rust-2024-prelude-collisions = 'warn'
190190
rust-2024-incompatible-pat = 'warn'
191191
missing-unsafe-on-extern = 'warn'
192+
impl-trait-overcaptures = 'warn'
192193

193194
# Don't warn about unknown cfgs for pulley
194195
[workspace.lints.rust.unexpected_cfgs]

cranelift/codegen/meta/src/gen_settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn gen_iterator(group: &SettingGroup, fmt: &mut Formatter) {
7676
fmtln!(fmt, "impl Flags {");
7777
fmt.indent(|fmt| {
7878
fmt.doc_comment("Iterates the setting values.");
79-
fmtln!(fmt, "pub fn iter(&self) -> impl Iterator<Item = Value> {");
79+
fmtln!(fmt, "pub fn iter(&self) -> impl Iterator<Item = Value> + use<> {");
8080
fmt.indent(|fmt| {
8181
fmtln!(fmt, "let mut bytes = [0; {}];", group.settings_size);
8282
fmtln!(fmt, "bytes.copy_from_slice(&self.bytes[0..{}]);", group.settings_size);

cranelift/codegen/meta/src/pulley.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum Operand<'a> {
4747
}
4848

4949
impl Inst<'_> {
50-
fn operands(&self) -> impl Iterator<Item = Operand<'_>> {
50+
fn operands(&self) -> impl Iterator<Item = Operand<'_>> + use<'_> {
5151
self.fields
5252
.iter()
5353
.map(|(name, ty)| match (*name, *ty) {

cranelift/codegen/src/isa/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<T> IsaBuilder<T> {
211211
}
212212

213213
/// Iterates the available settings in the builder.
214-
pub fn iter(&self) -> impl Iterator<Item = settings::Setting> {
214+
pub fn iter(&self) -> impl Iterator<Item = settings::Setting> + use<T> {
215215
self.setup.iter()
216216
}
217217

cranelift/codegen/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl Builder {
167167
}
168168

169169
/// Iterates the available settings in the builder.
170-
pub fn iter(&self) -> impl Iterator<Item = Setting> {
170+
pub fn iter(&self) -> impl Iterator<Item = Setting> + use<> {
171171
let template = self.template;
172172

173173
template.descriptors.iter().map(move |d| {

crates/cranelift/src/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'a> Compilation<'a> {
147147
/// compilation.
148148
///
149149
/// Each function is additionally accompanied with its module index.
150-
fn indexes(&self) -> impl Iterator<Item = (StaticModuleIndex, DefinedFuncIndex)> + '_ {
150+
fn indexes(&self) -> impl Iterator<Item = (StaticModuleIndex, DefinedFuncIndex)> + use<'_> {
151151
self.translations
152152
.iter()
153153
.flat_map(|(i, t)| t.module.defined_func_indices().map(move |j| (i, j)))

crates/cranelift/src/debug/transform/expression.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl CompiledExpression {
244244
addr_tr: &'a AddressTransform,
245245
frame_info: Option<&'a FunctionFrameInfo>,
246246
isa: &'a dyn TargetIsa,
247-
) -> impl Iterator<Item = Result<(write::Address, u64, write::Expression)>> + 'a {
247+
) -> impl Iterator<Item = Result<(write::Address, u64, write::Expression)>> + use<'a> {
248248
enum BuildWithLocalsResult<'a> {
249249
Empty,
250250
Simple(
@@ -747,7 +747,7 @@ impl<'a, 'b> ValueLabelRangesBuilder<'a, 'b> {
747747
}
748748
}
749749

750-
pub fn into_ranges(self) -> impl Iterator<Item = CachedValueLabelRange> {
750+
pub fn into_ranges(self) -> impl Iterator<Item = CachedValueLabelRange> + use<> {
751751
// Ranges with not-enough labels are discarded.
752752
let processed_labels_len = self.processed_labels.len();
753753
self.ranges

crates/environ/src/compile/module_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl ModuleTypesBuilder {
308308
pub fn rec_group_elements(
309309
&self,
310310
rec_group: ModuleInternedRecGroupIndex,
311-
) -> impl ExactSizeIterator<Item = ModuleInternedTypeIndex> {
311+
) -> impl ExactSizeIterator<Item = ModuleInternedTypeIndex> + use<> {
312312
self.types.rec_group_elements(rec_group)
313313
}
314314

crates/environ/src/fact/trampoline.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,13 +3069,14 @@ impl<'a> Source<'a> {
30693069

30703070
impl<'a> Destination<'a> {
30713071
/// Same as `Source::record_field_srcs` but for destinations.
3072-
fn record_field_dsts<'b>(
3072+
fn record_field_dsts<'b, I>(
30733073
&'b self,
30743074
types: &'b ComponentTypesBuilder,
3075-
fields: impl IntoIterator<Item = InterfaceType> + 'b,
3076-
) -> impl Iterator<Item = Destination<'b>> + 'b
3075+
fields: I,
3076+
) -> impl Iterator<Item = Destination<'b>> + use<'b, I>
30773077
where
30783078
'a: 'b,
3079+
I: IntoIterator<Item = InterfaceType> + 'b,
30793080
{
30803081
let mut offset = 0;
30813082
fields.into_iter().map(move |ty| match self {

crates/environ/src/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl Module {
537537

538538
/// Returns an iterator over all of the defined function indices in this
539539
/// module.
540-
pub fn defined_func_indices(&self) -> impl Iterator<Item = DefinedFuncIndex> {
540+
pub fn defined_func_indices(&self) -> impl Iterator<Item = DefinedFuncIndex> + use<> {
541541
(0..self.functions.len() - self.num_imported_funcs).map(|i| DefinedFuncIndex::new(i))
542542
}
543543

0 commit comments

Comments
 (0)