Skip to content

Commit 5ea1923

Browse files
committed
Auto merge of #86001 - richkadel:revert-85617-rustin-patch-fix, r=Mark-Simulacrum
Revert "shrinking the deprecated method span" Reverts #85617 Fixes: #86000 r? `@Mark-Simulacrum`
2 parents 34b9932 + 1384200 commit 5ea1923

File tree

8 files changed

+149
-163
lines changed

8 files changed

+149
-163
lines changed

compiler/rustc_passes/src/stability.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -828,11 +828,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
828828

829829
fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, id: hir::HirId) {
830830
if let Some(def_id) = path.res.opt_def_id() {
831-
let method_span = match path.segments {
832-
[.., _, last] => Some(last.ident.span),
833-
_ => None,
834-
};
835-
self.tcx.check_stability(def_id, Some(id), path.span, method_span)
831+
self.tcx.check_stability(def_id, Some(id), path.span, None)
836832
}
837833
intravisit::walk_path(self, path)
838834
}

src/test/ui/deprecation/deprecation-lint.rs

+18
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,24 @@ mod this_crate2 {
430430
// the patterns are all fine:
431431
(..) = x;
432432
}
433+
434+
#[derive(Debug)]
435+
#[deprecated(note = "Use something else instead")]
436+
enum DeprecatedDebugEnum {
437+
Variant1 { value: Option<String> },
438+
}
439+
440+
#[allow(deprecated)]
441+
impl DeprecatedDebugEnum {
442+
fn new() -> Self {
443+
DeprecatedDebugEnum::Variant1 { value: None }
444+
}
445+
}
446+
447+
#[allow(deprecated)]
448+
pub fn allow_dep() {
449+
let _ = DeprecatedDebugEnum::new();
450+
}
433451
}
434452

435453
fn main() {}

src/test/ui/deprecation/deprecation-lint.stderr

+54-54
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ LL | #![deny(deprecated)]
1111
| ^^^^^^^^^^
1212

1313
error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text
14-
--> $DIR/deprecation-lint.rs:21:16
14+
--> $DIR/deprecation-lint.rs:21:9
1515
|
1616
LL | Trait::trait_deprecated(&foo);
17-
| ^^^^^^^^^^^^^^^^
17+
| ^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text
20-
--> $DIR/deprecation-lint.rs:23:25
20+
--> $DIR/deprecation-lint.rs:23:9
2121
|
2222
LL | <Foo as Trait>::trait_deprecated(&foo);
23-
| ^^^^^^^^^^^^^^^^
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424

2525
error: use of deprecated function `deprecation_lint::deprecated_text`: text
2626
--> $DIR/deprecation-lint.rs:25:9
@@ -29,16 +29,16 @@ LL | deprecated_text();
2929
| ^^^^^^^^^^^^^^^
3030

3131
error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
32-
--> $DIR/deprecation-lint.rs:30:16
32+
--> $DIR/deprecation-lint.rs:30:9
3333
|
3434
LL | ... Trait::trait_deprecated_text(&foo);
35-
| ^^^^^^^^^^^^^^^^^^^^^
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636

3737
error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
38-
--> $DIR/deprecation-lint.rs:32:25
38+
--> $DIR/deprecation-lint.rs:32:9
3939
|
4040
LL | ... <Foo as Trait>::trait_deprecated_text(&foo);
41-
| ^^^^^^^^^^^^^^^^^^^^^
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4242

4343
error: use of deprecated struct `deprecation_lint::DeprecatedStruct`: text
4444
--> $DIR/deprecation-lint.rs:34:17
@@ -53,10 +53,10 @@ LL | let _ = DeprecatedUnitStruct;
5353
| ^^^^^^^^^^^^^^^^^^^^
5454

5555
error: use of deprecated variant `deprecation_lint::Enum::DeprecatedVariant`: text
56-
--> $DIR/deprecation-lint.rs:40:23
56+
--> $DIR/deprecation-lint.rs:40:17
5757
|
5858
LL | let _ = Enum::DeprecatedVariant;
59-
| ^^^^^^^^^^^^^^^^^
59+
| ^^^^^^^^^^^^^^^^^^^^^^^
6060

