mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Auto merge of #66607 - Centril:rollup-yb7cl73, r=Centril
Rollup of 5 pull requests Successful merges: - #65355 (Stabilize `!` in Rust 1.41.0) - #65730 (Suggest to add lifetime constraint at explicit ouput of functions) - #66468 (Cleanup Miri SIMD intrinsics) - #66515 (Reduce size of `hir::Expr` by boxing more of `hir::InlineAsm`) - #66602 (Revert "Update Source Code Pro and include italics") Failed merges: r? @ghost
This commit is contained in:
commit
35ef33a89d
@ -185,7 +185,7 @@ mod impls {
|
||||
bool char
|
||||
}
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl Clone for ! {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
|
@ -1128,24 +1128,24 @@ mod impls {
|
||||
|
||||
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl PartialEq for ! {
|
||||
fn eq(&self, _: &!) -> bool {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl Eq for ! {}
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl PartialOrd for ! {
|
||||
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl Ord for ! {
|
||||
fn cmp(&self, _: &!) -> Ordering {
|
||||
*self
|
||||
|
@ -40,8 +40,6 @@
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::fmt;
|
||||
|
||||
/// The identity function.
|
||||
///
|
||||
/// Two things are important to note about this function:
|
||||
@ -426,9 +424,7 @@ pub trait TryInto<T>: Sized {
|
||||
/// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T`
|
||||
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
|
||||
/// is implemented and cannot fail -- the associated `Error` type for
|
||||
/// calling `T::try_from()` on a value of type `T` is [`Infallible`].
|
||||
/// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be
|
||||
/// equivalent.
|
||||
/// calling `T::try_from()` on a value of type `T` is [`!`].
|
||||
///
|
||||
/// `TryFrom<T>` can be implemented as follows:
|
||||
///
|
||||
@ -477,7 +473,6 @@ pub trait TryInto<T>: Sized {
|
||||
/// [`TryInto`]: trait.TryInto.html
|
||||
/// [`i32::MAX`]: ../../std/i32/constant.MAX.html
|
||||
/// [`!`]: ../../std/primitive.never.html
|
||||
/// [`Infallible`]: enum.Infallible.html
|
||||
#[stable(feature = "try_from", since = "1.34.0")]
|
||||
pub trait TryFrom<T>: Sized {
|
||||
/// The type returned in the event of a conversion error.
|
||||
@ -615,9 +610,9 @@ impl AsRef<str> for str {
|
||||
// THE NO-ERROR ERROR TYPE
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// The error type for errors that can never happen.
|
||||
/// A type alias for [the `!` “never” type][never].
|
||||
///
|
||||
/// Since this enum has no variant, a value of this type can never actually exist.
|
||||
/// `Infallible` represents types of errors that can never happen since `!` has no valid values.
|
||||
/// This can be useful for generic APIs that use [`Result`] and parameterize the error type,
|
||||
/// to indicate that the result is always [`Ok`].
|
||||
///
|
||||
@ -634,33 +629,10 @@ impl AsRef<str> for str {
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Future compatibility
|
||||
/// # Eventual deprecation
|
||||
///
|
||||
/// This enum has the same role as [the `!` “never” type][never],
|
||||
/// which is unstable in this version of Rust.
|
||||
/// When `!` is stabilized, we plan to make `Infallible` a type alias to it:
|
||||
///
|
||||
/// ```ignore (illustrates future std change)
|
||||
/// pub type Infallible = !;
|
||||
/// ```
|
||||
///
|
||||
/// … and eventually deprecate `Infallible`.
|
||||
///
|
||||
///
|
||||
/// However there is one case where `!` syntax can be used
|
||||
/// before `!` is stabilized as a full-fleged type: in the position of a function’s return type.
|
||||
/// Specifically, it is possible implementations for two different function pointer types:
|
||||
///
|
||||
/// ```
|
||||
/// trait MyTrait {}
|
||||
/// impl MyTrait for fn() -> ! {}
|
||||
/// impl MyTrait for fn() -> std::convert::Infallible {}
|
||||
/// ```
|
||||
///
|
||||
/// With `Infallible` being an enum, this code is valid.
|
||||
/// However when `Infallible` becomes an alias for the never type,
|
||||
/// the two `impl`s will start to overlap
|
||||
/// and therefore will be disallowed by the language’s trait coherence rules.
|
||||
/// Previously, `Infallible` was defined as `enum Infallible {}`.
|
||||
/// Now that it is merely a type alias to `!`, we will eventually deprecate `Infallible`.
|
||||
///
|
||||
/// [`Ok`]: ../result/enum.Result.html#variant.Ok
|
||||
/// [`Result`]: ../result/enum.Result.html
|
||||
@ -668,57 +640,4 @@ impl AsRef<str> for str {
|
||||
/// [`Into`]: trait.Into.html
|
||||
/// [never]: ../../std/primitive.never.html
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
#[derive(Copy)]
|
||||
pub enum Infallible {}
|
||||
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
impl Clone for Infallible {
|
||||
fn clone(&self) -> Infallible {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
impl fmt::Debug for Infallible {
|
||||
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
impl fmt::Display for Infallible {
|
||||
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
impl PartialEq for Infallible {
|
||||
fn eq(&self, _: &Infallible) -> bool {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
impl Eq for Infallible {}
|
||||
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
impl PartialOrd for Infallible {
|
||||
fn partial_cmp(&self, _other: &Self) -> Option<crate::cmp::Ordering> {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
impl Ord for Infallible {
|
||||
fn cmp(&self, _other: &Self) -> crate::cmp::Ordering {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "convert_infallible", since = "1.34.0")]
|
||||
impl From<!> for Infallible {
|
||||
fn from(x: !) -> Self {
|
||||
x
|
||||
}
|
||||
}
|
||||
pub type Infallible = !;
|
||||
|
@ -1935,14 +1935,14 @@ macro_rules! fmt_refs {
|
||||
|
||||
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl Debug for ! {
|
||||
fn fmt(&self, _: &mut Formatter<'_>) -> Result {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl Display for ! {
|
||||
fn fmt(&self, _: &mut Formatter<'_>) -> Result {
|
||||
*self
|
||||
|
@ -85,7 +85,7 @@
|
||||
#![feature(iter_once_with)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(link_llvm_intrinsics)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(bootstrap, feature(never_type))]
|
||||
#![feature(nll)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(no_core)]
|
||||
|
@ -774,7 +774,7 @@ mod copy_impls {
|
||||
bool char
|
||||
}
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl Copy for ! {}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::convert::{TryFrom, Infallible};
|
||||
use crate::convert::TryFrom;
|
||||
use crate::fmt;
|
||||
use crate::intrinsics;
|
||||
use crate::mem;
|
||||
@ -4722,18 +4722,8 @@ impl fmt::Display for TryFromIntError {
|
||||
}
|
||||
|
||||
#[stable(feature = "try_from", since = "1.34.0")]
|
||||
impl From<Infallible> for TryFromIntError {
|
||||
fn from(x: Infallible) -> TryFromIntError {
|
||||
match x {}
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
impl From<!> for TryFromIntError {
|
||||
fn from(never: !) -> TryFromIntError {
|
||||
// Match rather than coerce to make sure that code like
|
||||
// `From<Infallible> for TryFromIntError` above will keep working
|
||||
// when `Infallible` becomes an alias to `!`.
|
||||
match never {}
|
||||
}
|
||||
}
|
||||
|
@ -1086,10 +1086,9 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
||||
ExprKind::Ret(ref optional_expression) => {
|
||||
walk_list!(visitor, visit_expr, optional_expression);
|
||||
}
|
||||
ExprKind::InlineAsm(_, ref outputs, ref inputs) => {
|
||||
for expr in outputs.iter().chain(inputs.iter()) {
|
||||
visitor.visit_expr(expr)
|
||||
}
|
||||
ExprKind::InlineAsm(ref asm) => {
|
||||
walk_list!(visitor, visit_expr, &asm.outputs_exprs);
|
||||
walk_list!(visitor, visit_expr, &asm.inputs_exprs);
|
||||
}
|
||||
ExprKind::Yield(ref subexpression, _) => {
|
||||
visitor.visit_expr(subexpression);
|
||||
|
@ -2170,6 +2170,16 @@ impl<'a> LoweringContext<'a> {
|
||||
impl_trait_return_allow: bool,
|
||||
make_ret_async: Option<NodeId>,
|
||||
) -> P<hir::FnDecl> {
|
||||
debug!("lower_fn_decl(\
|
||||
fn_decl: {:?}, \
|
||||
in_band_ty_params: {:?}, \
|
||||
impl_trait_return_allow: {}, \
|
||||
make_ret_async: {:?})",
|
||||
decl,
|
||||
in_band_ty_params,
|
||||
impl_trait_return_allow,
|
||||
make_ret_async,
|
||||
);
|
||||
let lt_mode = if make_ret_async.is_some() {
|
||||
// In `async fn`, argument-position elided lifetimes
|
||||
// must be transformed into fresh generic parameters so that
|
||||
@ -2462,7 +2472,7 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
hir::FunctionRetTy::Return(P(hir::Ty {
|
||||
kind: opaque_ty_ref,
|
||||
span,
|
||||
span: opaque_ty_span,
|
||||
hir_id: self.next_id(),
|
||||
}))
|
||||
}
|
||||
@ -2572,7 +2582,7 @@ impl<'a> LoweringContext<'a> {
|
||||
hir::Lifetime {
|
||||
hir_id: self.lower_node_id(id),
|
||||
span,
|
||||
name: name,
|
||||
name,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -966,7 +966,7 @@ impl LoweringContext<'_> {
|
||||
}
|
||||
|
||||
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind {
|
||||
let hir_asm = hir::InlineAsm {
|
||||
let inner = hir::InlineAsmInner {
|
||||
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
|
||||
outputs: asm.outputs
|
||||
.iter()
|
||||
@ -984,18 +984,18 @@ impl LoweringContext<'_> {
|
||||
alignstack: asm.alignstack,
|
||||
dialect: asm.dialect,
|
||||
};
|
||||
|
||||
let outputs = asm.outputs
|
||||
.iter()
|
||||
.map(|out| self.lower_expr(&out.expr))
|
||||
.collect();
|
||||
|
||||
let inputs = asm.inputs
|
||||
let hir_asm = hir::InlineAsm {
|
||||
inner,
|
||||
inputs_exprs: asm.inputs
|
||||
.iter()
|
||||
.map(|&(_, ref input)| self.lower_expr(input))
|
||||
.collect();
|
||||
|
||||
hir::ExprKind::InlineAsm(P(hir_asm), outputs, inputs)
|
||||
.collect(),
|
||||
outputs_exprs: asm.outputs
|
||||
.iter()
|
||||
.map(|out| self.lower_expr(&out.expr))
|
||||
.collect(),
|
||||
};
|
||||
hir::ExprKind::InlineAsm(P(hir_asm))
|
||||
}
|
||||
|
||||
fn lower_field(&mut self, f: &Field) -> hir::Field {
|
||||
|
@ -1457,7 +1457,7 @@ pub struct Expr {
|
||||
|
||||
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert_size!(Expr, 72);
|
||||
static_assert_size!(Expr, 64);
|
||||
|
||||
impl Expr {
|
||||
pub fn precedence(&self) -> ExprPrecedence {
|
||||
@ -1656,7 +1656,7 @@ pub enum ExprKind {
|
||||
Ret(Option<P<Expr>>),
|
||||
|
||||
/// Inline assembly (from `asm!`), with its outputs and inputs.
|
||||
InlineAsm(P<InlineAsm>, HirVec<Expr>, HirVec<Expr>),
|
||||
InlineAsm(P<InlineAsm>),
|
||||
|
||||
/// A struct or struct-like variant literal expression.
|
||||
///
|
||||
@ -2063,7 +2063,7 @@ pub struct InlineAsmOutput {
|
||||
// NOTE(eddyb) This is used within MIR as well, so unlike the rest of the HIR,
|
||||
// it needs to be `Clone` and use plain `Vec<T>` instead of `HirVec<T>`.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||
pub struct InlineAsm {
|
||||
pub struct InlineAsmInner {
|
||||
pub asm: Symbol,
|
||||
pub asm_str_style: StrStyle,
|
||||
pub outputs: Vec<InlineAsmOutput>,
|
||||
@ -2074,6 +2074,13 @@ pub struct InlineAsm {
|
||||
pub dialect: AsmDialect,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||
pub struct InlineAsm {
|
||||
pub inner: InlineAsmInner,
|
||||
pub outputs_exprs: HirVec<Expr>,
|
||||
pub inputs_exprs: HirVec<Expr>,
|
||||
}
|
||||
|
||||
/// Represents a parameter in a function header.
|
||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||
pub struct Param {
|
||||
|
@ -1365,14 +1365,15 @@ impl<'a> State<'a> {
|
||||
self.print_expr_maybe_paren(&expr, parser::PREC_JUMP);
|
||||
}
|
||||
}
|
||||
hir::ExprKind::InlineAsm(ref a, ref outputs, ref inputs) => {
|
||||
hir::ExprKind::InlineAsm(ref a) => {
|
||||
let i = &a.inner;
|
||||
self.s.word("asm!");
|
||||
self.popen();
|
||||
self.print_string(&a.asm.as_str(), a.asm_str_style);
|
||||
self.print_string(&i.asm.as_str(), i.asm_str_style);
|
||||
self.word_space(":");
|
||||
|
||||
let mut out_idx = 0;
|
||||
self.commasep(Inconsistent, &a.outputs, |s, out| {
|
||||
self.commasep(Inconsistent, &i.outputs, |s, out| {
|
||||
let constraint = out.constraint.as_str();
|
||||
let mut ch = constraint.chars();
|
||||
match ch.next() {
|
||||
@ -1383,7 +1384,7 @@ impl<'a> State<'a> {
|
||||
_ => s.print_string(&constraint, ast::StrStyle::Cooked),
|
||||
}
|
||||
s.popen();
|
||||
s.print_expr(&outputs[out_idx]);
|
||||
s.print_expr(&a.outputs_exprs[out_idx]);
|
||||
s.pclose();
|
||||
out_idx += 1;
|
||||
});
|
||||
@ -1391,28 +1392,28 @@ impl<'a> State<'a> {
|
||||
self.word_space(":");
|
||||
|
||||
let mut in_idx = 0;
|
||||
self.commasep(Inconsistent, &a.inputs, |s, co| {
|
||||
self.commasep(Inconsistent, &i.inputs, |s, co| {
|
||||
s.print_string(&co.as_str(), ast::StrStyle::Cooked);
|
||||
s.popen();
|
||||
s.print_expr(&inputs[in_idx]);
|
||||
s.print_expr(&a.inputs_exprs[in_idx]);
|
||||
s.pclose();
|
||||
in_idx += 1;
|
||||
});
|
||||
self.s.space();
|
||||
self.word_space(":");
|
||||
|
||||
self.commasep(Inconsistent, &a.clobbers, |s, co| {
|
||||
self.commasep(Inconsistent, &i.clobbers, |s, co| {
|
||||
s.print_string(&co.as_str(), ast::StrStyle::Cooked);
|
||||
});
|
||||
|
||||
let mut options = vec![];
|
||||
if a.volatile {
|
||||
if i.volatile {
|
||||
options.push("volatile");
|
||||
}
|
||||
if a.alignstack {
|
||||
if i.alignstack {
|
||||
options.push("alignstack");
|
||||
}
|
||||
if a.dialect == ast::AsmDialect::Intel {
|
||||
if i.dialect == ast::AsmDialect::Intel {
|
||||
options.push("intel");
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
///
|
||||
/// It will later be extended to trait objects.
|
||||
pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorReported> {
|
||||
let (span, sub, sup) = self.get_regions();
|
||||
let (span, sub, sup) = self.regions();
|
||||
|
||||
// Determine whether the sub and sup consist of both anonymous (elided) regions.
|
||||
let anon_reg_sup = self.tcx().is_suitable_region(sup)?;
|
||||
|
@ -77,7 +77,7 @@ impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> {
|
||||
.or_else(|| self.try_report_impl_not_conforming_to_trait())
|
||||
}
|
||||
|
||||
pub fn get_regions(&self) -> (Span, ty::Region<'tcx>, ty::Region<'tcx>) {
|
||||
pub fn regions(&self) -> (Span, ty::Region<'tcx>, ty::Region<'tcx>) {
|
||||
match (&self.error, self.regions) {
|
||||
(Some(ConcreteFailure(origin, sub, sup)), None) => (origin.span(), sub, sup),
|
||||
(Some(SubSupConflict(_, _, origin, sub, _, sup)), None) => (origin.span(), sub, sup),
|
||||
|
@ -11,7 +11,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// When given a `ConcreteFailure` for a function with parameters containing a named region and
|
||||
/// an anonymous region, emit an descriptive diagnostic error.
|
||||
pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<'a>> {
|
||||
let (span, sub, sup) = self.get_regions();
|
||||
let (span, sub, sup) = self.regions();
|
||||
|
||||
debug!(
|
||||
"try_report_named_anon_conflict(sub={:?}, sup={:?}, error={:?})",
|
||||
|
@ -20,8 +20,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
) = error.clone()
|
||||
{
|
||||
let anon_reg_sup = self.tcx().is_suitable_region(sup_r)?;
|
||||
let return_ty = self.tcx().return_type_impl_trait(anon_reg_sup.def_id);
|
||||
if sub_r == &RegionKind::ReStatic &&
|
||||
self.tcx().return_type_impl_trait(anon_reg_sup.def_id).is_some()
|
||||
return_ty.is_some()
|
||||
{
|
||||
let sp = var_origin.span();
|
||||
let return_sp = sub_origin.span();
|
||||
@ -52,9 +53,14 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
}) => name.to_string(),
|
||||
_ => "'_".to_owned(),
|
||||
};
|
||||
if let Ok(snippet) = self.tcx().sess.source_map().span_to_snippet(return_sp) {
|
||||
let fn_return_span = return_ty.unwrap().1;
|
||||
if let Ok(snippet) =
|
||||
self.tcx().sess.source_map().span_to_snippet(fn_return_span) {
|
||||
// only apply this suggestion onto functions with
|
||||
// explicit non-desugar'able return.
|
||||
if fn_return_span.desugaring_kind().is_none() {
|
||||
err.span_suggestion(
|
||||
return_sp,
|
||||
fn_return_span,
|
||||
&format!(
|
||||
"you can add a constraint to the return type to make it last \
|
||||
less than `'static` and match {}",
|
||||
@ -64,6 +70,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
}
|
||||
}
|
||||
err.emit();
|
||||
return Some(ErrorReported);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(drain_filter)]
|
||||
#![cfg_attr(windows, feature(libc))]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(bootstrap, feature(never_type))]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(overlapping_marker_traits)]
|
||||
#![feature(extern_types)]
|
||||
|
@ -283,15 +283,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||
self.borrow_expr(&base, bk);
|
||||
}
|
||||
|
||||
hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => {
|
||||
for (o, output) in ia.outputs.iter().zip(outputs) {
|
||||
hir::ExprKind::InlineAsm(ref ia) => {
|
||||
for (o, output) in ia.inner.outputs.iter().zip(&ia.outputs_exprs) {
|
||||
if o.is_indirect {
|
||||
self.consume_expr(output);
|
||||
} else {
|
||||
self.mutate_expr(output);
|
||||
}
|
||||
}
|
||||
self.consume_exprs(inputs);
|
||||
self.consume_exprs(&ia.inputs_exprs);
|
||||
}
|
||||
|
||||
hir::ExprKind::Continue(..) |
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
use crate::hir::def::{CtorKind, Namespace};
|
||||
use crate::hir::def_id::DefId;
|
||||
use crate::hir::{self, InlineAsm as HirInlineAsm};
|
||||
use crate::hir;
|
||||
use crate::mir::interpret::{PanicInfo, Scalar};
|
||||
use crate::mir::visit::MirVisitable;
|
||||
use crate::ty::adjustment::PointerCast;
|
||||
@ -1638,7 +1638,7 @@ pub enum FakeReadCause {
|
||||
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
|
||||
pub struct InlineAsm<'tcx> {
|
||||
pub asm: HirInlineAsm,
|
||||
pub asm: hir::InlineAsmInner,
|
||||
pub outputs: Box<[Place<'tcx>]>,
|
||||
pub inputs: Box<[(Span, Operand<'tcx>)]>,
|
||||
}
|
||||
|
@ -1529,14 +1529,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
return Some(FreeRegionInfo {
|
||||
def_id: suitable_region_binding_scope,
|
||||
boundregion: bound_region,
|
||||
is_impl_item: is_impl_item,
|
||||
is_impl_item,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn return_type_impl_trait(
|
||||
&self,
|
||||
scope_def_id: DefId,
|
||||
) -> Option<Ty<'tcx>> {
|
||||
) -> Option<(Ty<'tcx>, Span)> {
|
||||
// HACK: `type_of_def_id()` will fail on these (#55796), so return `None`.
|
||||
let hir_id = self.hir().as_local_hir_id(scope_def_id).unwrap();
|
||||
match self.hir().get(hir_id) {
|
||||
@ -1557,7 +1557,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let sig = ret_ty.fn_sig(*self);
|
||||
let output = self.erase_late_bound_regions(&sig.output());
|
||||
if output.is_impl_trait() {
|
||||
Some(output)
|
||||
let fn_decl = self.hir().fn_decl_by_hir_id(hir_id).unwrap();
|
||||
Some((output, fn_decl.output.span()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -2440,10 +2441,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
|
||||
#[inline]
|
||||
pub fn mk_diverging_default(self) -> Ty<'tcx> {
|
||||
if self.features().never_type {
|
||||
if self.features().never_type_fallback {
|
||||
self.types.never
|
||||
} else {
|
||||
self.intern_tup(&[])
|
||||
self.types.unit
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -697,7 +697,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
// SIMD vector types.
|
||||
ty::Adt(def, ..) if def.repr.simd() => {
|
||||
let element = self.layout_of(ty.simd_type(tcx))?;
|
||||
let count = ty.simd_size(tcx) as u64;
|
||||
let count = ty.simd_size(tcx);
|
||||
assert!(count > 0);
|
||||
let scalar = match element.abi {
|
||||
Abi::Scalar(ref scalar) => scalar.clone(),
|
||||
|
@ -301,7 +301,7 @@ CloneTypeFoldableAndLiftImpls! {
|
||||
::syntax_pos::symbol::Symbol,
|
||||
crate::hir::def::Res,
|
||||
crate::hir::def_id::DefId,
|
||||
crate::hir::InlineAsm,
|
||||
crate::hir::InlineAsmInner,
|
||||
crate::hir::MatchSource,
|
||||
crate::hir::Mutability,
|
||||
crate::hir::Unsafety,
|
||||
|
@ -1813,20 +1813,30 @@ impl<'tcx> TyS<'tcx> {
|
||||
|
||||
pub fn simd_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.kind {
|
||||
Adt(def, substs) => {
|
||||
def.non_enum_variant().fields[0].ty(tcx, substs)
|
||||
}
|
||||
Adt(def, substs) => def.non_enum_variant().fields[0].ty(tcx, substs),
|
||||
_ => bug!("simd_type called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simd_size(&self, _cx: TyCtxt<'_>) -> usize {
|
||||
pub fn simd_size(&self, _tcx: TyCtxt<'tcx>) -> u64 {
|
||||
// Parameter currently unused, but probably needed in the future to
|
||||
// allow `#[repr(simd)] struct Simd<T, const N: usize>([T; N]);`.
|
||||
match self.kind {
|
||||
Adt(def, _) => def.non_enum_variant().fields.len(),
|
||||
Adt(def, _) => def.non_enum_variant().fields.len() as u64,
|
||||
_ => bug!("simd_size called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>) {
|
||||
match self.kind {
|
||||
Adt(def, substs) => {
|
||||
let variant = def.non_enum_variant();
|
||||
(variant.fields.len() as u64, variant.fields[0].ty(tcx, substs))
|
||||
}
|
||||
_ => bug!("simd_size_and_type called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_region_ptr(&self) -> bool {
|
||||
match self.kind {
|
||||
|
@ -17,7 +17,7 @@ use libc::{c_uint, c_char};
|
||||
impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
fn codegen_inline_asm(
|
||||
&mut self,
|
||||
ia: &hir::InlineAsm,
|
||||
ia: &hir::InlineAsmInner,
|
||||
outputs: Vec<PlaceRef<'tcx, &'ll Value>>,
|
||||
mut inputs: Vec<&'ll Value>,
|
||||
span: Span,
|
||||
|
@ -1105,8 +1105,8 @@ fn generic_simd_intrinsic(
|
||||
let m_len = match in_ty.kind {
|
||||
// Note that this `.unwrap()` crashes for isize/usize, that's sort
|
||||
// of intentional as there's not currently a use case for that.
|
||||
ty::Int(i) => i.bit_width().unwrap(),
|
||||
ty::Uint(i) => i.bit_width().unwrap(),
|
||||
ty::Int(i) => i.bit_width().unwrap() as u64,
|
||||
ty::Uint(i) => i.bit_width().unwrap() as u64,
|
||||
_ => return_error!("`{}` is not an integral type", in_ty),
|
||||
};
|
||||
require_simd!(arg_tys[1], "argument");
|
||||
@ -1116,7 +1116,7 @@ fn generic_simd_intrinsic(
|
||||
m_len, v_len
|
||||
);
|
||||
let i1 = bx.type_i1();
|
||||
let i1xn = bx.type_vector(i1, m_len as u64);
|
||||
let i1xn = bx.type_vector(i1, m_len);
|
||||
let m_i1s = bx.bitcast(args[0].immediate(), i1xn);
|
||||
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
|
||||
}
|
||||
@ -1160,7 +1160,7 @@ fn generic_simd_intrinsic(
|
||||
}
|
||||
|
||||
if name.starts_with("simd_shuffle") {
|
||||
let n: usize = name["simd_shuffle".len()..].parse().unwrap_or_else(|_|
|
||||
let n: u64 = name["simd_shuffle".len()..].parse().unwrap_or_else(|_|
|
||||
span_bug!(span, "bad `simd_shuffle` instruction only caught in codegen?"));
|
||||
|
||||
require_simd!(ret_ty, "return");
|
||||
@ -1175,7 +1175,7 @@ fn generic_simd_intrinsic(
|
||||
in_elem, in_ty,
|
||||
ret_ty, ret_ty.simd_type(tcx));
|
||||
|
||||
let total_len = in_len as u128 * 2;
|
||||
let total_len = u128::from(in_len) * 2;
|
||||
|
||||
let vector = args[2].immediate();
|
||||
|
||||
@ -1251,7 +1251,7 @@ fn generic_simd_intrinsic(
|
||||
// trailing bits.
|
||||
let expected_int_bits = in_len.max(8);
|
||||
match ret_ty.kind {
|
||||
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => (),
|
||||
ty::Uint(i) if i.bit_width() == Some(expected_int_bits as usize) => (),
|
||||
_ => return_error!(
|
||||
"bitmask `{}`, expected `u{}`",
|
||||
ret_ty, expected_int_bits
|
||||
@ -1276,7 +1276,8 @@ fn generic_simd_intrinsic(
|
||||
|
||||
// Shift the MSB to the right by "in_elem_bitwidth - 1" into the first bit position.
|
||||
let shift_indices = vec![
|
||||
bx.cx.const_int(bx.type_ix(in_elem_bitwidth as _), (in_elem_bitwidth - 1) as _); in_len
|
||||
bx.cx.const_int(bx.type_ix(in_elem_bitwidth as _), (in_elem_bitwidth - 1) as _);
|
||||
in_len as _
|
||||
];
|
||||
let i_xn_msb = bx.lshr(i_xn, bx.const_vector(shift_indices.as_slice()));
|
||||
// Truncate vector to an <i1 x N>
|
||||
@ -1291,7 +1292,7 @@ fn generic_simd_intrinsic(
|
||||
name: &str,
|
||||
in_elem: &::rustc::ty::TyS<'_>,
|
||||
in_ty: &::rustc::ty::TyS<'_>,
|
||||
in_len: usize,
|
||||
in_len: u64,
|
||||
bx: &mut Builder<'a, 'll, 'tcx>,
|
||||
span: Span,
|
||||
args: &[OperandRef<'tcx, &'ll Value>],
|
||||
@ -1400,7 +1401,7 @@ fn generic_simd_intrinsic(
|
||||
// FIXME: use:
|
||||
// https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Function.h#L182
|
||||
// https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Intrinsics.h#L81
|
||||
fn llvm_vector_str(elem_ty: Ty<'_>, vec_len: usize, no_pointers: usize) -> String {
|
||||
fn llvm_vector_str(elem_ty: Ty<'_>, vec_len: u64, no_pointers: usize) -> String {
|
||||
let p0s: String = "p0".repeat(no_pointers);
|
||||
match elem_ty.kind {
|
||||
ty::Int(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()),
|
||||
@ -1410,7 +1411,7 @@ fn generic_simd_intrinsic(
|
||||
}
|
||||
}
|
||||
|
||||
fn llvm_vector_ty(cx: &CodegenCx<'ll, '_>, elem_ty: Ty<'_>, vec_len: usize,
|
||||
fn llvm_vector_ty(cx: &CodegenCx<'ll, '_>, elem_ty: Ty<'_>, vec_len: u64,
|
||||
mut no_pointers: usize) -> &'ll Type {
|
||||
// FIXME: use cx.layout_of(ty).llvm_type() ?
|
||||
let mut elem_ty = match elem_ty.kind {
|
||||
@ -1423,7 +1424,7 @@ fn generic_simd_intrinsic(
|
||||
elem_ty = cx.type_ptr_to(elem_ty);
|
||||
no_pointers -= 1;
|
||||
}
|
||||
cx.type_vector(elem_ty, vec_len as u64)
|
||||
cx.type_vector(elem_ty, vec_len)
|
||||
}
|
||||
|
||||
|
||||
@ -1506,7 +1507,7 @@ fn generic_simd_intrinsic(
|
||||
// Truncate the mask vector to a vector of i1s:
|
||||
let (mask, mask_ty) = {
|
||||
let i1 = bx.type_i1();
|
||||
let i1xn = bx.type_vector(i1, in_len as u64);
|
||||
let i1xn = bx.type_vector(i1, in_len);
|
||||
(bx.trunc(args[2].immediate(), i1xn), i1xn)
|
||||
};
|
||||
|
||||
@ -1606,7 +1607,7 @@ fn generic_simd_intrinsic(
|
||||
// Truncate the mask vector to a vector of i1s:
|
||||
let (mask, mask_ty) = {
|
||||
let i1 = bx.type_i1();
|
||||
let i1xn = bx.type_vector(i1, in_len as u64);
|
||||
let i1xn = bx.type_vector(i1, in_len);
|
||||
(bx.trunc(args[2].immediate(), i1xn), i1xn)
|
||||
};
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
use super::BackendTypes;
|
||||
use crate::mir::place::PlaceRef;
|
||||
use rustc::hir::{GlobalAsm, InlineAsm};
|
||||
use rustc::hir::{GlobalAsm, InlineAsmInner};
|
||||
use syntax_pos::Span;
|
||||
|
||||
pub trait AsmBuilderMethods<'tcx>: BackendTypes {
|
||||
/// Take an inline assembly expression and splat it out via LLVM
|
||||
fn codegen_inline_asm(
|
||||
&mut self,
|
||||
ia: &InlineAsm,
|
||||
ia: &InlineAsmInner,
|
||||
outputs: Vec<PlaceRef<'tcx, Self::Value>>,
|
||||
inputs: Vec<Self::Value>,
|
||||
span: Span,
|
||||
|
@ -8,7 +8,7 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(bootstrap, feature(never_type))]
|
||||
#![feature(nll)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
|
@ -4,7 +4,7 @@ command line flags.
|
||||
Erroneous code example:
|
||||
|
||||
```ignore (can't specify compiler flags from doctests)
|
||||
#![feature(never_type)] // error: the feature `never_type` is not in
|
||||
#![feature(specialization)] // error: the feature `specialization` is not in
|
||||
// the list of allowed features
|
||||
```
|
||||
|
||||
|
@ -715,10 +715,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
if let (Some(f), Some(ty::RegionKind::ReStatic)) =
|
||||
(self.to_error_region(fr), self.to_error_region(outlived_fr))
|
||||
{
|
||||
if let Some(ty::TyS {
|
||||
if let Some((ty::TyS {
|
||||
kind: ty::Opaque(did, substs),
|
||||
..
|
||||
}) = infcx
|
||||
}, _)) = infcx
|
||||
.tcx
|
||||
.is_suitable_region(f)
|
||||
.map(|r| r.def_id)
|
||||
|
@ -533,11 +533,11 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
||||
convert_path_expr(cx, expr, res)
|
||||
}
|
||||
|
||||
hir::ExprKind::InlineAsm(ref asm, ref outputs, ref inputs) => {
|
||||
hir::ExprKind::InlineAsm(ref asm) => {
|
||||
ExprKind::InlineAsm {
|
||||
asm,
|
||||
outputs: outputs.to_ref(),
|
||||
inputs: inputs.to_ref(),
|
||||
asm: &asm.inner,
|
||||
outputs: asm.outputs_exprs.to_ref(),
|
||||
inputs: asm.inputs_exprs.to_ref(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,10 @@ pub enum StmtKind<'tcx> {
|
||||
},
|
||||
}
|
||||
|
||||
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
rustc_data_structures::static_assert_size!(Expr<'_>, 168);
|
||||
|
||||
/// The Hair trait implementor lowers their expressions (`&'tcx H::Expr`)
|
||||
/// into instances of this `Expr` enum. This lowering can be done
|
||||
/// basically as lazily or as eagerly as desired: every recursive
|
||||
@ -264,7 +268,7 @@ pub enum ExprKind<'tcx> {
|
||||
user_ty: Option<Canonical<'tcx, UserType<'tcx>>>,
|
||||
},
|
||||
InlineAsm {
|
||||
asm: &'tcx hir::InlineAsm,
|
||||
asm: &'tcx hir::InlineAsmInner,
|
||||
outputs: Vec<ExprRef<'tcx>>,
|
||||
inputs: Vec<ExprRef<'tcx>>
|
||||
},
|
||||
|
@ -302,10 +302,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
self.copy_op_transmute(args[0], dest)?;
|
||||
}
|
||||
"simd_insert" => {
|
||||
let index = self.read_scalar(args[1])?.to_u32()? as u64;
|
||||
let scalar = args[2];
|
||||
let index = u64::from(self.read_scalar(args[1])?.to_u32()?);
|
||||
let elem = args[2];
|
||||
let input = args[0];
|
||||
let (len, e_ty) = self.read_vector_ty(input);
|
||||
let (len, e_ty) = input.layout.ty.simd_size_and_type(self.tcx.tcx);
|
||||
assert!(
|
||||
index < len,
|
||||
"Index `{}` must be in bounds of vector type `{}`: `[0, {})`",
|
||||
@ -317,15 +317,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
dest.layout.ty, input.layout.ty
|
||||
);
|
||||
assert_eq!(
|
||||
scalar.layout.ty, e_ty,
|
||||
"Scalar type `{}` must match vector element type `{}`",
|
||||
scalar.layout.ty, e_ty
|
||||
elem.layout.ty, e_ty,
|
||||
"Scalar element type `{}` must match vector element type `{}`",
|
||||
elem.layout.ty, e_ty
|
||||
);
|
||||
|
||||
for i in 0..len {
|
||||
let place = self.place_field(dest, i)?;
|
||||
let value = if i == index {
|
||||
scalar
|
||||
elem
|
||||
} else {
|
||||
self.operand_field(input, i)?
|
||||
};
|
||||
@ -333,8 +333,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
}
|
||||
"simd_extract" => {
|
||||
let index = self.read_scalar(args[1])?.to_u32()? as _;
|
||||
let (len, e_ty) = self.read_vector_ty(args[0]);
|
||||
let index = u64::from(self.read_scalar(args[1])?.to_u32()?);
|
||||
let (len, e_ty) = args[0].layout.ty.simd_size_and_type(self.tcx.tcx);
|
||||
assert!(
|
||||
index < len,
|
||||
"index `{}` is out-of-bounds of vector type `{}` with length `{}`",
|
||||
|
@ -316,17 +316,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Read vector length and element type
|
||||
pub fn read_vector_ty(
|
||||
&self, op: OpTy<'tcx, M::PointerTag>
|
||||
) -> (u64, &rustc::ty::TyS<'tcx>) {
|
||||
if let layout::Abi::Vector { .. } = op.layout.abi {
|
||||
(op.layout.ty.simd_size(*self.tcx) as _, op.layout.ty.simd_type(*self.tcx))
|
||||
} else {
|
||||
bug!("Type `{}` is not a SIMD vector type", op.layout.ty)
|
||||
}
|
||||
}
|
||||
|
||||
/// Read a scalar from a place
|
||||
pub fn read_scalar(
|
||||
&self,
|
||||
|
@ -264,6 +264,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
|
||||
match instance.def {
|
||||
ty::InstanceDef::Intrinsic(..) => {
|
||||
assert!(caller_abi == Abi::RustIntrinsic || caller_abi == Abi::PlatformIntrinsic);
|
||||
|
||||
let old_stack = self.cur_frame();
|
||||
let old_bb = self.frame().block;
|
||||
M::call_intrinsic(self, span, instance, args, dest, ret, unwind)?;
|
||||
|
@ -16,7 +16,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
|
||||
#![feature(decl_macro)]
|
||||
#![feature(drain_filter)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(bootstrap, feature(never_type))]
|
||||
#![feature(specialization)]
|
||||
#![feature(try_trait)]
|
||||
#![feature(unicode_internals)]
|
||||
|
@ -1184,7 +1184,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
self.propagate_through_expr(&e, succ)
|
||||
}
|
||||
|
||||
hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => {
|
||||
hir::ExprKind::InlineAsm(ref asm) => {
|
||||
let ia = &asm.inner;
|
||||
let outputs = &asm.outputs_exprs;
|
||||
let inputs = &asm.inputs_exprs;
|
||||
let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| {
|
||||
// see comment on places
|
||||
// in propagate_through_place_components()
|
||||
@ -1194,7 +1197,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
let acc = if o.is_rw { ACC_WRITE|ACC_READ } else { ACC_WRITE };
|
||||
let succ = self.write_place(output, succ, acc);
|
||||
self.propagate_through_place_components(output, succ)
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
// Inputs are executed first. Propagate last because of rev order
|
||||
self.propagate_through_exprs(inputs, succ)
|
||||
@ -1395,13 +1399,13 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) {
|
||||
}
|
||||
}
|
||||
|
||||
hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => {
|
||||
for input in inputs {
|
||||
hir::ExprKind::InlineAsm(ref asm) => {
|
||||
for input in &asm.inputs_exprs {
|
||||
this.visit_expr(input);
|
||||
}
|
||||
|
||||
// Output operands must be places
|
||||
for (o, output) in ia.outputs.iter().zip(outputs) {
|
||||
for (o, output) in asm.inner.outputs.iter().zip(&asm.outputs_exprs) {
|
||||
if !o.is_indirect {
|
||||
this.check_place(output);
|
||||
}
|
||||
|
@ -244,8 +244,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ExprKind::Path(ref qpath) => {
|
||||
self.check_expr_path(qpath, expr)
|
||||
}
|
||||
ExprKind::InlineAsm(_, ref outputs, ref inputs) => {
|
||||
for expr in outputs.iter().chain(inputs.iter()) {
|
||||
ExprKind::InlineAsm(ref asm) => {
|
||||
for expr in asm.outputs_exprs.iter().chain(asm.inputs_exprs.iter()) {
|
||||
self.check_expr(expr);
|
||||
}
|
||||
tcx.mk_unit()
|
||||
|
@ -3129,9 +3129,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
// Tries to apply a fallback to `ty` if it is an unsolved variable.
|
||||
// Non-numerics get replaced with ! or () (depending on whether
|
||||
// feature(never_type) is enabled, unconstrained ints with i32,
|
||||
// unconstrained floats with f64.
|
||||
//
|
||||
// - Unconstrained ints are replaced with `i32`.
|
||||
//
|
||||
// - Unconstrained floats are replaced with with `f64`.
|
||||
//
|
||||
// - Non-numerics get replaced with `!` when `#![feature(never_type_fallback)]`
|
||||
// is enabled. Otherwise, they are replaced with `()`.
|
||||
//
|
||||
// Fallback becomes very dubious if we have encountered type-checking errors.
|
||||
// In that case, fallback to Error.
|
||||
// The return value indicates whether fallback has occurred.
|
||||
|
@ -66,7 +66,7 @@ This API is completely unstable and subject to change.
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(nll)]
|
||||
#![feature(slice_patterns)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(bootstrap, feature(never_type))]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
||||
|
@ -697,12 +697,10 @@ themePicker.onblur = handleThemeButtonsBlur;
|
||||
static_files::source_serif_pro::ITALIC)?;
|
||||
write(cx.dst.join("SourceSerifPro-LICENSE.md"),
|
||||
static_files::source_serif_pro::LICENSE)?;
|
||||
write(cx.dst.join("SourceCodePro-Regular.ttf.woff"),
|
||||
write(cx.dst.join("SourceCodePro-Regular.woff"),
|
||||
static_files::source_code_pro::REGULAR)?;
|
||||
write(cx.dst.join("SourceCodePro-Semibold.ttf.woff"),
|
||||
write(cx.dst.join("SourceCodePro-Semibold.woff"),
|
||||
static_files::source_code_pro::SEMIBOLD)?;
|
||||
write(cx.dst.join("SourceCodePro-It.ttf.woff"),
|
||||
static_files::source_code_pro::ITALIC)?;
|
||||
write(cx.dst.join("SourceCodePro-LICENSE.txt"),
|
||||
static_files::source_code_pro::LICENSE)?;
|
||||
write(cx.dst.join("LICENSE-MIT.txt"),
|
||||
|
@ -23,8 +23,7 @@ included, and carry their own copyright notices and license terms:
|
||||
Copyright (c) Nicolas Gallagher and Jonathan Neal.
|
||||
Licensed under the MIT license (see LICENSE-MIT.txt).
|
||||
|
||||
* Source Code Pro (SourceCodePro-Regular.ttf.woff,
|
||||
SourceCodePro-Semibold.ttf.woff, SourceCodePro-It.ttf.woff):
|
||||
* Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff):
|
||||
|
||||
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
|
||||
with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
src/librustdoc/html/static/SourceCodePro-Regular.woff
Normal file
BIN
src/librustdoc/html/static/SourceCodePro-Regular.woff
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/librustdoc/html/static/SourceCodePro-Semibold.woff
Normal file
BIN
src/librustdoc/html/static/SourceCodePro-Semibold.woff
Normal file
Binary file not shown.
@ -39,19 +39,13 @@
|
||||
font-weight: 400;
|
||||
/* Avoid using locally installed font because bad versions are in circulation:
|
||||
* see https://github.com/rust-lang/rust/issues/24355 */
|
||||
src: url("SourceCodePro-Regular.ttf.woff") format('woff');
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Source Code Pro';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: url("SourceCodePro-It.ttf.woff") format('woff');
|
||||
src: url("SourceCodePro-Regular.woff") format('woff');
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Source Code Pro';
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
src: url("SourceCodePro-Semibold.ttf.woff") format('woff');
|
||||
src: url("SourceCodePro-Semibold.woff") format('woff');
|
||||
}
|
||||
|
||||
* {
|
||||
|
@ -96,15 +96,11 @@ pub mod source_serif_pro {
|
||||
|
||||
/// Files related to the Source Code Pro font.
|
||||
pub mod source_code_pro {
|
||||
/// The file `SourceCodePro-Regular.ttf.woff`, the Regular variant of the Source Code Pro font.
|
||||
pub static REGULAR: &'static [u8] = include_bytes!("static/SourceCodePro-Regular.ttf.woff");
|
||||
/// The file `SourceCodePro-Regular.woff`, the Regular variant of the Source Code Pro font.
|
||||
pub static REGULAR: &'static [u8] = include_bytes!("static/SourceCodePro-Regular.woff");
|
||||
|
||||
/// The file `SourceCodePro-Semibold.ttf.woff`, the Semibold variant of the Source Code Pro
|
||||
/// font.
|
||||
pub static SEMIBOLD: &'static [u8] = include_bytes!("static/SourceCodePro-Semibold.ttf.woff");
|
||||
|
||||
/// The file `SourceCodePro-It.ttf.woff`, the Italic variant of the Source Code Pro font.
|
||||
pub static ITALIC: &'static [u8] = include_bytes!("static/SourceCodePro-It.ttf.woff");
|
||||
/// The file `SourceCodePro-Semibold.woff`, the Semibold variant of the Source Code Pro font.
|
||||
pub static SEMIBOLD: &'static [u8] = include_bytes!("static/SourceCodePro-Semibold.woff");
|
||||
|
||||
/// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
|
||||
pub static LICENSE: &'static [u8] = include_bytes!("static/SourceCodePro-LICENSE.txt");
|
||||
|
@ -14,7 +14,7 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(drain_filter)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(bootstrap, feature(never_type))]
|
||||
#![feature(unicode_internals)]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
@ -11,7 +11,7 @@ Core encoding and decoding interfaces.
|
||||
#![feature(box_syntax)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(specialization)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(bootstrap, feature(never_type))]
|
||||
#![feature(nll)]
|
||||
#![feature(associated_type_bounds)]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
|
@ -465,7 +465,7 @@ impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
impl Error for ! {
|
||||
fn description(&self) -> &str { *self }
|
||||
}
|
||||
@ -551,13 +551,6 @@ impl Error for string::FromUtf16Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "str_parse_error2", since = "1.8.0")]
|
||||
impl Error for string::ParseError {
|
||||
fn description(&self) -> &str {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "decode_utf16", since = "1.9.0")]
|
||||
impl Error for char::DecodeUtf16Error {
|
||||
fn description(&self) -> &str {
|
||||
|
@ -280,7 +280,7 @@
|
||||
#![feature(maybe_uninit_ref)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(needs_panic_runtime)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(bootstrap, feature(never_type))]
|
||||
#![feature(nll)]
|
||||
#![cfg_attr(bootstrap, feature(on_unimplemented))]
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
@ -71,7 +71,6 @@ mod prim_bool { }
|
||||
/// write:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(never_type)]
|
||||
/// # fn foo() -> u32 {
|
||||
/// let x: ! = {
|
||||
/// return 123
|
||||
@ -201,7 +200,6 @@ mod prim_bool { }
|
||||
/// for example:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(never_type)]
|
||||
/// # use std::fmt;
|
||||
/// # trait Debug {
|
||||
/// # fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result;
|
||||
@ -239,7 +237,7 @@ mod prim_bool { }
|
||||
/// [`Default`]: default/trait.Default.html
|
||||
/// [`default()`]: default/trait.Default.html#tymethod.default
|
||||
///
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
#[stable(feature = "never_type", since = "1.41.0")]
|
||||
mod prim_never { }
|
||||
|
||||
#[doc(primitive = "char")]
|
||||
|
@ -253,6 +253,8 @@ declare_features! (
|
||||
(accepted, const_constructor, "1.40.0", Some(61456), None),
|
||||
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.
|
||||
(accepted, cfg_doctest, "1.40.0", Some(62210), None),
|
||||
/// Allows the `!` type. Does not imply 'exhaustive_patterns' any more.
|
||||
(accepted, never_type, "1.41.0", Some(35121), None),
|
||||
/// Allows relaxing the coherence rules such that
|
||||
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
|
||||
(accepted, re_rebalance_coherence, "1.41.0", Some(55437), None),
|
||||
|
@ -318,9 +318,6 @@ declare_features! (
|
||||
/// Allows `X..Y` patterns.
|
||||
(active, exclusive_range_pattern, "1.11.0", Some(37854), None),
|
||||
|
||||
/// Allows the `!` type. Does not imply 'exhaustive_patterns' (below) any more.
|
||||
(active, never_type, "1.13.0", Some(35121), None),
|
||||
|
||||
/// Allows exhaustive pattern matching on types that contain uninhabited types.
|
||||
(active, exhaustive_patterns, "1.13.0", Some(51085), None),
|
||||
|
||||
@ -523,6 +520,9 @@ declare_features! (
|
||||
/// Allows using the `efiapi` ABI.
|
||||
(active, abi_efiapi, "1.40.0", Some(65815), None),
|
||||
|
||||
/// Allows diverging expressions to fall back to `!` rather than `()`.
|
||||
(active, never_type_fallback, "1.41.0", Some(65992), None),
|
||||
|
||||
/// Allows using the `#[register_attr]` attribute.
|
||||
(active, register_attr, "1.41.0", Some(66080), None),
|
||||
|
||||
|
@ -521,25 +521,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
ast::TyKind::BareFn(ref bare_fn_ty) => {
|
||||
self.check_extern(bare_fn_ty.ext);
|
||||
}
|
||||
ast::TyKind::Never => {
|
||||
gate_feature_post!(&self, never_type, ty.span,
|
||||
"The `!` type is experimental");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_ty(self, ty)
|
||||
}
|
||||
|
||||
fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) {
|
||||
if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty {
|
||||
if let ast::TyKind::Never = output_ty.kind {
|
||||
// Do nothing.
|
||||
} else {
|
||||
self.visit_ty(output_ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &'a ast::Expr) {
|
||||
match e.kind {
|
||||
ast::ExprKind::Box(_) => {
|
||||
@ -567,10 +553,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
visit::walk_expr(self, e)
|
||||
}
|
||||
|
||||
fn visit_arm(&mut self, arm: &'a ast::Arm) {
|
||||
visit::walk_arm(self, arm)
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, pattern: &'a ast::Pat) {
|
||||
match &pattern.kind {
|
||||
PatKind::Slice(pats) => {
|
||||
|
@ -444,6 +444,7 @@ symbols! {
|
||||
negate_unsigned,
|
||||
never,
|
||||
never_type,
|
||||
never_type_fallback,
|
||||
new,
|
||||
next,
|
||||
__next,
|
||||
|
@ -12,8 +12,6 @@
|
||||
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}}
|
||||
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}}
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Entity {
|
||||
private: std::num::NonZeroU32,
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
pub enum Void {}
|
||||
|
||||
#[no_mangle]
|
||||
|
29
src/test/ui/async-await/issues/issue-62097.nll.stderr
Normal file
29
src/test/ui/async-await/issues/issue-62097.nll.stderr
Normal file
@ -0,0 +1,29 @@
|
||||
error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function
|
||||
--> $DIR/issue-62097.rs:13:13
|
||||
|
|
||||
LL | foo(|| self.bar()).await;
|
||||
| ^^ ---- `self` is borrowed here
|
||||
| |
|
||||
| may outlive borrowed value `self`
|
||||
|
|
||||
note: function requires argument type to outlive `'static`
|
||||
--> $DIR/issue-62097.rs:13:9
|
||||
|
|
||||
LL | foo(|| self.bar()).await;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
help: to force the closure to take ownership of `self` (and any other referenced variables), use the `move` keyword
|
||||
|
|
||||
LL | foo(move || self.bar()).await;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0521]: borrowed data escapes outside of function
|
||||
--> $DIR/issue-62097.rs:13:9
|
||||
|
|
||||
LL | pub async fn run_dummy_fn(&self) {
|
||||
| ----- `self` is a reference that is only valid in the function body
|
||||
LL | foo(|| self.bar()).await;
|
||||
| ^^^^^^^^^^^^^^^^^^ `self` escapes the function body here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0373`.
|
19
src/test/ui/async-await/issues/issue-62097.rs
Normal file
19
src/test/ui/async-await/issues/issue-62097.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// edition:2018
|
||||
async fn foo<F>(fun: F)
|
||||
where
|
||||
F: FnOnce() + 'static
|
||||
{
|
||||
fun()
|
||||
}
|
||||
|
||||
struct Struct;
|
||||
|
||||
impl Struct {
|
||||
pub async fn run_dummy_fn(&self) { //~ ERROR cannot infer
|
||||
foo(|| self.bar()).await;
|
||||
}
|
||||
|
||||
pub fn bar(&self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
16
src/test/ui/async-await/issues/issue-62097.stderr
Normal file
16
src/test/ui/async-await/issues/issue-62097.stderr
Normal file
@ -0,0 +1,16 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
--> $DIR/issue-62097.rs:12:31
|
||||
|
|
||||
LL | pub async fn run_dummy_fn(&self) {
|
||||
| ^^^^^ ...but this borrow...
|
||||
LL | foo(|| self.bar()).await;
|
||||
| --- this return type evaluates to the `'static` lifetime...
|
||||
|
|
||||
note: ...can't outlive the lifetime `'_` as defined on the method body at 12:31
|
||||
--> $DIR/issue-62097.rs:12:31
|
||||
|
|
||||
LL | pub async fn run_dummy_fn(&self) {
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -20,10 +20,6 @@ note: ...can't outlive the lifetime `'_` as defined on the method body at 11:14
|
||||
|
|
||||
LL | foo: &dyn Foo, bar: &'a dyn Foo
|
||||
| ^
|
||||
help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime `'_` as defined on the method body at 11:14
|
||||
|
|
||||
LL | foo + '_
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// run-pass
|
||||
#![feature(never_type)]
|
||||
#![feature(never_type_fallback)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(slice_patterns)]
|
||||
#![allow(unreachable_patterns)]
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
pub fn main() {
|
||||
loop {
|
||||
match None {
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
fn main() {
|
||||
// The `if false` expressions are simply to
|
||||
// make sure we don't avoid checking everything
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/break-while-condition.rs:9:20
|
||||
--> $DIR/break-while-condition.rs:7:20
|
||||
|
|
||||
LL | let _: ! = {
|
||||
| ____________________^
|
||||
@ -11,7 +11,7 @@ LL | | };
|
||||
found type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/break-while-condition.rs:16:13
|
||||
--> $DIR/break-while-condition.rs:14:13
|
||||
|
|
||||
LL | / while false {
|
||||
LL | | break
|
||||
@ -22,7 +22,7 @@ LL | | }
|
||||
found type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/break-while-condition.rs:24:13
|
||||
--> $DIR/break-while-condition.rs:22:13
|
||||
|
|
||||
LL | / while false {
|
||||
LL | | return
|
||||
|
@ -1,6 +1,5 @@
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
#![feature(never_type_fallback)]
|
||||
#![allow(unreachable_code)]
|
||||
|
||||
use std::error::Error;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
fn foo(x: usize, y: !, z: usize) { }
|
||||
|
||||
fn cast_a() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0605]: non-primitive cast: `i32` as `!`
|
||||
--> $DIR/coerce-to-bang-cast.rs:6:13
|
||||
--> $DIR/coerce-to-bang-cast.rs:4:13
|
||||
|
|
||||
LL | let y = {return; 22} as !;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
@ -7,7 +7,7 @@ LL | let y = {return; 22} as !;
|
||||
= note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
|
||||
|
||||
error[E0605]: non-primitive cast: `i32` as `!`
|
||||
--> $DIR/coerce-to-bang-cast.rs:11:13
|
||||
--> $DIR/coerce-to-bang-cast.rs:9:13
|
||||
|
|
||||
LL | let y = 22 as !;
|
||||
| ^^^^^^^
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
fn foo(x: usize, y: !, z: usize) { }
|
||||
|
||||
fn call_foo_a() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:6:17
|
||||
--> $DIR/coerce-to-bang.rs:4:17
|
||||
|
|
||||
LL | foo(return, 22, 44);
|
||||
| ^^ expected !, found integer
|
||||
@ -8,7 +8,7 @@ LL | foo(return, 22, 44);
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:18:13
|
||||
--> $DIR/coerce-to-bang.rs:16:13
|
||||
|
|
||||
LL | foo(22, 44, return);
|
||||
| ^^ expected !, found integer
|
||||
@ -17,7 +17,7 @@ LL | foo(22, 44, return);
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:26:12
|
||||
--> $DIR/coerce-to-bang.rs:24:12
|
||||
|
|
||||
LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverge.
|
||||
| ^ expected !, found integer
|
||||
@ -26,7 +26,7 @@ LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverg
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:36:12
|
||||
--> $DIR/coerce-to-bang.rs:34:12
|
||||
|
|
||||
LL | foo(a, b, c);
|
||||
| ^ expected !, found integer
|
||||
@ -35,7 +35,7 @@ LL | foo(a, b, c);
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:45:12
|
||||
--> $DIR/coerce-to-bang.rs:43:12
|
||||
|
|
||||
LL | foo(a, b, c);
|
||||
| ^ expected !, found integer
|
||||
@ -44,7 +44,7 @@ LL | foo(a, b, c);
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:50:21
|
||||
--> $DIR/coerce-to-bang.rs:48:21
|
||||
|
|
||||
LL | let x: [!; 2] = [return, 22];
|
||||
| ^^^^^^^^^^^^ expected !, found integer
|
||||
@ -53,7 +53,7 @@ LL | let x: [!; 2] = [return, 22];
|
||||
found type `[{integer}; 2]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:55:22
|
||||
--> $DIR/coerce-to-bang.rs:53:22
|
||||
|
|
||||
LL | let x: [!; 2] = [22, return];
|
||||
| ^^ expected !, found integer
|
||||
@ -62,7 +62,7 @@ LL | let x: [!; 2] = [22, return];
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:60:37
|
||||
--> $DIR/coerce-to-bang.rs:58:37
|
||||
|
|
||||
LL | let x: (usize, !, usize) = (22, 44, 66);
|
||||
| ^^ expected !, found integer
|
||||
@ -71,7 +71,7 @@ LL | let x: (usize, !, usize) = (22, 44, 66);
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:65:41
|
||||
--> $DIR/coerce-to-bang.rs:63:41
|
||||
|
|
||||
LL | let x: (usize, !, usize) = (return, 44, 66);
|
||||
| ^^ expected !, found integer
|
||||
@ -80,7 +80,7 @@ LL | let x: (usize, !, usize) = (return, 44, 66);
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:76:37
|
||||
--> $DIR/coerce-to-bang.rs:74:37
|
||||
|
|
||||
LL | let x: (usize, !, usize) = (22, 44, return);
|
||||
| ^^ expected !, found integer
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(const_raw_ptr_deref, never_type)]
|
||||
#![feature(const_raw_ptr_deref)]
|
||||
|
||||
const FOO: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
enum Helper<T, U> {
|
||||
T(T, [!; 0]),
|
||||
#[allow(dead_code)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0005]: refutable pattern in local binding: `T(_, _)` not covered
|
||||
--> $DIR/empty-never-array.rs:10:9
|
||||
--> $DIR/empty-never-array.rs:8:9
|
||||
|
|
||||
LL | / enum Helper<T, U> {
|
||||
LL | | T(T, [!; 0]),
|
||||
@ -20,7 +20,7 @@ LL | if let Helper::U(u) = Helper::T(t, []) { /* */ }
|
||||
|
|
||||
|
||||
error[E0381]: use of possibly-uninitialized variable: `u`
|
||||
--> $DIR/empty-never-array.rs:12:5
|
||||
--> $DIR/empty-never-array.rs:10:5
|
||||
|
|
||||
LL | u
|
||||
| ^ use of possibly-uninitialized `u`
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
fn foo() -> Result<u32, !> {
|
||||
Ok(123)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0005]: refutable pattern in local binding: `Err(_)` not covered
|
||||
--> $DIR/feature-gate-exhaustive-patterns.rs:8:9
|
||||
--> $DIR/feature-gate-exhaustive-patterns.rs:6:9
|
||||
|
|
||||
LL | let Ok(_x) = foo();
|
||||
| ^^^^^^ pattern `Err(_)` not covered
|
||||
|
@ -1,17 +0,0 @@
|
||||
// Test that ! errors when used in illegal positions with feature(never_type) disabled
|
||||
|
||||
trait Foo {
|
||||
type Wub;
|
||||
}
|
||||
|
||||
type Ma = (u32, !, i32); //~ ERROR type is experimental
|
||||
type Meeshka = Vec<!>; //~ ERROR type is experimental
|
||||
type Mow = &'static fn(!) -> !; //~ ERROR type is experimental
|
||||
type Skwoz = &'static mut !; //~ ERROR type is experimental
|
||||
|
||||
impl Foo for Meeshka {
|
||||
type Wub = !; //~ ERROR type is experimental
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
error[E0658]: The `!` type is experimental
|
||||
--> $DIR/feature-gate-never_type.rs:7:17
|
||||
|
|
||||
LL | type Ma = (u32, !, i32);
|
||||
| ^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/35121
|
||||
= help: add `#![feature(never_type)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: The `!` type is experimental
|
||||
--> $DIR/feature-gate-never_type.rs:8:20
|
||||
|
|
||||
LL | type Meeshka = Vec<!>;
|
||||
| ^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/35121
|
||||
= help: add `#![feature(never_type)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: The `!` type is experimental
|
||||
--> $DIR/feature-gate-never_type.rs:9:24
|
||||
|
|
||||
LL | type Mow = &'static fn(!) -> !;
|
||||
| ^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/35121
|
||||
= help: add `#![feature(never_type)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: The `!` type is experimental
|
||||
--> $DIR/feature-gate-never_type.rs:10:27
|
||||
|
|
||||
LL | type Skwoz = &'static mut !;
|
||||
| ^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/35121
|
||||
= help: add `#![feature(never_type)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: The `!` type is experimental
|
||||
--> $DIR/feature-gate-never_type.rs:13:16
|
||||
|
|
||||
LL | type Wub = !;
|
||||
| ^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/35121
|
||||
= help: add `#![feature(never_type)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -1,7 +1,6 @@
|
||||
// run-pass
|
||||
|
||||
#![allow(unreachable_code)]
|
||||
#![feature(never_type)]
|
||||
|
||||
#[allow(unused)]
|
||||
fn never_returns() {
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(never_type)]
|
||||
#![deny(unused_must_use)]
|
||||
|
||||
#[must_use]
|
||||
|
@ -1,17 +1,17 @@
|
||||
error: unused return value of `foo` that must be used
|
||||
--> $DIR/must_use-unit.rs:13:5
|
||||
--> $DIR/must_use-unit.rs:12:5
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/must_use-unit.rs:2:9
|
||||
--> $DIR/must_use-unit.rs:1:9
|
||||
|
|
||||
LL | #![deny(unused_must_use)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: unused return value of `bar` that must be used
|
||||
--> $DIR/must_use-unit.rs:15:5
|
||||
--> $DIR/must_use-unit.rs:14:5
|
||||
|
|
||||
LL | bar();
|
||||
| ^^^^^^
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This test checks that calling `mem::{uninitialized,zeroed}` with certain types results
|
||||
// in a lint.
|
||||
|
||||
#![feature(never_type, rustc_attrs)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(deprecated)]
|
||||
#![deny(invalid_value)]
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
fn main() {
|
||||
let val: ! = loop { break break; };
|
||||
//~^ ERROR mismatched types
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: denote infinite loops with `loop { ... }`
|
||||
--> $DIR/loop-break-value.rs:26:5
|
||||
--> $DIR/loop-break-value.rs:24:5
|
||||
|
|
||||
LL | 'while_loop: while true {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use `loop`
|
||||
@ -7,7 +7,7 @@ LL | 'while_loop: while true {
|
||||
= note: `#[warn(while_true)]` on by default
|
||||
|
||||
error[E0571]: `break` with value from a `while` loop
|
||||
--> $DIR/loop-break-value.rs:28:9
|
||||
--> $DIR/loop-break-value.rs:26:9
|
||||
|
|
||||
LL | break ();
|
||||
| ^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
@ -18,7 +18,7 @@ LL | break;
|
||||
| ^^^^^
|
||||
|
||||
error[E0571]: `break` with value from a `while` loop
|
||||
--> $DIR/loop-break-value.rs:30:13
|
||||
--> $DIR/loop-break-value.rs:28:13
|
||||
|
|
||||
LL | break 'while_loop 123;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
@ -29,7 +29,7 @@ LL | break;
|
||||
| ^^^^^
|
||||
|
||||
error[E0571]: `break` with value from a `while let` loop
|
||||
--> $DIR/loop-break-value.rs:38:12
|
||||
--> $DIR/loop-break-value.rs:36:12
|
||||
|
|
||||
LL | if break () {
|
||||
| ^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
@ -40,7 +40,7 @@ LL | if break {
|
||||
| ^^^^^
|
||||
|
||||
error[E0571]: `break` with value from a `while let` loop
|
||||
--> $DIR/loop-break-value.rs:43:9
|
||||
--> $DIR/loop-break-value.rs:41:9
|
||||
|
|
||||
LL | break None;
|
||||
| ^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
@ -51,7 +51,7 @@ LL | break;
|
||||
| ^^^^^
|
||||
|
||||
error[E0571]: `break` with value from a `while let` loop
|
||||
--> $DIR/loop-break-value.rs:49:13
|
||||
--> $DIR/loop-break-value.rs:47:13
|
||||
|
|
||||
LL | break 'while_let_loop "nope";
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
@ -62,7 +62,7 @@ LL | break;
|
||||
| ^^^^^
|
||||
|
||||
error[E0571]: `break` with value from a `for` loop
|
||||
--> $DIR/loop-break-value.rs:56:9
|
||||
--> $DIR/loop-break-value.rs:54:9
|
||||
|
|
||||
LL | break ();
|
||||
| ^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
@ -73,7 +73,7 @@ LL | break;
|
||||
| ^^^^^
|
||||
|
||||
error[E0571]: `break` with value from a `for` loop
|
||||
--> $DIR/loop-break-value.rs:57:9
|
||||
--> $DIR/loop-break-value.rs:55:9
|
||||
|
|
||||
LL | break [()];
|
||||
| ^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
@ -84,7 +84,7 @@ LL | break;
|
||||
| ^^^^^
|
||||
|
||||
error[E0571]: `break` with value from a `for` loop
|
||||
--> $DIR/loop-break-value.rs:64:13
|
||||
--> $DIR/loop-break-value.rs:62:13
|
||||
|
|
||||
LL | break 'for_loop Some(17);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
@ -95,7 +95,7 @@ LL | break;
|
||||
| ^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/loop-break-value.rs:4:31
|
||||
--> $DIR/loop-break-value.rs:2:31
|
||||
|
|
||||
LL | let val: ! = loop { break break; };
|
||||
| ^^^^^ expected !, found ()
|
||||
@ -104,7 +104,7 @@ LL | let val: ! = loop { break break; };
|
||||
found type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/loop-break-value.rs:11:19
|
||||
--> $DIR/loop-break-value.rs:9:19
|
||||
|
|
||||
LL | break 123;
|
||||
| ^^^ expected &str, found integer
|
||||
@ -113,7 +113,7 @@ LL | break 123;
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/loop-break-value.rs:16:15
|
||||
--> $DIR/loop-break-value.rs:14:15
|
||||
|
|
||||
LL | break "asdf";
|
||||
| ^^^^^^ expected i32, found reference
|
||||
@ -122,7 +122,7 @@ LL | break "asdf";
|
||||
found type `&'static str`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/loop-break-value.rs:21:31
|
||||
--> $DIR/loop-break-value.rs:19:31
|
||||
|
|
||||
LL | break 'outer_loop "nope";
|
||||
| ^^^^^^ expected i32, found reference
|
||||
@ -131,7 +131,7 @@ LL | break 'outer_loop "nope";
|
||||
found type `&'static str`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/loop-break-value.rs:73:26
|
||||
--> $DIR/loop-break-value.rs:71:26
|
||||
|
|
||||
LL | break 'c 123;
|
||||
| ^^^ expected (), found integer
|
||||
@ -140,7 +140,7 @@ LL | break 'c 123;
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/loop-break-value.rs:80:15
|
||||
--> $DIR/loop-break-value.rs:78:15
|
||||
|
|
||||
LL | break (break, break);
|
||||
| ^^^^^^^^^^^^^^ expected (), found tuple
|
||||
@ -149,7 +149,7 @@ LL | break (break, break);
|
||||
found type `(!, !)`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/loop-break-value.rs:85:15
|
||||
--> $DIR/loop-break-value.rs:83:15
|
||||
|
|
||||
LL | break 2;
|
||||
| ^ expected (), found integer
|
||||
@ -158,7 +158,7 @@ LL | break 2;
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/loop-break-value.rs:90:9
|
||||
--> $DIR/loop-break-value.rs:88:9
|
||||
|
|
||||
LL | break;
|
||||
| ^^^^^
|
||||
|
@ -2,7 +2,6 @@
|
||||
// ignore-wasm32-bare compiled with panic=abort by default
|
||||
|
||||
#![feature(fn_traits)]
|
||||
#![feature(never_type)]
|
||||
|
||||
use std::panic;
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
fn main() {
|
||||
let x: ! = panic!();
|
||||
let y: u32 = x;
|
||||
|
16
src/test/ui/never_type/auto-traits.rs
Normal file
16
src/test/ui/never_type/auto-traits.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// check-pass
|
||||
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
fn main() {
|
||||
enum Void {}
|
||||
|
||||
auto trait Auto {}
|
||||
fn assert_auto<T: Auto>() {}
|
||||
assert_auto::<Void>();
|
||||
assert_auto::<!>();
|
||||
|
||||
fn assert_send<T: Send>() {}
|
||||
assert_send::<Void>();
|
||||
assert_send::<!>();
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
// Test that we can't pass other types for !
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
fn foo(x: !) -> ! {
|
||||
x
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/call-fn-never-arg-wrong-type.rs:10:9
|
||||
--> $DIR/call-fn-never-arg-wrong-type.rs:8:9
|
||||
|
|
||||
LL | foo("wow");
|
||||
| ^^^^^ expected !, found reference
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
#![allow(unreachable_code)]
|
||||
|
||||
fn foo(x: !) -> ! {
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
fn main() {
|
||||
let x: ! = panic!();
|
||||
let y: u32 = x as u32;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// We need to opt into the `!` feature in order to trigger the
|
||||
// requirement that this is testing.
|
||||
#![feature(never_type)]
|
||||
// We need to opt into the `never_type_fallback` feature
|
||||
// to trigger the requirement that this is testing.
|
||||
#![feature(never_type_fallback)]
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(unsize, dispatch_from_dyn, never_type)]
|
||||
#![feature(unsize, dispatch_from_dyn)]
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
// These represent current behavior, but are pretty dubious. I would
|
||||
// like to revisit these and potentially change them. --nmatsakis
|
||||
|
||||
#![feature(never_type)]
|
||||
#![feature(never_type_fallback)]
|
||||
|
||||
trait BadDefault {
|
||||
fn default() -> Self;
|
||||
|
12
src/test/ui/never_type/feature-gate-never_type_fallback.rs
Normal file
12
src/test/ui/never_type/feature-gate-never_type_fallback.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// This is a feature gate test for `never_type_fallback`.
|
||||
// It works by using a scenario where the type fall backs to `()` rather than ´!`
|
||||
// in the case where `#![feature(never_type_fallback)]` would change it to `!`.
|
||||
|
||||
fn main() {}
|
||||
|
||||
trait T {}
|
||||
|
||||
fn should_ret_unit() -> impl T {
|
||||
//~^ ERROR the trait bound `(): T` is not satisfied
|
||||
panic!()
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
error[E0277]: the trait bound `(): T` is not satisfied
|
||||
--> $DIR/feature-gate-never_type_fallback.rs:9:25
|
||||
|
|
||||
LL | fn should_ret_unit() -> impl T {
|
||||
| ^^^^^^ the trait `T` is not implemented for `()`
|
||||
|
|
||||
= note: the return type of a function must have a statically known size
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
@ -1,7 +1,5 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
// Test that we can call static methods on ! both directly and when it appears in a generic
|
||||
|
||||
trait StringifyType {
|
||||
|
@ -1,7 +1,6 @@
|
||||
// check-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(never_type)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
|
||||
// Regression test for inhabitedness check. The old
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
#![warn(unused)]
|
||||
|
||||
fn main() {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user