Skip to content

Commit a7d15ab

Browse files
committed
Auto merge of rust-lang#139459 - compiler-errors:incr-tainting, r=<try>
Stop dirtying incremental with span access when computing region scope span This probably won't do any good, but I saw the `mir_build` query being recomputed in incremental a lot b/c it accesses untracked span data via the `SourceMap::end_point` method. There may be a smarter way to compute this w/o needing to do span computations which negatively affect incremental. r? `@ghost`
2 parents fd4dc18 + bc13c42 commit a7d15ab

File tree

254 files changed

+814
-1004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+814
-1004
lines changed

compiler/rustc_middle/src/ty/significant_drop_order.rs

+4-18
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,11 @@ pub fn ty_dtor_span<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Span> {
143143
| ty::UnsafeBinder(_) => None,
144144

145145
ty::Adt(adt_def, _) => {
146-
let did = adt_def.did();
147-
let try_local_did_span = |did: DefId| {
148-
if let Some(local) = did.as_local() {
149-
tcx.source_span(local)
150-
} else {
151-
tcx.def_span(did)
152-
}
153-
};
154-
let dtor = if let Some(dtor) = tcx.adt_destructor(did) {
155-
dtor.did
156-
} else if let Some(dtor) = tcx.adt_async_destructor(did) {
157-
return Some(tcx.source_span(dtor.impl_did));
146+
if let Some(dtor) = tcx.adt_destructor(adt_def.did()) {
147+
Some(tcx.def_span(tcx.parent(dtor.did)))
158148
} else {
159-
return Some(try_local_did_span(did));
160-
};
161-
let def_key = tcx.def_key(dtor);
162-
let Some(parent_index) = def_key.parent else { return Some(try_local_did_span(dtor)) };
163-
let parent_did = DefId { index: parent_index, krate: dtor.krate };
164-
Some(try_local_did_span(parent_did))
149+
Some(tcx.def_span(adt_def.did()))
150+
}
165151
}
166152
ty::Coroutine(did, _)
167153
| ty::CoroutineWitness(did, _)

compiler/rustc_mir_build/src/builder/scope.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1135,11 +1135,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
11351135

11361136
if scope.region_scope == region_scope {
11371137
let region_scope_span = region_scope.span(self.tcx, self.region_scope_tree);
1138-
// Attribute scope exit drops to scope's closing brace.
1139-
let scope_end = self.tcx.sess.source_map().end_point(region_scope_span);
11401138

11411139
scope.drops.push(DropData {
1142-
source_info: SourceInfo { span: scope_end, scope: scope.source_scope },
1140+
source_info: SourceInfo {
1141+
span: region_scope_span.shrink_to_hi(),
1142+
scope: scope.source_scope,
1143+
},
11431144
local,
11441145
kind: drop_kind,
11451146
});

tests/ui/async-await/async-closures/without-precise-captures-we-are-powerless.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ LL | outlives::<'a>(c());
2727
| argument requires that `c` is borrowed for `'a`
2828
LL | outlives::<'a>(call_once(c));
2929
LL | }
30-
| - `c` dropped here while still borrowed
30+
| - `c` dropped here while still borrowed
3131

3232
error[E0597]: `x` does not live long enough
3333
--> $DIR/without-precise-captures-we-are-powerless.rs:26:13
@@ -72,7 +72,7 @@ LL | outlives::<'a>(c());
7272
| argument requires that `c` is borrowed for `'a`
7373
LL | outlives::<'a>(call_once(c));
7474
LL | }
75-
| - `c` dropped here while still borrowed
75+
| - `c` dropped here while still borrowed
7676

7777
error[E0505]: cannot move out of `c` because it is borrowed
7878
--> $DIR/without-precise-captures-we-are-powerless.rs:32:30
@@ -126,7 +126,7 @@ LL | outlives::<'a>(c());
126126
| argument requires that `c` is borrowed for `'a`
127127
LL | outlives::<'a>(call_once(c));
128128
LL | }
129-
| - `c` dropped here while still borrowed
129+
| - `c` dropped here while still borrowed
130130

131131
error[E0621]: explicit lifetime required in the type of `x`
132132
--> $DIR/without-precise-captures-we-are-powerless.rs:44:5

tests/ui/async-await/feature-self-return-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | Foo::new(&bar).await
99
| ^^^^ borrowed value does not live long enough
1010
LL |
1111
LL | };
12-
| - `bar` dropped here while still borrowed
12+
| - `bar` dropped here while still borrowed
1313