6161
error: use of deprecated struct `deprecation_lint::DeprecatedTupleStruct`: text
6262
--> $DIR/deprecation-lint.rs:42:17
@@ -65,28 +65,28 @@ LL | let _ = DeprecatedTupleStruct (1);
6565
| ^^^^^^^^^^^^^^^^^^^^^
6666

6767
error: use of deprecated struct `deprecation_lint::nested::DeprecatedStruct`: text
68-
--> $DIR/deprecation-lint.rs:44:25
68+
--> $DIR/deprecation-lint.rs:44:17
6969
|
7070
LL | let _ = nested::DeprecatedStruct {
71-
| ^^^^^^^^^^^^^^^^
71+
| ^^^^^^^^^^^^^^^^^^^^^^^^
7272

7373
error: use of deprecated struct `deprecation_lint::nested::DeprecatedUnitStruct`: text
74-
--> $DIR/deprecation-lint.rs:48:25
74+
--> $DIR/deprecation-lint.rs:48:17
7575
|
7676
LL | let _ = nested::DeprecatedUnitStruct;
77-
| ^^^^^^^^^^^^^^^^^^^^
77+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7878

7979
error: use of deprecated variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text
80-
--> $DIR/deprecation-lint.rs:50:31
80+
--> $DIR/deprecation-lint.rs:50:17
8181
|
8282
LL | ... let _ = nested::Enum::DeprecatedVariant;
83-
| ^^^^^^^^^^^^^^^^^
83+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8484

8585
error: use of deprecated struct `deprecation_lint::nested::DeprecatedTupleStruct`: text
86-
--> $DIR/deprecation-lint.rs:52:25
86+
--> $DIR/deprecation-lint.rs:52:17
8787
|
8888
LL | ... let _ = nested::DeprecatedTupleStruct (1);
89-
| ^^^^^^^^^^^^^^^^^^^^^
89+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9090

9191
error: use of deprecated function `deprecation_lint::deprecated_text`: text
9292
--> $DIR/deprecation-lint.rs:59:25
@@ -101,28 +101,28 @@ LL | macro_test_arg!(macro_test_arg!(deprecated_text()));
101101
| ^^^^^^^^^^^^^^^
102102

103103
error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text
104-
--> $DIR/deprecation-lint.rs:65:16
104+
--> $DIR/deprecation-lint.rs:65:9
105105
|
106106
LL | Trait::trait_deprecated(&foo);
107-
| ^^^^^^^^^^^^^^^^
107+
| ^^^^^^^^^^^^^^^^^^^^^^^
108108

109109
error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text
110-
--> $DIR/deprecation-lint.rs:67:25
110+
--> $DIR/deprecation-lint.rs:67:9
111111
|
112112
LL | <Foo as Trait>::trait_deprecated(&foo);
113-
| ^^^^^^^^^^^^^^^^
113+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
114114

115115
error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
116-
--> $DIR/deprecation-lint.rs:69:16
116+
--> $DIR/deprecation-lint.rs:69:9
117117
|
118118
LL | ... Trait::trait_deprecated_text(&foo);
119-
| ^^^^^^^^^^^^^^^^^^^^^
119+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120120

121121
error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
122-
--> $DIR/deprecation-lint.rs:71:25
122+
--> $DIR/deprecation-lint.rs:71:9
123123
|
124124
LL | ... <Foo as Trait>::trait_deprecated_text(&foo);
125-
| ^^^^^^^^^^^^^^^^^^^^^
125+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126126

127127
error: use of deprecated trait `deprecation_lint::DeprecatedTrait`: text
128128
--> $DIR/deprecation-lint.rs:81:10
@@ -173,10 +173,10 @@ LL | let Deprecated2
173173
| ^^^^^^^^^^^
174174

175175
error: use of deprecated function `deprecation_lint::deprecated_mod::deprecated`: text
176-
--> $DIR/deprecation-lint.rs:162:25
176+
--> $DIR/deprecation-lint.rs:162:9
177177
|
178178
LL | deprecated_mod::deprecated();
179-
| ^^^^^^^^^^
179+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
180180

181181
error: use of deprecated function `this_crate::deprecated`: text
182182
--> $DIR/deprecation-lint.rs:245:9
@@ -185,16 +185,16 @@ LL | deprecated();
185185
| ^^^^^^^^^^
186186

187187
error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
188-
--> $DIR/deprecation-lint.rs:250:16
188+
--> $DIR/deprecation-lint.rs:250:9
189189
|
190190
LL | Trait::trait_deprecated(&foo);
191-
| ^^^^^^^^^^^^^^^^
191+
| ^^^^^^^^^^^^^^^^^^^^^^^
192192

193193
error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
194-
--> $DIR/deprecation-lint.rs:252:25
194+
--> $DIR/deprecation-lint.rs:252:9
195195
|
196196
LL | <Foo as Trait>::trait_deprecated(&foo);
197-
| ^^^^^^^^^^^^^^^^
197+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198198

199199
error: use of deprecated function `this_crate::deprecated_text`: text
200200
--> $DIR/deprecation-lint.rs:254:9
@@ -203,16 +203,16 @@ LL | deprecated_text();
203203
| ^^^^^^^^^^^^^^^
204204

205205
error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
206-
--> $DIR/deprecation-lint.rs:259:16
206+
--> $DIR/deprecation-lint.rs:259:9
207207
|
208208
LL | Trait::trait_deprecated_text(&foo);
209-
| ^^^^^^^^^^^^^^^^^^^^^
209+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
210210

211211
error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
212-
--> $DIR/deprecation-lint.rs:261:25
212+
--> $DIR/deprecation-lint.rs:261:9
213213
|
214214
LL | ... <Foo as Trait>::trait_deprecated_text(&foo);
215-
| ^^^^^^^^^^^^^^^^^^^^^
215+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
216216

217217
error: use of deprecated function `this_crate::deprecated_future`: text
218218
--> $DIR/deprecation-lint.rs:264:9
@@ -239,10 +239,10 @@ LL | let _ = DeprecatedUnitStruct;
239239
| ^^^^^^^^^^^^^^^^^^^^
240240

241241
error: use of deprecated unit variant `this_crate::Enum::DeprecatedVariant`: text
242-
--> $DIR/deprecation-lint.rs:274:23
242+
--> $DIR/deprecation-lint.rs:274:17
243243
|
244244
LL | let _ = Enum::DeprecatedVariant;
245-
| ^^^^^^^^^^^^^^^^^
245+
| ^^^^^^^^^^^^^^^^^^^^^^^
246246

247247
error: use of deprecated tuple struct `this_crate::DeprecatedTupleStruct`: text
248248
--> $DIR/deprecation-lint.rs:276:17
@@ -251,52 +251,52 @@ LL | let _ = DeprecatedTupleStruct (1);
251251
| ^^^^^^^^^^^^^^^^^^^^^
252252

253253
error: use of deprecated struct `this_crate::nested::DeprecatedStruct`: text
254-
--> $DIR/deprecation-lint.rs:278:25
254+
--> $DIR/deprecation-lint.rs:278:17
255255
|
256256
LL | let _ = nested::DeprecatedStruct {
257-
| ^^^^^^^^^^^^^^^^
257+
| ^^^^^^^^^^^^^^^^^^^^^^^^
258258

259259
error: use of deprecated unit struct `this_crate::nested::DeprecatedUnitStruct`: text
260-
--> $DIR/deprecation-lint.rs:283:25
260+
--> $DIR/deprecation-lint.rs:283:17
261261
|
262262
LL | let _ = nested::DeprecatedUnitStruct;
263-
| ^^^^^^^^^^^^^^^^^^^^
263+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
264264

265265
error: use of deprecated unit variant `this_crate::nested::Enum::DeprecatedVariant`: text
266-
--> $DIR/deprecation-lint.rs:285:31
266+
--> $DIR/deprecation-lint.rs:285:17
267267
|
268268
LL | ... let _ = nested::Enum::DeprecatedVariant;
269-
| ^^^^^^^^^^^^^^^^^
269+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
270270

271271
error: use of deprecated tuple struct `this_crate::nested::DeprecatedTupleStruct`: text
272-
--> $DIR/deprecation-lint.rs:287:25
272+
--> $DIR/deprecation-lint.rs:287:17
273273
|
274274
LL | ... let _ = nested::DeprecatedTupleStruct (1);
275-
| ^^^^^^^^^^^^^^^^^^^^^
275+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
276276

277277
error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
278-
--> $DIR/deprecation-lint.rs:292:16
278+
--> $DIR/deprecation-lint.rs:292:9
279279
|
280280
LL | Trait::trait_deprecated(&foo);
281-
| ^^^^^^^^^^^^^^^^
281+
| ^^^^^^^^^^^^^^^^^^^^^^^
282282

283283
error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
284-
--> $DIR/deprecation-lint.rs:294:25
284+
--> $DIR/deprecation-lint.rs:294:9
285285
|
286286
LL | <Foo as Trait>::trait_deprecated(&foo);
287-
| ^^^^^^^^^^^^^^^^
287+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
288288

289289
error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
290-
--> $DIR/deprecation-lint.rs:296:16
290+
--> $DIR/deprecation-lint.rs:296:9
291291
|
292292
LL | Trait::trait_deprecated_text(&foo);
293-
| ^^^^^^^^^^^^^^^^^^^^^
293+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
294294

295295
error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
296-
--> $DIR/deprecation-lint.rs:298:25
296+
--> $DIR/deprecation-lint.rs:298:9
297297
|
298298
LL | ... <Foo as Trait>::trait_deprecated_text(&foo);
299-
| ^^^^^^^^^^^^^^^^^^^^^
299+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
300300

301301
error: use of deprecated function `this_crate::test_fn_closure_body::{closure#0}::bar`
302302
--> $DIR/deprecation-lint.rs:316:13
+3-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// run-rustfix
22

33
#![feature(staged_api)]
4+
45
#![stable(since = "1.0.0", feature = "test")]
6+
57
#![deny(deprecated)]
68
#![allow(dead_code)]
79

@@ -19,21 +21,8 @@ impl Foo {
1921
fn replacement(&self) {}
2022
}
2123

22-
mod bar {
23-
#[rustc_deprecated(
24-
since = "1.0.0",
25-
reason = "replaced by `replacement`",
26-
suggestion = "replacement",
27-
)]
28-
#[stable(since = "1.0.0", feature = "test")]
29-
pub fn deprecated() {}
30-
31-
pub fn replacement() {}
32-
}
33-
3424
fn main() {
3525
let foo = Foo;
36-
foo.replacement(); //~ ERROR use of deprecated
3726

38-
bar::replacement(); //~ ERROR use of deprecated
27+
foo.replacement(); //~ ERROR use of deprecated
3928
}

src/test/ui/deprecation/suggestion.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// run-rustfix
22

33
#![feature(staged_api)]
4+
45
#![stable(since = "1.0.0", feature = "test")]
6+
57
#![deny(deprecated)]
68
#![allow(dead_code)]
79

@@ -19,21 +21,8 @@ impl Foo {
1921
fn replacement(&self) {}
2022
}
2123

22-
mod bar {
23-
#[rustc_deprecated(
24-
since = "1.0.0",
25-
reason = "replaced by `replacement`",
26-
suggestion = "replacement",
27-
)]
28-
#[stable(since = "1.0.0", feature = "test")]
29-
pub fn deprecated() {}
30-
31-
pub fn replacement() {}
32-
}
33-
3424
fn main() {
3525
let foo = Foo;
36-
foo.deprecated(); //~ ERROR use of deprecated
3726

38-
bar::deprecated(); //~ ERROR use of deprecated
27+
foo.deprecated(); //~ ERROR use of deprecated
3928
}
+6-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
error: use of deprecated function `bar::deprecated`: replaced by `replacement`
2-
--> $DIR/suggestion.rs:38:10
1+
error: use of deprecated associated function `Foo::deprecated`: replaced by `replacement`
2+
--> $DIR/suggestion.rs:27:9
33
|
4-
LL | bar::deprecated();
5-
| ^^^^^^^^^^ help: replace the use of the deprecated function: `replacement`
4+
LL | foo.deprecated();
5+
| ^^^^^^^^^^ help: replace the use of the deprecated associated function: `replacement`
66
|
77
note: the lint level is defined here
8-
--> $DIR/suggestion.rs:5:9
8+
--> $DIR/suggestion.rs:7:9
99
|
1010
LL | #![deny(deprecated)]
1111
| ^^^^^^^^^^
1212

13-
error: use of deprecated associated function `Foo::deprecated`: replaced by `replacement`
14-
--> $DIR/suggestion.rs:36:9
15-
|
16-
LL | foo.deprecated();
17-
| ^^^^^^^^^^ help: replace the use of the deprecated associated function: `replacement`
18-
19-
error: aborting due to 2 previous errors
13+
error: aborting due to previous error
2014

0 commit comments

Comments
 (0)