@@ -132,37 +132,37 @@ pub fn report_unstable(
132132/// Checks whether an item marked with `deprecated(since="X")` is currently
133133/// deprecated (i.e., whether X is not greater than the current rustc version).
134134pub fn deprecation_in_effect ( is_since_rustc_version : bool , since : Option < & str > ) -> bool {
135- let since = if let Some ( since) = since {
136- if is_since_rustc_version {
137- since
138- } else {
139- // We assume that the deprecation is in effect if it's not a
140- // rustc version.
141- return true ;
142- }
143- } else {
144- // If since attribute is not set, then we're definitely in effect.
145- return true ;
146- } ;
147135 fn parse_version ( ver : & str ) -> Vec < u32 > {
148136 // We ignore non-integer components of the version (e.g., "nightly").
149137 ver. split ( |c| c == '.' || c == '-' ) . flat_map ( |s| s. parse ( ) ) . collect ( )
150138 }
151139
152- if let Some ( rustc) = option_env ! ( "CFG_RELEASE" ) {
153- let since: Vec < u32 > = parse_version ( & since) ;
154- let rustc: Vec < u32 > = parse_version ( rustc) ;
155- // We simply treat invalid `since` attributes as relating to a previous
156- // Rust version, thus always displaying the warning.
157- if since. len ( ) != 3 {
158- return true ;
159- }
160- since <= rustc
161- } else {
162- // By default, a deprecation warning applies to
163- // the current version of the compiler.
164- true
140+ if !is_since_rustc_version {
141+ // The `since` field doesn't have semantic purpose in the stable `deprecated`
142+ // attribute, only in `rustc_deprecated`.
143+ return true ;
165144 }
145+
146+ if let Some ( since) = since {
147+ if since == "TBD" {
148+ return false ;
149+ }
150+
151+ if let Some ( rustc) = option_env ! ( "CFG_RELEASE" ) {
152+ let since: Vec < u32 > = parse_version ( & since) ;
153+ let rustc: Vec < u32 > = parse_version ( rustc) ;
154+ // We simply treat invalid `since` attributes as relating to a previous
155+ // Rust version, thus always displaying the warning.
156+ if since. len ( ) != 3 {
157+ return true ;
158+ }
159+ return since <= rustc;
160+ }
161+ } ;
162+
163+ // Assume deprecation is in effect if "since" field is missing
164+ // or if we can't determine the current Rust version.
165+ true
166166}
167167
168168pub fn deprecation_suggestion (
@@ -182,19 +182,24 @@ pub fn deprecation_suggestion(
182182}
183183
184184pub fn deprecation_message ( depr : & Deprecation , kind : & str , path : & str ) -> ( String , & ' static Lint ) {
185- let ( message, lint) = if deprecation_in_effect (
186- depr. is_since_rustc_version ,
187- depr. since . map ( Symbol :: as_str) . as_deref ( ) ,
188- ) {
185+ let since = depr. since . map ( Symbol :: as_str) ;
186+ let ( message, lint) = if deprecation_in_effect ( depr. is_since_rustc_version , since. as_deref ( ) ) {
189187 ( format ! ( "use of deprecated {} `{}`" , kind, path) , DEPRECATED )
190188 } else {
191189 (
192- format ! (
193- "use of {} `{}` that will be deprecated in future version {}" ,
194- kind,
195- path,
196- depr. since. unwrap( )
197- ) ,
190+ if since. as_deref ( ) == Some ( "TBD" ) {
191+ format ! (
192+ "use of {} `{}` that will be deprecated in a future Rust version" ,
193+ kind, path
194+ )
195+ } else {
196+ format ! (
197+ "use of {} `{}` that will be deprecated in future version {}" ,
198+ kind,
199+ path,
200+ since. unwrap( )
201+ )
202+ } ,
198203 DEPRECATED_IN_FUTURE ,
199204 )
200205 } ;
0 commit comments