Skip to content

Commit

Permalink
Auto merge of rust-lang#107688 - lukas-code:projection-with-lifetime,…
Browse files Browse the repository at this point in the history
… r=jackh726

ReErased regions are local

fix rust-lang#107678
fix rust-lang#107684
fix rust-lang#107686
fix rust-lang#107691
fix rust-lang#107730
  • Loading branch information
bors committed Feb 8, 2023
2 parents 3f059f6 + e2a1a2a commit b082e80
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_type_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ bitflags! {
// which is different from how types/const are freshened.
| TypeFlags::HAS_TY_FRESH.bits
| TypeFlags::HAS_CT_FRESH.bits
| TypeFlags::HAS_FREE_LOCAL_REGIONS.bits;
| TypeFlags::HAS_FREE_LOCAL_REGIONS.bits
| TypeFlags::HAS_RE_ERASED.bits;

/// Does this have `Projection`?
const HAS_TY_PROJECTION = 1 << 10;
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/mir/issue-107678-projection-with-lifetime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// build-pass

#![crate_type = "lib"]

pub trait StreamOnce {
type Error;
}

pub trait ResetStream: StreamOnce {
fn reset(&mut self) -> Result<(), Self::Error>;
}

impl<'a> ResetStream for &'a str
where Self: StreamOnce
{
#[inline]
fn reset(&mut self) -> Result<(), Self::Error> {
Ok(())
}
}
42 changes: 42 additions & 0 deletions tests/ui/mir/issue-107691.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// build-pass
// compile-flags: -C opt-level=3

#![crate_type = "lib"]

pub trait Archive {
type Archived;
type Resolver;

fn resolve(resolver: Self::Resolver, out: *mut Self::Archived);
}

pub type Archived<T> = <T as Archive>::Archived;
pub type Resolver<T> = <T as Archive>::Resolver;

pub struct Record<'a> {
_payload: &'a [u8],
}

pub struct ArchivedRecord<'a>
where
&'a [u8]: Archive,
{
_payload: Archived<&'a [u8]>,
}

pub struct RecordResolver<'a>
where
&'a [u8]: Archive,
{
_payload: Resolver<&'a [u8]>,
}

impl<'a> Archive for Record<'a>
where
&'a [u8]: Archive,
{
type Archived = ArchivedRecord<'a>;
type Resolver = RecordResolver<'a>;

fn resolve(_resolver: Self::Resolver, _out: *mut Self::Archived) {}
}
4 changes: 3 additions & 1 deletion tests/ui/recursion/issue-83150.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ LL | func(&mut iter.map(|x| x + 1))
= help: a `loop` may express intention better if this is on purpose
= note: `#[warn(unconditional_recursion)]` on by default

error[E0275]: overflow evaluating the requirement `Map<&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>, ...>: Iterator`
error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:12:24: 12:27]>: Iterator`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`)
= note: required for `&mut Map<&mut std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:12:24: 12:27]>` to implement `Iterator`
= note: 65 redundant requirements hidden
= note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>, ...>, ...>, ...>, ...>` to implement `Iterator`
= note: the full type name has been written to '$TEST_BUILD_DIR/recursion/issue-83150/issue-83150.long-type-hash.txt'

Expand Down

0 comments on commit b082e80

Please sign in to comment.