Skip to content

Commit e1b348f

Browse files
committed
Auto merge of #99133 - matthiaskrgr:rollup-eignphd, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #98713 (promote placeholder bounds to 'static obligations) - #99094 (Remove extra space in AtomicPtr::new docs) - #99095 (Remove duplicate notes from error on inter-crate ambiguous impl of traits) - #99114 (Group .test-arrow CSS rules and fix rgb/rgba property) - #99128 (Fix `download-ci-llvm` NixOS patching for binaries) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c396bb3 + 7cd6174 commit e1b348f

File tree

16 files changed

+136
-29
lines changed

16 files changed

+136
-29
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+33-5
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
917917
/// The idea then is to lower the `T: 'X` constraint into multiple
918918
/// bounds -- e.g., if `'X` is the union of two free lifetimes,
919919
/// `'1` and `'2`, then we would create `T: '1` and `T: '2`.
920+
#[instrument(level = "debug", skip(self, infcx, propagated_outlives_requirements))]
920921
fn try_promote_type_test(
921922
&self,
922923
infcx: &InferCtxt<'_, 'tcx>,
@@ -934,11 +935,41 @@ impl<'tcx> RegionInferenceContext<'tcx> {
934935
return false;
935936
};
936937

938+
debug!("subject = {:?}", subject);
939+
940+
let r_scc = self.constraint_sccs.scc(*lower_bound);
941+
942+
debug!(
943+
"lower_bound = {:?} r_scc={:?} universe={:?}",
944+
lower_bound, r_scc, self.scc_universes[r_scc]
945+
);
946+
947+
// If the type test requires that `T: 'a` where `'a` is a
948+
// placeholder from another universe, that effectively requires
949+
// `T: 'static`, so we have to propagate that requirement.
950+
//
951+
// It doesn't matter *what* universe because the promoted `T` will
952+
// always be in the root universe.
953+
if let Some(p) = self.scc_values.placeholders_contained_in(r_scc).next() {
954+
debug!("encountered placeholder in higher universe: {:?}, requiring 'static", p);
955+
let static_r = self.universal_regions.fr_static;
956+
propagated_outlives_requirements.push(ClosureOutlivesRequirement {
957+
subject,
958+
outlived_free_region: static_r,
959+
blame_span: locations.span(body),
960+
category: ConstraintCategory::Boring,
961+
});
962+
963+
// we can return here -- the code below might push add'l constraints
964+
// but they would all be weaker than this one.
965+
return true;
966+
}
967+
937968
// For each region outlived by lower_bound find a non-local,
938969
// universal region (it may be the same region) and add it to
939970
// `ClosureOutlivesRequirement`.
940-
let r_scc = self.constraint_sccs.scc(*lower_bound);
941971
for ur in self.scc_values.universal_regions_outlived_by(r_scc) {
972+
debug!("universal_region_outlived_by ur={:?}", ur);
942973
// Check whether we can already prove that the "subject" outlives `ur`.
943974
// If so, we don't have to propagate this requirement to our caller.
944975
//
@@ -963,8 +994,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
963994
continue;
964995
}
965996

966-
debug!("try_promote_type_test: ur={:?}", ur);
967-
968997
let non_local_ub = self.universal_region_relations.non_local_upper_bounds(ur);
969998
debug!("try_promote_type_test: non_local_ub={:?}", non_local_ub);
970999

@@ -1001,15 +1030,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10011030
/// will use it's *external name*, which will be a `RegionKind`
10021031
/// variant that can be used in query responses such as
10031032
/// `ReEarlyBound`.
1033+
#[instrument(level = "debug", skip(self, infcx))]
10041034
fn try_promote_type_test_subject(
10051035
&self,
10061036
infcx: &InferCtxt<'_, 'tcx>,
10071037
ty: Ty<'tcx>,
10081038
) -> Option<ClosureOutlivesSubject<'tcx>> {
10091039
let tcx = infcx.tcx;
10101040

1011-
debug!("try_promote_type_test_subject(ty = {:?})", ty);
1012-
10131041
let ty = tcx.fold_regions(ty, |r, _depth| {
10141042
let region_vid = self.to_region_vid(r);
10151043

compiler/rustc_trait_selection/src/traits/coherence.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::traits::{
1313
self, FulfillmentContext, Normalized, Obligation, ObligationCause, PredicateObligation,
1414
PredicateObligations, SelectionContext,
1515
};
16-
//use rustc_data_structures::fx::FxHashMap;
16+
use rustc_data_structures::fx::FxIndexSet;
1717
use rustc_errors::Diagnostic;
1818
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
1919
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
@@ -44,7 +44,7 @@ pub enum Conflict {
4444

4545
pub struct OverlapResult<'tcx> {
4646
pub impl_header: ty::ImplHeader<'tcx>,
47-
pub intercrate_ambiguity_causes: Vec<IntercrateAmbiguityCause>,
47+
pub intercrate_ambiguity_causes: FxIndexSet<IntercrateAmbiguityCause>,
4848

4949
/// `true` if the overlap might've been permitted before the shift
5050
/// to universes.

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
110110
IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc }
111111
};
112112
debug!(?cause, "evaluate_stack: pushing cause");
113-
self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause);
113+
self.intercrate_ambiguity_causes.as_mut().unwrap().insert(cause);
114114
}
115115
}
116116
}

