Auto merge of #134269 - matthiaskrgr:rollup-fkshwux, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N]) - #133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them) - #133938 (`rustc_mir_dataflow` cleanups, including some renamings) - #134058 (interpret: reduce usage of TypingEnv::fully_monomorphized) - #134130 (Stop using driver queries in the public API) - #134140 (Add AST support for unsafe binders) - #134229 (Fix typos in docs on provenance) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
4a204bebdf
119 changed files with 1341 additions and 639 deletions
|
@ -8,7 +8,7 @@ use rustc_ast::{
|
|||
};
|
||||
pub use rustc_ast::{
|
||||
BinOp, BinOpKind, BindingMode, BorrowKind, BoundConstness, BoundPolarity, ByRef, CaptureBy,
|
||||
ImplPolarity, IsAuto, Movability, Mutability, UnOp,
|
||||
ImplPolarity, IsAuto, Movability, Mutability, UnOp, UnsafeBinderCastKind,
|
||||
};
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::sorted_map::SortedMap;
|
||||
|
@ -1740,6 +1740,7 @@ impl Expr<'_> {
|
|||
| ExprKind::Struct(..)
|
||||
| ExprKind::Tup(_)
|
||||
| ExprKind::Type(..)
|
||||
| ExprKind::UnsafeBinderCast(..)
|
||||
| ExprKind::Err(_) => ExprPrecedence::Unambiguous,
|
||||
|
||||
ExprKind::DropTemps(ref expr, ..) => expr.precedence(),
|
||||
|
@ -1769,6 +1770,9 @@ impl Expr<'_> {
|
|||
// https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md#type-ascription-and-temporaries
|
||||
ExprKind::Type(ref e, _) => e.is_place_expr(allow_projections_from),
|
||||
|
||||
// Unsafe binder cast preserves place-ness of the sub-expression.
|
||||
ExprKind::UnsafeBinderCast(_, e, _) => e.is_place_expr(allow_projections_from),
|
||||
|
||||
ExprKind::Unary(UnOp::Deref, _) => true,
|
||||
|
||||
ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _, _) => {
|
||||
|
@ -1850,7 +1854,8 @@ impl Expr<'_> {
|
|||
| ExprKind::Field(base, _)
|
||||
| ExprKind::Index(base, _, _)
|
||||
| ExprKind::AddrOf(.., base)
|
||||
| ExprKind::Cast(base, _) => {
|
||||
| ExprKind::Cast(base, _)
|
||||
| ExprKind::UnsafeBinderCast(_, base, _) => {
|
||||
// This isn't exactly true for `Index` and all `Unary`, but we are using this
|
||||
// method exclusively for diagnostics and there's a *cultural* pressure against
|
||||
// them being used only for its side-effects.
|
||||
|
@ -2144,6 +2149,10 @@ pub enum ExprKind<'hir> {
|
|||
/// A suspension point for coroutines (i.e., `yield <expr>`).
|
||||
Yield(&'hir Expr<'hir>, YieldSource),
|
||||
|
||||
/// Operators which can be used to interconvert `unsafe` binder types.
|
||||
/// e.g. `unsafe<'a> &'a i32` <=> `&i32`.
|
||||
UnsafeBinderCast(UnsafeBinderCastKind, &'hir Expr<'hir>, Option<&'hir Ty<'hir>>),
|
||||
|
||||
/// A placeholder for an expression that wasn't syntactically well formed in some way.
|
||||
Err(rustc_span::ErrorGuaranteed),
|
||||
}
|
||||
|
@ -2780,6 +2789,12 @@ pub struct BareFnTy<'hir> {
|
|||
pub param_names: &'hir [Ident],
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, HashStable_Generic)]
|
||||
pub struct UnsafeBinderTy<'hir> {
|
||||
pub generic_params: &'hir [GenericParam<'hir>],
|
||||
pub inner_ty: &'hir Ty<'hir>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, HashStable_Generic)]
|
||||
pub struct OpaqueTy<'hir> {
|
||||
pub hir_id: HirId,
|
||||
|
@ -2878,6 +2893,8 @@ pub enum TyKind<'hir> {
|
|||
Ref(&'hir Lifetime, MutTy<'hir>),
|
||||
/// A bare function (e.g., `fn(usize) -> bool`).
|
||||
BareFn(&'hir BareFnTy<'hir>),
|
||||
/// An unsafe binder type (e.g. `unsafe<'a> Foo<'a>`).
|
||||
UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
|
||||
/// The never type (`!`).
|
||||
Never,
|
||||
/// A tuple (`(A, B, C, D, ...)`).
|
||||
|
|
|
@ -857,6 +857,10 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
ExprKind::Yield(ref subexpression, _) => {
|
||||
try_visit!(visitor.visit_expr(subexpression));
|
||||
}
|
||||
ExprKind::UnsafeBinderCast(_kind, expr, ty) => {
|
||||
try_visit!(visitor.visit_expr(expr));
|
||||
visit_opt!(visitor, visit_ty, ty);
|
||||
}
|
||||
ExprKind::Lit(_) | ExprKind::Err(_) => {}
|
||||
}
|
||||
V::Result::output()
|
||||
|
@ -886,6 +890,10 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) -> V::Resul
|
|||
walk_list!(visitor, visit_generic_param, function_declaration.generic_params);
|
||||
try_visit!(visitor.visit_fn_decl(function_declaration.decl));
|
||||
}
|
||||
TyKind::UnsafeBinder(ref unsafe_binder) => {
|
||||
walk_list!(visitor, visit_generic_param, unsafe_binder.generic_params);
|
||||
try_visit!(visitor.visit_ty(unsafe_binder.inner_ty));
|
||||
}
|
||||
TyKind::Path(ref qpath) => {
|
||||
try_visit!(visitor.visit_qpath(qpath, typ.hir_id, typ.span));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue