Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #110006

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a860a72
Fix issue when there are multiple candidates for edit_distance_with_s…
chenyukang Mar 20, 2023
7b4f436
add comments and cleanup
chenyukang Mar 26, 2023
6975b77
Add a test for issue 109396
WaffleLapkin Mar 30, 2023
b9d5a6b
Don't leave a comma at the start of argument list when removing argum…
WaffleLapkin Mar 30, 2023
4a4fc3b
Implement support for GeneratorWitnessMIR in new solver
compiler-errors Mar 30, 2023
48c1641
nit picks from review
WaffleLapkin Apr 5, 2023
279f35c
Derive String's PartialEq implementation
KamilaBorowska Apr 5, 2023
e9daab2
rustdoc: avoid including line numbers in Google SERP snippets
notriddle Apr 5, 2023
4fc3c6b
add comment
chenyukang Apr 5, 2023
5cb23e4
Remove f32 & f64 from MemDecoder/MemEncoder
scottmcm Apr 5, 2023
38b1741
improve/extend `detect_src_and_out` test
onur-ozkan Apr 6, 2023
ded0483
add `dont_check_failure_status` option in the compiler test
SparrowLii Apr 6, 2023
159b61e
Rollup merge of #109162 - ozkanonur:extend_detect_src_and_out_test, r…
matthiaskrgr Apr 6, 2023
dd70ddc
Rollup merge of #109395 - chenyukang:yukang/fix-109291, r=cjgillot
matthiaskrgr Apr 6, 2023
ffffa2d
Rollup merge of #109755 - compiler-errors:new-solver-generator-witnes…
matthiaskrgr Apr 6, 2023
e7376ef
Rollup merge of #109782 - WaffleLapkin:nocommawhenremovingarguments, …
matthiaskrgr Apr 6, 2023
f99b844
Rollup merge of #109977 - notriddle:notriddle/data-nosnippet, r=jsha,…
matthiaskrgr Apr 6, 2023
0ca7ecc
Rollup merge of #109980 - xfix:derive-string-partialeq, r=scottmcm
matthiaskrgr Apr 6, 2023
1976cc9
Rollup merge of #109984 - scottmcm:less-float, r=Nilstrieb
matthiaskrgr Apr 6, 2023
e547c48
Rollup merge of #110004 - SparrowLii:failure_status, r=oli-obk
matthiaskrgr Apr 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement support for GeneratorWitnessMIR in new solver
compiler-errors committed Apr 5, 2023
commit 4a4fc3bb5b1efe6857cf5d6c0b554ff36b966996
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::{def_id::DefId, Movability, Mutability};
use rustc_infer::traits::query::NoSolution;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::{
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
};

use crate::solve::EvalCtxt;

@@ -60,7 +62,16 @@ pub(super) fn instantiate_constituent_tys_for_auto_trait<'tcx>(

ty::GeneratorWitness(types) => Ok(ecx.instantiate_binder_with_placeholders(types).to_vec()),

ty::GeneratorWitnessMIR(..) => todo!(),
ty::GeneratorWitnessMIR(def_id, substs) => Ok(ecx
.tcx()
.generator_hidden_types(def_id)
.map(|bty| {
ecx.instantiate_binder_with_placeholders(replace_erased_lifetimes_with_bound_vars(
tcx,
bty.subst(tcx, substs),
))
})
.collect()),

// For `PhantomData<T>`, we pass `T`.
ty::Adt(def, substs) if def.is_phantom_data() => Ok(vec![substs.type_at(0)]),
@@ -76,6 +87,29 @@ pub(super) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
}
}

fn replace_erased_lifetimes_with_bound_vars<'tcx>(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
) -> ty::Binder<'tcx, Ty<'tcx>> {
debug_assert!(!ty.has_late_bound_regions());
let mut counter = 0;
let ty = tcx.fold_regions(ty, |mut r, current_depth| {
if let ty::ReErased = r.kind() {
let br = ty::BoundRegion {
var: ty::BoundVar::from_u32(counter),
kind: ty::BrAnon(counter, None),
};
counter += 1;
r = tcx.mk_re_late_bound(current_depth, br);
}
r
});
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
(0..counter).map(|i| ty::BoundVariableKind::Region(ty::BrAnon(i, None))),
);
ty::Binder::bind_with_vars(ty, bound_vars)
}

pub(super) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
ecx: &EvalCtxt<'_, 'tcx>,
ty: Ty<'tcx>,
@@ -178,7 +212,16 @@ pub(super) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(

ty::GeneratorWitness(types) => Ok(ecx.instantiate_binder_with_placeholders(types).to_vec()),

ty::GeneratorWitnessMIR(..) => todo!(),
ty::GeneratorWitnessMIR(def_id, substs) => Ok(ecx
.tcx()
.generator_hidden_types(def_id)
.map(|bty| {
ecx.instantiate_binder_with_placeholders(replace_erased_lifetimes_with_bound_vars(
ecx.tcx(),
bty.subst(ecx.tcx(), substs),
))
})
.collect()),
}
}

18 changes: 18 additions & 0 deletions tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0277]: `impl Future<Output = ()>` cannot be sent between threads safely
--> $DIR/auto-with-drop_tracking_mir.rs:24:13
|
LL | is_send(foo());
| ------- ^^^^^ `impl Future<Output = ()>` cannot be sent between threads safely
| |
| required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `impl Future<Output = ()>`
note: required by a bound in `is_send`
--> $DIR/auto-with-drop_tracking_mir.rs:23:24
|
LL | fn is_send(_: impl Send) {}
| ^^^^ required by this bound in `is_send`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
26 changes: 26 additions & 0 deletions tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// compile-flags: -Ztrait-solver=next -Zdrop-tracking-mir
// edition: 2021
// revisions: pass fail
//[pass] check-pass

#![feature(negative_impls)]

struct NotSync;
impl !Sync for NotSync {}

async fn foo() {
#[cfg(pass)]
let x = &();
#[cfg(fail)]
let x = &NotSync;
bar().await;
drop(x);
}

async fn bar() {}

fn main() {
fn is_send(_: impl Send) {}
is_send(foo());
//[fail]~^ ERROR `impl Future<Output = ()>` cannot be sent between threads safely
}