|
| 1 | +use hir_def::db::DefDatabase; |
| 2 | +use rustc_hash::FxHashMap; |
| 3 | +use span::Edition; |
| 4 | +use test_fixture::WithFixture; |
| 5 | +use triomphe::Arc; |
| 6 | + |
| 7 | +use crate::{ |
| 8 | + db::HirDatabase, |
| 9 | + mir::{MirBody, MirLowerError}, |
| 10 | + setup_tracing, |
| 11 | + test_db::TestDB, |
| 12 | +}; |
| 13 | + |
| 14 | +fn lower_mir( |
| 15 | + #[rust_analyzer::rust_fixture] ra_fixture: &str, |
| 16 | +) -> FxHashMap<String, Result<Arc<MirBody>, MirLowerError>> { |
| 17 | + let _tracing = setup_tracing(); |
| 18 | + let (db, file_ids) = TestDB::with_many_files(ra_fixture); |
| 19 | + let file_id = *file_ids.last().unwrap(); |
| 20 | + let module_id = db.module_for_file(file_id.file_id(&db)); |
| 21 | + let def_map = module_id.def_map(&db); |
| 22 | + let scope = &def_map[module_id.local_id].scope; |
| 23 | + let funcs = scope.declarations().filter_map(|x| match x { |
| 24 | + hir_def::ModuleDefId::FunctionId(it) => Some(it), |
| 25 | + _ => None, |
| 26 | + }); |
| 27 | + funcs |
| 28 | + .map(|func| { |
| 29 | + let name = db.function_signature(func).name.display(&db, Edition::CURRENT).to_string(); |
| 30 | + let mir = db.mir_body(func.into()); |
| 31 | + (name, mir) |
| 32 | + }) |
| 33 | + .collect() |
| 34 | +} |
| 35 | + |
| 36 | +#[test] |
| 37 | +fn dyn_projection_with_auto_traits_regression_next_solver() { |
| 38 | + lower_mir( |
| 39 | + r#" |
| 40 | +//- minicore: sized, send |
| 41 | +pub trait Deserializer {} |
| 42 | +
|
| 43 | +pub trait Strictest { |
| 44 | + type Object: ?Sized; |
| 45 | +} |
| 46 | +
|
| 47 | +impl Strictest for dyn CustomValue { |
| 48 | + type Object = dyn CustomValue + Send; |
| 49 | +} |
| 50 | +
|
| 51 | +pub trait CustomValue: Send {} |
| 52 | +
|
| 53 | +impl CustomValue for () {} |
| 54 | +
|
| 55 | +struct Box<T: ?Sized>; |
| 56 | +
|
| 57 | +type DeserializeFn<T> = fn(&mut dyn Deserializer) -> Box<T>; |
| 58 | +
|
| 59 | +fn foo() { |
| 60 | + (|deserializer| Box::new(())) as DeserializeFn<<dyn CustomValue as Strictest>::Object>; |
| 61 | +} |
| 62 | + "#, |
| 63 | + ); |
| 64 | +} |
0 commit comments