rust/compiler
bors 9a72afa7dd Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrum
Make `Step` trait safe to implement

This PR makes a few modifications to the `Step` trait that I believe better position it for stabilization in the short term. In particular,

1. `unsafe trait TrustedStep` is introduced, indicating that the implementation of `Step` for a given type upholds all stated invariants (which have remained unchanged). This is gated behind a new `trusted_step` feature, as stabilization is realistically blocked on min_specialization.
2. The `Step` trait is internally specialized on the `TrustedStep` trait, which avoids a serious performance regression.
3. `TrustedLen` is implemented for `T: TrustedStep` as the latter's invariants subsume the former's.
4. The `Step` trait is no longer `unsafe`, as the invariants must not be relied upon by unsafe code (unless the type implements `TrustedStep`).
5. `TrustedStep` is implemented for all types that implement `Step` in the standard library and compiler.
6. The `step_trait_ext` feature is merged into the `step_trait` feature. I was unable to find any reasoning for the features being split; the `_unchecked` methods need not necessarily be stabilized at the same time, but I think it is useful to have them under the same feature flag.

All existing implementations of `Step` will be broken, as it is not possible to `unsafe impl` a safe trait. Given this trait only exists on nightly, I feel this breakage is acceptable. The blanket `impl<T: Step> TrustedLen for T` will likely cause some minor breakage, but this should be covered by the equivalent impl for `TrustedStep`.

Hopefully these changes are sufficient to place `Step` in decent position for stabilization, which would allow user-defined types to be used with `a..b` syntax.
2021-05-30 01:21:39 +00:00
..
rustc use jemallocator in rustc/rustdoc 2021-04-04 14:10:26 -07:00
rustc_apfloat remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_arena Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_ast Specialize implementations 2021-05-26 18:07:09 -04:00
rustc_ast_lowering remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_ast_passes Stabilize extended_key_value_attributes 2021-05-18 01:01:36 -04:00
rustc_ast_pretty remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_attr remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_builtin_macros remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_codegen_cranelift Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27 2021-05-27 13:08:14 +02:00
rustc_codegen_llvm Fix static relocation model for PowerPC64 2021-05-28 03:48:39 +02:00
rustc_codegen_ssa Rollup merge of #85649 - ChrisDenton:update-cc, r=matthewjasper 2021-05-27 03:02:09 +02:00
rustc_data_structures Don't panic when failing to initialize incremental directory. 2021-05-25 14:40:33 -07:00
rustc_driver Auto merge of #83842 - LeSeulArtichaut:thir-vec, r=nikomatsakis 2021-05-19 18:41:23 +00:00
rustc_error_codes swap function order for better read flow 2021-05-13 13:22:24 +02:00
rustc_errors Stabilize extended_key_value_attributes 2021-05-18 01:01:36 -04:00
rustc_expand remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_feature stabilize member constraints 2021-05-26 06:01:53 -04:00
rustc_fs_util Optimize away a fs::metadata call. 2021-01-06 08:33:15 -08:00
rustc_graphviz Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_hir Specialize implementations 2021-05-26 18:07:09 -04:00
rustc_hir_pretty remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_incremental Auto merge of #85698 - ehuss:incremental-session-panic, r=estebank 2021-05-29 19:27:53 +00:00
rustc_index Unify feature flags as step_trait 2021-05-26 18:07:10 -04:00
rustc_infer Specialize implementations 2021-05-26 18:07:09 -04:00
rustc_interface Don't panic when failing to initialize incremental directory. 2021-05-25 14:40:33 -07:00
rustc_lexer Fix outdated crate names in compiler docs 2021-04-08 11:12:14 -05:00
rustc_lint Lint against non-camelCase trait alias names 2021-05-26 19:55:27 -04:00
rustc_lint_defs Add additional migrations to handle auto-traits and clone traits 2021-05-06 14:17:59 -04:00
rustc_llvm Update cc 2021-05-24 23:34:12 +01:00
rustc_macros Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
rustc_metadata remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_middle Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrum 2021-05-30 01:21:39 +00:00
rustc_mir Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrum 2021-05-30 01:21:39 +00:00
rustc_mir_build Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrum 2021-05-30 01:21:39 +00:00
rustc_parse remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_parse_format remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_passes Specialize implementations 2021-05-26 18:07:09 -04:00
rustc_plugin_impl Use () for plugin_registrar_fn. 2021-05-12 13:58:43 +02:00
rustc_privacy remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_query_impl Use () in dependency_formats. 2021-05-12 13:58:41 +02:00
rustc_query_system Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrum 2021-05-30 01:21:39 +00:00
rustc_resolve Rollup merge of #85478 - FabianWolff:issue-85348, r=petrochenkov 2021-05-26 13:32:05 +02:00
rustc_save_analysis remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_serialize Auto merge of #83465 - michaelwoerister:safe-read_raw_bytes, r=cjgillot 2021-03-26 01:28:59 +00:00
rustc_session Rollup merge of #85361 - bjorn3:rustdoc_target_json_path_canonicalize, r=jyn514 2021-05-25 13:05:09 +02:00
rustc_span Specialize implementations 2021-05-26 18:07:09 -04:00
rustc_symbol_mangling remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_target Specialize implementations 2021-05-26 18:07:09 -04:00
rustc_trait_selection stabilize member constraints 2021-05-26 06:01:53 -04:00
rustc_traits Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
rustc_ty_utils add new attribute rustc_insignificant_dtor and a query to check if a type has a significant drop 2021-05-14 22:57:33 -04:00
rustc_type_ir Specialize implementations 2021-05-26 18:07:09 -04:00
rustc_typeck Auto merge of #84968 - FabianWolff:master, r=estebank 2021-05-28 03:38:28 +00:00