1414
error: aborting due to 1 previous error
1515

tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ LL | || })()
5757
| |_______|
5858
| creates a temporary value which is freed while still in use
5959
LL | }
60-
| - temporary value is freed at the end of this statement
60+
| - temporary value is freed at the end of this statement
6161

6262
error[E0506]: cannot assign to `*x` because it is borrowed
6363
--> $DIR/issue-74072-lifetime-name-annotations.rs:27:9
@@ -106,7 +106,7 @@ LL | || })()
106106
| |_______|
107107
| creates a temporary value which is freed while still in use
108108
LL | }
109-
| - temporary value is freed at the end of this statement
109+
| - temporary value is freed at the end of this statement
110110

111111
error[E0506]: cannot assign to `*x` because it is borrowed
112112
--> $DIR/issue-74072-lifetime-name-annotations.rs:35:9

tests/ui/borrowck/alias-liveness/escaping-bounds-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed
22
--> $DIR/escaping-bounds-2.rs:10:31
33
|
44
LL | let func = get_func::<T>(&String::new());
5-
| ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
5+
| ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
66
| |
77
| creates a temporary value which is freed while still in use
88
LL | drop(func);

tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | test(&vec![])
77
| | creates a temporary value which is freed while still in use
88
| argument requires that borrow lasts for `'static`
99
LL | }
10-
| - temporary value is freed at the end of this statement
10+
| - temporary value is freed at the end of this statement
1111
|
1212
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
1313

tests/ui/borrowck/already-borrowed-as-mutable-if-let-133941.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | foo.g();
1111
| ^^^ second mutable borrow occurs here
1212
LL |
1313
LL | }
14-
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<Bar<'_>>`
14+
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<Bar<'_>>`
1515
|
1616
help: consider using the `matches!` macro
1717
|
@@ -32,7 +32,7 @@ LL | foo.g();
3232
| ^^^ second mutable borrow occurs here
3333
LL |
3434
LL | }
35-
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<Bar<'_>>`
35+
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<Bar<'_>>`
3636
|
3737
help: consider using the `matches!` macro
3838
|
@@ -52,7 +52,7 @@ LL | foo.g();
5252
| ^^^ second mutable borrow occurs here
5353
LL |
5454
LL | }
55-
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<Bar<'_>>`
55+
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<Bar<'_>>`
5656

5757
error[E0499]: cannot borrow `foo` as mutable more than once at a time
5858
--> $DIR/already-borrowed-as-mutable-if-let-133941.rs:37:9
@@ -66,13 +66,13 @@ LL | foo.g();
6666
| ^^^ second mutable borrow occurs here
6767
LL |
6868
LL | }
69-
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<Bar<'_>>`
69+
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<Bar<'_>>`
7070

7171
error[E0499]: cannot borrow `foo` as mutable more than once at a time
7272
--> $DIR/already-borrowed-as-mutable-if-let-133941.rs:40:45
7373
|
7474
LL | while let Some(_x) = {let _x = foo.f(); foo.g(); None::<()>} {
75-
| --- ^^^ - first borrow might be used here, when `_x` is dropped and runs the destructor for type `Option<Bar<'_>>`
75+
| --- ^^^ - first borrow might be used here, when `_x` is dropped and runs the destructor for type `Option<Bar<'_>>`
7676
| | |
7777
| | second mutable borrow occurs here
7878
| first mutable borrow occurs here
@@ -81,7 +81,7 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time
8181
--> $DIR/already-borrowed-as-mutable-if-let-133941.rs:43:42
8282
|
8383
LL | if let Some(_x) = {let _x = foo.f(); foo.g(); None::<()>} {
84-
| --- ^^^ - first borrow might be used here, when `_x` is dropped and runs the destructor for type `Option<Bar<'_>>`
84+
| --- ^^^ - first borrow might be used here, when `_x` is dropped and runs the destructor for type `Option<Bar<'_>>`
8585
| | |
8686
| | second mutable borrow occurs here
8787
| first mutable borrow occurs here

tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed
22
--> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:20:20
33
|
44
LL | let x = defer(&vec!["Goodbye", "world!"]);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
66
| |
77
| creates a temporary value which is freed while still in use
88
LL | x.x[0];

tests/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed
22
--> $DIR/borrowck-borrowed-uniq-rvalue.rs:8:28
33
|
44
LL | buggy_map.insert(42, &*Box::new(1));
5-
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
5+
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
66
| |
77
| creates a temporary value which is freed while still in use
88
...

tests/ui/borrowck/borrowck-fn-in-const-c.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0713]: borrow may still be in use when destructor runs
44
LL | return &local.inner;
55
| ^^^^^^^^^^^^ returning this value requires that `local.inner` is borrowed for `'static`
66
LL | }
7-
| - here, drop of `local` needs exclusive access to `local.inner`, because the type `DropString` implements the `Drop` trait
7+
| - here, drop of `local` needs exclusive access to `local.inner`, because the type `DropString` implements the `Drop` trait
88

