Skip to content

Commit 2567420

Browse files
committed
Auto merge of #96695 - JohnTitor:rollup-oo4fc1h, r=JohnTitor
Rollup of 6 pull requests Successful merges: - #96597 (openbsd: unbreak build on native platform) - #96662 (Fix typo in lint levels doc) - #96668 (Fix flaky rustdoc-ui test because it did not replace time result) - #96679 (Quick fix for #96223.) - #96684 (Update `ProjectionElem::Downcast` documentation) - #96686 (Add some TAIT-related tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents fed2c43 + 2ca778f commit 2567420

File tree

15 files changed

+218
-10
lines changed

15 files changed

+218
-10
lines changed

compiler/rustc_middle/src/mir/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2017,9 +2017,7 @@ pub enum ProjectionElem<V, T> {
20172017
from_end: bool,
20182018
},
20192019

2020-
/// "Downcast" to a variant of an ADT. Currently, we only introduce
2021-
/// this for ADTs with more than one variant. It may be better to
2022-
/// just introduce it always, or always for enums.
2020+
/// "Downcast" to a variant of an enum or a generator.
20232021
///
20242022
/// The included Symbol is the name of the variant, used for printing MIR.
20252023
Downcast(Option<Symbol>, VariantIdx),

compiler/rustc_middle/src/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_target::abi::VariantIdx;
1212
#[derive(Copy, Clone, Debug, TypeFoldable)]
1313
pub struct PlaceTy<'tcx> {
1414
pub ty: Ty<'tcx>,
15-
/// Downcast to a particular variant of an enum, if included.
15+
/// Downcast to a particular variant of an enum or a generator, if included.
1616
pub variant_index: Option<VariantIdx>,
1717
}
1818

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
866866
return false;
867867
}
868868

