rust/src/test/ui/impl-trait
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
..
auxiliary
issues Add tracking issue 2021-05-16 21:57:40 +02:00
multiple-lifetimes bless compare-mode=nll output 2021-05-26 12:05:34 -04:00
associated-impl-trait-type-generic-trait.full_tait.stderr Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
associated-impl-trait-type-generic-trait.rs Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
associated-impl-trait-type-trivial.full_tait.stderr Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
associated-impl-trait-type-trivial.rs Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
associated-impl-trait-type.full_tait.stderr Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
associated-impl-trait-type.rs Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
auto-trait-leak-rpass.rs
auto-trait-leak.rs Treat selection error as ambiguous when error type is present 2020-06-04 21:09:31 -04:00
auto-trait-leak.stderr Move from {{closure}}#0 syntax to {closure#0} for (def) path components 2020-09-25 22:46:14 +01:00
auto-trait-leak2.rs pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
auto-trait-leak2.stderr pretty.rs: Update Closure and Generator print 2020-09-28 01:27:19 -04:00
auto-trait.full_tait.stderr Remove trailing : from E0119 message 2021-04-06 18:16:11 -07:00
auto-trait.min_tait.stderr Remove trailing : from E0119 message 2021-04-06 18:16:11 -07:00
auto-trait.rs Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
binding-without-value.rs Expand "recursive opaque type" diagnostic 2020-06-15 11:08:43 -07:00
binding-without-value.stderr review comments 2020-06-15 12:11:28 -07:00
bindings-opaque.rs adjust tests 2020-05-09 14:40:17 +02:00
bindings-opaque.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
bindings.rs adjust tests 2020-05-09 14:40:17 +02:00
bindings.stderr Use correct span for structured suggestion 2021-01-07 16:52:44 -08:00
bound-normalization-fail.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
bound-normalization-fail.stderr Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
bound-normalization-pass.default.stderr Use its own TypeckResults to avoid ICE 2020-10-25 18:35:24 +09:00
bound-normalization-pass.rs Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
bound-normalization-pass.sa.stderr Use its own TypeckResults to avoid ICE 2020-10-25 18:35:24 +09:00
bounds_regression.rs
can-return-unconstrained-closure.rs
closure-calling-parent-fn.rs Update test stderr with results of enabling unused lints 2019-09-08 11:32:28 -04:00
closure-in-impl-trait-arg.rs arg position 2020-10-07 10:19:04 +02:00
closure-in-impl-trait.rs do not lower patterns in impl Trait 2020-10-07 10:19:04 +02:00
deprecated_annotation.rs
does-not-live-long-enough.rs Suggest move for closures and async blocks in more cases. 2020-04-08 13:01:53 +02:00
does-not-live-long-enough.stderr Suggest move for closures and async blocks in more cases. 2020-04-08 13:01:53 +02:00
dyn-trait-elided-two-inputs-assoc.rs distinguish object-lifetime-default elision from other elision 2019-08-19 13:50:42 -04:00
dyn-trait-elided-two-inputs-param.rs distinguish object-lifetime-default elision from other elision 2019-08-19 13:50:42 -04:00
dyn-trait-elided-two-inputs-ref-assoc.rs use static as object-lifetime default for type XX in Foo<Item=XX> 2019-08-19 13:50:44 -04:00
dyn-trait-elided-two-inputs-ref-param.rs distinguish object-lifetime-default elision from other elision 2019-08-19 13:50:42 -04:00
dyn-trait-return-should-be-impl-trait.rs Ensure tail expression will have a Ty for E0746 2020-04-20 11:17:03 -07:00
dyn-trait-return-should-be-impl-trait.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
equal-hidden-lifetimes.rs Handle equal regions in opaque type inference 2020-02-14 22:40:03 +00:00
equal-hidden-lifetimes.stderr rustc: Add a warning count upon completion 2020-04-11 16:15:24 +02:00
equality-rpass.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
equality-rpass.stderr Suggest minimal subset features in incomplete_features lint 2020-10-17 02:01:08 +09:00
equality.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
equality.stderr Suggest minimal subset features in incomplete_features lint 2020-10-17 02:01:08 +09:00
equality2.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
equality2.stderr fix expected/found order on impl trait projection mismatch 2021-03-16 16:55:11 +00:00
example-calendar.rs Unify feature flags as step_trait 2021-05-26 18:07:10 -04:00
example-st.rs
extra-item.rs
extra-item.stderr
hidden-lifetimes.rs
hidden-lifetimes.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
impl-generic-mismatch-ab.rs
impl-generic-mismatch-ab.stderr Suggest changing impl parameter types to match trait 2021-04-08 13:50:47 -07:00
impl-generic-mismatch.rs tests: remove ignore directives from tests that mention core/alloc/std spans. 2020-04-02 11:48:34 +03:00
impl-generic-mismatch.stderr mv std libs to library/ 2020-07-27 19:51:13 -05:00
impl-trait-in-bindings-issue-73003.rs Move some tests to more reasonable directories - 5 2021-03-20 11:41:24 -03:00
impl-trait-in-bindings-issue-73003.stderr Move some tests to more reasonable directories - 5 2021-03-20 11:41:24 -03:00
impl-trait-in-bindings.rs Move some tests to more reasonable directories - 5 2021-03-20 11:41:24 -03:00
impl-trait-in-bindings.stderr Move some tests to more reasonable directories - 5 2021-03-20 11:41:24 -03:00
impl-trait-in-macro.rs Make def_key and HIR parenting consistent. 2021-03-12 22:48:32 +01:00
impl-trait-in-macro.stderr Make def_key and HIR parenting consistent. 2021-03-12 22:48:32 +01:00
impl-trait-plus-priority.rs
impl-trait-plus-priority.stderr
impl_trait_projections.rs
impl_trait_projections.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
issue-55872-1.full_tait.stderr Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-55872-1.min_tait.stderr Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-55872-1.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-55872-2.full_tait.stderr Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-55872-2.min_tait.stderr Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-55872-2.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-55872.full_tait.stderr Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-55872.min_tait.stderr Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-55872.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
issue-56445.rs make ConstEvaluatable more strict 2020-09-08 16:39:12 +02:00
issue-57200.rs Add FIXMEs 2020-03-09 16:50:46 +09:00
issue-57200.stderr Add FIXMEs 2020-03-09 16:50:46 +09:00
issue-57201.rs Add FIXMEs 2020-03-09 16:50:46 +09:00
issue-57201.stderr Add FIXMEs 2020-03-09 16:50:46 +09:00
issue-60473.rs Forbid lifetime elision in let position impl Trait 2020-06-11 16:24:01 +01:00
issue-60473.stderr Forbid lifetime elision in let position impl Trait 2020-06-11 16:24:01 +01:00
issue-67166.rs Forbid lifetime elision in let position impl Trait 2020-06-11 16:24:01 +01:00
issue-67166.stderr Forbid lifetime elision in let position impl Trait 2020-06-11 16:24:01 +01:00
issue-68532.rs Add test for #68532 2020-05-27 00:48:37 +09:00
issue-69840.rs Add test for issue-69840 2020-06-23 17:52:51 +09:00
issue-72911.rs Add test for issue-72911 2020-07-26 18:54:54 +09:00
issue-72911.stderr Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasper 2020-09-09 15:05:45 -07:00
lifetimes.rs
method-suggestion-no-duplication.rs
method-suggestion-no-duplication.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
multiple-lifetimes.rs
must_outlive_least_region_or_bound.nll.stderr Further tweak wording of E0759 and introduce E0767 2020-07-22 12:25:54 -07:00
must_outlive_least_region_or_bound.rs Further tweak wording of E0759 and introduce E0767 2020-07-22 12:25:54 -07:00
must_outlive_least_region_or_bound.stderr Further tweak wording of E0759 and introduce E0767 2020-07-22 12:25:54 -07:00
needs_least_region_or_bound.rs stabilize member constraints 2021-05-26 06:01:53 -04:00
negative-reasoning.full_tait.stderr Remove trailing : from E0119 message 2021-04-06 18:16:11 -07:00
negative-reasoning.min_tait.stderr Remove trailing : from E0119 message 2021-04-06 18:16:11 -07:00
negative-reasoning.rs Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
nested-return-type.rs Fix and test nested impl Trait 2020-02-14 22:40:03 +00:00
nested_impl_trait.rs Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
nested_impl_trait.stderr Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
nesting.rs
no-method-suggested-traits.rs Unify output of "variant not found" errors 2020-01-08 08:05:31 -08:00
no-method-suggested-traits.stderr Tweak suggestion output 2021-04-23 18:57:52 -07:00
no-trait.rs
no-trait.stderr
object-unsafe-trait-in-return-position-dyn-trait.rs Account for object safety when suggesting Box<dyn Trait> 2020-01-16 09:49:14 -08:00
object-unsafe-trait-in-return-position-dyn-trait.stderr review comments 2020-10-20 09:26:15 -07:00
object-unsafe-trait-in-return-position-impl-trait.rs Account for object safety when suggesting Box<dyn Trait> 2020-01-16 09:49:14 -08:00
object-unsafe-trait-in-return-position-impl-trait.stderr Make suggestion more complete 2020-09-11 17:05:18 -07:00
point-to-type-err-cause-on-impl-trait-return.rs Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
point-to-type-err-cause-on-impl-trait-return.stderr Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
projection-mismatch-in-impl-where-clause.rs peel derives when checking normalized is expected 2021-03-16 16:55:11 +00:00
projection-mismatch-in-impl-where-clause.stderr rebase and update tests 2021-04-07 08:31:38 -07:00
recursive-impl-trait-type-direct.rs Update tests 2020-02-14 22:40:03 +00:00
recursive-impl-trait-type-direct.stderr review comments 2020-06-15 12:11:28 -07:00
recursive-impl-trait-type-indirect.rs Update tests 2020-02-14 22:40:03 +00:00
recursive-impl-trait-type-indirect.stderr pretty.rs: Update Closure and Generator print 2020-09-28 01:27:19 -04:00
recursive-impl-trait-type-through-non-recursive.rs Expand "recursive opaque type" diagnostic 2020-06-15 11:08:43 -07:00
recursive-impl-trait-type-through-non-recursive.stderr review comments 2020-06-15 12:11:28 -07:00
region-escape-via-bound-contravariant-closure.rs
region-escape-via-bound-contravariant.rs
region-escape-via-bound.rs
region-escape-via-bound.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
return-position-impl-trait-minimal.rs
static-return-lifetime-infered.nll.stderr Further tweak wording of E0759 and introduce E0767 2020-07-22 12:25:54 -07:00
static-return-lifetime-infered.rs Further tweak wording of E0759 and introduce E0767 2020-07-22 12:25:54 -07:00
static-return-lifetime-infered.stderr Further tweak wording of E0759 and introduce E0767 2020-07-22 12:25:54 -07:00
trait_type.rs
trait_type.stderr Suggest changing impl parameter types to match trait 2021-04-08 13:50:47 -07:00
type-alias-generic-param.full_tait.stderr Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
type-alias-generic-param.rs Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
type-alias-impl-trait-in-fn-body.full_tait.stderr Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
type-alias-impl-trait-in-fn-body.rs Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
type_parameters_captured.nll.stderr
type_parameters_captured.rs
type_parameters_captured.stderr Tweak type parameter errors to reduce verbosity 2020-05-30 10:22:26 -07:00
universal-mismatched-type.rs
universal-mismatched-type.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
universal-two-impl-traits.rs Make def_key and HIR parenting consistent. 2021-03-12 22:48:32 +01:00
universal-two-impl-traits.stderr Specific labels when referring to "expected" and "found" types 2019-11-18 11:02:22 -08:00
universal_hrtb_anon.rs
universal_hrtb_named.rs
universal_in_adt_in_parameters.rs
universal_in_impl_trait_in_parameters.rs
universal_in_trait_defn_parameters.rs
universal_multiple_bounds.rs
universal_wrong_bounds.rs
universal_wrong_bounds.stderr reword "possible candidate" import suggestion 2020-05-07 00:33:25 -04:00
unsafety-checking-cycle.rs Call is_freeze less in unsafety-checking 2020-02-14 20:12:46 +00:00
wf-eval-order.rs Fix bugs in evaluating WellFormed predicates 2020-10-06 11:19:31 +01:00
where-allowed-2.rs Expand "recursive opaque type" diagnostic 2020-06-15 11:08:43 -07:00
where-allowed-2.stderr review comments 2020-06-15 12:11:28 -07:00
where-allowed.rs forbid impl Trait in generic param defaults 2021-04-06 16:21:08 +01:00
where-allowed.stderr forbid impl Trait in generic param defaults 2021-04-06 16:21:08 +01:00
xcrate.rs
xcrate_simple.rs