Skip to content

Commit 285ce48

Browse files
committed
Auto merge of rust-lang#135159 - matthiaskrgr:rollup-3nijgmt, r=matthiaskrgr
Rollup of 4 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#135146 (Don't enable anyhow's `backtrace` feature in opt-dist) - rust-lang#135153 (chore: remove redundant words in comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 243d2ca + 6d70757 commit 285ce48

File tree

13 files changed

+63
-20
lines changed

13 files changed

+63
-20
lines changed

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"

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(())

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
}

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

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

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

src/ci/docker/host-x86_64/dist-riscv64-linux/patches/gcc/8.5.0/0002-hidden-jump-target.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ https://sourceware.org/bugzilla/show_bug.cgi?id=28509
1010
And this is the first version of the proposed binutils patch,
1111
https://sourceware.org/pipermail/binutils/2021-November/118398.html
1212

13-
After applying the binutils patch, I get the the unexpected error when
13+
After applying the binutils patch, I get the unexpected error when
1414
building libgcc,
1515

1616
/scratch/nelsonc/riscv-gnu-toolchain/riscv-gcc/libgcc/config/riscv/div.S:42:

src/tools/opt-dist/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
build_helper = { path = "../../build_helper" }
88
env_logger = "0.11"
99
log = "0.4"
10-
anyhow = { version = "1", features = ["backtrace"] }
10+
anyhow = "1"
1111
humantime = "2"
1212
humansize = "2"
1313
sysinfo = { version = "0.31.2", default-features = false, features = ["disk"] }

tests/ui/coroutine/issue-52304.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ check-pass
2+
//@ revisions: current next
3+
//@ ignore-compare-mode-next-solver (explicit revisions)
24

35
#![feature(coroutines, coroutine_trait)]
46

tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Here, there are two types with the same name. One of these has a `derive` annotation, but in the
2-
// expansion these `impl`s are associated to the the *other* type. There is a suggestion to remove
2+
// expansion these `impl`s are associated to the *other* type. There is a suggestion to remove
33
// unneeded type parameters, but because we're now point at a type with no type parameters, the
44
// suggestion would suggest removing code from an empty span, which would ICE in nightly.
55
//

tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr renamed to tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.current.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0308]: mismatched types
2-
--> $DIR/const-in-impl-fn-return-type.rs:15:39
2+
--> $DIR/const-in-impl-fn-return-type.rs:20:39
33
|
44
LL | fn func<const N: u32>() -> [(); { () }] {
55
| ^^ expected `usize`, found `()`
66

77
error: the constant `N` is not of type `usize`
8-
--> $DIR/const-in-impl-fn-return-type.rs:7:32
8+
--> $DIR/const-in-impl-fn-return-type.rs:12:32
99
|
1010
LL | fn func<const N: u32>() -> [(); N];
1111
| ^^^^^^^ expected `usize`, found `u32`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/const-in-impl-fn-return-type.rs:20:39
3+
|
4+
LL | fn func<const N: u32>() -> [(); { () }] {
5+
| ^^ expected `usize`, found `()`
6+
7+
error: the constant `N` is not of type `usize`
8+
--> $DIR/const-in-impl-fn-return-type.rs:12:32
9+
|
10+
LL | fn func<const N: u32>() -> [(); N];
11+
| ^^^^^^^ expected `usize`, found `u32`
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0308`.

tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
//@ revisions: current next
2+
//@[next] compile-flags: -Znext-solver
3+
//@ ignore-compare-mode-next-solver (explicit revisions)
4+
15
// Regression test for #114918
6+
27
// Test that a const generic enclosed in a block within the return type
38
// of an impl fn produces a type mismatch error instead of triggering
49
// a const eval cycle

0 commit comments

Comments
 (0)