99
error: aborting due to 1 previous error
1010

tests/ui/borrowck/fn-item-check-trait-ref.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed
22
--> $DIR/fn-item-check-trait-ref.rs:13:7
33
|
44
LL | (&String::new()).assert_static();
5-
| --^^^^^^^^^^^^^------------------ temporary value is freed at the end of this statement
5+
| --^^^^^^^^^^^^^----------------- - temporary value is freed at the end of this statement
66
| | |
77
| | creates a temporary value which is freed while still in use
88
| argument requires that borrow lasts for `'static`

tests/ui/borrowck/fn-item-check-type-params.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ error[E0716]: temporary value dropped while borrowed
2323
--> $DIR/fn-item-check-type-params.rs:48:11
2424
|
2525
LL | want(&String::new(), extend_lt);
26-
| ------^^^^^^^^^^^^^------------- temporary value is freed at the end of this statement
26+
| ------^^^^^^^^^^^^^------------ - temporary value is freed at the end of this statement
2727
| | |
2828
| | creates a temporary value which is freed while still in use
2929
| argument requires that borrow lasts for `'static`
@@ -32,7 +32,7 @@ error[E0716]: temporary value dropped while borrowed
3232
--> $DIR/fn-item-check-type-params.rs:54:26
3333
|
3434
LL | let val = extend_lt(&String::from("blah blah blah"));
35-
| -----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- temporary value is freed at the end of this statement
35+
| -----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - temporary value is freed at the end of this statement
3636
| | |
3737
| | creates a temporary value which is freed while still in use
3838
| argument requires that borrow lasts for `'static`

tests/ui/borrowck/implementation-not-general-enough-ice-133252.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LL | force_send(async_load(&not_static));
2121
| argument requires that `not_static` is borrowed for `'1`
2222
...
2323
LL | }
24-
| - `not_static` dropped here while still borrowed
24+
| - `not_static` dropped here while still borrowed
2525
|
2626
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
2727
--> $DIR/implementation-not-general-enough-ice-133252.rs:16:18

tests/ui/borrowck/issue-114374-invalid-help-fmt-args.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed
22
--> $DIR/issue-114374-invalid-help-fmt-args.rs:5:13
33
|
44
LL | let x = format_args!("a {} {} {}.", 1, format_args!("b{}!", 2), 3);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
66
| |
77
| creates a temporary value which is freed while still in use
88
...
@@ -16,7 +16,7 @@ error[E0716]: temporary value dropped while borrowed
1616
--> $DIR/issue-114374-invalid-help-fmt-args.rs:10:15
1717
|
1818
LL | let foo = format_args!("{}", "hi");
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
2020
| |
2121
| creates a temporary value which is freed while still in use
2222
LL |

tests/ui/borrowck/issue-11493.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed
22
--> $DIR/issue-11493.rs:6:35
33
|
44
LL | let y = x.as_ref().unwrap_or(&id(5));
5-
| ^^^^^ - temporary value is freed at the end of this statement
5+
| ^^^^^ - temporary value is freed at the end of this statement
66
| |
77
| creates a temporary value which is freed while still in use
88
LL | let _ = &y;

tests/ui/borrowck/issue-17545.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | / bar.call((
77
LL | | &id(()),
88
| | ^^^^^^ creates a temporary value which is freed while still in use
99
LL | | ));
10-
| | -- temporary value is freed at the end of this statement
10+
| | - - temporary value is freed at the end of this statement
1111
| |______|
1212
| argument requires that borrow lasts for `'a`
1313

