Skip to content

Commit 7f4a612

Browse files
committed
Reduce number of lints, add feature gate.
1 parent 5e38d1d commit 7f4a612

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

text/0000-type-ascription.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- Start Date: 2015-2-3
22
- RFC PR: (leave this empty)
33
- Rust Issue: (leave this empty)
4+
- Feature: `ascription`
45

56
# Summary
67

@@ -113,6 +114,8 @@ expression are exactly those of the implicit coercion.
113114
@eddyb has implemented the expressions part of this RFC,
114115
[PR](https://github.com/rust-lang/rust/pull/21836).
115116

117+
This feature should land behind the `ascription` feature gate.
118+
116119

117120
### coercion and `as` vs `:`
118121

@@ -126,23 +129,19 @@ confusing for users, since there is no reason to use type ascription rather than
126129
as the default whether or not it is required, then it loses its function as a
127130
warning sign for programmers to beware of.
128131

129-
To address this I propose three lints which check for: trivial casts, coercible
130-
casts, and trivial numeric casts. Other than these lints we stick with the
131-
proposal from #401 that unnecessary casts will no longer be an error.
132-
133-
A trivial cast is a cast `x as T` where `x` has type `U` and `U` is a subtype of
134-
`T` (note that subtyping includes reflexivity).
132+
To address this I propose two lints which check for: trivial casts and trivial
133+
numeric casts. Other than these lints we stick with the proposal from #401 that
134+
unnecessary casts will no longer be an error.
135135

136-
A coercible cast is a cast `x as T` where `x` has type `U` and `x` can be
137-
implicitly coerced to `T`, but `U` is not a subtype of `T`.
136+
A trivial cast is a cast `x as T` where `x` has type `U` and `x` can be
137+
implicitly coerced to `T` or is already a subtype of `T`.
138138

139139
A trivial numeric cast is a cast `x as T` where `x` has type `U` and `x` is
140140
implicitly coercible to `T` or `U` is a subtype of `T`, and both `U` and `T` are
141141
numeric types.
142142

143-
Like any lints, these can be customised per-crate by the programmer. The trivial
144-
cast lint is 'deny' by default (i.e., causes an error); the coercible cast and
145-
trivial numeric cast lints are 'warn' by default.
143+
Like any lints, these can be customised per-crate by the programmer. Both lints
144+
are 'warn' by default.
146145

147146
Although this is a somewhat complex scheme, it allows code that works today to
148147
work with only minor adjustment, it allows for a backwards compatible path to

0 commit comments

Comments
 (0)