compiler/rustc_trait_selection/src/traits/select/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::traits::error_reporting::InferCtxtExt;
2424
use crate::traits::project::ProjectAndUnifyResult;
2525
use crate::traits::project::ProjectionCacheKeyExt;
2626
use crate::traits::ProjectionCacheKey;
27-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
27+
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
2828
use rustc_data_structures::stack::ensure_sufficient_stack;
2929
use rustc_errors::{Diagnostic, ErrorGuaranteed};
3030
use rustc_hir as hir;
@@ -52,7 +52,7 @@ pub use rustc_middle::traits::select::*;
5252
mod candidate_assembly;
5353
mod confirmation;
5454

55-
#[derive(Clone, Debug)]
55+
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
5656
pub enum IntercrateAmbiguityCause {
5757
DownstreamCrate { trait_desc: String, self_desc: Option<String> },
5858
UpstreamCrateUpdate { trait_desc: String, self_desc: Option<String> },
@@ -128,7 +128,7 @@ pub struct SelectionContext<'cx, 'tcx> {
128128
/// We don't do his until we detect a coherence error because it can
129129
/// lead to false overflow results (#47139) and because always
130130
/// computing it may negatively impact performance.
131-
intercrate_ambiguity_causes: Option<Vec<IntercrateAmbiguityCause>>,
131+
intercrate_ambiguity_causes: Option<FxIndexSet<IntercrateAmbiguityCause>>,
132132

133133
/// The mode that trait queries run in, which informs our error handling
134134
/// policy. In essence, canonicalized queries need their errors propagated
@@ -254,14 +254,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
254254
pub fn enable_tracking_intercrate_ambiguity_causes(&mut self) {
255255
assert!(self.intercrate);
256256
assert!(self.intercrate_ambiguity_causes.is_none());
257-
self.intercrate_ambiguity_causes = Some(vec![]);
257+
self.intercrate_ambiguity_causes = Some(FxIndexSet::default());
258258
debug!("selcx: enable_tracking_intercrate_ambiguity_causes");
259259
}
260260

261261
/// Gets the intercrate ambiguity causes collected since tracking
262262
/// was enabled and disables tracking at the same time. If
263263
/// tracking is not enabled, just returns an empty vector.
264-
pub fn take_intercrate_ambiguity_causes(&mut self) -> Vec<IntercrateAmbiguityCause> {
264+
pub fn take_intercrate_ambiguity_causes(&mut self) -> FxIndexSet<IntercrateAmbiguityCause> {
265265
assert!(self.intercrate);
266266
self.intercrate_ambiguity_causes.take().unwrap_or_default()
267267
}
@@ -960,7 +960,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
960960
});
961961

962962
debug!(?cause, "evaluate_stack: pushing cause");
963-
self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause);
963+
self.intercrate_ambiguity_causes.as_mut().unwrap().insert(cause);
964964
}
965965
}
966966
}
@@ -1252,7 +1252,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12521252
reservation impl ambiguity on {:?}",
12531253
def_id
12541254
);
1255-
intercrate_ambiguity_clauses.push(
1255+
intercrate_ambiguity_clauses.insert(
12561256
IntercrateAmbiguityCause::ReservationImpl {
12571257
message: value.to_string(),
12581258
},

compiler/rustc_trait_selection/src/traits/specialize/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use specialization_graph::GraphExt;
1515
use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt};
1616
use crate::traits::select::IntercrateAmbiguityCause;
1717
use crate::traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine};
18-
use rustc_data_structures::fx::FxHashSet;
18+
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1919
use rustc_errors::{struct_span_err, EmissionGuarantee, LintDiagnosticBuilder};
2020
use rustc_hir::def_id::{DefId, LocalDefId};
2121
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
@@ -33,7 +33,7 @@ pub struct OverlapError {
3333
pub with_impl: DefId,
3434
pub trait_desc: String,
3535
pub self_desc: Option<String>,
36-
pub intercrate_ambiguity_causes: Vec<IntercrateAmbiguityCause>,
36+
pub intercrate_ambiguity_causes: FxIndexSet<IntercrateAmbiguityCause>,
3737
pub involves_placeholder: bool,
3838
}
3939

