Auto merge of #97873 - Dylan-DPC:rollup-g6ptsdq, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #97276 (Stabilize `const_intrinsic_copy`) - #97763 (Allow ptr_from_addr_cast to fail) - #97846 (Specify DWARF alignment in bits, not bytes.) - #97848 (Impl Traits lowering minor refactors) - #97865 (remove `BorrowckMode`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
09d52bc5d4
@ -19,7 +19,6 @@ use rustc_span::symbol::{kw, sym, Ident};
|
|||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::spec::abi;
|
use rustc_target::spec::abi;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use tracing::debug;
|
|
||||||
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
@ -117,6 +116,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
|
|||||||
self.owners[def_id]
|
self.owners[def_id]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip(self, c))]
|
||||||
fn lower_crate(&mut self, c: &Crate) {
|
fn lower_crate(&mut self, c: &Crate) {
|
||||||
debug_assert_eq!(self.resolver.local_def_id(CRATE_NODE_ID), CRATE_DEF_ID);
|
debug_assert_eq!(self.resolver.local_def_id(CRATE_NODE_ID), CRATE_DEF_ID);
|
||||||
|
|
||||||
@ -127,6 +127,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn lower_item(&mut self, item: &Item) {
|
fn lower_item(&mut self, item: &Item) {
|
||||||
self.with_lctx(item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
|
self.with_lctx(item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
|
||||||
}
|
}
|
||||||
@ -485,6 +486,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
(ty, self.lower_const_body(span, body))
|
(ty, self.lower_const_body(span, body))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn lower_use_tree(
|
fn lower_use_tree(
|
||||||
&mut self,
|
&mut self,
|
||||||
tree: &UseTree,
|
tree: &UseTree,
|
||||||
@ -494,8 +496,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
ident: &mut Ident,
|
ident: &mut Ident,
|
||||||
attrs: Option<&'hir [Attribute]>,
|
attrs: Option<&'hir [Attribute]>,
|
||||||
) -> hir::ItemKind<'hir> {
|
) -> hir::ItemKind<'hir> {
|
||||||
debug!("lower_use_tree(tree={:?})", tree);
|
|
||||||
|
|
||||||
let path = &tree.prefix;
|
let path = &tree.prefix;
|
||||||
let segments = prefix.segments.iter().chain(path.segments.iter()).cloned().collect();
|
let segments = prefix.segments.iter().chain(path.segments.iter()).cloned().collect();
|
||||||
|
|
||||||
@ -1298,6 +1298,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
|
|
||||||
/// Return the pair of the lowered `generics` as `hir::Generics` and the evaluation of `f` with
|
/// Return the pair of the lowered `generics` as `hir::Generics` and the evaluation of `f` with
|
||||||
/// the carried impl trait definitions and bounds.
|
/// the carried impl trait definitions and bounds.
|
||||||
|
#[instrument(level = "debug", skip(self, f))]
|
||||||
fn lower_generics<T>(
|
fn lower_generics<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
generics: &Generics,
|
generics: &Generics,
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![allow(rustc::potential_query_instability)]
|
#![allow(rustc::potential_query_instability)]
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate tracing;
|
||||||
|
|
||||||
use rustc_ast::visit;
|
use rustc_ast::visit;
|
||||||
use rustc_ast::{self as ast, *};
|
use rustc_ast::{self as ast, *};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
@ -63,7 +66,6 @@ use rustc_span::{Span, DUMMY_SP};
|
|||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use tracing::{debug, trace};
|
|
||||||
|
|
||||||
macro_rules! arena_vec {
|
macro_rules! arena_vec {
|
||||||
($this:expr; $($x:expr),*) => (
|
($this:expr; $($x:expr),*) => (
|
||||||
@ -439,7 +441,7 @@ pub fn lower_crate<'a, 'hir>(
|
|||||||
arena.alloc(krate)
|
arena.alloc(krate)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
enum ParamMode {
|
enum ParamMode {
|
||||||
/// Any path in a type context.
|
/// Any path in a type context.
|
||||||
Explicit,
|
Explicit,
|
||||||
@ -455,6 +457,7 @@ enum ParenthesizedGenericArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
|
#[instrument(level = "debug", skip(self, f))]
|
||||||
fn with_hir_id_owner(
|
fn with_hir_id_owner(
|
||||||
&mut self,
|
&mut self,
|
||||||
owner: NodeId,
|
owner: NodeId,
|
||||||
@ -599,12 +602,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
self.lower_node_id(node_id)
|
self.lower_node_id(node_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "trace", skip(self))]
|
||||||
fn lower_res(&mut self, res: Res<NodeId>) -> Res {
|
fn lower_res(&mut self, res: Res<NodeId>) -> Res {
|
||||||
let res: Result<Res, ()> = res.apply_id(|id| {
|
let res: Result<Res, ()> = res.apply_id(|id| {
|
||||||
let owner = self.current_hir_id_owner;
|
let owner = self.current_hir_id_owner;
|
||||||
let local_id = self.node_id_to_local_id.get(&id).copied().ok_or(())?;
|
let local_id = self.node_id_to_local_id.get(&id).copied().ok_or(())?;
|
||||||
Ok(hir::HirId { owner, local_id })
|
Ok(hir::HirId { owner, local_id })
|
||||||
});
|
});
|
||||||
|
trace!(?res);
|
||||||
|
|
||||||
// We may fail to find a HirId when the Res points to a Local from an enclosing HIR owner.
|
// We may fail to find a HirId when the Res points to a Local from an enclosing HIR owner.
|
||||||
// This can happen when trying to lower the return type `x` in erroneous code like
|
// This can happen when trying to lower the return type `x` in erroneous code like
|
||||||
// async fn foo(x: u8) -> x {}
|
// async fn foo(x: u8) -> x {}
|
||||||
@ -851,6 +857,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// returns a `hir::TypeBinding` representing `Item`.
|
/// returns a `hir::TypeBinding` representing `Item`.
|
||||||
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn lower_assoc_ty_constraint(
|
fn lower_assoc_ty_constraint(
|
||||||
&mut self,
|
&mut self,
|
||||||
constraint: &AssocConstraint,
|
constraint: &AssocConstraint,
|
||||||
@ -1011,6 +1018,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn lower_generic_arg(
|
fn lower_generic_arg(
|
||||||
&mut self,
|
&mut self,
|
||||||
arg: &ast::GenericArg,
|
arg: &ast::GenericArg,
|
||||||
@ -1081,6 +1089,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> &'hir hir::Ty<'hir> {
|
fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> &'hir hir::Ty<'hir> {
|
||||||
self.arena.alloc(self.lower_ty_direct(t, itctx))
|
self.arena.alloc(self.lower_ty_direct(t, itctx))
|
||||||
}
|
}
|
||||||
@ -1212,41 +1221,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
ImplTraitContext::Universal => {
|
ImplTraitContext::Universal => {
|
||||||
// Add a definition for the in-band `Param`.
|
let span = t.span;
|
||||||
let def_id = self.resolver.local_def_id(def_node_id);
|
|
||||||
|
|
||||||
let hir_bounds =
|
|
||||||
self.lower_param_bounds(bounds, ImplTraitContext::Universal);
|
|
||||||
// Set the name to `impl Bound1 + Bound2`.
|
|
||||||
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
|
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
|
||||||
let param = hir::GenericParam {
|
let (param, bounds, path) =
|
||||||
hir_id: self.lower_node_id(def_node_id),
|
self.lower_generic_and_bounds(def_node_id, span, ident, bounds);
|
||||||
name: ParamName::Plain(self.lower_ident(ident)),
|
|
||||||
pure_wrt_drop: false,
|
|
||||||
span: self.lower_span(span),
|
|
||||||
kind: hir::GenericParamKind::Type { default: None, synthetic: true },
|
|
||||||
colon_span: None,
|
|
||||||
};
|
|
||||||
self.impl_trait_defs.push(param);
|
self.impl_trait_defs.push(param);
|
||||||
|
if let Some(bounds) = bounds {
|
||||||
if let Some(preds) = self.lower_generic_bound_predicate(
|
self.impl_trait_bounds.push(bounds);
|
||||||
ident,
|
|
||||||
def_node_id,
|
|
||||||
&GenericParamKind::Type { default: None },
|
|
||||||
hir_bounds,
|
|
||||||
hir::PredicateOrigin::ImplTrait,
|
|
||||||
) {
|
|
||||||
self.impl_trait_bounds.push(preds)
|
|
||||||
}
|
}
|
||||||
|
path
|
||||||
hir::TyKind::Path(hir::QPath::Resolved(
|
|
||||||
None,
|
|
||||||
self.arena.alloc(hir::Path {
|
|
||||||
span: self.lower_span(span),
|
|
||||||
res: Res::Def(DefKind::TyParam, def_id.to_def_id()),
|
|
||||||
segments: arena_vec![self; hir::PathSegment::from_ident(self.lower_ident(ident))],
|
|
||||||
}),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
ImplTraitContext::Disallowed(position) => {
|
ImplTraitContext::Disallowed(position) => {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
@ -1737,6 +1720,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "trace", skip(self))]
|
||||||
fn lower_param_bound(
|
fn lower_param_bound(
|
||||||
&mut self,
|
&mut self,
|
||||||
tpb: &GenericBound,
|
tpb: &GenericBound,
|
||||||
@ -1862,8 +1846,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
self.arena.alloc_from_iter(self.lower_generic_params_mut(params))
|
self.arena.alloc_from_iter(self.lower_generic_params_mut(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "trace", skip(self))]
|
||||||
fn lower_generic_param(&mut self, param: &GenericParam) -> hir::GenericParam<'hir> {
|
fn lower_generic_param(&mut self, param: &GenericParam) -> hir::GenericParam<'hir> {
|
||||||
let (name, kind) = match param.kind {
|
let (name, kind) = self.lower_generic_param_kind(param);
|
||||||
|
|
||||||
|
let hir_id = self.lower_node_id(param.id);
|
||||||
|
self.lower_attrs(hir_id, ¶m.attrs);
|
||||||
|
hir::GenericParam {
|
||||||
|
hir_id,
|
||||||
|
name,
|
||||||
|
span: self.lower_span(param.span()),
|
||||||
|
pure_wrt_drop: self.sess.contains_name(¶m.attrs, sym::may_dangle),
|
||||||
|
kind,
|
||||||
|
colon_span: param.colon_span.map(|s| self.lower_span(s)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lower_generic_param_kind(
|
||||||
|
&mut self,
|
||||||
|
param: &GenericParam,
|
||||||
|
) -> (hir::ParamName, hir::GenericParamKind<'hir>) {
|
||||||
|
match param.kind {
|
||||||
GenericParamKind::Lifetime => {
|
GenericParamKind::Lifetime => {
|
||||||
// AST resolution emitted an error on those parameters, so we lower them using
|
// AST resolution emitted an error on those parameters, so we lower them using
|
||||||
// `ParamName::Error`.
|
// `ParamName::Error`.
|
||||||
@ -1897,17 +1900,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
hir::GenericParamKind::Const { ty, default },
|
hir::GenericParamKind::Const { ty, default },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
let hir_id = self.lower_node_id(param.id);
|
|
||||||
self.lower_attrs(hir_id, ¶m.attrs);
|
|
||||||
hir::GenericParam {
|
|
||||||
hir_id,
|
|
||||||
name,
|
|
||||||
span: self.lower_span(param.span()),
|
|
||||||
pure_wrt_drop: self.sess.contains_name(¶m.attrs, sym::may_dangle),
|
|
||||||
kind,
|
|
||||||
colon_span: param.colon_span.map(|s| self.lower_span(s)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1954,6 +1946,47 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))
|
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn lower_generic_and_bounds(
|
||||||
|
&mut self,
|
||||||
|
node_id: NodeId,
|
||||||
|
span: Span,
|
||||||
|
ident: Ident,
|
||||||
|
bounds: &[GenericBound],
|
||||||
|
) -> (hir::GenericParam<'hir>, Option<hir::WherePredicate<'hir>>, hir::TyKind<'hir>) {
|
||||||
|
// Add a definition for the in-band `Param`.
|
||||||
|
let def_id = self.resolver.local_def_id(node_id);
|
||||||
|
|
||||||
|
let hir_bounds = self.lower_param_bounds(bounds, ImplTraitContext::Universal);
|
||||||
|
// Set the name to `impl Bound1 + Bound2`.
|
||||||
|
let param = hir::GenericParam {
|
||||||
|
hir_id: self.lower_node_id(node_id),
|
||||||
|
name: ParamName::Plain(self.lower_ident(ident)),
|
||||||
|
pure_wrt_drop: false,
|
||||||
|
span: self.lower_span(span),
|
||||||
|
kind: hir::GenericParamKind::Type { default: None, synthetic: true },
|
||||||
|
colon_span: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let preds = self.lower_generic_bound_predicate(
|
||||||
|
ident,
|
||||||
|
node_id,
|
||||||
|
&GenericParamKind::Type { default: None },
|
||||||
|
hir_bounds,
|
||||||
|
hir::PredicateOrigin::ImplTrait,
|
||||||
|
);
|
||||||
|
|
||||||
|
let ty = hir::TyKind::Path(hir::QPath::Resolved(
|
||||||
|
None,
|
||||||
|
self.arena.alloc(hir::Path {
|
||||||
|
span: self.lower_span(span),
|
||||||
|
res: Res::Def(DefKind::TyParam, def_id.to_def_id()),
|
||||||
|
segments: arena_vec![self; hir::PathSegment::from_ident(self.lower_ident(ident))],
|
||||||
|
}),
|
||||||
|
));
|
||||||
|
|
||||||
|
(param, preds, ty)
|
||||||
|
}
|
||||||
|
|
||||||
/// Lowers a block directly to an expression, presuming that it
|
/// Lowers a block directly to an expression, presuming that it
|
||||||
/// has no attributes and is not targeted by a `break`.
|
/// has no attributes and is not targeted by a `break`.
|
||||||
fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
|
fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
|
||||||
|
@ -15,6 +15,7 @@ use smallvec::smallvec;
|
|||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
|
#[instrument(level = "trace", skip(self))]
|
||||||
pub(crate) fn lower_qpath(
|
pub(crate) fn lower_qpath(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
@ -23,7 +24,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
param_mode: ParamMode,
|
param_mode: ParamMode,
|
||||||
itctx: ImplTraitContext,
|
itctx: ImplTraitContext,
|
||||||
) -> hir::QPath<'hir> {
|
) -> hir::QPath<'hir> {
|
||||||
debug!("lower_qpath(id: {:?}, qself: {:?}, p: {:?})", id, qself, p);
|
|
||||||
let qself_position = qself.as_ref().map(|q| q.position);
|
let qself_position = qself.as_ref().map(|q| q.position);
|
||||||
let qself = qself.as_ref().map(|q| self.lower_ty(&q.ty, itctx));
|
let qself = qself.as_ref().map(|q| self.lower_ty(&q.ty, itctx));
|
||||||
|
|
||||||
|
@ -1365,7 +1365,7 @@ pub fn build_global_var_di_node<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId, glo
|
|||||||
is_local_to_unit,
|
is_local_to_unit,
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
global_align.bytes() as u32,
|
global_align.bits() as u32,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
let addr = addr.to_machine_usize(self)?;
|
let addr = addr.to_machine_usize(self)?;
|
||||||
|
|
||||||
// Then turn address into pointer.
|
// Then turn address into pointer.
|
||||||
let ptr = M::ptr_from_addr_cast(&self, addr);
|
let ptr = M::ptr_from_addr_cast(&self, addr)?;
|
||||||
Ok(Scalar::from_maybe_pointer(ptr, self).into())
|
Ok(Scalar::from_maybe_pointer(ptr, self).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,11 +294,10 @@ pub trait Machine<'mir, 'tcx>: Sized {
|
|||||||
fn ptr_from_addr_cast(
|
fn ptr_from_addr_cast(
|
||||||
ecx: &InterpCx<'mir, 'tcx, Self>,
|
ecx: &InterpCx<'mir, 'tcx, Self>,
|
||||||
addr: u64,
|
addr: u64,
|
||||||
) -> Pointer<Option<Self::PointerTag>>;
|
) -> InterpResult<'tcx, Pointer<Option<Self::PointerTag>>>;
|
||||||
|
|
||||||
// FIXME: Transmuting an integer to a pointer should just always return a `None`
|
|
||||||
// provenance, but that causes problems with function pointers in Miri.
|
|
||||||
/// Hook for returning a pointer from a transmute-like operation on an addr.
|
/// Hook for returning a pointer from a transmute-like operation on an addr.
|
||||||
|
/// This is only needed to support Miri's (unsound) "allow-ptr-int-transmute" flag.
|
||||||
fn ptr_from_addr_transmute(
|
fn ptr_from_addr_transmute(
|
||||||
ecx: &InterpCx<'mir, 'tcx, Self>,
|
ecx: &InterpCx<'mir, 'tcx, Self>,
|
||||||
addr: u64,
|
addr: u64,
|
||||||
@ -519,8 +518,10 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
|
|||||||
fn ptr_from_addr_cast(
|
fn ptr_from_addr_cast(
|
||||||
_ecx: &InterpCx<$mir, $tcx, Self>,
|
_ecx: &InterpCx<$mir, $tcx, Self>,
|
||||||
addr: u64,
|
addr: u64,
|
||||||
) -> Pointer<Option<AllocId>> {
|
) -> InterpResult<$tcx, Pointer<Option<AllocId>>> {
|
||||||
Pointer::new(None, Size::from_bytes(addr))
|
// Allow these casts, but make the pointer not dereferenceable.
|
||||||
|
// (I.e., they behave like transmutation.)
|
||||||
|
Ok(Pointer::new(None, Size::from_bytes(addr)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -547,23 +547,6 @@ pub enum PrintRequest {
|
|||||||
LinkArgs,
|
LinkArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub enum BorrowckMode {
|
|
||||||
Mir,
|
|
||||||
Migrate,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BorrowckMode {
|
|
||||||
/// Returns whether we should run the MIR-based borrow check, but also fall back
|
|
||||||
/// on the AST borrow check if the MIR-based one errors.
|
|
||||||
pub fn migrate(self) -> bool {
|
|
||||||
match self {
|
|
||||||
BorrowckMode::Mir => false,
|
|
||||||
BorrowckMode::Migrate => true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum Input {
|
pub enum Input {
|
||||||
/// Load source code from a file.
|
/// Load source code from a file.
|
||||||
File(PathBuf),
|
File(PathBuf),
|
||||||
|
@ -23,7 +23,7 @@ use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
|
|||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_hir::intravisit::{walk_generics, Visitor as _};
|
use rustc_hir::intravisit::{walk_generics, Visitor as _};
|
||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
use rustc_hir::{GenericArg, GenericArgs};
|
use rustc_hir::{GenericArg, GenericArgs, OpaqueTyOrigin};
|
||||||
use rustc_middle::middle::stability::AllowUnstable;
|
use rustc_middle::middle::stability::AllowUnstable;
|
||||||
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, Subst, SubstsRef};
|
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, Subst, SubstsRef};
|
||||||
use rustc_middle::ty::GenericParamDefKind;
|
use rustc_middle::ty::GenericParamDefKind;
|
||||||
@ -2627,16 +2627,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
let def_id = item_id.def_id.to_def_id();
|
let def_id = item_id.def_id.to_def_id();
|
||||||
|
|
||||||
match opaque_ty.kind {
|
match opaque_ty.kind {
|
||||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => self
|
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
|
||||||
.impl_trait_ty_to_ty(
|
self.impl_trait_ty_to_ty(def_id, lifetimes, origin)
|
||||||
def_id,
|
}
|
||||||
lifetimes,
|
|
||||||
matches!(
|
|
||||||
origin,
|
|
||||||
hir::OpaqueTyOrigin::FnReturn(..)
|
|
||||||
| hir::OpaqueTyOrigin::AsyncFn(..)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i),
|
ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2705,7 +2698,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
&self,
|
&self,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
lifetimes: &[hir::GenericArg<'_>],
|
lifetimes: &[hir::GenericArg<'_>],
|
||||||
replace_parent_lifetimes: bool,
|
origin: OpaqueTyOrigin,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
debug!("impl_trait_ty_to_ty(def_id={:?}, lifetimes={:?})", def_id, lifetimes);
|
debug!("impl_trait_ty_to_ty(def_id={:?}, lifetimes={:?})", def_id, lifetimes);
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
@ -2735,7 +2728,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
// For `impl Trait` in the types of statics, constants,
|
// For `impl Trait` in the types of statics, constants,
|
||||||
// locals and type aliases. These capture all parent
|
// locals and type aliases. These capture all parent
|
||||||
// lifetimes, so they can use their identity subst.
|
// lifetimes, so they can use their identity subst.
|
||||||
GenericParamDefKind::Lifetime if replace_parent_lifetimes => {
|
GenericParamDefKind::Lifetime
|
||||||
|
if matches!(
|
||||||
|
origin,
|
||||||
|
hir::OpaqueTyOrigin::FnReturn(..) | hir::OpaqueTyOrigin::AsyncFn(..)
|
||||||
|
) =>
|
||||||
|
{
|
||||||
tcx.lifetimes.re_static.into()
|
tcx.lifetimes.re_static.into()
|
||||||
}
|
}
|
||||||
_ => tcx.mk_param_from_def(param),
|
_ => tcx.mk_param_from_def(param),
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#![feature(const_convert)]
|
#![feature(const_convert)]
|
||||||
#![feature(const_cow_is_borrowed)]
|
#![feature(const_cow_is_borrowed)]
|
||||||
#![feature(const_heap)]
|
#![feature(const_heap)]
|
||||||
#![feature(const_intrinsic_copy)]
|
|
||||||
#![feature(const_mut_refs)]
|
#![feature(const_mut_refs)]
|
||||||
#![feature(const_nonnull_slice_from_raw_parts)]
|
#![feature(const_nonnull_slice_from_raw_parts)]
|
||||||
#![feature(const_ptr_write)]
|
#![feature(const_ptr_write)]
|
||||||
|
@ -2118,11 +2118,11 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
|
|||||||
/// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append
|
/// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append
|
||||||
#[doc(alias = "memcpy")]
|
#[doc(alias = "memcpy")]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
|
pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2200,11 +2200,11 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
|
|||||||
/// ```
|
/// ```
|
||||||
#[doc(alias = "memmove")]
|
#[doc(alias = "memmove")]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
|
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
fn copy<T>(src: *const T, dst: *mut T, count: usize);
|
fn copy<T>(src: *const T, dst: *mut T, count: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,6 @@
|
|||||||
#![feature(const_convert)]
|
#![feature(const_convert)]
|
||||||
#![feature(const_inherent_unchecked_arith)]
|
#![feature(const_inherent_unchecked_arith)]
|
||||||
#![feature(const_int_unchecked_arith)]
|
#![feature(const_int_unchecked_arith)]
|
||||||
#![feature(const_intrinsic_copy)]
|
|
||||||
#![feature(const_intrinsic_forget)]
|
#![feature(const_intrinsic_forget)]
|
||||||
#![feature(const_likely)]
|
#![feature(const_likely)]
|
||||||
#![feature(const_maybe_uninit_uninit_array)]
|
#![feature(const_maybe_uninit_uninit_array)]
|
||||||
|
@ -1199,7 +1199,7 @@ impl<T: ?Sized> *const T {
|
|||||||
/// See [`ptr::copy`] for safety concerns and examples.
|
/// See [`ptr::copy`] for safety concerns and examples.
|
||||||
///
|
///
|
||||||
/// [`ptr::copy`]: crate::ptr::copy()
|
/// [`ptr::copy`]: crate::ptr::copy()
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
|
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
|
||||||
@ -1218,7 +1218,7 @@ impl<T: ?Sized> *const T {
|
|||||||
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
|
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
|
||||||
///
|
///
|
||||||
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
|
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
|
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
|
||||||
|
@ -1136,7 +1136,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
|
|||||||
// We are calling the intrinsics directly to avoid function calls in the generated code
|
// We are calling the intrinsics directly to avoid function calls in the generated code
|
||||||
// as `intrinsics::copy_nonoverlapping` is a wrapper function.
|
// as `intrinsics::copy_nonoverlapping` is a wrapper function.
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1331,7 +1331,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
|
|||||||
// We are calling the intrinsics directly to avoid function calls in the generated code
|
// We are calling the intrinsics directly to avoid function calls in the generated code
|
||||||
// as `intrinsics::copy_nonoverlapping` is a wrapper function.
|
// as `intrinsics::copy_nonoverlapping` is a wrapper function.
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1311,7 +1311,7 @@ impl<T: ?Sized> *mut T {
|
|||||||
/// See [`ptr::copy`] for safety concerns and examples.
|
/// See [`ptr::copy`] for safety concerns and examples.
|
||||||
///
|
///
|
||||||
/// [`ptr::copy`]: crate::ptr::copy()
|
/// [`ptr::copy`]: crate::ptr::copy()
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
|
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
|
||||||
@ -1330,7 +1330,7 @@ impl<T: ?Sized> *mut T {
|
|||||||
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
|
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
|
||||||
///
|
///
|
||||||
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
|
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
|
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
|
||||||
@ -1349,7 +1349,7 @@ impl<T: ?Sized> *mut T {
|
|||||||
/// See [`ptr::copy`] for safety concerns and examples.
|
/// See [`ptr::copy`] for safety concerns and examples.
|
||||||
///
|
///
|
||||||
/// [`ptr::copy`]: crate::ptr::copy()
|
/// [`ptr::copy`]: crate::ptr::copy()
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub const unsafe fn copy_from(self, src: *const T, count: usize)
|
pub const unsafe fn copy_from(self, src: *const T, count: usize)
|
||||||
@ -1368,7 +1368,7 @@ impl<T: ?Sized> *mut T {
|
|||||||
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
|
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
|
||||||
///
|
///
|
||||||
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
|
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
|
pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
|
||||||
|
@ -84,7 +84,6 @@
|
|||||||
#![feature(const_option)]
|
#![feature(const_option)]
|
||||||
#![feature(const_option_ext)]
|
#![feature(const_option_ext)]
|
||||||
#![feature(const_result)]
|
#![feature(const_result)]
|
||||||
#![feature(const_intrinsic_copy)]
|
|
||||||
#![feature(integer_atomics)]
|
#![feature(integer_atomics)]
|
||||||
#![feature(int_roundings)]
|
#![feature(int_roundings)]
|
||||||
#![feature(slice_group_by)]
|
#![feature(slice_group_by)]
|
||||||
|
8
src/test/codegen/debug-alignment.rs
Normal file
8
src/test/codegen/debug-alignment.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Verifies that DWARF alignment is specified properly.
|
||||||
|
//
|
||||||
|
// compile-flags: -C debuginfo=2
|
||||||
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
|
// CHECK: !DIGlobalVariable
|
||||||
|
// CHECK: align: 32
|
||||||
|
pub static A: u32 = 1;
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
#![feature(intrinsics, staged_api)]
|
#![feature(intrinsics, staged_api)]
|
||||||
#![feature(const_mut_refs, const_intrinsic_copy)]
|
#![feature(const_mut_refs)]
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
|
||||||
|
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
fn copy<T>(src: *const T, dst: *mut T, count: usize);
|
fn copy<T>(src: *const T, dst: *mut T, count: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#![feature(intrinsics, staged_api, const_intrinsic_copy)]
|
#![feature(intrinsics, staged_api)]
|
||||||
#![stable(feature = "core", since = "1.6.0")]
|
#![stable(feature = "core", since = "1.6.0")]
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
|
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
|
||||||
// Const stability attributes are not inherited from parent items.
|
// Const stability attributes are not inherited from parent items.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#![feature(intrinsics, staged_api, const_intrinsic_copy)]
|
#![feature(intrinsics, staged_api)]
|
||||||
#![stable(feature = "core", since = "1.6.0")]
|
#![stable(feature = "core", since = "1.6.0")]
|
||||||
|
|
||||||
extern "rust-intrinsic" {
|
extern "rust-intrinsic" {
|
||||||
@ -6,7 +6,7 @@ extern "rust-intrinsic" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
|
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const unsafe fn stuff<T>(src: *const T, dst: *mut T, count: usize) {
|
pub const unsafe fn stuff<T>(src: *const T, dst: *mut T, count: usize) {
|
||||||
unsafe { copy(src, dst, count) } //~ ERROR cannot call non-const fn
|
unsafe { copy(src, dst, count) } //~ ERROR cannot call non-const fn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user