Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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

Lines changed: 4 additions & 18 deletions
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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
...

0 commit comments

Comments
 (0)