ignore uncaptured lifetimes when checking opaques
This commit is contained in:
parent
92f40b8059
commit
4e1999d387
11 changed files with 183 additions and 17 deletions
|
@ -0,0 +1,74 @@
|
|||
// issue: #110623
|
||||
//@ check-pass
|
||||
|
||||
use std::{collections::BTreeMap, num::ParseIntError, str::FromStr};
|
||||
|
||||
enum FileSystem {
|
||||
File(usize),
|
||||
Directory(BTreeMap<String, FileSystem>),
|
||||
}
|
||||
|
||||
impl FromStr for FileSystem {
|
||||
type Err = ParseIntError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
if s.starts_with("dir") {
|
||||
Ok(Self::new_dir())
|
||||
} else {
|
||||
Ok(Self::File(s.split_whitespace().next().unwrap().parse()?))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FileSystem {
|
||||
fn new_dir() -> FileSystem {
|
||||
FileSystem::Directory(BTreeMap::new())
|
||||
}
|
||||
|
||||
fn insert(&mut self, name: String, other: FileSystem) -> Option<FileSystem> {
|
||||
match self {
|
||||
FileSystem::File(_) => panic!("can only insert into directory!"),
|
||||
FileSystem::Directory(tree) => tree.insert(name, other),
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively build a tree from commands. This uses (abuses?)
|
||||
// the fact that `cd /` only appears at the start and that
|
||||
// subsequent `cd`s can only move ONE level to use the recursion
|
||||
// stack as the filesystem stack
|
||||
fn build<'a>(
|
||||
&mut self,
|
||||
mut commands: impl Iterator<Item = &'a str> + 'a,
|
||||
) -> Option<impl Iterator<Item = &'a str> + 'a> {
|
||||
let cmd = commands.next()?;
|
||||
let mut elements = cmd.lines();
|
||||
match elements.next().map(str::trim) {
|
||||
Some("cd /") | None => self.build(commands),
|
||||
Some("cd ..") => {
|
||||
// return to higher scope
|
||||
Some(commands)
|
||||
}
|
||||
Some("ls") => {
|
||||
for item in elements {
|
||||
let name = item.split_whitespace().last().unwrap();
|
||||
let prior = self.insert(name.to_string(), item.parse().unwrap());
|
||||
debug_assert!(prior.is_none());
|
||||
}
|
||||
// continue on
|
||||
self.build(commands)
|
||||
}
|
||||
Some(other_cd) => {
|
||||
let name = other_cd
|
||||
.trim()
|
||||
.strip_prefix("cd ")
|
||||
.expect("expected a cd command");
|
||||
let mut directory = FileSystem::new_dir();
|
||||
let further_commands = directory.build(commands);
|
||||
self.insert(name.to_string(), directory);
|
||||
self.build(further_commands?) // THIS LINE FAILS TO COMPILE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,13 @@
|
|||
//@ check-pass
|
||||
|
||||
#![feature(adt_const_params)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
trait Bar<const FOO: &'static str> {}
|
||||
impl Bar<"asdf"> for () {}
|
||||
|
||||
fn foo<const FOO: &'static str>() -> impl Bar<"asdf"> {
|
||||
()
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,16 @@
|
|||
// issue: #111906
|
||||
//@ check-pass
|
||||
|
||||
#![allow(unconditional_recursion)]
|
||||
|
||||
fn foo<'a: 'a>() -> impl Sized {
|
||||
let _: () = foo::<'a>();
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn bar<'a: 'a>() -> impl Sized + 'a {
|
||||
let _: *mut &'a () = bar::<'a>();
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -1,4 +1,4 @@
|
|||
error: {foo<DefId(..)_'a/#0>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
||||
error: {foo<'{erased}>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
||||
--> $DIR/erased-regions-in-hidden-ty.rs:12:36
|
||||
|
|
||||
LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: {foo<DefId(..)_'a/#0>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
||||
error: {foo<'{erased}>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
||||
--> $DIR/erased-regions-in-hidden-ty.rs:12:36
|
||||
|
|
||||
LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// Make sure that the compiler can handle `ReErased` in the hidden type of an opaque.
|
||||
|
||||
fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
|
||||
//~^ ERROR 'a/#0>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
||||
//~^ ERROR '{erased}>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
||||
// Can't write whole type because of lack of path sanitization
|
||||
|| ()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue