Skip to content

Commit 0f1e965

Browse files
committed
Auto merge of rust-lang#135172 - matthiaskrgr:rollup-8fe3fxi, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#134742 (Use `PostBorrowckAnalysis` in `check_coroutine_obligations`) - rust-lang#134771 (Report correct `SelectionError` for `ConstArgHasType` in new solver fulfill) - rust-lang#134951 (Suppress host effect predicates if underlying trait doesn't hold) - rust-lang#135097 (bootstrap: Consolidate coverage test suite steps into a single step) - rust-lang#135146 (Don't enable anyhow's `backtrace` feature in opt-dist) - rust-lang#135153 (chore: remove redundant words in comment) - rust-lang#135157 (Move the has_errors check in rustdoc back to after TyCtxt is created) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 243d2ca + 873ae7a commit 0f1e965

File tree

20 files changed

+269
-163
lines changed

20 files changed

+269
-163
lines changed

Diff for: Cargo.lock

-3
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ name = "anyhow"
185185
version = "1.0.95"
186186
source = "registry+https://github.com/rust-lang/crates.io-index"
187187
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
188-
dependencies = [
189-
"backtrace",
190-
]
191188

192189
[[package]]
193190
name = "ar_archive_writer"

Diff for: compiler/rustc_hir_analysis/src/check/check.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -1845,13 +1845,18 @@ pub(super) fn check_coroutine_obligations(
18451845

18461846
debug!(?typeck_results.coroutine_stalled_predicates);
18471847

1848+
let mode = if tcx.next_trait_solver_globally() {
1849+
TypingMode::post_borrowck_analysis(tcx, def_id)
1850+
} else {
1851+
TypingMode::analysis_in_body(tcx, def_id)
1852+
};
1853+
18481854
let infcx = tcx
18491855
.infer_ctxt()
18501856
// typeck writeback gives us predicates with their regions erased.
18511857
// As borrowck already has checked lifetimes, we do not need to do it again.
18521858
.ignoring_regions()
1853-
// FIXME(#132279): This should eventually use the already defined hidden types.
1854-
.build(TypingMode::analysis_in_body(tcx, def_id));
1859+
.build(mode);
18551860

18561861
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
18571862
for (predicate, cause) in &typeck_results.coroutine_stalled_predicates {
@@ -1864,12 +1869,14 @@ pub(super) fn check_coroutine_obligations(
18641869
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
18651870
}
18661871

1867-
// Check that any hidden types found when checking these stalled coroutine obligations
1868-
// are valid.
1869-
for (key, ty) in infcx.take_opaque_types() {
1870-
let hidden_type = infcx.resolve_vars_if_possible(ty.hidden_type);
1871-
let key = infcx.resolve_vars_if_possible(key);
1872-
sanity_check_found_hidden_type(tcx, key, hidden_type)?;
1872+
if !tcx.next_trait_solver_globally() {
1873+
// Check that any hidden types found when checking these stalled coroutine obligations
1874+
// are valid.
1875+
for (key, ty) in infcx.take_opaque_types() {
1876+
let hidden_type = infcx.resolve_vars_if_possible(ty.hidden_type);
1877+
let key = infcx.resolve_vars_if_possible(key);
1878+
sanity_check_found_hidden_type(tcx, key, hidden_type)?;
1879+
}
18731880
}
18741881

18751882
Ok(())

Diff for: compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+38-19
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
114114
//
115115
// We rely on a few heuristics to identify cases where this root
116116
// obligation is more important than the leaf obligation:
117-
let (main_trait_predicate, o) = if let ty::PredicateKind::Clause(
117+
let (main_trait_predicate, main_obligation) = if let ty::PredicateKind::Clause(
118118
ty::ClauseKind::Trait(root_pred)
119119
) = root_obligation.predicate.kind().skip_binder()
120120
&& !leaf_trait_predicate.self_ty().skip_binder().has_escaping_bound_vars()
@@ -199,7 +199,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
199199
notes,
200200
parent_label,
201201
append_const_msg,
202-
} = self.on_unimplemented_note(main_trait_predicate, o, &mut long_ty_file);
202+
} = self.on_unimplemented_note(main_trait_predicate, main_obligation, &mut long_ty_file);
203203

204204
let have_alt_message = message.is_some() || label.is_some();
205205
let is_try_conversion = self.is_try_conversion(span, main_trait_ref.def_id());
@@ -538,23 +538,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
538538
}
539539

540540
ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => {
541-
// FIXME(const_trait_impl): We should recompute the predicate with `~const`
542-
// if it's `const`, and if it holds, explain that this bound only
543-
// *conditionally* holds. If that fails, we should also do selection
544-
// to drill this down to an impl or built-in source, so we can
545-
// point at it and explain that while the trait *is* implemented,
546-
// that implementation is not const.
547-
let err_msg = self.get_standard_error_message(
548-
bound_predicate.rebind(ty::TraitPredicate {
549-
trait_ref: predicate.trait_ref,
550-
polarity: ty::PredicatePolarity::Positive,
551-
}),
552-
None,
553-
Some(predicate.constness),
554-
None,
555-
String::new(),
556-
);
557-
struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg)
541+
self.report_host_effect_error(bound_predicate.rebind(predicate), obligation.param_env, span)
558542
}
559543

560544
ty::PredicateKind::Subtype(predicate) => {
@@ -763,6 +747,41 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
763747
applied_do_not_recommend
764748
}
765749

750+
fn report_host_effect_error(
751+
&self,
752+
predicate: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>,
753+
param_env: ty::ParamEnv<'tcx>,
754+
span: Span,
755+
) -> Diag<'a> {
756+
// FIXME(const_trait_impl): We should recompute the predicate with `~const`
757+
// if it's `const`, and if it holds, explain that this bound only
758+
// *conditionally* holds. If that fails, we should also do selection
759+
// to drill this down to an impl or built-in source, so we can
760+
// point at it and explain that while the trait *is* implemented,
761+
// that implementation is not const.
762+
let trait_ref = predicate.map_bound(|predicate| ty::TraitPredicate {
763+
trait_ref: predicate.trait_ref,
764+
polarity: ty::PredicatePolarity::Positive,
765+
});
766+
let err_msg = self.get_standard_error_message(
767+
trait_ref,
768+
None,
769+
Some(predicate.constness()),
770+
None,
771+
String::new(),
772+
);
773+
let mut diag = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg);
774+
if !self.predicate_may_hold(&Obligation::new(
775+
self.tcx,
776+
ObligationCause::dummy(),
777+
param_env,
778+
trait_ref,
779+
)) {
780+
diag.downgrade_to_delayed_bug();
781+
}
782+
diag
783+
}
784+
766785
fn emit_specialized_closure_kind_error(
767786
&self,
768787
obligation: &PredicateObligation<'tcx>,

Diff for: compiler/rustc_trait_selection/src/solve/fulfill.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use rustc_infer::traits::{
1010
self, FromSolverError, MismatchedProjectionTypes, Obligation, ObligationCause,
1111
ObligationCauseCode, PredicateObligation, PredicateObligations, SelectionError, TraitEngine,
1212
};
13-
use rustc_middle::bug;
1413
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1514
use rustc_middle::ty::{self, TyCtxt};
15+
use rustc_middle::{bug, span_bug};
1616
use rustc_next_trait_solver::solve::{GenerateProofTree, HasChanged, SolverDelegateEvalExt as _};
1717
use tracing::{instrument, trace};
1818

@@ -258,6 +258,23 @@ fn fulfillment_error_for_no_solution<'tcx>(
258258
MismatchedProjectionTypes { err: TypeError::Mismatch },
259259
)
260260
}
261+
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, expected_ty)) => {
262+
let ct_ty = match ct.kind() {
263+
ty::ConstKind::Unevaluated(uv) => {
264+
infcx.tcx.type_of(uv.def).instantiate(infcx.tcx, uv.args)
265+
}
266+
ty::ConstKind::Param(param_ct) => param_ct.find_ty_from_env(obligation.param_env),
267+
_ => span_bug!(
268+
obligation.cause.span,
269+
"ConstArgHasWrongType failed but we don't know how to compute type"
270+
),
271+
};
272+
FulfillmentErrorCode::Select(SelectionError::ConstArgHasWrongType {
273+
ct,
274+
ct_ty,
275+
expected_ty,
276+
})
277+
}
261278
ty::PredicateKind::NormalizesTo(..) => {
262279
FulfillmentErrorCode::Project(MismatchedProjectionTypes { err: TypeError::Mismatch })
263280
}

Diff for: library/std/src/ffi/os_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl OsString {
550550
OsStr::from_inner_mut(self.inner.leak())
551551
}
552552

553-
/// Truncate the the `OsString` to the specified length.
553+
/// Truncate the `OsString` to the specified length.
554554
///
555555
/// # Panics
556556
/// Panics if `len` does not lie on a valid `OsStr` boundary

Diff for: library/std/src/pipe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl PipeReader {
9797
/// let mut jobs = vec![];
9898
/// let (reader, mut writer) = std::pipe::pipe()?;
9999
///
100-
/// // Write NUM_SLOT characters the the pipe.
100+
/// // Write NUM_SLOT characters the pipe.
101101
/// writer.write_all(&[b'|'; NUM_SLOT as usize])?;
102102
///
103103
/// // Spawn several processes that read a character from the pipe, do some work, then

Diff for: library/std/src/sync/poison/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl<T: ?Sized> Mutex<T> {
534534
/// # Errors
535535
///
536536
/// If another user of this mutex panicked while holding the mutex, then
537-
/// this call will return an error containing the the underlying data
537+
/// this call will return an error containing the underlying data
538538
/// instead.
539539
///
540540
/// # Examples

0 commit comments

Comments
 (0)