869-
let orig_ty = old_pred.self_ty().skip_binder();
869+
// This is a quick fix to resolve an ICE (#96223).
870+
// This change should probably be deeper.
871+
// As suggested by @jackh726, `mk_trait_obligation_with_new_self_ty` could take a `Binder<(TraitRef, Ty)>
872+
// instead of `Binder<Ty>` leading to some changes to its call places.
873+
let Some(orig_ty) = old_pred.self_ty().no_bound_vars() else {
874+
return false;
875+
};
870876
let mk_result = |new_ty| {
871877
let obligation =
872878
self.mk_trait_obligation_with_new_self_ty(param_env, old_pred, new_ty);

src/bootstrap/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,8 @@ impl<'a> Builder<'a> {
14051405
// FIXME(davidtwco): #[cfg(not(bootstrap))] - #95612 needs to be in the bootstrap compiler
14061406
// for this conditional to be removed.
14071407
if !target.contains("windows") || compiler.stage >= 1 {
1408-
if target.contains("linux") || target.contains("windows") {
1408+
if target.contains("linux") || target.contains("windows") || target.contains("openbsd")
1409+
{
14091410
rustflags.arg("-Zunstable-options");
14101411
}
14111412
match self.config.rust_split_debuginfo {

src/doc/rustc/src/lints/levels.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ This lint level gives you that.
100100
'force-warn' does for 'warn'. It's the same as 'deny' in that a lint at this
101101
level will produce an error, but unlike the 'deny' level, the 'forbid' level
102102
can not be overridden to be anything lower than an error. However, lint
103-
levels may still be capped with `--cap-lints` (see below) so `rustc --cap-
104-
lints warn` will make lints set to 'forbid' just
105-
warn.
103+
levels may still be capped with `--cap-lints` (see below) so `rustc --cap-lints warn`
104+
will make lints set to 'forbid' just warn.
106105

107106
## Configuring warning levels
108107

src/test/rustdoc-ui/block-doc-comment.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// check-pass
22
// compile-flags:--test
3+
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
34

45
// This test ensures that no code block is detected in the doc comments.
56

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
running 0 tests
33

4-
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
4+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
55

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Previously ICEd because we didn't properly track binders in suggestions
2+
// check-fail
3+
4+
pub trait Foo<'de>: Sized {}
5+
6+
pub trait Bar<'a>: 'static {
7+
type Inner: 'a;
8+
}
9+
10+
pub trait Fubar {
11+
type Bar: for<'a> Bar<'a>;
12+
}
13+
14+
pub struct Baz<T>(pub T);
15+
16+
impl<'de, T> Foo<'de> for Baz<T> where T: Foo<'de> {}
17+
18+
struct Empty;
19+
20+
impl<M> Dummy<M> for Empty
21+
where
22+
M: Fubar,
23+
for<'de> Baz<<M::Bar as Bar<'de>>::Inner>: Foo<'de>,
24+
{
25+
}
26+
27+
pub trait Dummy<M>
28+
where
29+
M: Fubar,
30+
{
31+
}
32+
33+
pub struct EmptyBis<'a>(&'a [u8]);
34+
35+
impl<'a> Bar<'a> for EmptyBis<'static> {
36+
type Inner = EmptyBis<'a>;
37+
}
38+
39+
pub struct EmptyMarker;
40+
41+
impl Fubar for EmptyMarker {
42+
type Bar = EmptyBis<'static>;
43+
}
44+
45+
fn icey_bounds<D: Dummy<EmptyMarker>>(p: &D) {}
46+
47+
fn trigger_ice() {
48+
let p = Empty;
49+
icey_bounds(&p); //~ERROR the trait bound
50+
}
51+
52+
fn main() {}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0277]: the trait bound `for<'de> EmptyBis<'de>: Foo<'_>` is not satisfied
2+
--> $DIR/issue-96223.rs:49:17
3+
|
4+
LL | icey_bounds(&p);
5+
| ----------- ^^ the trait `for<'de> Foo<'_>` is not implemented for `EmptyBis<'de>`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the trait `Foo<'de>` is implemented for `Baz<T>`
10+
note: required because of the requirements on the impl of `for<'de> Foo<'de>` for `Baz<EmptyBis<'de>>`
11+
--> $DIR/issue-96223.rs:16:14
12+
|
13+
LL | impl<'de, T> Foo<'de> for Baz<T> where T: Foo<'de> {}
14+
| ^^^^^^^^ ^^^^^^
15+
note: required because of the requirements on the impl of `Dummy<EmptyMarker>` for `Empty`
16+
--> $DIR/issue-96223.rs:20:9
17+
|
18+
LL | impl<M> Dummy<M> for Empty
19+
| ^^^^^^^^ ^^^^^
20+
note: required by a bound in `icey_bounds`
21+
--> $DIR/issue-96223.rs:45:19
22+
|
23+
LL | fn icey_bounds<D: Dummy<EmptyMarker>>(p: &D) {}
24+
| ^^^^^^^^^^^^^^^^^^ required by this bound in `icey_bounds`
25+
26+
error: aborting due to previous error
27+
28+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(type_alias_impl_trait)]
2+
3+
type Foo = impl Fn() -> Foo;
4+
5+
fn foo() -> Foo {
6+
foo //~ ERROR: overflow evaluating the requirement `fn() -> Foo {foo}: Sized`
7+
}
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized`
2+
--> $DIR/issue-53398-cyclic-types.rs:6:5
3+
|
4+
LL | foo
5+
| ^^^
6+
|
7+
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`)
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0275`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// check-pass
2+
3+
#![feature(generators, generator_trait)]
4+
#![feature(type_alias_impl_trait)]
5+
6+
use std::ops::{Generator, GeneratorState};
7+
use std::pin::Pin;
8+
9+
type RandGenerator<'a> = impl Generator<Return = (), Yield = u64> + 'a;
10+
fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> {
11+
move || {
12+
let _rng = rng;
13+
loop {
14+
yield 0;
15+
}
16+
}
17+
}
18+
19+
pub type RandGeneratorWithIndirection<'a> = impl Generator<Return = (), Yield = u64> + 'a;
20+
pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndirection<'a> {
21+
fn helper<'b>(rng: &'b ()) -> impl 'b + Generator<Return = (), Yield = u64> {
22+
move || {
23+
let _rng = rng;
24+
loop {
25+
yield 0;
26+
}
27+
}
28+
}
29+
30+
helper(rng)
31+
}
32+
33+
fn main() {
34+
let mut gen = rand_generator(&());
35+
match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) {
36+
GeneratorState::Yielded(_) => {}
37+
GeneratorState::Complete(_) => {}
38+
};
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
trait SomeTrait {}
6+
impl SomeTrait for () {}
7+
8+
trait MyFuture {
9+
type Output;
10+
}
11+
impl<T> MyFuture for T {
12+
type Output = T;
13+
}
14+
15+
trait ReturnsFuture {
16+
type Output: SomeTrait;
17+
type Future: MyFuture<Output = Result<Self::Output, ()>>;
18+
fn func() -> Self::Future;
19+
}
20+
21+
struct Foo;
22+
23+
impl ReturnsFuture for Foo {
24+
type Output = impl SomeTrait;
25+
type Future = impl MyFuture<Output = Result<Self::Output, ()>>;
26+
fn func() -> Self::Future {
27+
Result::<(), ()>::Err(())
28+
}
29+
}
30+
31+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![feature(type_alias_impl_trait, generator_trait, generators)]
2+
use std::ops::Generator;
3+
4+
trait Runnable {
5+
type Gen: Generator<Yield = (), Return = ()>;
6+
7+
fn run(&mut self) -> Self::Gen;
8+
}
9+
10+
struct Implementor {}
11+
12+
impl Runnable for Implementor {
13+
type Gen = impl Generator<Yield = (), Return = ()>;
14+
15+
fn run(&mut self) -> Self::Gen {
16+
move || { //~ ERROR: type mismatch resolving
17+
yield 1;
18+
}
19+
}
20+
}
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:16:9: 18:10] as Generator>::Yield == ()`
2+
--> $DIR/issue-94429.rs:16:9
3+
|
4+
LL | / move || {
5+
LL | | yield 1;
6+
LL | | }
7+
| |_________^ expected integer, found `()`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)