tests/ui/borrowck/issue-36082.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0716]: temporary value dropped while borrowed
22
--> $DIR/issue-36082.rs:9:19
33
|
44
LL | let val: &_ = x.borrow().0;
5-
| ^^^^^^^^^^ - temporary value is freed at the end of this statement
5+
| ^^^^^^^^^^ - temporary value is freed at the end of this statement
66
| |
77
| creates a temporary value which is freed while still in use
88
...

tests/ui/borrowck/issue-47646.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | println!("{:?}", heap);
1111
| ^^^^ immutable borrow occurs here
1212
...
1313
LL | };
14-
| - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(Option<PeekMut<'_, i32>>, ())`
14+
| - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(Option<PeekMut<'_, i32>>, ())`
1515
|
1616
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
1717

tests/ui/borrowck/issue-82462.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | v.push(*x);
1010
| ^^^^^^^^^^ mutable borrow occurs here
1111
LL | break;
1212
LL | }
13-
| - ... and the immutable borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DroppingSlice`
13+
| - ... and the immutable borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DroppingSlice`
1414
|
1515
help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
1616
|

tests/ui/borrowck/issue-85581.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | Some(_) => { heap.pop(); },
1010
| ^^^^ second mutable borrow occurs here
1111
...
1212
LL | }
13-
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<PeekMut<'_, i32>>`
13+
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<PeekMut<'_, i32>>`
1414

1515
error: aborting due to 1 previous error
1616

tests/ui/borrowck/let_underscore_temporary.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | &a
77
| ^^ borrowed value does not live long enough
88
LL |
99
LL | };
10-
| - `a` dropped here while still borrowed
10+
| - `a` dropped here while still borrowed
1111

1212
error[E0597]: `a` does not live long enough
1313
--> $DIR/let_underscore_temporary.rs:26:9
@@ -18,7 +18,7 @@ LL | &a
1818
| ^^ borrowed value does not live long enough
1919
LL |
2020
LL | };
21-
| - `a` dropped here while still borrowed
21+
| - `a` dropped here while still borrowed
2222

2323
error[E0597]: `a` does not live long enough
2424
--> $DIR/let_underscore_temporary.rs:39:9
@@ -29,7 +29,7 @@ LL | &a
2929
| ^^ borrowed value does not live long enough
3030
LL |
3131
LL | };
32-
| - `a` dropped here while still borrowed
32+
| - `a` dropped here while still borrowed
3333

3434
error[E0597]: `a` does not live long enough
3535
--> $DIR/let_underscore_temporary.rs:54:9
@@ -40,7 +40,7 @@ LL | &a
4040
| ^^ borrowed value does not live long enough
4141
LL |
4242
LL | };
43-
| - `a` dropped here while still borrowed
43+
| - `a` dropped here while still borrowed
4444

4545
error[E0597]: `a` does not live long enough
4646
--> $DIR/let_underscore_temporary.rs:71:9
@@ -51,7 +51,7 @@ LL | &a
5151
| ^^ borrowed value does not live long enough
5252
LL |
5353
LL | } {
54-
| - `a` dropped here while still borrowed
54+
| - `a` dropped here while still borrowed
5555

5656
error[E0597]: `a` does not live long enough
5757
--> $DIR/let_underscore_temporary.rs:92:9
@@ -62,7 +62,7 @@ LL | &a
6262
| ^^ borrowed value does not live long enough
6363
LL |
6464
LL | } {
65-
| - `a` dropped here while still borrowed
65+
| - `a` dropped here while still borrowed
6666

6767
error: aborting due to 6 previous errors
6868

tests/ui/btreemap/btreemap_dropck.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | let _map = BTreeMap::from_iter([((), PrintOnDrop(&s))]);
88
LL | drop(s);
99
| ^ move out of `s` occurs here
1010
LL | }
11-
| - borrow might be used here, when `_map` is dropped and runs the `Drop` code for type `BTreeMap`
11+
| - borrow might be used here, when `_map` is dropped and runs the `Drop` code for type `BTreeMap`
1212
|
1313
help: consider cloning the value if the performance cost is acceptable
1414
|

tests/ui/c-variadic/variadic-ffi-4.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ LL | ap0 = &mut ap1;
117117
| assignment requires that `ap1` is borrowed for `'3`
118118
...
119119
LL | }
120-
| - `ap1` dropped here while still borrowed
120+
| - `ap1` dropped here while still borrowed
121121

122122
error: lifetime may not live long enough
123123
--> $DIR/variadic-ffi-4.rs:35:5

0 commit comments

Comments
 (0)