Auto merge of #90249 - matthiaskrgr:rollup-xwtfhq3, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #89889 (Use the "nice E0277 errors"[1] for `!Send` `impl Future` from foreign crate) - #90127 (Do not mention a reexported item if it's private) - #90143 (tidy: Remove submodules from edition exception list) - #90238 (Add alias for guillaume.gomez@huawei.com) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
32f3887b9b
10 changed files with 121 additions and 102 deletions
1
.mailmap
1
.mailmap
|
@ -111,6 +111,7 @@ Graydon Hoare <graydon@pobox.com> Graydon Hoare <graydon@mozilla.com>
|
||||||
Guillaume Gomez <guillaume1.gomez@gmail.com>
|
Guillaume Gomez <guillaume1.gomez@gmail.com>
|
||||||
Guillaume Gomez <guillaume1.gomez@gmail.com> ggomez <ggomez@ggo.ifr.lan>
|
Guillaume Gomez <guillaume1.gomez@gmail.com> ggomez <ggomez@ggo.ifr.lan>
|
||||||
Guillaume Gomez <guillaume1.gomez@gmail.com> Guillaume Gomez <ggomez@ggo.ifr.lan>
|
Guillaume Gomez <guillaume1.gomez@gmail.com> Guillaume Gomez <ggomez@ggo.ifr.lan>
|
||||||
|
Guillaume Gomez <guillaume1.gomez@gmail.com> Guillaume Gomez <guillaume.gomez@huawei.com>
|
||||||
Hanna Kruppe <hanna.kruppe@gmail.com> <robin.kruppe@gmail.com>
|
Hanna Kruppe <hanna.kruppe@gmail.com> <robin.kruppe@gmail.com>
|
||||||
Heather <heather@cynede.net> <Cynede@Gentoo.org>
|
Heather <heather@cynede.net> <Cynede@Gentoo.org>
|
||||||
Heather <heather@cynede.net> <Heather@cynede.net>
|
Heather <heather@cynede.net> <Heather@cynede.net>
|
||||||
|
|
|
@ -829,6 +829,15 @@ impl<'a> Resolver<'a> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #90113: Do not count an inaccessible reexported item as a candidate.
|
||||||
|
if let NameBindingKind::Import { binding, .. } = name_binding.kind {
|
||||||
|
if this.is_accessible_from(binding.vis, parent_scope.module)
|
||||||
|
&& !this.is_accessible_from(name_binding.vis, parent_scope.module)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// collect results based on the filter function
|
// collect results based on the filter function
|
||||||
// avoid suggesting anything from the same module in which we are resolving
|
// avoid suggesting anything from the same module in which we are resolving
|
||||||
if ident.name == lookup_ident.name
|
if ident.name == lookup_ident.name
|
||||||
|
|
|
@ -151,7 +151,7 @@ pub trait InferCtxtExt<'tcx> {
|
||||||
outer_generator: Option<DefId>,
|
outer_generator: Option<DefId>,
|
||||||
trait_ref: ty::TraitRef<'tcx>,
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
target_ty: Ty<'tcx>,
|
target_ty: Ty<'tcx>,
|
||||||
typeck_results: &ty::TypeckResults<'tcx>,
|
typeck_results: Option<&ty::TypeckResults<'tcx>>,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
next_code: Option<&ObligationCauseCode<'tcx>>,
|
next_code: Option<&ObligationCauseCode<'tcx>>,
|
||||||
);
|
);
|
||||||
|
@ -1460,11 +1460,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only continue if a generator was found.
|
// Only continue if a generator was found.
|
||||||
debug!(
|
debug!(?generator, ?trait_ref, ?target_ty, "maybe_note_obligation_cause_for_async_await");
|
||||||
"maybe_note_obligation_cause_for_async_await: generator={:?} trait_ref={:?} \
|
|
||||||
target_ty={:?}",
|
|
||||||
generator, trait_ref, target_ty
|
|
||||||
);
|
|
||||||
let (generator_did, trait_ref, target_ty) = match (generator, trait_ref, target_ty) {
|
let (generator_did, trait_ref, target_ty) = match (generator, trait_ref, target_ty) {
|
||||||
(Some(generator_did), Some(trait_ref), Some(target_ty)) => {
|
(Some(generator_did), Some(trait_ref), Some(target_ty)) => {
|
||||||
(generator_did, trait_ref, target_ty)
|
(generator_did, trait_ref, target_ty)
|
||||||
|
@ -1474,14 +1470,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let span = self.tcx.def_span(generator_did);
|
let span = self.tcx.def_span(generator_did);
|
||||||
|
|
||||||
// Do not ICE on closure typeck (#66868).
|
|
||||||
if !generator_did.is_local() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the typeck results from the infcx if the generator is the function we are
|
|
||||||
// currently type-checking; otherwise, get them by performing a query.
|
|
||||||
// This is needed to avoid cycles.
|
|
||||||
let in_progress_typeck_results = self.in_progress_typeck_results.map(|t| t.borrow());
|
let in_progress_typeck_results = self.in_progress_typeck_results.map(|t| t.borrow());
|
||||||
let generator_did_root = self.tcx.closure_base_def_id(generator_did);
|
let generator_did_root = self.tcx.closure_base_def_id(generator_did);
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -1492,14 +1480,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
in_progress_typeck_results.as_ref().map(|t| t.hir_owner),
|
in_progress_typeck_results.as_ref().map(|t| t.hir_owner),
|
||||||
span
|
span
|
||||||
);
|
);
|
||||||
let query_typeck_results;
|
|
||||||
let typeck_results: &TypeckResults<'tcx> = match &in_progress_typeck_results {
|
|
||||||
Some(t) if t.hir_owner.to_def_id() == generator_did_root => t,
|
|
||||||
_ => {
|
|
||||||
query_typeck_results = self.tcx.typeck(generator_did.expect_local());
|
|
||||||
&query_typeck_results
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let generator_body = generator_did
|
let generator_body = generator_did
|
||||||
.as_local()
|
.as_local()
|
||||||
|
@ -1542,51 +1522,59 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
let mut interior_or_upvar_span = None;
|
let mut interior_or_upvar_span = None;
|
||||||
let mut interior_extra_info = None;
|
let mut interior_extra_info = None;
|
||||||
|
|
||||||
if let Some(upvars) = self.tcx.upvars_mentioned(generator_did) {
|
// Get the typeck results from the infcx if the generator is the function we are currently
|
||||||
interior_or_upvar_span = upvars.iter().find_map(|(upvar_id, upvar)| {
|
// type-checking; otherwise, get them by performing a query. This is needed to avoid
|
||||||
let upvar_ty = typeck_results.node_type(*upvar_id);
|
// cycles. If we can't use resolved types because the generator comes from another crate,
|
||||||
let upvar_ty = self.resolve_vars_if_possible(upvar_ty);
|
// we still provide a targeted error but without all the relevant spans.
|
||||||
if ty_matches(ty::Binder::dummy(upvar_ty)) {
|
let query_typeck_results;
|
||||||
Some(GeneratorInteriorOrUpvar::Upvar(upvar.span))
|
let typeck_results: Option<&TypeckResults<'tcx>> = match &in_progress_typeck_results {
|
||||||
} else {
|
Some(t) if t.hir_owner.to_def_id() == generator_did_root => Some(&t),
|
||||||
None
|
_ if generator_did.is_local() => {
|
||||||
}
|
query_typeck_results = self.tcx.typeck(generator_did.expect_local());
|
||||||
});
|
Some(&query_typeck_results)
|
||||||
|
}
|
||||||
|
_ => None, // Do not ICE on closure typeck (#66868).
|
||||||
};
|
};
|
||||||
|
if let Some(typeck_results) = typeck_results {
|
||||||
|
if let Some(upvars) = self.tcx.upvars_mentioned(generator_did) {
|
||||||
|
interior_or_upvar_span = upvars.iter().find_map(|(upvar_id, upvar)| {
|
||||||
|
let upvar_ty = typeck_results.node_type(*upvar_id);
|
||||||
|
let upvar_ty = self.resolve_vars_if_possible(upvar_ty);
|
||||||
|
if ty_matches(ty::Binder::dummy(upvar_ty)) {
|
||||||
|
Some(GeneratorInteriorOrUpvar::Upvar(upvar.span))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// The generator interior types share the same binders
|
// The generator interior types share the same binders
|
||||||
if let Some(cause) =
|
if let Some(cause) =
|
||||||
typeck_results.generator_interior_types.as_ref().skip_binder().iter().find(
|
typeck_results.generator_interior_types.as_ref().skip_binder().iter().find(
|
||||||
|ty::GeneratorInteriorTypeCause { ty, .. }| {
|
|ty::GeneratorInteriorTypeCause { ty, .. }| {
|
||||||
ty_matches(typeck_results.generator_interior_types.rebind(ty))
|
ty_matches(typeck_results.generator_interior_types.rebind(ty))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Check to see if any awaited expressions have the target type.
|
// Check to see if any awaited expressions have the target type.
|
||||||
let from_awaited_ty = visitor
|
let from_awaited_ty = visitor
|
||||||
.awaits
|
.awaits
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|id| hir.expect_expr(id))
|
.map(|id| hir.expect_expr(id))
|
||||||
.find(|await_expr| {
|
.find(|await_expr| {
|
||||||
let ty = typeck_results.expr_ty_adjusted(&await_expr);
|
ty_matches(ty::Binder::dummy(typeck_results.expr_ty_adjusted(&await_expr)))
|
||||||
debug!(
|
})
|
||||||
"maybe_note_obligation_cause_for_async_await: await_expr={:?}",
|
.map(|expr| expr.span);
|
||||||
await_expr
|
let ty::GeneratorInteriorTypeCause { span, scope_span, yield_span, expr, .. } =
|
||||||
);
|
cause;
|
||||||
ty_matches(ty::Binder::dummy(ty))
|
|
||||||
})
|
|
||||||
.map(|expr| expr.span);
|
|
||||||
let ty::GeneratorInteriorTypeCause { span, scope_span, yield_span, expr, .. } = cause;
|
|
||||||
|
|
||||||
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(*span));
|
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(*span));
|
||||||
interior_extra_info = Some((*scope_span, *yield_span, *expr, from_awaited_ty));
|
interior_extra_info = Some((*scope_span, *yield_span, *expr, from_awaited_ty));
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(span));
|
||||||
|
}
|
||||||
|
|
||||||
debug!(
|
|
||||||
"maybe_note_obligation_cause_for_async_await: interior_or_upvar={:?} \
|
|
||||||
generator_interior_types={:?}",
|
|
||||||
interior_or_upvar_span, typeck_results.generator_interior_types
|
|
||||||
);
|
|
||||||
if let Some(interior_or_upvar_span) = interior_or_upvar_span {
|
if let Some(interior_or_upvar_span) = interior_or_upvar_span {
|
||||||
self.note_obligation_cause_for_async_await(
|
self.note_obligation_cause_for_async_await(
|
||||||
err,
|
err,
|
||||||
|
@ -1617,7 +1605,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
outer_generator: Option<DefId>,
|
outer_generator: Option<DefId>,
|
||||||
trait_ref: ty::TraitRef<'tcx>,
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
target_ty: Ty<'tcx>,
|
target_ty: Ty<'tcx>,
|
||||||
typeck_results: &ty::TypeckResults<'tcx>,
|
typeck_results: Option<&ty::TypeckResults<'tcx>>,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
next_code: Option<&ObligationCauseCode<'tcx>>,
|
next_code: Option<&ObligationCauseCode<'tcx>>,
|
||||||
) {
|
) {
|
||||||
|
@ -1828,7 +1816,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
// Look at the last interior type to get a span for the `.await`.
|
// Look at the last interior type to get a span for the `.await`.
|
||||||
debug!(
|
debug!(
|
||||||
"note_obligation_cause_for_async_await generator_interior_types: {:#?}",
|
"note_obligation_cause_for_async_await generator_interior_types: {:#?}",
|
||||||
typeck_results.generator_interior_types
|
typeck_results.as_ref().map(|t| &t.generator_interior_types)
|
||||||
);
|
);
|
||||||
explain_yield(interior_span, yield_span, scope_span);
|
explain_yield(interior_span, yield_span, scope_span);
|
||||||
}
|
}
|
||||||
|
@ -1849,10 +1837,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
// ^^^^^^^ a temporary `&T` created inside this method call due to `&self`
|
// ^^^^^^^ a temporary `&T` created inside this method call due to `&self`
|
||||||
// ```
|
// ```
|
||||||
//
|
//
|
||||||
let is_region_borrow = typeck_results
|
let is_region_borrow = if let Some(typeck_results) = typeck_results {
|
||||||
.expr_adjustments(expr)
|
typeck_results
|
||||||
.iter()
|
.expr_adjustments(expr)
|
||||||
.any(|adj| adj.is_region_borrow());
|
.iter()
|
||||||
|
.any(|adj| adj.is_region_borrow())
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
// ```rust
|
// ```rust
|
||||||
// struct Foo(*const u8);
|
// struct Foo(*const u8);
|
||||||
|
@ -1865,15 +1857,16 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
DefKind::Fn | DefKind::Ctor(..) => target_ty.is_unsafe_ptr(),
|
DefKind::Fn | DefKind::Ctor(..) => target_ty.is_unsafe_ptr(),
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
if let Some(typeck_results) = typeck_results {
|
||||||
if (typeck_results.is_method_call(e) && is_region_borrow)
|
if (typeck_results.is_method_call(e) && is_region_borrow)
|
||||||
|| is_raw_borrow_inside_fn_like_call
|
|| is_raw_borrow_inside_fn_like_call
|
||||||
{
|
{
|
||||||
err.span_help(
|
err.span_help(
|
||||||
parent_span,
|
parent_span,
|
||||||
"consider moving this into a `let` \
|
"consider moving this into a `let` \
|
||||||
binding to create a shorter lived borrow",
|
binding to create a shorter lived borrow",
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit b5c68b02984f74e99d1f1b332029e05f607e2660
|
Subproject commit a01d151a7250a540a9cb7ccce5956f020c677c21
|
|
@ -1 +1 @@
|
||||||
Subproject commit fba15a46ca8efa97e8a955794724ac7ce27805b8
|
Subproject commit b06008731af0f7d07cd0614e820c8276dfed1c18
|
|
@ -7,5 +7,5 @@ fn g(_: impl Send) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
g(issue_67893::run())
|
g(issue_67893::run())
|
||||||
//~^ ERROR: `MutexGuard<'_, ()>` cannot be sent between threads safely
|
//~^ ERROR generator cannot be sent between threads safely
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
error[E0277]: `MutexGuard<'_, ()>` cannot be sent between threads safely
|
error: generator cannot be sent between threads safely
|
||||||
--> $DIR/issue-67893.rs:9:5
|
--> $DIR/issue-67893.rs:9:5
|
||||||
|
|
|
|
||||||
LL | g(issue_67893::run())
|
LL | g(issue_67893::run())
|
||||||
| ^ `MutexGuard<'_, ()>` cannot be sent between threads safely
|
| ^ generator is not `Send`
|
||||||
|
|
|
||||||
::: $DIR/auxiliary/issue_67893.rs:7:20
|
|
||||||
|
|
|
||||||
LL | pub async fn run() {
|
|
||||||
| - within this `impl Future`
|
|
||||||
|
|
|
|
||||||
= help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
|
= help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
|
||||||
= note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc<Mutex<()>>, &'r Mutex<()>, Result<MutexGuard<'s, ()>, PoisonError<MutexGuard<'t0, ()>>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}`
|
|
||||||
= note: required because it appears within the type `[static generator@run::{closure#0}]`
|
|
||||||
= note: required because it appears within the type `from_generator::GenFuture<[static generator@run::{closure#0}]>`
|
|
||||||
= note: required because it appears within the type `impl Future`
|
|
||||||
= note: required because it appears within the type `impl Future`
|
|
||||||
note: required by a bound in `g`
|
note: required by a bound in `g`
|
||||||
--> $DIR/issue-67893.rs:6:14
|
--> $DIR/issue-67893.rs:6:14
|
||||||
|
|
|
|
||||||
|
@ -23,4 +13,3 @@ LL | fn g(_: impl Send) {}
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
|
||||||
|
|
21
src/test/ui/resolve/issue-90113.rs
Normal file
21
src/test/ui/resolve/issue-90113.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
mod list {
|
||||||
|
pub use self::List::Cons;
|
||||||
|
|
||||||
|
pub enum List<T> {
|
||||||
|
Cons(T, Box<List<T>>),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod alias {
|
||||||
|
use crate::list::List;
|
||||||
|
|
||||||
|
pub type Foo = List<String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo(l: crate::alias::Foo) {
|
||||||
|
match l {
|
||||||
|
Cons(..) => {} //~ ERROR: cannot find tuple struct or tuple variant `Cons` in this scope
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
14
src/test/ui/resolve/issue-90113.stderr
Normal file
14
src/test/ui/resolve/issue-90113.stderr
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
error[E0531]: cannot find tuple struct or tuple variant `Cons` in this scope
|
||||||
|
--> $DIR/issue-90113.rs:17:9
|
||||||
|
|
|
||||||
|
LL | Cons(..) => {}
|
||||||
|
| ^^^^ not found in this scope
|
||||||
|
|
|
||||||
|
help: consider importing this tuple variant
|
||||||
|
|
|
||||||
|
LL | use list::List::Cons;
|
||||||
|
|
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0531`.
|
|
@ -18,21 +18,13 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||||
&mut |path| super::filter_dirs(path) || path.ends_with("src/test"),
|
&mut |path| super::filter_dirs(path) || path.ends_with("src/test"),
|
||||||
&mut |entry, contents| {
|
&mut |entry, contents| {
|
||||||
let file = entry.path();
|
let file = entry.path();
|
||||||
let filestr = file.to_string_lossy().replace("\\", "/");
|
|
||||||
let filename = file.file_name().unwrap();
|
let filename = file.file_name().unwrap();
|
||||||
if filename != "Cargo.toml" {
|
if filename != "Cargo.toml" {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Library crates are not yet ready to migrate to 2021.
|
// Library crates are not yet ready to migrate to 2021.
|
||||||
//
|
if path.components().any(|c| c.as_os_str() == "library") {
|
||||||
// The reference and rustc-dev-guide are submodules, so are left at
|
|
||||||
// 2018 for now. They should be removed from this exception list
|
|
||||||
// when bumped.
|
|
||||||
if path.components().any(|c| c.as_os_str() == "library")
|
|
||||||
|| filestr.contains("src/doc/reference/style-check/Cargo.toml")
|
|
||||||
|| filestr.contains("src/doc/rustc-dev-guide/ci/date-check/Cargo.toml")
|
|
||||||
{
|
|
||||||
let has = contents.lines().any(is_edition_2018);
|
let has = contents.lines().any(is_edition_2018);
|
||||||
if !has {
|
if !has {
|
||||||
tidy_error!(
|
tidy_error!(
|
||||||
|
|
Loading…
Add table
Reference in a new issue