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

Commit f6f91cf

Browse files
committed
Auto merge of rust-lang#116546 - matthiaskrgr:rollup-df6tque, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - rust-lang#115882 (improve the suggestion of `generic_bound_failure`) - rust-lang#116527 (Bump libc dependency) - rust-lang#116532 (Add RUSTFLAGS_BOOTSTRAP to RUSTFLAGS for bootstrap compilation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bf9a1c8 + d16f1cc commit f6f91cf

File tree

85 files changed

+1182
-740
lines changed

Some content is hidden

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

85 files changed

+1182
-740
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,9 +2150,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"
21502150

21512151
[[package]]
21522152
name = "libc"
2153-
version = "0.2.148"
2153+
version = "0.2.149"
21542154
source = "registry+https://github.com/rust-lang/crates.io-index"
2155-
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
2155+
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
21562156
dependencies = [
21572157
"rustc-std-workspace-core",
21582158
]

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 198 additions & 310 deletions
Large diffs are not rendered by default.

compiler/rustc_middle/src/ty/context.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,24 +1057,29 @@ impl<'tcx> TyCtxt<'tcx> {
10571057
}
10581058

10591059
/// Returns the `DefId` and the `BoundRegionKind` corresponding to the given region.
1060-
pub fn is_suitable_region(self, region: Region<'tcx>) -> Option<FreeRegionInfo> {
1061-
let (suitable_region_binding_scope, bound_region) = match *region {
1062-
ty::ReFree(ref free_region) => {
1063-
(free_region.scope.expect_local(), free_region.bound_region)
1060+
pub fn is_suitable_region(self, mut region: Region<'tcx>) -> Option<FreeRegionInfo> {
1061+
let (suitable_region_binding_scope, bound_region) = loop {
1062+
let def_id = match region.kind() {
1063+
ty::ReFree(fr) => fr.bound_region.get_id()?.as_local()?,
1064+
ty::ReEarlyBound(ebr) => ebr.def_id.expect_local(),
1065+
_ => return None, // not a free region
1066+
};
1067+
let scope = self.local_parent(def_id);
1068+
if self.def_kind(scope) == DefKind::OpaqueTy {
1069+
// Lifetime params of opaque types are synthetic and thus irrelevant to
1070+
// diagnostics. Map them back to their origin!
1071+
region = self.map_rpit_lifetime_to_fn_lifetime(def_id);
1072+
continue;
10641073
}
1065-
ty::ReEarlyBound(ref ebr) => (
1066-
self.local_parent(ebr.def_id.expect_local()),
1067-
ty::BoundRegionKind::BrNamed(ebr.def_id, ebr.name),
1068-
),
1069-
_ => return None, // not a free region
1074+
break (scope, ty::BrNamed(def_id.into(), self.item_name(def_id.into())));
10701075
};
10711076

10721077
let is_impl_item = match self.hir().find_by_def_id(suitable_region_binding_scope) {
10731078
Some(Node::Item(..) | Node::TraitItem(..)) => false,
10741079
Some(Node::ImplItem(..)) => {
10751080
self.is_bound_region_in_impl_item(suitable_region_binding_scope)
10761081
}
1077-
_ => return None,
1082+
_ => false,
10781083
};
10791084

10801085
Some(FreeRegionInfo {

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1717
panic_unwind = { path = "../panic_unwind", optional = true }
1818
panic_abort = { path = "../panic_abort" }
1919
core = { path = "../core", public = true }
20-
libc = { version = "0.2.148", default-features = false, features = ['rustc-dep-of-std'], public = true }
20+
libc = { version = "0.2.149", default-features = false, features = ['rustc-dep-of-std'], public = true }
2121
compiler_builtins = { version = "0.1.100" }
2222
profiler_builtins = { path = "../profiler_builtins", optional = true }
2323
unwind = { path = "../unwind" }

src/bootstrap/bootstrap.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,13 @@ def build_bootstrap_cmd(self, env):
954954
if deny_warnings:
955955
env["RUSTFLAGS"] += " -Dwarnings"
956956

957+
# Add RUSTFLAGS_BOOTSTRAP to RUSTFLAGS for bootstrap compilation.
958+
# Note that RUSTFLAGS_BOOTSTRAP should always be added to the end of
959+
# RUSTFLAGS to be actually effective (e.g., if we have `-Dwarnings` in
960+
# RUSTFLAGS, passing `-Awarnings` from RUSTFLAGS_BOOTSTRAP should override it).
961+
if "RUSTFLAGS_BOOTSTRAP" in env:
962+
env["RUSTFLAGS"] += " " + env["RUSTFLAGS_BOOTSTRAP"]
963+
957964
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
958965
os.pathsep + env["PATH"]
959966
if not os.path.isfile(self.cargo()):

tests/ui/associated-inherent-types/regionck-1.stderr

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ error[E0309]: the parameter type `T` may not live long enough
22
--> $DIR/regionck-1.rs:9:30
33
|
44
LL | type NoTyOutliv<'a, T> = &'a T;
5-
| ^^^^^- help: consider adding a where clause: `where T: 'a`
6-
| |
7-
| ...so that the reference type `&'a T` does not outlive the data it points at
5+
| -- ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at
6+
| |
7+
| the parameter type `T` must be valid for the lifetime `'a` as defined here...
8+
|
9+
help: consider adding an explicit lifetime bound
10+
|
11+
LL | type NoTyOutliv<'a, T: 'a> = &'a T;
12+
| ++++
813

914
error[E0491]: in type `&'a &'b ()`, reference has a longer lifetime than the data it references
1015
--> $DIR/regionck-1.rs:10:31

tests/ui/async-await/in-trait/async-generics-and-bounds.stderr

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,29 @@ error[E0311]: the parameter type `U` may not live long enough
22
--> $DIR/async-generics-and-bounds.rs:12:5
33
|
44
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| | |
7+
| | the parameter type `U` must be valid for the anonymous lifetime as defined here...
8+
| ...so that the reference type `&(T, U)` does not outlive the data it points at
69
|
7-
note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
8-
--> $DIR/async-generics-and-bounds.rs:12:18
10+
help: consider adding an explicit lifetime bound
911
|
10-
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
11-
| ^
12-
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
13-
--> $DIR/async-generics-and-bounds.rs:12:5
14-
|
15-
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
LL | async fn foo<'a>(&'a self) -> &'a (T, U) where T: Debug + Sized, U: Hash, U: 'a;
13+
| ++++ ++ ++ +++++++
1714

1815
error[E0311]: the parameter type `T` may not live long enough
1916
--> $DIR/async-generics-and-bounds.rs:12:5
2017
|
2118
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
22-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19+
| ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
| | |
21+
| | the parameter type `T` must be valid for the anonymous lifetime as defined here...
22+
| ...so that the reference type `&(T, U)` does not outlive the data it points at
2323
|
24-
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
25-
--> $DIR/async-generics-and-bounds.rs:12:18
24+
help: consider adding an explicit lifetime bound
2625
|
27-
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
28-
| ^
29-
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
30-
--> $DIR/async-generics-and-bounds.rs:12:5
31-
|
32-
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
33-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
LL | async fn foo<'a>(&'a self) -> &'a (T, U) where T: Debug + Sized, U: Hash, T: 'a;
27+
| ++++ ++ ++ +++++++
3428

3529
error: aborting due to 2 previous errors
3630

tests/ui/async-await/in-trait/async-generics.stderr

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,29 @@ error[E0311]: the parameter type `U` may not live long enough
22
--> $DIR/async-generics.rs:9:5
33
|
44
LL | async fn foo(&self) -> &(T, U);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^
6+
| | |
7+
| | the parameter type `U` must be valid for the anonymous lifetime as defined here...
8+
| ...so that the reference type `&(T, U)` does not outlive the data it points at
69
|
7-
note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
8-
--> $DIR/async-generics.rs:9:18
10+
help: consider adding an explicit lifetime bound
911
|
10-
LL | async fn foo(&self) -> &(T, U);
11-
| ^
12-
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
13-
--> $DIR/async-generics.rs:9:5
14-
|
15-
LL | async fn foo(&self) -> &(T, U);
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
LL | async fn foo<'a>(&'a self) -> &'a (T, U) where U: 'a;
13+
| ++++ ++ ++ +++++++++++
1714

1815
error[E0311]: the parameter type `T` may not live long enough
1916
--> $DIR/async-generics.rs:9:5
2017
|
2118
LL | async fn foo(&self) -> &(T, U);
22-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19+
| ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^
20+
| | |
21+
| | the parameter type `T` must be valid for the anonymous lifetime as defined here...
22+
| ...so that the reference type `&(T, U)` does not outlive the data it points at
2323
|
24-
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
25-
--> $DIR/async-generics.rs:9:18
24+
help: consider adding an explicit lifetime bound
2625
|
27-
LL | async fn foo(&self) -> &(T, U);
28-
| ^
29-
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
30-
--> $DIR/async-generics.rs:9:5
31-
|
32-
LL | async fn foo(&self) -> &(T, U);
33-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
LL | async fn foo<'a>(&'a self) -> &'a (T, U) where T: 'a;
27+
| ++++ ++ ++ +++++++++++
3428

3529
error: aborting due to 2 previous errors
3630

tests/ui/builtin-superkinds/builtin-superkinds-self-type.stderr

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ error[E0310]: the parameter type `T` may not live long enough
22
--> $DIR/builtin-superkinds-self-type.rs:10:16
33
|
44
LL | impl <T: Sync> Foo for T { }
5-
| ^^^ ...so that the type `T` will meet its required lifetime bounds...
5+
| ^^^
6+
| |
7+
| the parameter type `T` must be valid for the static lifetime...
8+
| ...so that the type `T` will meet its required lifetime bounds...
69
|
710
note: ...that is required by this bound
811
--> $DIR/builtin-superkinds-self-type.rs:6:24
912
|
1013
LL | trait Foo : Sized+Sync+'static {
1114
| ^^^^^^^
12-
help: consider adding an explicit lifetime bound...
15+
help: consider adding an explicit lifetime bound
1316
|
1417
LL | impl <T: Sync + 'static> Foo for T { }
1518
| +++++++++

tests/ui/coercion/issue-53475.stderr

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough
22
--> $DIR/issue-53475.rs:10:1
33
|
44
LL | impl<T> CoerceUnsized<Foo<dyn Any>> for Foo<T> {}
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| the parameter type `T` must be valid for the static lifetime...
8+
| ...so that the type `T` will meet its required lifetime bounds
69
|
7-
help: consider adding an explicit lifetime bound...
10+
help: consider adding an explicit lifetime bound
811
|
912
LL | impl<T: 'static> CoerceUnsized<Foo<dyn Any>> for Foo<T> {}
1013
| +++++++++

0 commit comments

Comments
 (0)