library/core/src/sync/atomic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ impl<T> AtomicPtr<T> {
991991
/// use std::sync::atomic::AtomicPtr;
992992
///
993993
/// let ptr = &mut 5;
994-
/// let atomic_ptr = AtomicPtr::new(ptr);
994+
/// let atomic_ptr = AtomicPtr::new(ptr);
995995
/// ```
996996
#[inline]
997997
#[stable(feature = "rust1", since = "1.0.0")]

src/bootstrap/native.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) {
147147
let key = format!("{}{}", llvm_sha, config.llvm_assertions);
148148
if program_out_of_date(&llvm_stamp, &key) && !config.dry_run {
149149
download_ci_llvm(builder, &llvm_sha);
150-
for binary in ["llvm-config", "FileCheck"] {
151-
builder.fix_bin_or_dylib(&llvm_root.join("bin").join(binary));
150+
for entry in t!(fs::read_dir(llvm_root.join("bin"))) {
151+
builder.fix_bin_or_dylib(&t!(entry).path());
152152
}
153153

154154
// Update the timestamp of llvm-config to force rustc_llvm to be

src/librustdoc/html/static/css/themes/dark.css

+1-3
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ a {
178178
color: #D2991D;
179179
}
180180

181-
a.test-arrow {
182-
color: #dedede;
183-
}
184181
body.source .example-wrap pre.rust a {
185182
background: #333;
186183
}
@@ -255,6 +252,7 @@ pre.rust .question-mark {
255252
}
256253

257254
a.test-arrow {
255+
color: #dedede;
258256
background-color: rgba(78, 139, 202, 0.2);
259257
}
260258

src/librustdoc/html/static/css/themes/light.css

+2-4
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ a {
175175
color: #3873AD;
176176
}
177177

178-
a.test-arrow {
179-
color: #f5f5f5;
180-
}
181178
body.source .example-wrap pre.rust a {
182179
background: #eee;
183180
}
@@ -239,7 +236,8 @@ pre.rust .question-mark {
239236
}
240237

241238
a.test-arrow {
242-
background-color: rgb(78, 139, 202, 0.2);
239+
color: #f5f5f5;
240+
background-color: rgba(78, 139, 202, 0.2);
243241
}
244242

245243
a.test-arrow:hover{

src/test/ui/coherence/coherence-projection-conflict-orphan.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ LL | impl<A:Iterator> Foo<A::Item> for A { }
88
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32`
99
|
1010
= note: upstream crates may add a new impl of trait `std::iter::Iterator` for type `i32` in future versions
11-
= note: upstream crates may add a new impl of trait `std::iter::Iterator` for type `i32` in future versions
1211

1312
error: aborting due to previous error
1413

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
struct S;
2+
3+
impl From<()> for S {
4+
fn from(x: ()) -> Self {
5+
S
6+
}
7+
}
8+
9+
impl<I> From<I> for S
10+
//~^ ERROR conflicting implementations of trait
11+
where
12+
I: Iterator<Item = ()>,
13+
{
14+
fn from(x: I) -> Self {
15+
S
16+
}
17+
}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0119]: conflicting implementations of trait `std::convert::From<()>` for type `S`
2+
--> $DIR/inter-crate-ambiguity-causes-notes.rs:9:1
3+
|
4+
LL | impl From<()> for S {
5+
| ------------------- first implementation here
6+
...
7+
LL | impl<I> From<I> for S
8+
| ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S`
9+
|
10+
= note: upstream crates may add a new impl of trait `std::iter::Iterator` for type `()` in future versions
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0119`.

src/test/ui/generic-associated-types/issue-91139.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fn foo<T>() {
2222
//~| ERROR `T` does not live long enough
2323
//~| ERROR `T` does not live long enough
2424
//~| ERROR `T` does not live long enough
25+
//~| ERROR `T` may not live long enough
2526
//
2627
// FIXME: This error is bogus, but it arises because we try to validate
2728
// that `<() as Foo<T>>::Type<'a>` is valid, which requires proving

src/test/ui/generic-associated-types/issue-91139.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ error: `T` does not live long enough
3434
LL | let _: for<'a> fn(<() as Foo<T>>::Type<'a>, &'a T) = |_, _| ();
3535
| ^^^^^^^^^
3636

37+
error[E0310]: the parameter type `T` may not live long enough
38+
--> $DIR/issue-91139.rs:16:58
39+
|
40+
LL | let _: for<'a> fn(<() as Foo<T>>::Type<'a>, &'a T) = |_, _| ();
41+
| ^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
42+
|
43+
help: consider adding an explicit lifetime bound...
44+
|
45+
LL | fn foo<T: 'static>() {
46+
| +++++++++
47+
3748
error: `T` does not live long enough
3849
--> $DIR/issue-91139.rs:16:58
3950
|
@@ -46,5 +57,6 @@ error: `T` does not live long enough
4657
LL | let _: for<'a> fn(<() as Foo<T>>::Type<'a>, &'a T) = |_, _| ();
4758
| ^^^^^^^^^
4859

49-
error: aborting due to 8 previous errors
60+
error: aborting due to 9 previous errors
5061

62+
For more information about this error, try `rustc --explain E0310`.

src/test/ui/nll/issue-98693.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Regression test for #98693.
2+
//
3+
// The closure encounters an obligation that `T` must outlive `!U1`,
4+
// a placeholder from universe U1. We were ignoring this placeholder
5+
// when promoting the constraint to the enclosing function, and
6+
// thus incorrectly judging the closure to be safe.
7+
8+
fn assert_static<T>()
9+
where
10+
for<'a> T: 'a,
11+
{
12+
}
13+
14+
fn test<T>() {
15+
|| {
16+
//~^ ERROR the parameter type `T` may not live long enough
17+
assert_static::<T>();
18+
};
19+
}
20+
21+
fn main() {}

src/test/ui/nll/issue-98693.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0310]: the parameter type `T` may not live long enough
2+
--> $DIR/issue-98693.rs:15:5
3+
|
4+
LL | / || {
5+
LL | |
6+
LL | | assert_static::<T>();
7+
LL | | };
8+
| |_____^ ...so that the type `T` will meet its required lifetime bounds
9+
|
10+
help: consider adding an explicit lifetime bound...
11+
|
12+
LL | fn test<T: 'static>() {
13+
| +++++++++
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0310`.

0 commit comments

Comments
 (0)