From ac1d06712b2384c22301023549bae5dd41de6de3 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 22 Jul 2024 14:03:42 -0400 Subject: [PATCH 1/6] Set compiler crates to edition 2024 --- compiler/rustc/Cargo.toml | 4 +++- compiler/rustc_abi/Cargo.toml | 4 +++- compiler/rustc_arena/Cargo.toml | 4 +++- compiler/rustc_ast/Cargo.toml | 4 +++- compiler/rustc_ast_ir/Cargo.toml | 4 +++- compiler/rustc_ast_lowering/Cargo.toml | 4 +++- compiler/rustc_ast_passes/Cargo.toml | 4 +++- compiler/rustc_ast_pretty/Cargo.toml | 4 +++- compiler/rustc_attr/Cargo.toml | 4 +++- compiler/rustc_baked_icu_data/Cargo.toml | 4 +++- compiler/rustc_borrowck/Cargo.toml | 4 +++- compiler/rustc_builtin_macros/Cargo.toml | 4 +++- compiler/rustc_codegen_llvm/Cargo.toml | 4 +++- compiler/rustc_codegen_ssa/Cargo.toml | 4 +++- compiler/rustc_const_eval/Cargo.toml | 4 +++- compiler/rustc_data_structures/Cargo.toml | 4 +++- compiler/rustc_driver/Cargo.toml | 4 +++- compiler/rustc_driver_impl/Cargo.toml | 4 +++- compiler/rustc_error_codes/Cargo.toml | 4 +++- compiler/rustc_error_messages/Cargo.toml | 4 +++- compiler/rustc_errors/Cargo.toml | 4 +++- compiler/rustc_expand/Cargo.toml | 4 +++- compiler/rustc_feature/Cargo.toml | 4 +++- compiler/rustc_feature/src/tests.rs | 6 +++++- compiler/rustc_fluent_macro/Cargo.toml | 4 +++- compiler/rustc_fs_util/Cargo.toml | 4 +++- compiler/rustc_graphviz/Cargo.toml | 4 +++- compiler/rustc_hir/Cargo.toml | 4 +++- compiler/rustc_hir_analysis/Cargo.toml | 4 +++- compiler/rustc_hir_pretty/Cargo.toml | 4 +++- compiler/rustc_hir_typeck/Cargo.toml | 4 +++- compiler/rustc_incremental/Cargo.toml | 4 +++- compiler/rustc_index/Cargo.toml | 4 +++- compiler/rustc_index_macros/Cargo.toml | 4 +++- compiler/rustc_infer/Cargo.toml | 4 +++- compiler/rustc_interface/Cargo.toml | 4 +++- compiler/rustc_interface/src/passes.rs | 22 +++++++++++++-------- compiler/rustc_lexer/Cargo.toml | 4 +++- compiler/rustc_lint/Cargo.toml | 4 +++- compiler/rustc_lint_defs/Cargo.toml | 4 +++- compiler/rustc_llvm/Cargo.toml | 4 +++- compiler/rustc_llvm/build.rs | 10 ++++++++-- compiler/rustc_log/Cargo.toml | 4 +++- compiler/rustc_macros/Cargo.toml | 4 +++- compiler/rustc_metadata/Cargo.toml | 4 +++- compiler/rustc_middle/Cargo.toml | 4 +++- compiler/rustc_mir_build/Cargo.toml | 4 +++- compiler/rustc_mir_dataflow/Cargo.toml | 4 +++- compiler/rustc_mir_transform/Cargo.toml | 4 +++- compiler/rustc_monomorphize/Cargo.toml | 4 +++- compiler/rustc_next_trait_solver/Cargo.toml | 4 +++- compiler/rustc_parse/Cargo.toml | 4 +++- compiler/rustc_parse_format/Cargo.toml | 4 +++- compiler/rustc_passes/Cargo.toml | 4 +++- compiler/rustc_privacy/Cargo.toml | 4 +++- compiler/rustc_query_impl/Cargo.toml | 4 +++- compiler/rustc_query_system/Cargo.toml | 4 +++- compiler/rustc_resolve/Cargo.toml | 4 +++- compiler/rustc_sanitizers/Cargo.toml | 4 +++- compiler/rustc_serialize/Cargo.toml | 4 +++- compiler/rustc_session/Cargo.toml | 4 +++- compiler/rustc_smir/Cargo.toml | 4 +++- compiler/rustc_span/Cargo.toml | 4 +++- compiler/rustc_symbol_mangling/Cargo.toml | 4 +++- compiler/rustc_target/Cargo.toml | 4 +++- compiler/rustc_trait_selection/Cargo.toml | 4 +++- compiler/rustc_traits/Cargo.toml | 4 +++- compiler/rustc_transmute/Cargo.toml | 4 +++- compiler/rustc_ty_utils/Cargo.toml | 4 +++- compiler/rustc_type_ir/Cargo.toml | 4 +++- compiler/rustc_type_ir_macros/Cargo.toml | 4 +++- compiler/stable_mir/Cargo.toml | 4 +++- 72 files changed, 234 insertions(+), 80 deletions(-) diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml index a2fc9d5c408e3..cb33de6a14fd9 100644 --- a/compiler/rustc/Cargo.toml +++ b/compiler/rustc/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc-main" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_abi/Cargo.toml b/compiler/rustc_abi/Cargo.toml index 7448f066d0ac1..1a1ec228ae9e6 100644 --- a/compiler/rustc_abi/Cargo.toml +++ b/compiler/rustc_abi/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_abi" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_arena/Cargo.toml b/compiler/rustc_arena/Cargo.toml index 382ab2b077547..e5afc562f954f 100644 --- a/compiler/rustc_arena/Cargo.toml +++ b/compiler/rustc_arena/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_arena" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ast/Cargo.toml b/compiler/rustc_ast/Cargo.toml index d33f9666b484c..e09da9a7149f4 100644 --- a/compiler/rustc_ast/Cargo.toml +++ b/compiler/rustc_ast/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_ast" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # FIXME: bumping memchr to 2.7.1 causes linker errors in MSVC thin-lto diff --git a/compiler/rustc_ast_ir/Cargo.toml b/compiler/rustc_ast_ir/Cargo.toml index 1905574073f13..a0a4b1caa5ae8 100644 --- a/compiler/rustc_ast_ir/Cargo.toml +++ b/compiler/rustc_ast_ir/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_ast_ir" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ast_lowering/Cargo.toml b/compiler/rustc_ast_lowering/Cargo.toml index 8cc4521e0a78d..2929f19019e9e 100644 --- a/compiler/rustc_ast_lowering/Cargo.toml +++ b/compiler/rustc_ast_lowering/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_ast_lowering" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] doctest = false diff --git a/compiler/rustc_ast_passes/Cargo.toml b/compiler/rustc_ast_passes/Cargo.toml index eace5ce820892..24e8553ef4eeb 100644 --- a/compiler/rustc_ast_passes/Cargo.toml +++ b/compiler/rustc_ast_passes/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_ast_passes" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ast_pretty/Cargo.toml b/compiler/rustc_ast_pretty/Cargo.toml index 9ae5c9b3cec6c..9e1883237c8e5 100644 --- a/compiler/rustc_ast_pretty/Cargo.toml +++ b/compiler/rustc_ast_pretty/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_ast_pretty" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_attr/Cargo.toml b/compiler/rustc_attr/Cargo.toml index 3b24452450abe..1858caa19cb7c 100644 --- a/compiler/rustc_attr/Cargo.toml +++ b/compiler/rustc_attr/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_attr" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_baked_icu_data/Cargo.toml b/compiler/rustc_baked_icu_data/Cargo.toml index e6cfb4887c911..2302a6ed389dc 100644 --- a/compiler/rustc_baked_icu_data/Cargo.toml +++ b/compiler/rustc_baked_icu_data/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_baked_icu_data" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_borrowck/Cargo.toml b/compiler/rustc_borrowck/Cargo.toml index bafc62c7318b4..448686abe9221 100644 --- a/compiler/rustc_borrowck/Cargo.toml +++ b/compiler/rustc_borrowck/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_borrowck" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_builtin_macros/Cargo.toml b/compiler/rustc_builtin_macros/Cargo.toml index 21b87be4b81d2..1f65bfc7e7b7b 100644 --- a/compiler/rustc_builtin_macros/Cargo.toml +++ b/compiler/rustc_builtin_macros/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_builtin_macros" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] doctest = false diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index a93baf88413a1..b358d4e0c571d 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_codegen_llvm" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] test = false diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index 3ab4cd0a0f53c..d743e1631665a 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_codegen_ssa" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_const_eval/Cargo.toml b/compiler/rustc_const_eval/Cargo.toml index c4f8841d71c63..07bff2327b92d 100644 --- a/compiler/rustc_const_eval/Cargo.toml +++ b/compiler/rustc_const_eval/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_const_eval" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index 38c6c8a8d11c7..92e4e67a38ae8 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_data_structures" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_driver/Cargo.toml b/compiler/rustc_driver/Cargo.toml index ae9712ad66d83..1e0cd55578099 100644 --- a/compiler/rustc_driver/Cargo.toml +++ b/compiler/rustc_driver/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_driver" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["dylib"] diff --git a/compiler/rustc_driver_impl/Cargo.toml b/compiler/rustc_driver_impl/Cargo.toml index 6d6d3f35a4b1b..1ea8072657046 100644 --- a/compiler/rustc_driver_impl/Cargo.toml +++ b/compiler/rustc_driver_impl/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_driver_impl" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_error_codes/Cargo.toml b/compiler/rustc_error_codes/Cargo.toml index de668b81b7e07..0cfb9d871f53b 100644 --- a/compiler/rustc_error_codes/Cargo.toml +++ b/compiler/rustc_error_codes/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_error_codes" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_error_messages/Cargo.toml b/compiler/rustc_error_messages/Cargo.toml index 5b6b8b3f183f4..d60c84b539813 100644 --- a/compiler/rustc_error_messages/Cargo.toml +++ b/compiler/rustc_error_messages/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_error_messages" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_errors/Cargo.toml b/compiler/rustc_errors/Cargo.toml index 59cf4e5f210b7..d33f8c728225c 100644 --- a/compiler/rustc_errors/Cargo.toml +++ b/compiler/rustc_errors/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_errors" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_expand/Cargo.toml b/compiler/rustc_expand/Cargo.toml index ce014364b0d01..bc4a2f9bd8502 100644 --- a/compiler/rustc_expand/Cargo.toml +++ b/compiler/rustc_expand/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_expand" version = "0.0.0" -edition = "2021" +edition = "2024" build = false [lib] diff --git a/compiler/rustc_feature/Cargo.toml b/compiler/rustc_feature/Cargo.toml index 9df320e1279ed..89695ded7eec8 100644 --- a/compiler/rustc_feature/Cargo.toml +++ b/compiler/rustc_feature/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_feature" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_feature/src/tests.rs b/compiler/rustc_feature/src/tests.rs index 50433e44b1350..f9dfa906512fd 100644 --- a/compiler/rustc_feature/src/tests.rs +++ b/compiler/rustc_feature/src/tests.rs @@ -2,8 +2,12 @@ use super::UnstableFeatures; #[test] fn rustc_bootstrap_parsing() { + // FIXME(edition_2024): Audit this for safety. This is probably racey, per: + // . let is_bootstrap = |env, krate| { - std::env::set_var("RUSTC_BOOTSTRAP", env); + unsafe { + std::env::set_var("RUSTC_BOOTSTRAP", env); + } matches!(UnstableFeatures::from_environment(krate), UnstableFeatures::Cheat) }; assert!(is_bootstrap("1", None)); diff --git a/compiler/rustc_fluent_macro/Cargo.toml b/compiler/rustc_fluent_macro/Cargo.toml index eeceaa4691a2a..5294052463f9d 100644 --- a/compiler/rustc_fluent_macro/Cargo.toml +++ b/compiler/rustc_fluent_macro/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_fluent_macro" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/compiler/rustc_fs_util/Cargo.toml b/compiler/rustc_fs_util/Cargo.toml index 4b76200c06c53..a0d0b0d634ee6 100644 --- a/compiler/rustc_fs_util/Cargo.toml +++ b/compiler/rustc_fs_util/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_fs_util" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_graphviz/Cargo.toml b/compiler/rustc_graphviz/Cargo.toml index 780004ae3fbc8..8e1b06a999126 100644 --- a/compiler/rustc_graphviz/Cargo.toml +++ b/compiler/rustc_graphviz/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_graphviz" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_hir/Cargo.toml b/compiler/rustc_hir/Cargo.toml index ac24c47d0b795..c0cd1dd29896f 100644 --- a/compiler/rustc_hir/Cargo.toml +++ b/compiler/rustc_hir/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_hir" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_hir_analysis/Cargo.toml b/compiler/rustc_hir_analysis/Cargo.toml index 04ca7f123d3e0..0ad0634b3df5f 100644 --- a/compiler/rustc_hir_analysis/Cargo.toml +++ b/compiler/rustc_hir_analysis/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_hir_analysis" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] test = false diff --git a/compiler/rustc_hir_pretty/Cargo.toml b/compiler/rustc_hir_pretty/Cargo.toml index aacf41b6eb737..a549abfacb1a9 100644 --- a/compiler/rustc_hir_pretty/Cargo.toml +++ b/compiler/rustc_hir_pretty/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_hir_pretty" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_hir_typeck/Cargo.toml b/compiler/rustc_hir_typeck/Cargo.toml index 73a775690d66b..9b7aa0790aae5 100644 --- a/compiler/rustc_hir_typeck/Cargo.toml +++ b/compiler/rustc_hir_typeck/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_hir_typeck" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_incremental/Cargo.toml b/compiler/rustc_incremental/Cargo.toml index 46a63b02e8469..ccef6efa99b0c 100644 --- a/compiler/rustc_incremental/Cargo.toml +++ b/compiler/rustc_incremental/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_incremental" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_index/Cargo.toml b/compiler/rustc_index/Cargo.toml index f7d18f84e3452..2c08573d7f448 100644 --- a/compiler/rustc_index/Cargo.toml +++ b/compiler/rustc_index/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_index" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_index_macros/Cargo.toml b/compiler/rustc_index_macros/Cargo.toml index 07ee81788ce46..82153883296e9 100644 --- a/compiler/rustc_index_macros/Cargo.toml +++ b/compiler/rustc_index_macros/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_index_macros" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/compiler/rustc_infer/Cargo.toml b/compiler/rustc_infer/Cargo.toml index 1f616710200f8..e0bc4d80c6cbe 100644 --- a/compiler/rustc_infer/Cargo.toml +++ b/compiler/rustc_infer/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_infer" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] doctest = false diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml index b5abf145d6b5b..61192b2e8c695 100644 --- a/compiler/rustc_interface/Cargo.toml +++ b/compiler/rustc_interface/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_interface" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index b93bc3ed84f54..a3b2b191c832f 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -182,13 +182,16 @@ fn configure_and_expand( new_path.push(path); } } - env::set_var( - "PATH", - &env::join_paths( - new_path.iter().filter(|p| env::join_paths(iter::once(p)).is_ok()), - ) - .unwrap(), - ); + // SAFETY: `set_var` is not racey on windows. + unsafe { + env::set_var( + "PATH", + &env::join_paths( + new_path.iter().filter(|p| env::join_paths(iter::once(p)).is_ok()), + ) + .unwrap(), + ); + } } // Create the config for macro expansion @@ -227,7 +230,10 @@ fn configure_and_expand( } if cfg!(windows) { - env::set_var("PATH", &old_path); + // SAFETY: `set_var` is not racey on windows. + unsafe { + env::set_var("PATH", &old_path); + } } krate diff --git a/compiler/rustc_lexer/Cargo.toml b/compiler/rustc_lexer/Cargo.toml index 84b9e29229553..1ae9d335d20db 100644 --- a/compiler/rustc_lexer/Cargo.toml +++ b/compiler/rustc_lexer/Cargo.toml @@ -1,8 +1,10 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_lexer" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" repository = "https://github.com/rust-lang/rust/" description = """ Rust lexer used by rustc. No stability guarantees are provided. diff --git a/compiler/rustc_lint/Cargo.toml b/compiler/rustc_lint/Cargo.toml index 232d4c18fa486..8db8284cff63f 100644 --- a/compiler/rustc_lint/Cargo.toml +++ b/compiler/rustc_lint/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_lint" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_lint_defs/Cargo.toml b/compiler/rustc_lint_defs/Cargo.toml index eb2a184ef84b1..197eae6b851be 100644 --- a/compiler/rustc_lint_defs/Cargo.toml +++ b/compiler/rustc_lint_defs/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_lint_defs" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_llvm/Cargo.toml b/compiler/rustc_llvm/Cargo.toml index 1f74aaf9965a7..9b71672297ffe 100644 --- a/compiler/rustc_llvm/Cargo.toml +++ b/compiler/rustc_llvm/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_llvm" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index f092110a324ec..633f4ee5fc6b1 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -51,9 +51,15 @@ fn detect_llvm_link() -> (&'static str, &'static str) { fn restore_library_path() { let key = tracked_env_var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR"); if let Some(env) = tracked_env_var_os("REAL_LIBRARY_PATH") { - env::set_var(&key, env); + // FIXME(edition_2024): Audit this for safety. + unsafe { + env::set_var(&key, env); + } } else { - env::remove_var(&key); + // FIXME(edition_2024): Audit this for safety. + unsafe { + env::remove_var(&key); + } } } diff --git a/compiler/rustc_log/Cargo.toml b/compiler/rustc_log/Cargo.toml index fe399bc77e32a..96aca2a8911f4 100644 --- a/compiler/rustc_log/Cargo.toml +++ b/compiler/rustc_log/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_log" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_macros/Cargo.toml b/compiler/rustc_macros/Cargo.toml index d8d2bef496404..054b7cf63b516 100644 --- a/compiler/rustc_macros/Cargo.toml +++ b/compiler/rustc_macros/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_macros" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/compiler/rustc_metadata/Cargo.toml b/compiler/rustc_metadata/Cargo.toml index 79d3482472a81..3a3a386f7210c 100644 --- a/compiler/rustc_metadata/Cargo.toml +++ b/compiler/rustc_metadata/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_metadata" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index b23589afb5874..bd6273b7cd66d 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_middle" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_mir_build/Cargo.toml b/compiler/rustc_mir_build/Cargo.toml index 529e9cc271136..1b23f6068d0ab 100644 --- a/compiler/rustc_mir_build/Cargo.toml +++ b/compiler/rustc_mir_build/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_mir_build" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_mir_dataflow/Cargo.toml b/compiler/rustc_mir_dataflow/Cargo.toml index 7199db677c464..a9ed5e019a8ec 100644 --- a/compiler/rustc_mir_dataflow/Cargo.toml +++ b/compiler/rustc_mir_dataflow/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_mir_dataflow" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_mir_transform/Cargo.toml b/compiler/rustc_mir_transform/Cargo.toml index 07ca51a67aefb..dfd159944909b 100644 --- a/compiler/rustc_mir_transform/Cargo.toml +++ b/compiler/rustc_mir_transform/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_mir_transform" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_monomorphize/Cargo.toml b/compiler/rustc_monomorphize/Cargo.toml index c7f1b9fa78454..38c54b58ba516 100644 --- a/compiler/rustc_monomorphize/Cargo.toml +++ b/compiler/rustc_monomorphize/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_monomorphize" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_next_trait_solver/Cargo.toml b/compiler/rustc_next_trait_solver/Cargo.toml index fdf44e1237815..d971da9082323 100644 --- a/compiler/rustc_next_trait_solver/Cargo.toml +++ b/compiler/rustc_next_trait_solver/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_next_trait_solver" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_parse/Cargo.toml b/compiler/rustc_parse/Cargo.toml index c59ae48a07d03..043682f9db27a 100644 --- a/compiler/rustc_parse/Cargo.toml +++ b/compiler/rustc_parse/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_parse" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_parse_format/Cargo.toml b/compiler/rustc_parse_format/Cargo.toml index 707c4e318474a..c074faff31e40 100644 --- a/compiler/rustc_parse_format/Cargo.toml +++ b/compiler/rustc_parse_format/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_parse_format" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_passes/Cargo.toml b/compiler/rustc_passes/Cargo.toml index b45a8dae277ed..164ff155b23b6 100644 --- a/compiler/rustc_passes/Cargo.toml +++ b/compiler/rustc_passes/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_passes" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_privacy/Cargo.toml b/compiler/rustc_privacy/Cargo.toml index f998e0ff1547f..e83b5db93c8a4 100644 --- a/compiler/rustc_privacy/Cargo.toml +++ b/compiler/rustc_privacy/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_privacy" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_query_impl/Cargo.toml b/compiler/rustc_query_impl/Cargo.toml index 2bb1be22b985d..715bf6cba34e7 100644 --- a/compiler/rustc_query_impl/Cargo.toml +++ b/compiler/rustc_query_impl/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_query_impl" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_query_system/Cargo.toml b/compiler/rustc_query_system/Cargo.toml index 2f42fa47728c0..acb0f43f7b69b 100644 --- a/compiler/rustc_query_system/Cargo.toml +++ b/compiler/rustc_query_system/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_query_system" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_resolve/Cargo.toml b/compiler/rustc_resolve/Cargo.toml index b71853b871dc5..f67c38a6971e6 100644 --- a/compiler/rustc_resolve/Cargo.toml +++ b/compiler/rustc_resolve/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_resolve" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_sanitizers/Cargo.toml b/compiler/rustc_sanitizers/Cargo.toml index aea2f7dda7f36..ff8c6ff294096 100644 --- a/compiler/rustc_sanitizers/Cargo.toml +++ b/compiler/rustc_sanitizers/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_sanitizers" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] bitflags = "2.5.0" diff --git a/compiler/rustc_serialize/Cargo.toml b/compiler/rustc_serialize/Cargo.toml index 8bf98c16361eb..5094072f4554f 100644 --- a/compiler/rustc_serialize/Cargo.toml +++ b/compiler/rustc_serialize/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_serialize" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index 721a9275d0188..00f3364f1e797 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_session" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_smir/Cargo.toml b/compiler/rustc_smir/Cargo.toml index 1230667ee910a..e9181490d0228 100644 --- a/compiler/rustc_smir/Cargo.toml +++ b/compiler/rustc_smir/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_smir" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_span/Cargo.toml b/compiler/rustc_span/Cargo.toml index 3fdfe77ead972..0f9c862c0d5f6 100644 --- a/compiler/rustc_span/Cargo.toml +++ b/compiler/rustc_span/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_span" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_symbol_mangling/Cargo.toml b/compiler/rustc_symbol_mangling/Cargo.toml index 65aa9e40c8ba3..0bdfc06f62182 100644 --- a/compiler/rustc_symbol_mangling/Cargo.toml +++ b/compiler/rustc_symbol_mangling/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_symbol_mangling" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_target/Cargo.toml b/compiler/rustc_target/Cargo.toml index c7d24154e8bd4..9d7dc99023e1a 100644 --- a/compiler/rustc_target/Cargo.toml +++ b/compiler/rustc_target/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_target" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_trait_selection/Cargo.toml b/compiler/rustc_trait_selection/Cargo.toml index f023a0eb53aeb..f56e3cbae0805 100644 --- a/compiler/rustc_trait_selection/Cargo.toml +++ b/compiler/rustc_trait_selection/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_trait_selection" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 9c788116d98c3..cfe14d1490a68 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_traits" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_transmute/Cargo.toml b/compiler/rustc_transmute/Cargo.toml index 4732e968f6b40..06b73235de1ae 100644 --- a/compiler/rustc_transmute/Cargo.toml +++ b/compiler/rustc_transmute/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_transmute" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ty_utils/Cargo.toml b/compiler/rustc_ty_utils/Cargo.toml index 01d5251bfa0cc..5ccb3e986c80a 100644 --- a/compiler/rustc_ty_utils/Cargo.toml +++ b/compiler/rustc_ty_utils/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_ty_utils" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_type_ir/Cargo.toml b/compiler/rustc_type_ir/Cargo.toml index 98cc116bd004d..1a8ec65923ba4 100644 --- a/compiler/rustc_type_ir/Cargo.toml +++ b/compiler/rustc_type_ir/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_type_ir" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_type_ir_macros/Cargo.toml b/compiler/rustc_type_ir_macros/Cargo.toml index cb95ca6834623..7bd89b3757305 100644 --- a/compiler/rustc_type_ir_macros/Cargo.toml +++ b/compiler/rustc_type_ir_macros/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "rustc_type_ir_macros" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/compiler/stable_mir/Cargo.toml b/compiler/stable_mir/Cargo.toml index 2edb3f140d7ac..db33983b18beb 100644 --- a/compiler/stable_mir/Cargo.toml +++ b/compiler/stable_mir/Cargo.toml @@ -1,7 +1,9 @@ +cargo-features = ["edition2024"] + [package] name = "stable_mir" version = "0.1.0-preview" -edition = "2021" +edition = "2024" [dependencies] scoped-tls = "1.0" From f7c859be50c98a7620768707f8fc7229e53fa2dd Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 22 Jul 2024 14:22:57 -0400 Subject: [PATCH 2/6] Remove unncessary outlives and captures from RPITs --- compiler/rustc_abi/src/lib.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 5 ++-- compiler/rustc_attr/src/builtin.rs | 6 ++--- compiler/rustc_borrowck/src/borrow_set.rs | 2 +- .../src/diagnostics/conflict_errors.rs | 3 +-- .../rustc_borrowck/src/member_constraints.rs | 7 ++---- .../rustc_borrowck/src/region_infer/mod.rs | 6 ++--- .../src/region_infer/reverse_sccs.rs | 2 +- .../rustc_borrowck/src/region_infer/values.rs | 17 ++++++------- .../src/type_check/free_region_relations.rs | 2 +- .../src/type_check/liveness/local_use_map.rs | 8 +++---- .../rustc_borrowck/src/universal_regions.rs | 4 ++-- .../src/coverageinfo/map_data.rs | 5 ++-- compiler/rustc_codegen_ssa/src/mir/locals.rs | 2 +- .../src/graph/implementation/mod.rs | 8 +++---- .../src/graph/scc/mod.rs | 2 +- .../src/sorted_map/index_map.rs | 8 +++---- compiler/rustc_data_structures/src/sso/map.rs | 2 +- compiler/rustc_data_structures/src/sso/set.rs | 2 +- .../rustc_data_structures/src/sync/vec.rs | 4 ++-- .../src/transitive_relation.rs | 2 +- compiler/rustc_expand/src/proc_macro.rs | 2 +- compiler/rustc_hir/src/definitions.rs | 2 +- compiler/rustc_hir/src/lang_items.rs | 2 +- compiler/rustc_hir_analysis/src/bounds.rs | 4 ++-- compiler/rustc_hir_analysis/src/collect.rs | 3 +-- .../rustc_hir_analysis/src/variance/mod.rs | 7 ++---- compiler/rustc_hir_typeck/src/lib.rs | 2 +- compiler/rustc_index/src/bit_set.rs | 2 +- compiler/rustc_index/src/interval.rs | 4 ++-- compiler/rustc_index/src/slice.rs | 6 ++--- compiler/rustc_index/src/vec.rs | 4 ++-- .../src/infer/canonical/query_response.rs | 3 +-- .../rustc_infer/src/infer/free_regions.rs | 2 +- compiler/rustc_infer/src/infer/mod.rs | 5 ++-- .../rustc_infer/src/infer/outlives/mod.rs | 2 +- compiler/rustc_lexer/src/lib.rs | 2 +- compiler/rustc_lint/src/context.rs | 6 ++--- compiler/rustc_metadata/src/rmeta/decoder.rs | 24 ++++++++----------- compiler/rustc_middle/src/hir/map/mod.rs | 10 ++++---- compiler/rustc_middle/src/hir/mod.rs | 12 +++++----- compiler/rustc_middle/src/hir/place.rs | 2 +- .../interpret/allocation/provenance_map.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 9 +++---- compiler/rustc_middle/src/mir/pretty.rs | 2 +- compiler/rustc_middle/src/mir/terminator.rs | 4 ++-- compiler/rustc_middle/src/mir/traversal.rs | 2 +- compiler/rustc_middle/src/ty/adt.rs | 3 +-- compiler/rustc_middle/src/ty/assoc.rs | 7 ++---- compiler/rustc_middle/src/ty/closure.rs | 3 +-- compiler/rustc_middle/src/ty/context.rs | 8 +++---- compiler/rustc_middle/src/ty/generic_args.rs | 8 +++---- compiler/rustc_middle/src/ty/mod.rs | 4 ++-- compiler/rustc_middle/src/ty/predicate.rs | 9 +++---- compiler/rustc_middle/src/ty/sty.rs | 5 ++-- compiler/rustc_middle/src/ty/trait_def.rs | 4 ++-- .../src/build/expr/as_place.rs | 2 +- compiler/rustc_mir_build/src/thir/cx/mod.rs | 2 +- .../rustc_mir_dataflow/src/move_paths/mod.rs | 6 ++--- compiler/rustc_mir_dataflow/src/un_derefer.rs | 2 +- .../rustc_mir_dataflow/src/value_analysis.rs | 6 +---- compiler/rustc_mir_transform/src/coroutine.rs | 2 +- .../src/coverage/counters.rs | 3 +-- .../rustc_mir_transform/src/coverage/graph.rs | 3 +-- .../rustc_mir_transform/src/coverage/query.rs | 3 +-- .../rustc_mir_transform/src/coverage/spans.rs | 3 +-- .../rustc_mir_transform/src/jump_threading.rs | 4 ++-- compiler/rustc_mir_transform/src/sroa.rs | 2 +- compiler/rustc_mir_transform/src/ssa.rs | 2 +- compiler/rustc_parse/src/parser/mod.rs | 2 +- compiler/rustc_pattern_analysis/src/lib.rs | 2 +- .../rustc_pattern_analysis/src/pat_column.rs | 2 +- compiler/rustc_pattern_analysis/src/rustc.rs | 3 +-- .../rustc_pattern_analysis/src/usefulness.rs | 2 +- .../tests/common/mod.rs | 3 +-- .../src/dep_graph/serialized.rs | 2 +- compiler/rustc_session/src/parse.rs | 2 +- .../error_reporting/infer/need_type_info.rs | 2 +- .../src/solve/fulfill.rs | 2 +- .../src/traits/fulfill.rs | 3 +-- .../src/traits/object_safety.rs | 2 +- .../src/traits/outlives_bounds.rs | 4 ++-- .../traits/specialize/specialization_graph.rs | 7 ++---- .../src/traits/vtable.rs | 2 +- compiler/rustc_ty_utils/src/implied_bounds.rs | 4 ++-- .../rustc_ty_utils/src/layout_sanity_check.rs | 2 +- compiler/rustc_ty_utils/src/needs_drop.rs | 2 +- compiler/stable_mir/src/mir/body.rs | 2 +- compiler/stable_mir/src/ty.rs | 2 +- 89 files changed, 160 insertions(+), 207 deletions(-) diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 7bd2507d1ade6..10c414286fde0 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1297,7 +1297,7 @@ impl FieldsShape { /// Gets source indices of the fields by increasing offsets. #[inline] - pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator + '_ { + pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator { let mut inverse_small = [0u8; 64]; let mut inverse_big = IndexVec::new(); let use_small = self.count() <= inverse_small.len(); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index efd3ae336afb8..2efcfda9ddb94 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -45,7 +45,6 @@ use std::collections::hash_map::Entry; use rustc_ast::node_id::NodeMap; use rustc_ast::ptr::P; use rustc_ast::{self as ast, *}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::sorted_map::SortedMap; @@ -2078,7 +2077,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &'s mut self, params: &'s [GenericParam], source: hir::GenericParamSource, - ) -> impl Iterator> + Captures<'a> + Captures<'s> { + ) -> impl Iterator> { params.iter().map(move |param| self.lower_generic_param(param, source)) } @@ -2242,7 +2241,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &'s mut self, bounds: &'s [GenericBound], itctx: ImplTraitContext, - ) -> impl Iterator> + Captures<'s> + Captures<'a> { + ) -> impl Iterator> { bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx)) } diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 309049b98f0e2..a35ccb4332d42 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -1166,14 +1166,14 @@ pub fn find_transparency( pub fn allow_internal_unstable<'a>( sess: &'a Session, attrs: &'a [Attribute], -) -> impl Iterator + 'a { +) -> impl Iterator { allow_unstable(sess, attrs, sym::allow_internal_unstable) } pub fn rustc_allow_const_fn_unstable<'a>( sess: &'a Session, attrs: &'a [Attribute], -) -> impl Iterator + 'a { +) -> impl Iterator { allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable) } @@ -1181,7 +1181,7 @@ fn allow_unstable<'a>( sess: &'a Session, attrs: &'a [Attribute], symbol: Symbol, -) -> impl Iterator + 'a { +) -> impl Iterator { let attrs = attr::filter_by_name(attrs, symbol); let list = attrs .filter_map(move |attr| { diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs index fbda44550a19c..7ace011e6868b 100644 --- a/compiler/rustc_borrowck/src/borrow_set.rs +++ b/compiler/rustc_borrowck/src/borrow_set.rs @@ -160,7 +160,7 @@ impl<'tcx> BorrowSet<'tcx> { self.location_map.len() } - pub(crate) fn indices(&self) -> impl Iterator { + pub(crate) fn indices(&self) -> impl Iterator + 'static { BorrowIndex::ZERO..BorrowIndex::from_usize(self.len()) } diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index c7a5d516ad72d..115e078e45742 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -8,7 +8,6 @@ use std::ops::ControlFlow; use either::Either; use hir::{ClosureKind, Path}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::codes::*; use rustc_errors::{struct_span_code_err, Applicability, Diag, MultiSpan}; @@ -3556,7 +3555,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { fn predecessor_locations<'a, 'tcx>( body: &'a mir::Body<'tcx>, location: Location, - ) -> impl Iterator + Captures<'tcx> + 'a { + ) -> impl Iterator { if location.statement_index == 0 { let predecessors = body.basic_blocks.predecessors()[location.block].to_vec(); Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb))) diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs index fc621a3b8283d..a96982c48c0ce 100644 --- a/compiler/rustc_borrowck/src/member_constraints.rs +++ b/compiler/rustc_borrowck/src/member_constraints.rs @@ -1,7 +1,6 @@ use std::hash::Hash; use std::ops::Index; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexMap; use rustc_index::{IndexSlice, IndexVec}; use rustc_middle::infer::MemberConstraint; @@ -151,9 +150,7 @@ impl<'tcx, R> MemberConstraintSet<'tcx, R> where R: Copy + Hash + Eq, { - pub(crate) fn all_indices( - &self, - ) -> impl Iterator + Captures<'tcx> + '_ { + pub(crate) fn all_indices(&self) -> impl Iterator { self.constraints.indices() } @@ -163,7 +160,7 @@ where pub(crate) fn indices( &self, member_region_vid: R, - ) -> impl Iterator + Captures<'tcx> + '_ { + ) -> impl Iterator { let mut next = self.first_constraints.get(&member_region_vid).cloned(); std::iter::from_fn(move || -> Option { if let Some(current) = next { diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index d6bb006cd7e00..f062fa5463b4f 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -553,7 +553,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Returns an iterator over all the region indices. - pub fn regions(&self) -> impl Iterator + 'tcx { + pub fn regions(&self) -> impl Iterator { self.definitions.indices() } @@ -566,7 +566,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Returns an iterator over all the outlives constraints. - pub fn outlives_constraints(&self) -> impl Iterator> + '_ { + pub fn outlives_constraints(&self) -> impl Iterator> { self.constraints.outlives().iter().copied() } @@ -606,7 +606,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { pub(crate) fn placeholders_contained_in<'a>( &'a self, r: RegionVid, - ) -> impl Iterator + 'a { + ) -> impl Iterator { let scc = self.constraint_sccs.scc(r); self.scc_values.placeholders_contained_in(scc) } diff --git a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs index 3cc5fa4404e35..1e74e86876771 100644 --- a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs +++ b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs @@ -23,7 +23,7 @@ impl ReverseSccGraph { pub(super) fn upper_bounds<'a>( &'a self, scc0: ConstraintSccIndex, - ) -> impl Iterator + 'a { + ) -> impl Iterator { let mut duplicates = FxIndexSet::default(); graph::depth_first_search(&self.graph, scc0) .flat_map(move |scc1| { diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index 30dc062ae7cea..e02e407b4283b 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -100,7 +100,7 @@ impl LivenessValues { } /// Iterate through each region that has a value in this set. - pub(crate) fn regions(&self) -> impl Iterator + '_ { + pub(crate) fn regions(&self) -> impl Iterator { self.points.as_ref().expect("use with_specific_points").rows() } @@ -108,7 +108,7 @@ impl LivenessValues { // We are passing query instability implications to the caller. #[rustc_lint_query_instability] #[allow(rustc::potential_query_instability)] - pub(crate) fn live_regions_unordered(&self) -> impl Iterator + '_ { + pub(crate) fn live_regions_unordered(&self) -> impl Iterator { self.live_regions.as_ref().unwrap().iter().copied() } @@ -173,7 +173,7 @@ impl LivenessValues { } /// Returns an iterator of all the points where `region` is live. - fn live_points(&self, region: RegionVid) -> impl Iterator + '_ { + fn live_points(&self, region: RegionVid) -> impl Iterator { let Some(points) = &self.points else { unreachable!( "Should be using LivenessValues::with_specific_points to ask whether live at a location" @@ -359,7 +359,7 @@ impl RegionValues { } /// Returns the locations contained within a given region `r`. - pub(crate) fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator + 'a { + pub(crate) fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator { self.points.row(r).into_iter().flat_map(move |set| { set.iter() .take_while(move |&p| self.elements.point_in_range(p)) @@ -371,7 +371,7 @@ impl RegionValues { pub(crate) fn universal_regions_outlived_by<'a>( &'a self, r: N, - ) -> impl Iterator + 'a { + ) -> impl Iterator { self.free_regions.row(r).into_iter().flat_map(|set| set.iter()) } @@ -379,7 +379,7 @@ impl RegionValues { pub(crate) fn placeholders_contained_in<'a>( &'a self, r: N, - ) -> impl Iterator + 'a { + ) -> impl Iterator { self.placeholders .row(r) .into_iter() @@ -388,10 +388,7 @@ impl RegionValues { } /// Returns all the elements contained in a given region's value. - pub(crate) fn elements_contained_in<'a>( - &'a self, - r: N, - ) -> impl Iterator + 'a { + pub(crate) fn elements_contained_in<'a>(&'a self, r: N) -> impl Iterator { let points_iter = self.locations_outlived_by(r).map(RegionElement::Location); let free_regions_iter = diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index c711190cb97ab..c68a367b85159 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -176,7 +176,7 @@ impl UniversalRegionRelations<'_> { } /// Returns the _non-transitive_ set of known `outlives` constraints between free regions. - pub(crate) fn known_outlives(&self) -> impl Iterator + '_ { + pub(crate) fn known_outlives(&self) -> impl Iterator { self.outlives.base_edges() } } diff --git a/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs b/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs index ccd9fb25739cc..6f88d4eb05a73 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs @@ -54,7 +54,7 @@ rustc_index::newtype_index! { fn appearances_iter( first: Option, appearances: &Appearances, -) -> impl Iterator + '_ { +) -> impl Iterator { AppearancesIter { appearances, current: first } } @@ -107,17 +107,17 @@ impl LocalUseMap { local_use_map } - pub(crate) fn defs(&self, local: Local) -> impl Iterator + '_ { + pub(crate) fn defs(&self, local: Local) -> impl Iterator { appearances_iter(self.first_def_at[local], &self.appearances) .map(move |aa| self.appearances[aa].point_index) } - pub(crate) fn uses(&self, local: Local) -> impl Iterator + '_ { + pub(crate) fn uses(&self, local: Local) -> impl Iterator { appearances_iter(self.first_use_at[local], &self.appearances) .map(move |aa| self.appearances[aa].point_index) } - pub(crate) fn drops(&self, local: Local) -> impl Iterator + '_ { + pub(crate) fn drops(&self, local: Local) -> impl Iterator { appearances_iter(self.first_drop_at[local], &self.appearances) .map(move |aa| self.appearances[aa].point_index) } diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index c3edbcb50cc3d..4c3bf12227842 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -312,7 +312,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// Returns an iterator over all the RegionVids corresponding to /// universally quantified free regions. - pub(crate) fn universal_regions(&self) -> impl Iterator { + pub(crate) fn universal_regions(&self) -> impl Iterator + 'static { (FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize) } @@ -338,7 +338,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// Gets an iterator over all the early-bound regions that have names. pub(crate) fn named_universal_regions<'s>( &'s self, - ) -> impl Iterator, ty::RegionVid)> + 's { + ) -> impl Iterator, ty::RegionVid)> { self.indices.indices.iter().map(|(&r, &v)| (r, v)) } diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs index 5ed640b840e76..2402363967c68 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs @@ -1,4 +1,3 @@ -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexSet; use rustc_index::bit_set::BitSet; use rustc_middle::mir::coverage::{ @@ -200,7 +199,7 @@ impl<'tcx> FunctionCoverage<'tcx> { } /// Returns an iterator over all filenames used by this function's mappings. - pub(crate) fn all_file_names(&self) -> impl Iterator + Captures<'_> { + pub(crate) fn all_file_names(&self) -> impl Iterator { self.function_coverage_info.mappings.iter().map(|mapping| mapping.source_region.file_name) } @@ -208,7 +207,7 @@ impl<'tcx> FunctionCoverage<'tcx> { /// passed through FFI to LLVM. pub(crate) fn counter_expressions( &self, - ) -> impl Iterator + ExactSizeIterator + Captures<'_> { + ) -> impl Iterator + ExactSizeIterator { // We know that LLVM will optimize out any unused expressions before // producing the final coverage map, so there's no need to do the same // thing on the Rust side unless we're confident we can do much better. diff --git a/compiler/rustc_codegen_ssa/src/mir/locals.rs b/compiler/rustc_codegen_ssa/src/mir/locals.rs index 93f0ab36f2a2f..70f99ad985ac1 100644 --- a/compiler/rustc_codegen_ssa/src/mir/locals.rs +++ b/compiler/rustc_codegen_ssa/src/mir/locals.rs @@ -32,7 +32,7 @@ impl<'tcx, V> Locals<'tcx, V> { Locals { values: IndexVec::default() } } - pub(super) fn indices(&self) -> impl DoubleEndedIterator + Clone + 'tcx { + pub(super) fn indices(&self) -> impl DoubleEndedIterator + Clone + 'static { self.values.indices() } } diff --git a/compiler/rustc_data_structures/src/graph/implementation/mod.rs b/compiler/rustc_data_structures/src/graph/implementation/mod.rs index 43fdfe6ee0d73..5f9dcd492fd65 100644 --- a/compiler/rustc_data_structures/src/graph/implementation/mod.rs +++ b/compiler/rustc_data_structures/src/graph/implementation/mod.rs @@ -193,11 +193,11 @@ impl Graph { AdjacentEdges { graph: self, direction, next: first_edge } } - pub fn successor_nodes(&self, source: NodeIndex) -> impl Iterator + '_ { + pub fn successor_nodes(&self, source: NodeIndex) -> impl Iterator { self.outgoing_edges(source).targets() } - pub fn predecessor_nodes(&self, target: NodeIndex) -> impl Iterator + '_ { + pub fn predecessor_nodes(&self, target: NodeIndex) -> impl Iterator { self.incoming_edges(target).sources() } @@ -255,11 +255,11 @@ pub struct AdjacentEdges<'g, N, E> { } impl<'g, N: Debug, E: Debug> AdjacentEdges<'g, N, E> { - fn targets(self) -> impl Iterator + 'g { + fn targets(self) -> impl Iterator { self.map(|(_, edge)| edge.target) } - fn sources(self) -> impl Iterator + 'g { + fn sources(self) -> impl Iterator { self.map(|(_, edge)| edge.source) } } diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index 06fedef00fc3f..b472d8371e946 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -133,7 +133,7 @@ impl Sccs { /// meaning that if `S1 -> S2`, we will visit `S2` first and `S1` after. /// This is convenient when the edges represent dependencies: when you visit /// `S1`, the value for `S2` will already have been computed. - pub fn all_sccs(&self) -> impl Iterator { + pub fn all_sccs(&self) -> impl Iterator + 'static { (0..self.scc_data.len()).map(S::new) } diff --git a/compiler/rustc_data_structures/src/sorted_map/index_map.rs b/compiler/rustc_data_structures/src/sorted_map/index_map.rs index e9a5fb5197548..9c06540d47401 100644 --- a/compiler/rustc_data_structures/src/sorted_map/index_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map/index_map.rs @@ -63,13 +63,13 @@ impl SortedIndexMultiMap { /// Returns an iterator over the items in the map in insertion order. #[inline] - pub fn iter(&self) -> impl '_ + DoubleEndedIterator { + pub fn iter(&self) -> impl DoubleEndedIterator { self.items.iter().map(|(k, v)| (k, v)) } /// Returns an iterator over the items in the map in insertion order along with their indices. #[inline] - pub fn iter_enumerated(&self) -> impl '_ + DoubleEndedIterator { + pub fn iter_enumerated(&self) -> impl DoubleEndedIterator { self.items.iter_enumerated().map(|(i, (k, v))| (i, (k, v))) } @@ -84,7 +84,7 @@ impl SortedIndexMultiMap { /// If there are multiple items that are equivalent to `key`, they will be yielded in /// insertion order. #[inline] - pub fn get_by_key(&self, key: K) -> impl Iterator + '_ { + pub fn get_by_key(&self, key: K) -> impl Iterator { self.get_by_key_enumerated(key).map(|(_, v)| v) } @@ -94,7 +94,7 @@ impl SortedIndexMultiMap { /// If there are multiple items that are equivalent to `key`, they will be yielded in /// insertion order. #[inline] - pub fn get_by_key_enumerated(&self, key: K) -> impl Iterator + '_ { + pub fn get_by_key_enumerated(&self, key: K) -> impl Iterator { let lower_bound = self.idx_sorted_by_item_key.partition_point(|&i| self.items[i].0 < key); self.idx_sorted_by_item_key[lower_bound..].iter().map_while(move |&i| { let (k, v) = &self.items[i]; diff --git a/compiler/rustc_data_structures/src/sso/map.rs b/compiler/rustc_data_structures/src/sso/map.rs index 3200249a2dc4c..827c82fa46a11 100644 --- a/compiler/rustc_data_structures/src/sso/map.rs +++ b/compiler/rustc_data_structures/src/sso/map.rs @@ -165,7 +165,7 @@ impl SsoHashMap { /// Clears the map, returning all key-value pairs as an iterator. Keeps the /// allocated memory for reuse. - pub fn drain(&mut self) -> impl Iterator + '_ { + pub fn drain(&mut self) -> impl Iterator { match self { SsoHashMap::Array(array) => Either::Left(array.drain(..)), SsoHashMap::Map(map) => Either::Right(map.drain()), diff --git a/compiler/rustc_data_structures/src/sso/set.rs b/compiler/rustc_data_structures/src/sso/set.rs index a4b40138933de..e3fa1cbf4cc57 100644 --- a/compiler/rustc_data_structures/src/sso/set.rs +++ b/compiler/rustc_data_structures/src/sso/set.rs @@ -80,7 +80,7 @@ impl SsoHashSet { /// Clears the set, returning all elements in an iterator. #[inline] - pub fn drain(&mut self) -> impl Iterator + '_ { + pub fn drain(&mut self) -> impl Iterator { self.map.drain().map(entry_to_key) } } diff --git a/compiler/rustc_data_structures/src/sync/vec.rs b/compiler/rustc_data_structures/src/sync/vec.rs index 314496ce9f095..4586a51d674a1 100644 --- a/compiler/rustc_data_structures/src/sync/vec.rs +++ b/compiler/rustc_data_structures/src/sync/vec.rs @@ -62,14 +62,14 @@ impl AppendOnlyVec { self.vec.read().get(i).copied() } - pub fn iter_enumerated(&self) -> impl Iterator + '_ { + pub fn iter_enumerated(&self) -> impl Iterator { (0..) .map(|i| (i, self.get(i))) .take_while(|(_, o)| o.is_some()) .filter_map(|(i, o)| Some((i, o?))) } - pub fn iter(&self) -> impl Iterator + '_ { + pub fn iter(&self) -> impl Iterator { (0..).map(|i| self.get(i)).take_while(|o| o.is_some()).flatten() } } diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs index e81ebb9a4be22..33ac279f3e0ae 100644 --- a/compiler/rustc_data_structures/src/transitive_relation.rs +++ b/compiler/rustc_data_structures/src/transitive_relation.rs @@ -363,7 +363,7 @@ impl TransitiveRelation { /// Lists all the base edges in the graph: the initial _non-transitive_ set of element /// relations, which will be later used as the basis for the transitive closure computation. - pub fn base_edges(&self) -> impl Iterator + '_ { + pub fn base_edges(&self) -> impl Iterator { self.edges .iter() .map(move |edge| (self.elements[edge.source.0], self.elements[edge.target.0])) diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs index d1dcec0cc1574..6dcbcd671057f 100644 --- a/compiler/rustc_expand/src/proc_macro.rs +++ b/compiler/rustc_expand/src/proc_macro.rs @@ -31,7 +31,7 @@ impl pm::bridge::server::MessagePipe for MessagePipe { } } -fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy { +fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy + 'static { pm::bridge::server::MaybeCrossThread::>::new( ecx.sess.opts.unstable_opts.proc_macro_execution_strategy == ProcMacroExecutionStrategy::CrossThread, diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index 8c2be2152ea3a..7e5d88fde374f 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -92,7 +92,7 @@ impl DefPathTable { pub fn enumerated_keys_and_path_hashes( &self, - ) -> impl Iterator + ExactSizeIterator + '_ { + ) -> impl Iterator + ExactSizeIterator { self.index_to_key .iter_enumerated() .map(move |(index, key)| (index, key, self.def_path_hash(index))) diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index c148dc7f53b7a..7982e5db301f4 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -61,7 +61,7 @@ impl LanguageItems { self.reverse_items.get(&def_id).copied() } - pub fn iter(&self) -> impl Iterator + '_ { + pub fn iter(&self) -> impl Iterator { self.items .iter() .enumerate() diff --git a/compiler/rustc_hir_analysis/src/bounds.rs b/compiler/rustc_hir_analysis/src/bounds.rs index d0b0c08aa798b..98e9bb95c27e6 100644 --- a/compiler/rustc_hir_analysis/src/bounds.rs +++ b/compiler/rustc_hir_analysis/src/bounds.rs @@ -177,11 +177,11 @@ impl<'tcx> Bounds<'tcx> { &self, // FIXME(effects): remove tcx _tcx: TyCtxt<'tcx>, - ) -> impl Iterator, Span)> + '_ { + ) -> impl Iterator, Span)> { self.clauses.iter().cloned() } - pub(crate) fn effects_min_tys(&self) -> impl Iterator> + '_ { + pub(crate) fn effects_min_tys(&self) -> impl Iterator> { self.effects_min_tys.keys().copied() } } diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index ac9976148e25c..eeb609ee32484 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -19,7 +19,6 @@ use std::iter; use std::ops::Bound; use rustc_ast::Recovered; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::unord::UnordMap; use rustc_errors::{ @@ -1766,7 +1765,7 @@ fn polarity_of_impl( fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>( tcx: TyCtxt<'tcx>, generics: &'a hir::Generics<'a>, -) -> impl Iterator> + Captures<'tcx> { +) -> impl Iterator> { generics.params.iter().filter(move |param| match param.kind { GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id), _ => false, diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index 12bb9a3f9e0f3..614f71580c46e 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -77,11 +77,8 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] { fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] { let generics = tcx.generics_of(item_def_id); - // Opaque types may only use regions that are bound. So for - // ```rust - // type Foo<'a, 'b, 'c> = impl Trait<'a> + 'b; - // ``` - // we may not use `'c` in the hidden type. + /// Collect the lifetimes that are mentioned in the opaque that come from the parent, + /// and mark them as invariant. struct OpaqueTypeLifetimeCollector<'tcx> { tcx: TyCtxt<'tcx>, root_def_id: DefId, diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index e2c1eef837f29..b690256ec9e17 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -121,7 +121,7 @@ pub fn inspect_typeck<'tcx>( fn typeck_with_fallback<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, - fallback: impl Fn() -> Ty<'tcx> + 'tcx, + fallback: impl Fn() -> Ty<'tcx>, inspector: Option>, ) -> &'tcx ty::TypeckResults<'tcx> { // Closures' typeck results come from their outermost function, diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index 506afbae40c6e..7307d75849bc6 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -1861,7 +1861,7 @@ impl SparseBitMatrix { /// Iterates through all the columns set to true in a given row of /// the matrix. - pub fn iter(&self, row: R) -> impl Iterator + '_ { + pub fn iter(&self, row: R) -> impl Iterator { self.row(row).into_iter().flat_map(|r| r.iter()) } diff --git a/compiler/rustc_index/src/interval.rs b/compiler/rustc_index/src/interval.rs index 34f541a8cc639..a828314c2f986 100644 --- a/compiler/rustc_index/src/interval.rs +++ b/compiler/rustc_index/src/interval.rs @@ -51,7 +51,7 @@ impl IntervalSet { self.map.clear(); } - pub fn iter(&self) -> impl Iterator + '_ + pub fn iter(&self) -> impl Iterator where I: Step, { @@ -59,7 +59,7 @@ impl IntervalSet { } /// Iterates through intervals stored in the set, in order. - pub fn iter_intervals(&self) -> impl Iterator> + '_ + pub fn iter_intervals(&self) -> impl Iterator> where I: Step, { diff --git a/compiler/rustc_index/src/slice.rs b/compiler/rustc_index/src/slice.rs index 956d32c9a6943..4636f294f13bb 100644 --- a/compiler/rustc_index/src/slice.rs +++ b/compiler/rustc_index/src/slice.rs @@ -63,9 +63,7 @@ impl IndexSlice { } #[inline] - pub fn iter_enumerated( - &self, - ) -> impl DoubleEndedIterator + ExactSizeIterator + '_ { + pub fn iter_enumerated(&self) -> impl DoubleEndedIterator + ExactSizeIterator { self.raw.iter().enumerate().map(|(n, t)| (I::new(n), t)) } @@ -84,7 +82,7 @@ impl IndexSlice { #[inline] pub fn iter_enumerated_mut( &mut self, - ) -> impl DoubleEndedIterator + ExactSizeIterator + '_ { + ) -> impl DoubleEndedIterator + ExactSizeIterator { self.raw.iter_mut().enumerate().map(|(n, t)| (I::new(n), t)) } diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs index 1cb8bc861af98..7f3f3ead5f2af 100644 --- a/compiler/rustc_index/src/vec.rs +++ b/compiler/rustc_index/src/vec.rs @@ -132,7 +132,7 @@ impl IndexVec { } #[inline] - pub fn drain>(&mut self, range: R) -> impl Iterator + '_ { + pub fn drain>(&mut self, range: R) -> impl Iterator { self.raw.drain(range) } @@ -140,7 +140,7 @@ impl IndexVec { pub fn drain_enumerated>( &mut self, range: R, - ) -> impl Iterator + '_ { + ) -> impl Iterator { let begin = match range.start_bound() { std::ops::Bound::Included(i) => *i, std::ops::Bound::Excluded(i) => i.checked_add(1).unwrap(), diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 95d7bb7eb3830..6644a40876cfd 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -10,7 +10,6 @@ use std::fmt::Debug; use std::iter; -use rustc_data_structures::captures::Captures; use rustc_index::{Idx, IndexVec}; use rustc_middle::arena::ArenaAllocatable; use rustc_middle::mir::ConstraintCategory; @@ -556,7 +555,7 @@ impl<'tcx> InferCtxt<'tcx> { param_env: ty::ParamEnv<'tcx>, uninstantiated_region_constraints: &'a [QueryOutlivesConstraint<'tcx>], result_args: &'a CanonicalVarValues<'tcx>, - ) -> impl Iterator> + 'a + Captures<'tcx> { + ) -> impl Iterator> { uninstantiated_region_constraints.iter().map(move |&constraint| { let predicate = instantiate_value(self.tcx, result_args, constraint); self.query_outlives_constraint_to_obligation(predicate, cause.clone(), param_env) diff --git a/compiler/rustc_infer/src/infer/free_regions.rs b/compiler/rustc_infer/src/infer/free_regions.rs index 5452ba67497bc..8fa5361121c67 100644 --- a/compiler/rustc_infer/src/infer/free_regions.rs +++ b/compiler/rustc_infer/src/infer/free_regions.rs @@ -38,7 +38,7 @@ pub struct FreeRegionMap<'tcx> { } impl<'tcx> FreeRegionMap<'tcx> { - pub fn elements(&self) -> impl Iterator> + '_ { + pub fn elements(&self) -> impl Iterator> { self.relation.elements().copied() } diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 0e767b7fb2efd..8e4ab7db526dd 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -12,7 +12,6 @@ use region_constraints::{ }; pub use relate::combine::{CombineFields, PredicateEmittingRelation}; pub use relate::StructurallyRelateAliases; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::undo_log::Rollback; @@ -238,7 +237,7 @@ impl<'tcx> InferCtxtInner<'tcx> { // while looping through this. pub fn iter_opaque_types( &self, - ) -> impl Iterator, ty::OpaqueHiddenType<'tcx>)> + '_ { + ) -> impl Iterator, ty::OpaqueHiddenType<'tcx>)> { self.opaque_type_storage.opaque_types.iter().map(|(&k, v)| (k, v.hidden_type)) } } @@ -1477,7 +1476,7 @@ impl<'tcx> InferCtxt<'tcx> { #[inline] pub fn is_ty_infer_var_definitely_unchanged<'a>( &'a self, - ) -> (impl Fn(TyOrConstInferVar) -> bool + Captures<'tcx> + 'a) { + ) -> impl Fn(TyOrConstInferVar) -> bool { // This hoists the borrow/release out of the loop body. let inner = self.inner.try_borrow(); diff --git a/compiler/rustc_infer/src/infer/outlives/mod.rs b/compiler/rustc_infer/src/infer/outlives/mod.rs index f5c873b037552..9028d30f61ac2 100644 --- a/compiler/rustc_infer/src/infer/outlives/mod.rs +++ b/compiler/rustc_infer/src/infer/outlives/mod.rs @@ -19,7 +19,7 @@ pub mod verify; #[instrument(level = "debug", skip(param_env), ret)] pub fn explicit_outlives_bounds<'tcx>( param_env: ty::ParamEnv<'tcx>, -) -> impl Iterator> + 'tcx { +) -> impl Iterator> { param_env .caller_bounds() .into_iter() diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index 60aab668cbaa6..ceeb8bdde14b8 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -279,7 +279,7 @@ pub fn validate_raw_str(input: &str, prefix_len: u32) -> Result<(), RawStrError> } /// Creates an iterator that produces tokens from the input string. -pub fn tokenize(input: &str) -> impl Iterator + '_ { +pub fn tokenize(input: &str) -> impl Iterator { let mut cursor = Cursor::new(input); std::iter::from_fn(move || { let token = cursor.advance_token(); diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index c9e2eee16b3b9..9119bdd473f99 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -159,7 +159,7 @@ impl LintStore { pub fn get_lint_groups<'t>( &'t self, - ) -> impl Iterator, bool)> + 't { + ) -> impl Iterator, bool)> { self.lint_groups .iter() .filter(|(_, LintGroup { depr, .. })| { @@ -173,7 +173,7 @@ impl LintStore { pub fn register_early_pass( &mut self, - pass: impl Fn() -> EarlyLintPassObject + 'static + sync::DynSend + sync::DynSync, + pass: impl Fn() -> EarlyLintPassObject + sync::DynSend + sync::DynSync + 'static, ) { self.early_passes.push(Box::new(pass)); } @@ -186,7 +186,7 @@ impl LintStore { /// * See [rust-clippy#5518](https://github.com/rust-lang/rust-clippy/pull/5518) pub fn register_pre_expansion_pass( &mut self, - pass: impl Fn() -> EarlyLintPassObject + 'static + sync::DynSend + sync::DynSync, + pass: impl Fn() -> EarlyLintPassObject + sync::DynSend + sync::DynSync + 'static, ) { self.pre_expansion_passes.push(Box::new(pass)); } diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index f3ae24a5895a8..42c86fb123d12 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -7,7 +7,6 @@ use std::{io, iter, mem}; pub(super) use cstore_impl::provide; use proc_macro::bridge::client::ProcMacro; use rustc_ast as ast; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::owned_slice::OwnedSlice; @@ -957,7 +956,7 @@ impl CrateRoot { pub(crate) fn decode_crate_deps<'a>( &self, metadata: &'a MetadataBlob, - ) -> impl ExactSizeIterator + Captures<'a> { + ) -> impl ExactSizeIterator { self.crate_deps.decode(metadata) } } @@ -1256,7 +1255,7 @@ impl<'a> CrateMetadataRef<'a> { self, id: DefIndex, sess: &'a Session, - ) -> impl Iterator + 'a { + ) -> impl Iterator { iter::from_coroutine( #[coroutine] move || { @@ -1306,10 +1305,7 @@ impl<'a> CrateMetadataRef<'a> { .is_some_and(|ident| ident.name == kw::SelfLower) } - fn get_associated_item_or_field_def_ids( - self, - id: DefIndex, - ) -> impl Iterator + 'a { + fn get_associated_item_or_field_def_ids(self, id: DefIndex) -> impl Iterator { self.root .tables .associated_item_or_field_def_ids @@ -1363,7 +1359,7 @@ impl<'a> CrateMetadataRef<'a> { self, id: DefIndex, sess: &'a Session, - ) -> impl Iterator + 'a { + ) -> impl Iterator { self.root .tables .attributes @@ -1400,12 +1396,12 @@ impl<'a> CrateMetadataRef<'a> { } /// Decodes all traits in the crate (for rustdoc and rustc diagnostics). - fn get_traits(self) -> impl Iterator + 'a { + fn get_traits(self) -> impl Iterator { self.root.traits.decode(self).map(move |index| self.local_def_id(index)) } /// Decodes all trait impls in the crate (for rustdoc). - fn get_trait_impls(self) -> impl Iterator + 'a { + fn get_trait_impls(self) -> impl Iterator { self.cdata.trait_impls.values().flat_map(move |impls| { impls.decode(self).map(move |(impl_index, _)| self.local_def_id(impl_index)) }) @@ -1446,7 +1442,7 @@ impl<'a> CrateMetadataRef<'a> { } } - fn get_native_libraries(self, sess: &'a Session) -> impl Iterator + 'a { + fn get_native_libraries(self, sess: &'a Session) -> impl Iterator { self.root.native_libraries.decode((self, sess)) } @@ -1459,7 +1455,7 @@ impl<'a> CrateMetadataRef<'a> { .decode((self, sess)) } - fn get_foreign_modules(self, sess: &'a Session) -> impl Iterator + 'a { + fn get_foreign_modules(self, sess: &'a Session) -> impl Iterator { self.root.foreign_modules.decode((self, sess)) } @@ -1790,7 +1786,7 @@ impl<'a> CrateMetadataRef<'a> { .decode(self) } - fn get_doc_link_traits_in_scope(self, index: DefIndex) -> impl Iterator + 'a { + fn get_doc_link_traits_in_scope(self, index: DefIndex) -> impl Iterator { self.root .tables .doc_link_traits_in_scope @@ -1861,7 +1857,7 @@ impl CrateMetadata { cdata } - pub(crate) fn dependencies(&self) -> impl Iterator + '_ { + pub(crate) fn dependencies(&self) -> impl Iterator { self.dependencies.iter().copied() } diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 8b0a855612c19..8015102d56198 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -183,12 +183,12 @@ impl<'hir> Map<'hir> { } #[inline] - pub fn items(self) -> impl Iterator + 'hir { + pub fn items(self) -> impl Iterator { self.tcx.hir_crate_items(()).free_items.iter().copied() } #[inline] - pub fn module_items(self, module: LocalModDefId) -> impl Iterator + 'hir { + pub fn module_items(self, module: LocalModDefId) -> impl Iterator { self.tcx.hir_module_items(module).free_items() } @@ -289,7 +289,7 @@ impl<'hir> Map<'hir> { }) } - pub fn body_param_names(self, id: BodyId) -> impl Iterator + 'hir { + pub fn body_param_names(self, id: BodyId) -> impl Iterator { self.body(id).params.iter().map(|arg| match arg.pat.kind { PatKind::Binding(_, _, ident, _) => ident, _ => Ident::empty(), @@ -343,7 +343,7 @@ impl<'hir> Map<'hir> { /// crate. If you would prefer to iterate over the bodies /// themselves, you can do `self.hir().krate().body_ids.iter()`. #[inline] - pub fn body_owners(self) -> impl Iterator + 'hir { + pub fn body_owners(self) -> impl Iterator { self.tcx.hir_crate_items(()).body_owners.iter().copied() } @@ -496,7 +496,7 @@ impl<'hir> Map<'hir> { /// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// until the crate root is reached. Prefer this over your own loop using `parent_id`. #[inline] - pub fn parent_id_iter(self, current_id: HirId) -> impl Iterator + 'hir { + pub fn parent_id_iter(self, current_id: HirId) -> impl Iterator { ParentHirIterator::new(self, current_id) } diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 596d9f077372e..10cfd82983412 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -38,25 +38,25 @@ impl ModuleItems { /// include foreign items. If you want to e.g. get all functions, use `definitions()` below. /// /// However, this does include the `impl` blocks themselves. - pub fn free_items(&self) -> impl Iterator + '_ { + pub fn free_items(&self) -> impl Iterator { self.free_items.iter().copied() } - pub fn trait_items(&self) -> impl Iterator + '_ { + pub fn trait_items(&self) -> impl Iterator { self.trait_items.iter().copied() } /// Returns all items that are associated with some `impl` block (both inherent and trait impl /// blocks). - pub fn impl_items(&self) -> impl Iterator + '_ { + pub fn impl_items(&self) -> impl Iterator { self.impl_items.iter().copied() } - pub fn foreign_items(&self) -> impl Iterator + '_ { + pub fn foreign_items(&self) -> impl Iterator { self.foreign_items.iter().copied() } - pub fn owners(&self) -> impl Iterator + '_ { + pub fn owners(&self) -> impl Iterator { self.free_items .iter() .map(|id| id.owner_id) @@ -65,7 +65,7 @@ impl ModuleItems { .chain(self.foreign_items.iter().map(|id| id.owner_id)) } - pub fn definitions(&self) -> impl Iterator + '_ { + pub fn definitions(&self) -> impl Iterator { self.owners().map(|id| id.def_id) } diff --git a/compiler/rustc_middle/src/hir/place.rs b/compiler/rustc_middle/src/hir/place.rs index 4c7af0bc3726d..31da307562f31 100644 --- a/compiler/rustc_middle/src/hir/place.rs +++ b/compiler/rustc_middle/src/hir/place.rs @@ -97,7 +97,7 @@ impl<'tcx> Place<'tcx> { /// The types are in the reverse order that they are applied. So if /// `x: &*const u32` and the `Place` is `**x`, then the types returned are ///`*const u32` then `&*const u32`. - pub fn deref_tys(&self) -> impl Iterator> + '_ { + pub fn deref_tys(&self) -> impl Iterator> { self.projections.iter().enumerate().rev().filter_map(move |(index, proj)| { if ProjectionKind::Deref == proj.kind { Some(self.ty_before_projection(index)) diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs index 4fe219441a064..4839cd5b7135e 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs @@ -121,7 +121,7 @@ impl ProvenanceMap { } /// Yields all the provenances stored in this map. - pub fn provenances(&self) -> impl Iterator + '_ { + pub fn provenances(&self) -> impl Iterator { let bytes = self.bytes.iter().flat_map(|b| b.values()); self.ptrs.values().chain(bytes).copied() } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 54dcfaf5d5429..e20f6841c44e2 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -11,7 +11,6 @@ pub use basic_blocks::BasicBlocks; use either::Either; use polonius_engine::Atom; pub use rustc_ast::Mutability; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::graph::dominators::Dominators; use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg}; @@ -471,7 +470,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable locals. #[inline] - pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator + Captures<'tcx> + 'a { + pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator { (self.arg_count + 1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; @@ -481,9 +480,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable arguments and locals. #[inline] - pub fn mut_vars_and_args_iter<'a>( - &'a self, - ) -> impl Iterator + Captures<'tcx> + 'a { + pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator { (1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; @@ -513,7 +510,7 @@ impl<'tcx> Body<'tcx> { } #[inline] - pub fn drain_vars_and_temps<'a>(&'a mut self) -> impl Iterator> + 'a { + pub fn drain_vars_and_temps<'a>(&'a mut self) -> impl Iterator> { self.local_decls.drain(self.arg_count + 1..) } diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index d66d0be10095f..88034d0605b88 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1476,7 +1476,7 @@ pub fn write_allocations<'tcx>( ) -> io::Result<()> { fn alloc_ids_from_alloc( alloc: ConstAllocation<'_>, - ) -> impl DoubleEndedIterator + '_ { + ) -> impl DoubleEndedIterator { alloc.inner().provenance().ptrs().values().map(|p| p.alloc_id()) } diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index c34e22eb87311..c58b589f95c3b 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -411,8 +411,8 @@ pub use helper::*; mod helper { use super::*; - pub type Successors<'a> = impl DoubleEndedIterator + 'a; - pub type SuccessorsMut<'a> = impl DoubleEndedIterator + 'a; + pub type Successors<'a> = impl DoubleEndedIterator; + pub type SuccessorsMut<'a> = impl DoubleEndedIterator; impl SwitchTargets { /// Like [`SwitchTargets::target_for_value`], but returning the same type as diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs index b8b74da401c9f..8b3ec91ce30fa 100644 --- a/compiler/rustc_middle/src/mir/traversal.rs +++ b/compiler/rustc_middle/src/mir/traversal.rs @@ -281,7 +281,7 @@ pub fn mono_reachable_reverse_postorder<'a, 'tcx>( /// This is clearer than writing `preorder` in cases where the order doesn't matter. pub fn reachable<'a, 'tcx>( body: &'a Body<'tcx>, -) -> impl 'a + Iterator)> { +) -> impl Iterator)> { preorder(body) } diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 204f61b4804e4..21237c51946f1 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -3,7 +3,6 @@ use std::hash::{Hash, Hasher}; use std::ops::Range; use std::str; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; @@ -538,7 +537,7 @@ impl<'tcx> AdtDef<'tcx> { pub fn discriminants( self, tcx: TyCtxt<'tcx>, - ) -> impl Iterator)> + Captures<'tcx> { + ) -> impl Iterator)> { assert!(self.is_enum()); let repr_type = self.repr().discr_type(); let initial = repr_type.initial_discriminant(tcx); diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index db56e0016a2d6..bbdb62f822d77 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -167,7 +167,7 @@ impl AssocItems { /// /// New code should avoid relying on definition order. If you need a particular associated item /// for a known trait, make that trait a lang item instead of indexing this array. - pub fn in_definition_order(&self) -> impl '_ + Iterator { + pub fn in_definition_order(&self) -> impl Iterator { self.items.iter().map(|(_, v)| v) } @@ -176,10 +176,7 @@ impl AssocItems { } /// Returns an iterator over all associated items with the given name, ignoring hygiene. - pub fn filter_by_name_unhygienic( - &self, - name: Symbol, - ) -> impl '_ + Iterator { + pub fn filter_by_name_unhygienic(&self, name: Symbol) -> impl Iterator { self.items.get_by_key(name) } diff --git a/compiler/rustc_middle/src/ty/closure.rs b/compiler/rustc_middle/src/ty/closure.rs index 809801c33e1ad..9d46a05e01abb 100644 --- a/compiler/rustc_middle/src/ty/closure.rs +++ b/compiler/rustc_middle/src/ty/closure.rs @@ -1,6 +1,5 @@ use std::fmt::Write; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; use rustc_hir::def_id::LocalDefId; @@ -417,7 +416,7 @@ pub fn analyze_coroutine_closure_captures<'a, 'tcx: 'a, T>( parent_captures: impl IntoIterator>, child_captures: impl IntoIterator>, mut for_each: impl FnMut((usize, &'a CapturedPlace<'tcx>), (usize, &'a CapturedPlace<'tcx>)) -> T, -) -> impl Iterator + Captures<'a> + Captures<'tcx> { +) -> impl Iterator { std::iter::from_coroutine( #[coroutine] move || { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index cd06d7b8e533e..a8a356d68b336 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1830,7 +1830,7 @@ impl<'tcx> TyCtxt<'tcx> { Ok(TyCtxtFeed { key: num, tcx: self }) } - pub fn iter_local_def_id(self) -> impl Iterator + 'tcx { + pub fn iter_local_def_id(self) -> impl Iterator { // Create a dependency to the red node to be sure we re-execute this when the amount of // definitions change. self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE); @@ -2059,7 +2059,7 @@ impl<'tcx> TyCtxt<'tcx> { self.limits(()).move_size_limit } - pub fn all_traits(self) -> impl Iterator + 'tcx { + pub fn all_traits(self) -> impl Iterator { iter::once(LOCAL_CRATE) .chain(self.crates(()).iter().copied()) .flat_map(move |cnum| self.traits(cnum).iter().copied()) @@ -2249,7 +2249,7 @@ macro_rules! sty_debug_print { } impl<'tcx> TyCtxt<'tcx> { - pub fn debug_stats(self) -> impl std::fmt::Debug + 'tcx { + pub fn debug_stats(self) -> impl std::fmt::Debug { struct DebugStats<'tcx>(TyCtxt<'tcx>); impl<'tcx> std::fmt::Debug for DebugStats<'tcx> { @@ -2508,7 +2508,7 @@ impl<'tcx> TyCtxt<'tcx> { /// does not compute the full elaborated super-predicates but just the set of def-ids. It is used /// to identify which traits may define a given associated type to help avoid cycle errors, /// and to make size estimates for vtable layout computation. - pub fn supertrait_def_ids(self, trait_def_id: DefId) -> impl Iterator + 'tcx { + pub fn supertrait_def_ids(self, trait_def_id: DefId) -> impl Iterator { rustc_type_ir::elaborate::supertrait_def_ids(self, trait_def_id) } diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index 80c31e236e2c2..5b360f3e16911 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -483,17 +483,17 @@ impl<'tcx> GenericArgs<'tcx> { } #[inline] - pub fn types(&'tcx self) -> impl DoubleEndedIterator> + 'tcx { + pub fn types(&'tcx self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_type()) } #[inline] - pub fn regions(&'tcx self) -> impl DoubleEndedIterator> + 'tcx { + pub fn regions(&'tcx self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_region()) } #[inline] - pub fn consts(&'tcx self) -> impl DoubleEndedIterator> + 'tcx { + pub fn consts(&'tcx self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_const()) } @@ -503,7 +503,7 @@ impl<'tcx> GenericArgs<'tcx> { &'tcx self, tcx: TyCtxt<'tcx>, def_id: DefId, - ) -> impl DoubleEndedIterator> + 'tcx { + ) -> impl DoubleEndedIterator> { let generics = tcx.generics_of(def_id); self.iter().enumerate().filter_map(|(i, k)| match k.unpack() { _ if Some(i) == generics.host_effect_index => None, diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e637ced7139a6..52c4e24cab03c 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1496,7 +1496,7 @@ impl<'tcx> TyCtxt<'tcx> { self.typeck(self.hir().body_owner_def_id(body)) } - pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator { + pub fn provided_trait_methods(self, id: DefId) -> impl Iterator { self.associated_items(id) .in_definition_order() .filter(move |item| item.kind == AssocKind::Fn && item.defaultness(self).has_value()) @@ -1831,7 +1831,7 @@ impl<'tcx> TyCtxt<'tcx> { self, did: DefId, attr: &'attr [Symbol], - ) -> impl Iterator + 'attr + ) -> impl Iterator where 'tcx: 'attr, { diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 8e72505b86200..10c0fd92ec489 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -1,6 +1,5 @@ use std::cmp::Ordering; -use rustc_data_structures::captures::Captures; use rustc_data_structures::intern::Interned; use rustc_hir::def_id::DefId; use rustc_macros::{extension, HashStable}; @@ -332,7 +331,7 @@ impl<'tcx> ty::List> { #[inline] pub fn projection_bounds<'a>( &'a self, - ) -> impl Iterator>> + 'a { + ) -> impl Iterator>> { self.iter().filter_map(|predicate| { predicate .map_bound(|pred| match pred { @@ -344,16 +343,14 @@ impl<'tcx> ty::List> { } #[inline] - pub fn auto_traits<'a>(&'a self) -> impl Iterator + Captures<'tcx> + 'a { + pub fn auto_traits<'a>(&'a self) -> impl Iterator { self.iter().filter_map(|predicate| match predicate.skip_binder() { ExistentialPredicate::AutoTrait(did) => Some(did), _ => None, }) } - pub fn without_auto_traits( - &self, - ) -> impl Iterator> + '_ { + pub fn without_auto_traits(&self) -> impl Iterator> { self.iter().filter(|predicate| { !matches!(predicate.as_ref().skip_binder(), ExistentialPredicate::AutoTrait(_)) }) diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 44309697ba987..79638f3e41f3a 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -8,7 +8,6 @@ use std::iter; use std::ops::{ControlFlow, Range}; use hir::def::{CtorKind, DefKind}; -use rustc_data_structures::captures::Captures; use rustc_errors::{ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -105,7 +104,7 @@ impl<'tcx> ty::CoroutineArgs> { self, def_id: DefId, tcx: TyCtxt<'tcx>, - ) -> impl Iterator)> + Captures<'tcx> { + ) -> impl Iterator)> { self.variant_range(def_id, tcx).map(move |index| { (index, Discr { val: index.as_usize() as u128, ty: self.discr_ty(tcx) }) }) @@ -139,7 +138,7 @@ impl<'tcx> ty::CoroutineArgs> { self, def_id: DefId, tcx: TyCtxt<'tcx>, - ) -> impl Iterator> + Captures<'tcx>> { + ) -> impl Iterator>> { let layout = tcx.coroutine_layout(def_id, self.kind_ty()).unwrap(); layout.variant_fields.iter().map(move |variant| { variant.iter().map(move |field| { diff --git a/compiler/rustc_middle/src/ty/trait_def.rs b/compiler/rustc_middle/src/ty/trait_def.rs index 82690f70e5f18..49ab28634a57c 100644 --- a/compiler/rustc_middle/src/ty/trait_def.rs +++ b/compiler/rustc_middle/src/ty/trait_def.rs @@ -188,7 +188,7 @@ impl<'tcx> TyCtxt<'tcx> { self, trait_def_id: DefId, self_ty: Ty<'tcx>, - ) -> impl Iterator + 'tcx { + ) -> impl Iterator { let impls = self.trait_impls_of(trait_def_id); if let Some(simp) = fast_reject::simplify_type(self, self_ty, TreatParams::InstantiateWithInfer) @@ -204,7 +204,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Returns an iterator containing all impls for `trait_def_id`. /// /// `trait_def_id` MUST BE the `DefId` of a trait. - pub fn all_impls(self, trait_def_id: DefId) -> impl Iterator + 'tcx { + pub fn all_impls(self, trait_def_id: DefId) -> impl Iterator { let TraitImpls { blanket_impls, non_blanket_impls } = self.trait_impls_of(trait_def_id); blanket_impls.iter().chain(non_blanket_impls.iter().flat_map(|(_, v)| v)).cloned() diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index 07784982631f8..f0d8f207b4d20 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -220,7 +220,7 @@ fn strip_prefix<'a, 'tcx>( mut base_ty: Ty<'tcx>, projections: &'a [PlaceElem<'tcx>], prefix_projections: &[HirProjection<'tcx>], -) -> impl Iterator> + 'a { +) -> impl Iterator> { let mut iter = projections .iter() .copied() diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index 5b5f97cb51410..a325ed3c44599 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -161,7 +161,7 @@ impl<'tcx> Cx<'tcx> { owner_id: HirId, fn_decl: &'tcx hir::FnDecl<'tcx>, body: &'tcx hir::Body<'tcx>, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> { let fn_sig = self.typeck_results.liberated_fn_sigs()[owner_id]; body.params.iter().enumerate().map(move |(index, param)| { diff --git a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs index bc1177976b5de..f11dbf782140c 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs @@ -67,7 +67,7 @@ impl<'tcx> MovePath<'tcx> { pub fn parents<'a>( &self, move_paths: &'a IndexSlice>, - ) -> impl 'a + Iterator)> { + ) -> impl Iterator)> { let first = self.parent.map(|mpi| (mpi, &move_paths[mpi])); MovePathLinearIter { next: first, @@ -81,7 +81,7 @@ impl<'tcx> MovePath<'tcx> { pub fn children<'a>( &self, move_paths: &'a IndexSlice>, - ) -> impl 'a + Iterator)> { + ) -> impl Iterator)> { let first = self.first_child.map(|mpi| (mpi, &move_paths[mpi])); MovePathLinearIter { next: first, @@ -343,7 +343,7 @@ impl<'tcx> MovePathLookup<'tcx> { /// `MovePathIndex`es. pub fn iter_locals_enumerated( &self, - ) -> impl DoubleEndedIterator + '_ { + ) -> impl DoubleEndedIterator { self.locals.iter_enumerated().filter_map(|(l, &idx)| Some((l, idx?))) } } diff --git a/compiler/rustc_mir_dataflow/src/un_derefer.rs b/compiler/rustc_mir_dataflow/src/un_derefer.rs index b803ecc575ee0..673fa233eb84f 100644 --- a/compiler/rustc_mir_dataflow/src/un_derefer.rs +++ b/compiler/rustc_mir_dataflow/src/un_derefer.rs @@ -28,7 +28,7 @@ impl<'tcx> UnDerefer<'tcx> { pub(crate) fn iter_projections( &self, place: PlaceRef<'tcx>, - ) -> impl Iterator, PlaceElem<'tcx>)> + '_ { + ) -> impl Iterator, PlaceElem<'tcx>)> { ProjectionIter::new(self.deref_chain(place.local), place) } } diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 0540436632014..5b5fa40d38654 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -36,7 +36,6 @@ use std::assert_matches::assert_matches; use std::fmt::{Debug, Formatter}; use std::ops::Range; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxIndexSet, StdEntry}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_index::bit_set::BitSet; @@ -1062,10 +1061,7 @@ impl<'tcx> Map<'tcx> { } /// Iterate over all direct children. - fn children( - &self, - parent: PlaceIndex, - ) -> impl Iterator + Captures<'_> + Captures<'tcx> { + fn children(&self, parent: PlaceIndex) -> impl Iterator { Children::new(self, parent) } diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index 1fb74f5d82ca2..5ce82d3c20f82 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -781,7 +781,7 @@ struct CoroutineSavedLocals(BitSet); impl CoroutineSavedLocals { /// Returns an iterator over each `CoroutineSavedLocal` along with the `Local` it corresponds /// to. - fn iter_enumerated(&self) -> impl '_ + Iterator { + fn iter_enumerated(&self) -> impl Iterator { self.iter().enumerate().map(|(i, l)| (CoroutineSavedLocal::from(i), l)) } diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index ef4031c5c034f..5e8c378f0a7a1 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -1,6 +1,5 @@ use std::fmt::{self, Debug}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::graph::DirectedGraph; use rustc_index::IndexVec; @@ -235,7 +234,7 @@ impl CoverageCounters { /// with a counter *expression*, along with the ID of that expression. pub(super) fn bcb_nodes_with_coverage_expressions( &self, - ) -> impl Iterator + Captures<'_> { + ) -> impl Iterator { self.bcb_counters.iter_enumerated().filter_map(|(bcb, &counter_kind)| match counter_kind { // Yield the BCB along with its associated expression ID. Some(BcbCounter::Expression { id }) => Some((bcb, id)), diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 743aa6790583f..7f3c66f335a19 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -2,7 +2,6 @@ use std::cmp::Ordering; use std::collections::VecDeque; use std::ops::{Index, IndexMut}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::dominators::{self, Dominators}; use rustc_data_structures::graph::{self, DirectedGraph, StartNode}; @@ -571,7 +570,7 @@ fn find_loop_backedges( fn short_circuit_preorder<'a, 'tcx, F, Iter>( body: &'a mir::Body<'tcx>, filtered_successors: F, -) -> impl Iterator + Captures<'a> + Captures<'tcx> +) -> impl Iterator where F: Fn(BasicBlock) -> Iter, Iter: IntoIterator, diff --git a/compiler/rustc_mir_transform/src/coverage/query.rs b/compiler/rustc_mir_transform/src/coverage/query.rs index e65a5fdd5e7f1..4852d4da985ea 100644 --- a/compiler/rustc_mir_transform/src/coverage/query.rs +++ b/compiler/rustc_mir_transform/src/coverage/query.rs @@ -1,4 +1,3 @@ -use rustc_data_structures::captures::Captures; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::coverage::{CounterId, CoverageKind}; use rustc_middle::mir::{Body, CoverageIdsInfo, Statement, StatementKind}; @@ -98,7 +97,7 @@ fn coverage_ids_info<'tcx>( fn all_coverage_in_mir_body<'a, 'tcx>( body: &'a Body<'tcx>, -) -> impl Iterator + Captures<'tcx> { +) -> impl Iterator { body.basic_blocks.iter().flat_map(|bb_data| &bb_data.statements).filter_map(|statement| { match statement.kind { StatementKind::Coverage(ref kind) if !is_inlined(body, statement) => Some(kind), diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index b904b0d2599b1..1761d4029563b 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -1,6 +1,5 @@ use std::collections::VecDeque; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_middle::mir; use rustc_span::{DesugaringKind, ExpnKind, MacroKind, Span}; @@ -183,7 +182,7 @@ fn divide_spans_into_buckets(input_covspans: Vec, holes: &[Hole]) -> Ve fn drain_front_while<'a, T>( queue: &'a mut VecDeque, mut pred_fn: impl FnMut(&T) -> bool, -) -> impl Iterator + Captures<'a> { +) -> impl Iterator { std::iter::from_fn(move || if pred_fn(queue.front()?) { queue.pop_front() } else { None }) } diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 1810569bc8ea8..9bb48686e974e 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -170,11 +170,11 @@ impl HasBottom for ConditionSet<'_> { } impl<'a> ConditionSet<'a> { - fn iter(self) -> impl Iterator + 'a { + fn iter(self) -> impl Iterator { self.0.iter().copied() } - fn iter_matches(self, value: ScalarInt) -> impl Iterator + 'a { + fn iter_matches(self, value: ScalarInt) -> impl Iterator { self.iter().filter(move |c| c.matches(value)) } diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs index e6dd2cfd862d8..f42d2abb468cd 100644 --- a/compiler/rustc_mir_transform/src/sroa.rs +++ b/compiler/rustc_mir_transform/src/sroa.rs @@ -180,7 +180,7 @@ impl<'tcx> ReplacementMap<'tcx> { fn place_fragments( &self, place: Place<'tcx>, - ) -> Option, Local)> + '_> { + ) -> Option, Local)>> { let local = place.as_local()?; let fields = self.fragments[local].as_ref()?; Some(fields.iter_enumerated().filter_map(|(field, &opt_ty_local)| { diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index ba64216f9e1ca..90c662eed625b 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -138,7 +138,7 @@ impl SsaLocals { pub(super) fn assignments<'a, 'tcx>( &'a self, body: &'a Body<'tcx>, - ) -> impl Iterator, Location)> + 'a { + ) -> impl Iterator, Location)> { self.assignment_order.iter().filter_map(|&local| { if let Set1::One(DefLocation::Assignment(loc)) = self.assignments[local] { let stmt = body.stmt_at(loc).left()?; diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 9d9265d5318db..0456d5180ab29 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1573,7 +1573,7 @@ impl<'a> Parser<'a> { // Debug view of the parser's token stream, up to `{lookahead}` tokens. // Only used when debugging. #[allow(unused)] - pub(crate) fn debug_lookahead(&self, lookahead: usize) -> impl fmt::Debug + '_ { + pub(crate) fn debug_lookahead(&self, lookahead: usize) -> impl fmt::Debug { struct DebugParser<'dbg> { parser: &'dbg Parser<'dbg>, lookahead: usize, diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index fec44d5af55da..1a8b916db6243 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -65,7 +65,7 @@ pub trait PatCx: Sized + fmt::Debug { &'a self, ctor: &'a Constructor, ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator + Captures<'a>; + ) -> impl Iterator + ExactSizeIterator; /// The set of all the constructors for `ty`. /// diff --git a/compiler/rustc_pattern_analysis/src/pat_column.rs b/compiler/rustc_pattern_analysis/src/pat_column.rs index eb4e095c1c662..ebd316cb5e168 100644 --- a/compiler/rustc_pattern_analysis/src/pat_column.rs +++ b/compiler/rustc_pattern_analysis/src/pat_column.rs @@ -41,7 +41,7 @@ impl<'p, Cx: PatCx> PatternColumn<'p, Cx> { pub fn head_ty(&self) -> Option<&Cx::Ty> { self.patterns.first().map(|pat| pat.ty()) } - pub fn iter<'a>(&'a self) -> impl Iterator> + Captures<'a> { + pub fn iter<'a>(&'a self) -> impl Iterator> { self.patterns.iter().copied() } diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 6c09f97bfe731..1cd06dfd6a205 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -936,8 +936,7 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> { &'a self, ctor: &'a crate::constructor::Constructor, ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator + Captures<'a> - { + ) -> impl Iterator + ExactSizeIterator { self.ctor_sub_tys(ctor, *ty) } fn ctors_for_ty( diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index 814559a66c568..4288afeca487d 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -905,7 +905,7 @@ impl PlaceInfo { &'a self, cx: &'a Cx, ctor: &'a Constructor, - ) -> impl Iterator + ExactSizeIterator + Captures<'a> { + ) -> impl Iterator + ExactSizeIterator { let ctor_sub_tys = cx.ctor_sub_tys(ctor, &self.ty); let ctor_sub_validity = self.validity.specialize(ctor); ctor_sub_tys.map(move |(ty, PrivateUninhabitedField(private_uninhabited))| PlaceInfo { diff --git a/compiler/rustc_pattern_analysis/tests/common/mod.rs b/compiler/rustc_pattern_analysis/tests/common/mod.rs index ec0bcd43ad24d..fd82e589f43b2 100644 --- a/compiler/rustc_pattern_analysis/tests/common/mod.rs +++ b/compiler/rustc_pattern_analysis/tests/common/mod.rs @@ -160,8 +160,7 @@ impl PatCx for Cx { &'a self, ctor: &'a Constructor, ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator + Captures<'a> - { + ) -> impl Iterator + ExactSizeIterator { ty.sub_tys(ctor).into_iter().map(|ty| (ty, PrivateUninhabitedField(false))) } diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index a4fb0a5b07220..bc78878a84a24 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -98,7 +98,7 @@ impl SerializedDepGraph { pub fn edge_targets_from( &self, source: SerializedDepNodeIndex, - ) -> impl Iterator + Clone + '_ { + ) -> impl Iterator + Clone { let header = self.edge_list_indices[source]; let mut raw = &self.edge_list_data[header.start()..]; // Figure out where the edge list for `source` ends by getting the start index of the next diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 1db31f5b0a775..2c26803269b75 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -331,7 +331,7 @@ impl ParseSess { self.proc_macro_quoted_spans.push(span) } - pub fn proc_macro_quoted_spans(&self) -> impl Iterator + '_ { + pub fn proc_macro_quoted_spans(&self) -> impl Iterator { // This is equivalent to `.iter().copied().enumerate()`, but that isn't possible for // AppendOnlyVec, so we resort to this scheme. self.proc_macro_quoted_spans.iter_enumerated() diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index cf9891f15adcf..9fef75af204ec 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -1021,7 +1021,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { &self, path: &'tcx hir::Path<'tcx>, args: GenericArgsRef<'tcx>, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> + 'tcx { let tcx = self.tecx.tcx; let have_turbofish = path.segments.iter().any(|segment| { segment.args.is_some_and(|args| args.args.iter().any(|arg| arg.is_ty_or_const())) diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index cfc73e2e47e87..5032d8d15e481 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -70,7 +70,7 @@ impl<'tcx> ObligationStorage<'tcx> { obligations } - fn unstalled_for_select(&mut self) -> impl Iterator> { + fn unstalled_for_select(&mut self) -> impl Iterator> + 'tcx { mem::take(&mut self.pending).into_iter() } diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 16ba06f8667ff..d7c165cb17ab5 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -1,6 +1,5 @@ use std::marker::PhantomData; -use rustc_data_structures::captures::Captures; use rustc_data_structures::obligation_forest::{ Error, ForestObligation, ObligationForest, ObligationProcessor, Outcome, ProcessResult, }; @@ -840,7 +839,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> { fn args_infer_vars<'a, 'tcx>( selcx: &SelectionContext<'a, 'tcx>, args: ty::Binder<'tcx, GenericArgsRef<'tcx>>, -) -> impl Iterator + Captures<'tcx> { +) -> impl Iterator { selcx .infcx .resolve_vars_if_possible(args) diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index a3d5c5307974d..150081aad6145 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -131,7 +131,7 @@ fn object_safety_violations_for_trait( fn sized_trait_bound_spans<'tcx>( tcx: TyCtxt<'tcx>, bounds: hir::GenericBounds<'tcx>, -) -> impl 'tcx + Iterator { +) -> impl Iterator { bounds.iter().filter_map(move |b| match b { hir::GenericBound::Trait(trait_ref, hir::TraitBoundModifier::None) if trait_has_sized_self( diff --git a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs index ee1b0fc6f2e5e..b682556451be3 100644 --- a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs +++ b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs @@ -12,8 +12,8 @@ use tracing::{debug, instrument}; use crate::infer::InferCtxt; use crate::traits::{ObligationCause, ObligationCtxt}; -pub type BoundsCompat<'a, 'tcx: 'a> = impl Iterator> + 'a; -pub type Bounds<'a, 'tcx: 'a> = impl Iterator> + 'a; +pub type BoundsCompat<'a, 'tcx: 'a> = impl Iterator>; +pub type Bounds<'a, 'tcx: 'a> = impl Iterator>; /// Implied bounds are region relationships that we deduce /// automatically. The idea is that (e.g.) a caller must check that a diff --git a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs index 13620f4b8d9cc..82ef3ebd30e75 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs @@ -200,15 +200,12 @@ impl<'tcx> Children { } } -fn iter_children(children: &Children) -> impl Iterator + '_ { +fn iter_children(children: &Children) -> impl Iterator { let nonblanket = children.non_blanket_impls.iter().flat_map(|(_, v)| v.iter()); children.blanket_impls.iter().chain(nonblanket).cloned() } -fn filtered_children( - children: &mut Children, - st: SimplifiedType, -) -> impl Iterator + '_ { +fn filtered_children(children: &mut Children, st: SimplifiedType) -> impl Iterator { let nonblanket = children.non_blanket_impls.entry(st).or_default().iter(); children.blanket_impls.iter().chain(nonblanket).cloned() } diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index f525c17e0531c..f197100421695 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -208,7 +208,7 @@ fn own_existential_vtable_entries(tcx: TyCtxt<'_>, trait_def_id: DefId) -> &[Def fn own_existential_vtable_entries_iter( tcx: TyCtxt<'_>, trait_def_id: DefId, -) -> impl Iterator + '_ { +) -> impl Iterator { let trait_methods = tcx .associated_items(trait_def_id) .in_definition_order() diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index 70321a071a208..90ce2827a84c3 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -149,7 +149,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' } } -fn fn_sig_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator + '_ { +fn fn_sig_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator { let node = tcx.hir_node_by_def_id(def_id); if let Some(decl) = node.fn_decl() { decl.inputs.iter().map(|ty| ty.span).chain(iter::once(decl.output.span())) @@ -158,7 +158,7 @@ fn fn_sig_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator, def_id: LocalDefId) -> impl Iterator + '_ { +fn impl_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator { let item = tcx.hir().expect_item(def_id); if let hir::ItemKind::Impl(impl_) = item.kind { let trait_args = impl_ diff --git a/compiler/rustc_ty_utils/src/layout_sanity_check.rs b/compiler/rustc_ty_utils/src/layout_sanity_check.rs index be0a7c5ee890a..a2fb8b92b818e 100644 --- a/compiler/rustc_ty_utils/src/layout_sanity_check.rs +++ b/compiler/rustc_ty_utils/src/layout_sanity_check.rs @@ -29,7 +29,7 @@ pub(super) fn sanity_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou fn non_zst_fields<'tcx, 'a>( cx: &'a LayoutCx<'tcx>, layout: &'a TyAndLayout<'tcx>, - ) -> impl Iterator)> + 'a { + ) -> impl Iterator)> { (0..layout.layout.fields().count()).filter_map(|i| { let field = layout.field(cx, i); // Also checking `align == 1` here leads to test failures in diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 9a3956596d23f..b46cd15b7388f 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -342,7 +342,7 @@ fn drop_tys_helper<'tcx>( fn adt_consider_insignificant_dtor<'tcx>( tcx: TyCtxt<'tcx>, -) -> impl Fn(ty::AdtDef<'tcx>) -> Option + 'tcx { +) -> impl Fn(ty::AdtDef<'tcx>) -> Option { move |adt_def: ty::AdtDef<'tcx>| { let is_marked_insig = tcx.has_attr(adt_def.did(), sym::rustc_insignificant_dtor); if is_marked_insig { diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 7c09fe1a08541..444819f886bdd 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -855,7 +855,7 @@ impl SwitchTargets { } /// The conditional targets which are only taken if the pattern matches the given value. - pub fn branches(&self) -> impl Iterator + '_ { + pub fn branches(&self) -> impl Iterator { self.branches.iter().copied() } diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index 5bad3d5ae7a3c..3137a1ebec575 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -790,7 +790,7 @@ impl AdtDef { } /// Iterate over the variants in this ADT. - pub fn variants_iter(&self) -> impl Iterator + '_ { + pub fn variants_iter(&self) -> impl Iterator { (0..self.num_variants()) .map(|idx| VariantDef { idx: VariantIdx::to_val(idx), adt_def: *self }) } From c673863474f555047c56fc642b0ab32f0dae86db Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 22 Jul 2024 14:45:46 -0400 Subject: [PATCH 3/6] Simplify some lifetimes --- compiler/rustc_ast_lowering/src/lib.rs | 12 ++++++------ compiler/rustc_attr/src/builtin.rs | 18 +++++++++--------- .../src/diagnostics/conflict_errors.rs | 4 ++-- .../rustc_borrowck/src/region_infer/mod.rs | 4 ++-- .../src/region_infer/reverse_sccs.rs | 5 +---- .../rustc_borrowck/src/region_infer/values.rs | 13 +++++-------- .../rustc_borrowck/src/universal_regions.rs | 4 ++-- compiler/rustc_hir_analysis/src/collect.rs | 6 +++--- .../src/infer/canonical/query_response.rs | 10 +++++----- compiler/rustc_infer/src/infer/mod.rs | 4 +--- compiler/rustc_lint/src/context.rs | 4 +--- compiler/rustc_metadata/src/rmeta/decoder.rs | 4 ++-- compiler/rustc_middle/src/mir/mod.rs | 4 ++-- compiler/rustc_middle/src/ty/generic_args.rs | 8 ++++---- compiler/rustc_middle/src/ty/mod.rs | 9 +++------ compiler/rustc_middle/src/ty/predicate.rs | 6 +++--- .../rustc_mir_build/src/build/expr/as_place.rs | 4 ++-- compiler/rustc_mir_build/src/thir/cx/mod.rs | 4 ++-- .../rustc_mir_transform/src/coverage/graph.rs | 4 ++-- .../rustc_mir_transform/src/coverage/spans.rs | 4 ++-- compiler/rustc_mir_transform/src/ssa.rs | 2 +- compiler/rustc_pattern_analysis/src/lib.rs | 2 +- .../rustc_pattern_analysis/src/pat_column.rs | 2 +- compiler/rustc_pattern_analysis/src/rustc.rs | 3 ++- .../rustc_pattern_analysis/src/usefulness.rs | 2 +- .../rustc_pattern_analysis/tests/common/mod.rs | 3 ++- .../src/traits/fulfill.rs | 4 ++-- .../rustc_ty_utils/src/layout_sanity_check.rs | 6 +++--- 28 files changed, 72 insertions(+), 83 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 2efcfda9ddb94..cd1f9521e6156 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -2073,9 +2073,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { self.new_named_lifetime_with_res(new_id, ident, res) } - fn lower_generic_params_mut<'s>( - &'s mut self, - params: &'s [GenericParam], + fn lower_generic_params_mut( + &mut self, + params: &[GenericParam], source: hir::GenericParamSource, ) -> impl Iterator> { params.iter().map(move |param| self.lower_generic_param(param, source)) @@ -2237,9 +2237,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, itctx)) } - fn lower_param_bounds_mut<'s>( - &'s mut self, - bounds: &'s [GenericBound], + fn lower_param_bounds_mut( + &mut self, + bounds: &[GenericBound], itctx: ImplTraitContext, ) -> impl Iterator> { bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx)) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index a35ccb4332d42..d49afe34fc725 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -1163,23 +1163,23 @@ pub fn find_transparency( (transparency.map_or(fallback, |t| t.0), error) } -pub fn allow_internal_unstable<'a>( - sess: &'a Session, - attrs: &'a [Attribute], +pub fn allow_internal_unstable( + sess: &Session, + attrs: &[Attribute], ) -> impl Iterator { allow_unstable(sess, attrs, sym::allow_internal_unstable) } -pub fn rustc_allow_const_fn_unstable<'a>( - sess: &'a Session, - attrs: &'a [Attribute], +pub fn rustc_allow_const_fn_unstable( + sess: &Session, + attrs: &[Attribute], ) -> impl Iterator { allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable) } -fn allow_unstable<'a>( - sess: &'a Session, - attrs: &'a [Attribute], +fn allow_unstable( + sess: &Session, + attrs: &[Attribute], symbol: Symbol, ) -> impl Iterator { let attrs = attr::filter_by_name(attrs, symbol); diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 115e078e45742..e0b6cc29b65fb 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -3552,8 +3552,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { location: Location, mpi: MovePathIndex, ) -> (Vec, Vec) { - fn predecessor_locations<'a, 'tcx>( - body: &'a mir::Body<'tcx>, + fn predecessor_locations<'tcx>( + body: &mir::Body<'tcx>, location: Location, ) -> impl Iterator { if location.statement_index == 0 { diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index f062fa5463b4f..5162cf232e688 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -603,8 +603,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { self.scc_values.region_value_str(scc) } - pub(crate) fn placeholders_contained_in<'a>( - &'a self, + pub(crate) fn placeholders_contained_in( + &self, r: RegionVid, ) -> impl Iterator { let scc = self.constraint_sccs.scc(r); diff --git a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs index 1e74e86876771..8a75c44c2ce9e 100644 --- a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs +++ b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs @@ -20,10 +20,7 @@ pub(crate) struct ReverseSccGraph { impl ReverseSccGraph { /// Find all universal regions that are required to outlive the given SCC. - pub(super) fn upper_bounds<'a>( - &'a self, - scc0: ConstraintSccIndex, - ) -> impl Iterator { + pub(super) fn upper_bounds(&self, scc0: ConstraintSccIndex) -> impl Iterator { let mut duplicates = FxIndexSet::default(); graph::depth_first_search(&self.graph, scc0) .flat_map(move |scc1| { diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index e02e407b4283b..bf0a604a52867 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -359,7 +359,7 @@ impl RegionValues { } /// Returns the locations contained within a given region `r`. - pub(crate) fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator { + pub(crate) fn locations_outlived_by(&self, r: N) -> impl Iterator { self.points.row(r).into_iter().flat_map(move |set| { set.iter() .take_while(move |&p| self.elements.point_in_range(p)) @@ -368,16 +368,13 @@ impl RegionValues { } /// Returns just the universal regions that are contained in a given region's value. - pub(crate) fn universal_regions_outlived_by<'a>( - &'a self, - r: N, - ) -> impl Iterator { + pub(crate) fn universal_regions_outlived_by(&self, r: N) -> impl Iterator { self.free_regions.row(r).into_iter().flat_map(|set| set.iter()) } /// Returns all the elements contained in a given region's value. - pub(crate) fn placeholders_contained_in<'a>( - &'a self, + pub(crate) fn placeholders_contained_in( + &self, r: N, ) -> impl Iterator { self.placeholders @@ -388,7 +385,7 @@ impl RegionValues { } /// Returns all the elements contained in a given region's value. - pub(crate) fn elements_contained_in<'a>(&'a self, r: N) -> impl Iterator { + pub(crate) fn elements_contained_in(&self, r: N) -> impl Iterator { let points_iter = self.locations_outlived_by(r).map(RegionElement::Location); let free_regions_iter = diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 4c3bf12227842..0bcb7ae9ebc65 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -336,8 +336,8 @@ impl<'tcx> UniversalRegions<'tcx> { } /// Gets an iterator over all the early-bound regions that have names. - pub(crate) fn named_universal_regions<'s>( - &'s self, + pub(crate) fn named_universal_regions( + &self, ) -> impl Iterator, ty::RegionVid)> { self.indices.indices.iter().map(|(&r, &v)| (r, v)) } diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index eeb609ee32484..9f41d3592697b 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1762,10 +1762,10 @@ fn polarity_of_impl( /// the lifetimes that are declared. For fns or methods, we have to /// screen out those that do not appear in any where-clauses etc using /// `resolve_lifetime::early_bound_lifetimes`. -fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>( +fn early_bound_lifetimes_from_generics<'a, 'tcx>( tcx: TyCtxt<'tcx>, - generics: &'a hir::Generics<'a>, -) -> impl Iterator> { + generics: &'a hir::Generics<'tcx>, +) -> impl Iterator> { generics.params.iter().filter(move |param| match param.kind { GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id), _ => false, diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 6644a40876cfd..efdba22b0f1a7 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -549,12 +549,12 @@ impl<'tcx> InferCtxt<'tcx> { /// Converts the region constraints resulting from a query into an /// iterator of obligations. - fn query_outlives_constraints_into_obligations<'a>( - &'a self, - cause: &'a ObligationCause<'tcx>, + fn query_outlives_constraints_into_obligations( + &self, + cause: &ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, - uninstantiated_region_constraints: &'a [QueryOutlivesConstraint<'tcx>], - result_args: &'a CanonicalVarValues<'tcx>, + uninstantiated_region_constraints: &[QueryOutlivesConstraint<'tcx>], + result_args: &CanonicalVarValues<'tcx>, ) -> impl Iterator> { uninstantiated_region_constraints.iter().map(move |&constraint| { let predicate = instantiate_value(self.tcx, result_args, constraint); diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 8e4ab7db526dd..62554374179cf 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1474,9 +1474,7 @@ impl<'tcx> InferCtxt<'tcx> { /// The returned function is used in a fast path. If it returns `true` the variable is /// unchanged, `false` indicates that the status is unknown. #[inline] - pub fn is_ty_infer_var_definitely_unchanged<'a>( - &'a self, - ) -> impl Fn(TyOrConstInferVar) -> bool { + pub fn is_ty_infer_var_definitely_unchanged(&self) -> impl Fn(TyOrConstInferVar) -> bool { // This hoists the borrow/release out of the loop body. let inner = self.inner.try_borrow(); diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 9119bdd473f99..58cddcdcd00c2 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -157,9 +157,7 @@ impl LintStore { &self.lints } - pub fn get_lint_groups<'t>( - &'t self, - ) -> impl Iterator, bool)> { + pub fn get_lint_groups(&self) -> impl Iterator, bool)> { self.lint_groups .iter() .filter(|(_, LintGroup { depr, .. })| { diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 42c86fb123d12..e7c993108e36e 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -953,9 +953,9 @@ impl CrateRoot { self.stable_crate_id } - pub(crate) fn decode_crate_deps<'a>( + pub(crate) fn decode_crate_deps( &self, - metadata: &'a MetadataBlob, + metadata: &MetadataBlob, ) -> impl ExactSizeIterator { self.crate_deps.decode(metadata) } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index e20f6841c44e2..e5e3f138883c2 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -470,7 +470,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable locals. #[inline] - pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator { + pub fn mut_vars_iter(&self) -> impl Iterator { (self.arg_count + 1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; @@ -480,7 +480,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable arguments and locals. #[inline] - pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator { + pub fn mut_vars_and_args_iter(&self) -> impl Iterator { (1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index 5b360f3e16911..9caf73462fe84 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -483,24 +483,24 @@ impl<'tcx> GenericArgs<'tcx> { } #[inline] - pub fn types(&'tcx self) -> impl DoubleEndedIterator> { + pub fn types(&self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_type()) } #[inline] - pub fn regions(&'tcx self) -> impl DoubleEndedIterator> { + pub fn regions(&self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_region()) } #[inline] - pub fn consts(&'tcx self) -> impl DoubleEndedIterator> { + pub fn consts(&self) -> impl DoubleEndedIterator> { self.iter().filter_map(|k| k.as_const()) } /// Returns generic arguments that are not lifetimes or host effect params. #[inline] pub fn non_erasable_generics( - &'tcx self, + &self, tcx: TyCtxt<'tcx>, def_id: DefId, ) -> impl DoubleEndedIterator> { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 52c4e24cab03c..92b18ebe8860c 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1827,14 +1827,11 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn get_attrs_by_path<'attr>( + pub fn get_attrs_by_path( self, did: DefId, - attr: &'attr [Symbol], - ) -> impl Iterator - where - 'tcx: 'attr, - { + attr: &[Symbol], + ) -> impl Iterator { let filter_fn = move |a: &&ast::Attribute| a.path_matches(attr); if let Some(did) = did.as_local() { self.hir().attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn) diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 10c0fd92ec489..d246bcdfa439f 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -329,8 +329,8 @@ impl<'tcx> ty::List> { } #[inline] - pub fn projection_bounds<'a>( - &'a self, + pub fn projection_bounds( + &self, ) -> impl Iterator>> { self.iter().filter_map(|predicate| { predicate @@ -343,7 +343,7 @@ impl<'tcx> ty::List> { } #[inline] - pub fn auto_traits<'a>(&'a self) -> impl Iterator { + pub fn auto_traits(&self) -> impl Iterator { self.iter().filter_map(|predicate| match predicate.skip_binder() { ExistentialPredicate::AutoTrait(did) => Some(did), _ => None, diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index f0d8f207b4d20..ad40c79ebf82f 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -216,9 +216,9 @@ fn to_upvars_resolved_place_builder<'tcx>( /// Supports only HIR projection kinds that represent a path that might be /// captured by a closure or a coroutine, i.e., an `Index` or a `Subslice` /// projection kinds are unsupported. -fn strip_prefix<'a, 'tcx>( +fn strip_prefix<'tcx>( mut base_ty: Ty<'tcx>, - projections: &'a [PlaceElem<'tcx>], + projections: &[PlaceElem<'tcx>], prefix_projections: &[HirProjection<'tcx>], ) -> impl Iterator> { let mut iter = projections diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index a325ed3c44599..3ed7fb5c4f406 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -156,8 +156,8 @@ impl<'tcx> Cx<'tcx> { }) } - fn explicit_params<'a>( - &'a mut self, + fn explicit_params( + &mut self, owner_id: HirId, fn_decl: &'tcx hir::FnDecl<'tcx>, body: &'tcx hir::Body<'tcx>, diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 7f3c66f335a19..fd2fd2e8b5f12 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -567,8 +567,8 @@ fn find_loop_backedges( backedges } -fn short_circuit_preorder<'a, 'tcx, F, Iter>( - body: &'a mir::Body<'tcx>, +fn short_circuit_preorder<'tcx, F, Iter>( + body: &mir::Body<'tcx>, filtered_successors: F, ) -> impl Iterator where diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 1761d4029563b..59d90f076ea1c 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -179,8 +179,8 @@ fn divide_spans_into_buckets(input_covspans: Vec, holes: &[Hole]) -> Ve /// Similar to `.drain(..)`, but stops just before it would remove an item not /// satisfying the predicate. -fn drain_front_while<'a, T>( - queue: &'a mut VecDeque, +fn drain_front_while( + queue: &mut VecDeque, mut pred_fn: impl FnMut(&T) -> bool, ) -> impl Iterator { std::iter::from_fn(move || if pred_fn(queue.front()?) { queue.pop_front() } else { None }) diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index 90c662eed625b..aca9dcbe0bf42 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -136,7 +136,7 @@ impl SsaLocals { } pub(super) fn assignments<'a, 'tcx>( - &'a self, + &self, body: &'a Body<'tcx>, ) -> impl Iterator, Location)> { self.assignment_order.iter().filter_map(|&local| { diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index 1a8b916db6243..fec44d5af55da 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -65,7 +65,7 @@ pub trait PatCx: Sized + fmt::Debug { &'a self, ctor: &'a Constructor, ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator; + ) -> impl Iterator + ExactSizeIterator + Captures<'a>; /// The set of all the constructors for `ty`. /// diff --git a/compiler/rustc_pattern_analysis/src/pat_column.rs b/compiler/rustc_pattern_analysis/src/pat_column.rs index ebd316cb5e168..eb4e095c1c662 100644 --- a/compiler/rustc_pattern_analysis/src/pat_column.rs +++ b/compiler/rustc_pattern_analysis/src/pat_column.rs @@ -41,7 +41,7 @@ impl<'p, Cx: PatCx> PatternColumn<'p, Cx> { pub fn head_ty(&self) -> Option<&Cx::Ty> { self.patterns.first().map(|pat| pat.ty()) } - pub fn iter<'a>(&'a self) -> impl Iterator> { + pub fn iter<'a>(&'a self) -> impl Iterator> + Captures<'a> { self.patterns.iter().copied() } diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 1cd06dfd6a205..6c09f97bfe731 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -936,7 +936,8 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> { &'a self, ctor: &'a crate::constructor::Constructor, ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator { + ) -> impl Iterator + ExactSizeIterator + Captures<'a> + { self.ctor_sub_tys(ctor, *ty) } fn ctors_for_ty( diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index 4288afeca487d..814559a66c568 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -905,7 +905,7 @@ impl PlaceInfo { &'a self, cx: &'a Cx, ctor: &'a Constructor, - ) -> impl Iterator + ExactSizeIterator { + ) -> impl Iterator + ExactSizeIterator + Captures<'a> { let ctor_sub_tys = cx.ctor_sub_tys(ctor, &self.ty); let ctor_sub_validity = self.validity.specialize(ctor); ctor_sub_tys.map(move |(ty, PrivateUninhabitedField(private_uninhabited))| PlaceInfo { diff --git a/compiler/rustc_pattern_analysis/tests/common/mod.rs b/compiler/rustc_pattern_analysis/tests/common/mod.rs index fd82e589f43b2..ec0bcd43ad24d 100644 --- a/compiler/rustc_pattern_analysis/tests/common/mod.rs +++ b/compiler/rustc_pattern_analysis/tests/common/mod.rs @@ -160,7 +160,8 @@ impl PatCx for Cx { &'a self, ctor: &'a Constructor, ty: &'a Self::Ty, - ) -> impl Iterator + ExactSizeIterator { + ) -> impl Iterator + ExactSizeIterator + Captures<'a> + { ty.sub_tys(ctor).into_iter().map(|ty| (ty, PrivateUninhabitedField(false))) } diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index d7c165cb17ab5..6ca54dd593547 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -836,8 +836,8 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> { } /// Returns the set of inference variables contained in `args`. -fn args_infer_vars<'a, 'tcx>( - selcx: &SelectionContext<'a, 'tcx>, +fn args_infer_vars<'tcx>( + selcx: &SelectionContext<'_, 'tcx>, args: ty::Binder<'tcx, GenericArgsRef<'tcx>>, ) -> impl Iterator { selcx diff --git a/compiler/rustc_ty_utils/src/layout_sanity_check.rs b/compiler/rustc_ty_utils/src/layout_sanity_check.rs index a2fb8b92b818e..95bd9e787066e 100644 --- a/compiler/rustc_ty_utils/src/layout_sanity_check.rs +++ b/compiler/rustc_ty_utils/src/layout_sanity_check.rs @@ -26,9 +26,9 @@ pub(super) fn sanity_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou } /// Yields non-ZST fields of the type - fn non_zst_fields<'tcx, 'a>( - cx: &'a LayoutCx<'tcx>, - layout: &'a TyAndLayout<'tcx>, + fn non_zst_fields<'tcx>( + cx: &LayoutCx<'tcx>, + layout: &TyAndLayout<'tcx>, ) -> impl Iterator)> { (0..layout.layout.fields().count()).filter_map(|i| { let field = layout.field(cx, i); From 93ea92c40852d23ca5989d0fa11bc730d7d26ad4 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 6 Aug 2024 12:20:12 -0400 Subject: [PATCH 4/6] Actually use precise capturing in favor of outlives --- compiler/rustc_borrowck/src/borrow_set.rs | 2 +- compiler/rustc_borrowck/src/universal_regions.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/locals.rs | 4 +++- compiler/rustc_data_structures/src/graph/scc/mod.rs | 2 +- compiler/rustc_expand/src/expand.rs | 2 +- compiler/rustc_expand/src/proc_macro.rs | 2 +- compiler/rustc_index/src/slice.rs | 2 +- .../src/error_reporting/infer/need_type_info.rs | 2 +- compiler/rustc_trait_selection/src/solve/fulfill.rs | 4 +++- 9 files changed, 13 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs index 7ace011e6868b..42faff3d35975 100644 --- a/compiler/rustc_borrowck/src/borrow_set.rs +++ b/compiler/rustc_borrowck/src/borrow_set.rs @@ -160,7 +160,7 @@ impl<'tcx> BorrowSet<'tcx> { self.location_map.len() } - pub(crate) fn indices(&self) -> impl Iterator + 'static { + pub(crate) fn indices(&self) -> impl Iterator + use<> { BorrowIndex::ZERO..BorrowIndex::from_usize(self.len()) } diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 0bcb7ae9ebc65..1d24948492ae1 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -312,7 +312,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// Returns an iterator over all the RegionVids corresponding to /// universally quantified free regions. - pub(crate) fn universal_regions(&self) -> impl Iterator + 'static { + pub(crate) fn universal_regions(&self) -> impl Iterator + use<> { (FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize) } diff --git a/compiler/rustc_codegen_ssa/src/mir/locals.rs b/compiler/rustc_codegen_ssa/src/mir/locals.rs index 70f99ad985ac1..55db0ba5596df 100644 --- a/compiler/rustc_codegen_ssa/src/mir/locals.rs +++ b/compiler/rustc_codegen_ssa/src/mir/locals.rs @@ -32,7 +32,9 @@ impl<'tcx, V> Locals<'tcx, V> { Locals { values: IndexVec::default() } } - pub(super) fn indices(&self) -> impl DoubleEndedIterator + Clone + 'static { + pub(super) fn indices( + &self, + ) -> impl DoubleEndedIterator + Clone + use<'tcx, V> { self.values.indices() } } diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index b472d8371e946..dcbdbac26f7a6 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -133,7 +133,7 @@ impl Sccs { /// meaning that if `S1 -> S2`, we will visit `S2` first and `S1` after. /// This is convenient when the edges represent dependencies: when you visit /// `S1`, the value for `S2` will already have been computed. - pub fn all_sccs(&self) -> impl Iterator + 'static { + pub fn all_sccs(&self) -> impl Iterator + use { (0..self.scc_data.len()).map(S::new) } diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 0d56a005f159e..f68ff56709f67 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -1727,7 +1727,7 @@ fn build_single_delegations<'a, Node: InvocationCollectorNode>( suffixes: &'a [(Ident, Option)], item_span: Span, from_glob: bool, -) -> impl Iterator> + 'a { +) -> impl Iterator> + use<'a, Node> { if suffixes.is_empty() { // Report an error for now, to avoid keeping stem for resolution and // stability checks. diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs index 6dcbcd671057f..53c5da40ed3cf 100644 --- a/compiler/rustc_expand/src/proc_macro.rs +++ b/compiler/rustc_expand/src/proc_macro.rs @@ -31,7 +31,7 @@ impl pm::bridge::server::MessagePipe for MessagePipe { } } -fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy + 'static { +fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy + use<> { pm::bridge::server::MaybeCrossThread::>::new( ecx.sess.opts.unstable_opts.proc_macro_execution_strategy == ProcMacroExecutionStrategy::CrossThread, diff --git a/compiler/rustc_index/src/slice.rs b/compiler/rustc_index/src/slice.rs index 4636f294f13bb..b94281b912065 100644 --- a/compiler/rustc_index/src/slice.rs +++ b/compiler/rustc_index/src/slice.rs @@ -70,7 +70,7 @@ impl IndexSlice { #[inline] pub fn indices( &self, - ) -> impl DoubleEndedIterator + ExactSizeIterator + Clone + 'static { + ) -> impl DoubleEndedIterator + ExactSizeIterator + Clone + use { (0..self.len()).map(|n| I::new(n)) } diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index 9fef75af204ec..2b36b425793d8 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -1021,7 +1021,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { &self, path: &'tcx hir::Path<'tcx>, args: GenericArgsRef<'tcx>, - ) -> impl Iterator> + 'tcx { + ) -> impl Iterator> + use<'tcx> { let tcx = self.tecx.tcx; let have_turbofish = path.segments.iter().any(|segment| { segment.args.is_some_and(|args| args.args.iter().any(|arg| arg.is_ty_or_const())) diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 5032d8d15e481..f6d44cdfa644f 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -70,7 +70,9 @@ impl<'tcx> ObligationStorage<'tcx> { obligations } - fn unstalled_for_select(&mut self) -> impl Iterator> + 'tcx { + fn unstalled_for_select( + &mut self, + ) -> impl Iterator> + use<'tcx> { mem::take(&mut self.pending).into_iter() } From d22fb9a64fe9fe3f77564844ada41b7ae8c04912 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 18 Sep 2024 15:39:23 -0400 Subject: [PATCH 5/6] Fix builtin lints --- compiler/rustc_lint/src/builtin.rs | 6 ++---- compiler/rustc_lint/src/foreign_modules.rs | 4 ++-- compiler/rustc_lint/src/types.rs | 2 +- compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 8b92180e9bd00..aea8fcbe172d7 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -998,10 +998,8 @@ declare_lint! { /// ### Example /// /// ```rust - /// #[no_mangle] - /// fn foo(t: T) { - /// - /// } + /// #[unsafe(no_mangle)] + /// fn foo(t: T) {} /// ``` /// /// {{produces}} diff --git a/compiler/rustc_lint/src/foreign_modules.rs b/compiler/rustc_lint/src/foreign_modules.rs index 33b8b7c544bcc..f20e7878e25c2 100644 --- a/compiler/rustc_lint/src/foreign_modules.rs +++ b/compiler/rustc_lint/src/foreign_modules.rs @@ -35,12 +35,12 @@ declare_lint! { /// /// ```rust /// mod m { - /// extern "C" { + /// unsafe extern "C" { /// fn foo(); /// } /// } /// - /// extern "C" { + /// unsafe extern "C" { /// fn foo(_: u32); /// } /// ``` diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index f9d0cd49708ae..b18de47dc665a 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -527,7 +527,7 @@ declare_lint! { /// ### Example /// /// ```rust - /// extern "C" { + /// unsafe extern "C" { /// static STATIC: String; /// } /// ``` diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index acdedb0614122..c194299a124eb 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2829,7 +2829,7 @@ declare_lint! { /// /// ```rust /// enum Void {} - /// extern { + /// unsafe extern { /// static EXTERN: Void; /// } /// ``` @@ -4095,7 +4095,7 @@ declare_lint! { /// ```rust /// #![warn(ffi_unwind_calls)] /// - /// extern "C-unwind" { + /// unsafe extern "C-unwind" { /// fn foo(); /// } /// @@ -4836,7 +4836,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust + /// ```rust,edition2021 /// #![warn(missing_unsafe_on_extern)] /// #![allow(dead_code)] /// @@ -4873,7 +4873,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust + /// ```rust,edition2021 /// #![warn(unsafe_attr_outside_unsafe)] /// /// #[no_mangle] From d33d91393fa46bd30042fa26006ce7d1f1d46768 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 21 Sep 2024 13:37:25 -0400 Subject: [PATCH 6/6] Add issue number, fix into_iter FIXME --- compiler/rustc_feature/src/tests.rs | 2 +- compiler/rustc_llvm/build.rs | 4 ++-- compiler/rustc_mir_transform/src/inline.rs | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_feature/src/tests.rs b/compiler/rustc_feature/src/tests.rs index f9dfa906512fd..c5e459b9970cf 100644 --- a/compiler/rustc_feature/src/tests.rs +++ b/compiler/rustc_feature/src/tests.rs @@ -2,7 +2,7 @@ use super::UnstableFeatures; #[test] fn rustc_bootstrap_parsing() { - // FIXME(edition_2024): Audit this for safety. This is probably racey, per: + // FIXME(edition_2024, #130672): Audit this for safety. This is probably racey, per: // . let is_bootstrap = |env, krate| { unsafe { diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 633f4ee5fc6b1..7a2e1ad13694d 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -51,12 +51,12 @@ fn detect_llvm_link() -> (&'static str, &'static str) { fn restore_library_path() { let key = tracked_env_var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR"); if let Some(env) = tracked_env_var_os("REAL_LIBRARY_PATH") { - // FIXME(edition_2024): Audit this for safety. + // FIXME(edition_2024, #130672): Audit this for safety. unsafe { env::set_var(&key, env); } } else { - // FIXME(edition_2024): Audit this for safety. + // FIXME(edition_2024, #130672): Audit this for safety. unsafe { env::remove_var(&key); } diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 2de75e2ef50fc..ae3eb168762dc 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -799,8 +799,7 @@ impl<'tcx> Inliner<'tcx> { // // and the vector is `[closure_ref, tmp0, tmp1, tmp2]`. if callsite.fn_sig.abi() == Abi::RustCall && callee_body.spread_arg.is_none() { - // FIXME(edition_2024): switch back to a normal method call. - let mut args = <_>::into_iter(args); + let mut args = args.into_iter(); let self_ = self.create_temp_if_necessary( args.next().unwrap().node, callsite, @@ -834,8 +833,7 @@ impl<'tcx> Inliner<'tcx> { closure_ref_arg.chain(tuple_tmp_args).collect() } else { - // FIXME(edition_2024): switch back to a normal method call. - <_>::into_iter(args) + args.into_iter() .map(|a| self.create_temp_if_necessary(a.node, callsite, caller_body, return_block)) .collect() }