Skip to content

Commit

Permalink
Auto merge of rust-lang#96695 - JohnTitor:rollup-oo4fc1h, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

Successful merges:

 - rust-lang#96597 (openbsd: unbreak build on native platform)
 - rust-lang#96662 (Fix typo in lint levels doc)
 - rust-lang#96668 (Fix flaky rustdoc-ui test because it did not replace time result)
 - rust-lang#96679 (Quick fix for rust-lang#96223.)
 - rust-lang#96684 (Update `ProjectionElem::Downcast` documentation)
 - rust-lang#96686 (Add some TAIT-related tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed May 4, 2022
2 parents fed2c43 + 2ca778f commit 2567420
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 10 deletions.
4 changes: 1 addition & 3 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2017,9 +2017,7 @@ pub enum ProjectionElem<V, T> {
from_end: bool,
},

/// "Downcast" to a variant of an ADT. Currently, we only introduce
/// this for ADTs with more than one variant. It may be better to
/// just introduce it always, or always for enums.
/// "Downcast" to a variant of an enum or a generator.
///
/// The included Symbol is the name of the variant, used for printing MIR.
Downcast(Option<Symbol>, VariantIdx),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_target::abi::VariantIdx;
#[derive(Copy, Clone, Debug, TypeFoldable)]
pub struct PlaceTy<'tcx> {
pub ty: Ty<'tcx>,
/// Downcast to a particular variant of an enum, if included.
/// Downcast to a particular variant of an enum or a generator, if included.
pub variant_index: Option<VariantIdx>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
return false;
}

let orig_ty = old_pred.self_ty().skip_binder();
// This is a quick fix to resolve an ICE (#96223).
// This change should probably be deeper.
// As suggested by @jackh726, `mk_trait_obligation_with_new_self_ty` could take a `Binder<(TraitRef, Ty)>
// instead of `Binder<Ty>` leading to some changes to its call places.
let Some(orig_ty) = old_pred.self_ty().no_bound_vars() else {
return false;
};
let mk_result = |new_ty| {
let obligation =
self.mk_trait_obligation_with_new_self_ty(param_env, old_pred, new_ty);
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,8 @@ impl<'a> Builder<'a> {
// FIXME(davidtwco): #[cfg(not(bootstrap))] - #95612 needs to be in the bootstrap compiler
// for this conditional to be removed.
if !target.contains("windows") || compiler.stage >= 1 {
if target.contains("linux") || target.contains("windows") {
if target.contains("linux") || target.contains("windows") || target.contains("openbsd")
{
rustflags.arg("-Zunstable-options");
}
match self.config.rust_split_debuginfo {
Expand Down
5 changes: 2 additions & 3 deletions src/doc/rustc/src/lints/levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ This lint level gives you that.
'force-warn' does for 'warn'. It's the same as 'deny' in that a lint at this
level will produce an error, but unlike the 'deny' level, the 'forbid' level
can not be overridden to be anything lower than an error. However, lint
levels may still be capped with `--cap-lints` (see below) so `rustc --cap-
lints warn` will make lints set to 'forbid' just
warn.
levels may still be capped with `--cap-lints` (see below) so `rustc --cap-lints warn`
will make lints set to 'forbid' just warn.

## Configuring warning levels

Expand Down
1 change: 1 addition & 0 deletions src/test/rustdoc-ui/block-doc-comment.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// check-pass
// compile-flags:--test
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"

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

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/block-doc-comment.stdout
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

running 0 tests

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

52 changes: 52 additions & 0 deletions src/test/ui/suggestions/issue-96223.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Previously ICEd because we didn't properly track binders in suggestions
// check-fail

pub trait Foo<'de>: Sized {}

pub trait Bar<'a>: 'static {
type Inner: 'a;
}

pub trait Fubar {
type Bar: for<'a> Bar<'a>;
}

pub struct Baz<T>(pub T);

impl<'de, T> Foo<'de> for Baz<T> where T: Foo<'de> {}

struct Empty;

impl<M> Dummy<M> for Empty
where
M: Fubar,
for<'de> Baz<<M::Bar as Bar<'de>>::Inner>: Foo<'de>,
{
}

pub trait Dummy<M>
where
M: Fubar,
{
}

pub struct EmptyBis<'a>(&'a [u8]);

impl<'a> Bar<'a> for EmptyBis<'static> {
type Inner = EmptyBis<'a>;
}

pub struct EmptyMarker;

impl Fubar for EmptyMarker {
type Bar = EmptyBis<'static>;
}

fn icey_bounds<D: Dummy<EmptyMarker>>(p: &D) {}

fn trigger_ice() {
let p = Empty;
icey_bounds(&p); //~ERROR the trait bound
}

fn main() {}
28 changes: 28 additions & 0 deletions src/test/ui/suggestions/issue-96223.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
error[E0277]: the trait bound `for<'de> EmptyBis<'de>: Foo<'_>` is not satisfied
--> $DIR/issue-96223.rs:49:17
|
LL | icey_bounds(&p);
| ----------- ^^ the trait `for<'de> Foo<'_>` is not implemented for `EmptyBis<'de>`
| |
| required by a bound introduced by this call
|
= help: the trait `Foo<'de>` is implemented for `Baz<T>`
note: required because of the requirements on the impl of `for<'de> Foo<'de>` for `Baz<EmptyBis<'de>>`
--> $DIR/issue-96223.rs:16:14
|
LL | impl<'de, T> Foo<'de> for Baz<T> where T: Foo<'de> {}
| ^^^^^^^^ ^^^^^^
note: required because of the requirements on the impl of `Dummy<EmptyMarker>` for `Empty`
--> $DIR/issue-96223.rs:20:9
|
LL | impl<M> Dummy<M> for Empty
| ^^^^^^^^ ^^^^^
note: required by a bound in `icey_bounds`
--> $DIR/issue-96223.rs:45:19
|
LL | fn icey_bounds<D: Dummy<EmptyMarker>>(p: &D) {}
| ^^^^^^^^^^^^^^^^^^ required by this bound in `icey_bounds`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
9 changes: 9 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(type_alias_impl_trait)]

type Foo = impl Fn() -> Foo;

fn foo() -> Foo {
foo //~ ERROR: overflow evaluating the requirement `fn() -> Foo {foo}: Sized`
}

fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized`
--> $DIR/issue-53398-cyclic-types.rs:6:5
|
LL | foo
| ^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0275`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// check-pass

#![feature(generators, generator_trait)]
#![feature(type_alias_impl_trait)]

use std::ops::{Generator, GeneratorState};
use std::pin::Pin;

type RandGenerator<'a> = impl Generator<Return = (), Yield = u64> + 'a;
fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> {
move || {
let _rng = rng;
loop {
yield 0;
}
}
}

pub type RandGeneratorWithIndirection<'a> = impl Generator<Return = (), Yield = u64> + 'a;
pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndirection<'a> {
fn helper<'b>(rng: &'b ()) -> impl 'b + Generator<Return = (), Yield = u64> {
move || {
let _rng = rng;
loop {
yield 0;
}
}
}

helper(rng)
}

fn main() {
let mut gen = rand_generator(&());
match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) {
GeneratorState::Yielded(_) => {}
GeneratorState::Complete(_) => {}
};
}
31 changes: 31 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-89952.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// check-pass

#![feature(type_alias_impl_trait)]

trait SomeTrait {}
impl SomeTrait for () {}

trait MyFuture {
type Output;
}
impl<T> MyFuture for T {
type Output = T;
}

trait ReturnsFuture {
type Output: SomeTrait;
type Future: MyFuture<Output = Result<Self::Output, ()>>;
fn func() -> Self::Future;
}

struct Foo;

impl ReturnsFuture for Foo {
type Output = impl SomeTrait;
type Future = impl MyFuture<Output = Result<Self::Output, ()>>;
fn func() -> Self::Future {
Result::<(), ()>::Err(())
}
}

fn main() {}
22 changes: 22 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-94429.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#![feature(type_alias_impl_trait, generator_trait, generators)]
use std::ops::Generator;

trait Runnable {
type Gen: Generator<Yield = (), Return = ()>;

fn run(&mut self) -> Self::Gen;
}

struct Implementor {}

impl Runnable for Implementor {
type Gen = impl Generator<Yield = (), Return = ()>;

fn run(&mut self) -> Self::Gen {
move || { //~ ERROR: type mismatch resolving
yield 1;
}
}
}

fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-94429.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:16:9: 18:10] as Generator>::Yield == ()`
--> $DIR/issue-94429.rs:16:9
|
LL | / move || {
LL | | yield 1;
LL | | }
| |_________^ expected integer, found `()`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0271`.

0 comments on commit 2567420

Please sign in to comment.