Skip to content

Commit 35ef33a

Browse files
committed
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
2 parents f1b882b + 5ab2bcc commit 35ef33a

File tree

159 files changed

+432
-564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+432
-564
lines changed

src/libcore/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ mod impls {
185185
bool char
186186
}
187187

188-
#[unstable(feature = "never_type", issue = "35121")]
188+
#[stable(feature = "never_type", since = "1.41.0")]
189189
impl Clone for ! {
190190
#[inline]
191191
fn clone(&self) -> Self {

src/libcore/cmp.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1128,24 +1128,24 @@ mod impls {
11281128

11291129
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
11301130

1131-
#[unstable(feature = "never_type", issue = "35121")]
1131+
#[stable(feature = "never_type", since = "1.41.0")]
11321132
impl PartialEq for ! {
11331133
fn eq(&self, _: &!) -> bool {
11341134
*self
11351135
}
11361136
}
11371137

1138-
#[unstable(feature = "never_type", issue = "35121")]
1138+
#[stable(feature = "never_type", since = "1.41.0")]
11391139
impl Eq for ! {}
11401140

1141-
#[unstable(feature = "never_type", issue = "35121")]
1141+
#[stable(feature = "never_type", since = "1.41.0")]
11421142
impl PartialOrd for ! {
11431143
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
11441144
*self
11451145
}
11461146
}
11471147

1148-
#[unstable(feature = "never_type", issue = "35121")]
1148+
#[stable(feature = "never_type", since = "1.41.0")]
11491149
impl Ord for ! {
11501150
fn cmp(&self, _: &!) -> Ordering {
11511151
*self

src/libcore/convert.rs

+7-88
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
4141
#![stable(feature = "rust1", since = "1.0.0")]
4242

43-
use crate::fmt;
44-
4543
/// The identity function.
4644
///
4745
/// Two things are important to note about this function:
@@ -426,9 +424,7 @@ pub trait TryInto<T>: Sized {
426424
/// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T`
427425
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
428426
/// is implemented and cannot fail -- the associated `Error` type for
429-
/// calling `T::try_from()` on a value of type `T` is [`Infallible`].
430-
/// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be
431-
/// equivalent.
427+
/// calling `T::try_from()` on a value of type `T` is [`!`].
432428
///
433429
/// `TryFrom<T>` can be implemented as follows:
434430
///
@@ -477,7 +473,6 @@ pub trait TryInto<T>: Sized {
477473
/// [`TryInto`]: trait.TryInto.html
478474
/// [`i32::MAX`]: ../../std/i32/constant.MAX.html
479475
/// [`!`]: ../../std/primitive.never.html
480-
/// [`Infallible`]: enum.Infallible.html
481476
#[stable(feature = "try_from", since = "1.34.0")]
482477
pub trait TryFrom<T>: Sized {
483478
/// The type returned in the event of a conversion error.
@@ -615,9 +610,9 @@ impl AsRef<str> for str {
615610
// THE NO-ERROR ERROR TYPE
616611
////////////////////////////////////////////////////////////////////////////////
617612

618-
/// The error type for errors that can never happen.
613+
/// A type alias for [the `!` “never” type][never].
619614
///
620-
/// Since this enum has no variant, a value of this type can never actually exist.
615+
/// `Infallible` represents types of errors that can never happen since `!` has no valid values.
621616
/// This can be useful for generic APIs that use [`Result`] and parameterize the error type,
622617
/// to indicate that the result is always [`Ok`].
623618
///
@@ -634,91 +629,15 @@ impl AsRef<str> for str {
634629
/// }
635630
/// ```
636631
///
637-
/// # Future compatibility
638-
///
639-
/// This enum has the same role as [the `!` “never” type][never],
640-
/// which is unstable in this version of Rust.
641-
/// When `!` is stabilized, we plan to make `Infallible` a type alias to it:
642-
///
643-
/// ```ignore (illustrates future std change)
644-
/// pub type Infallible = !;
645-
/// ```
646-
///
647-
/// … and eventually deprecate `Infallible`.
648-
///
649-
///
650-
/// However there is one case where `!` syntax can be used
651-
/// before `!` is stabilized as a full-fleged type: in the position of a function’s return type.
652-
/// Specifically, it is possible implementations for two different function pointer types:
653-
///
654-
/// ```
655-
/// trait MyTrait {}
656-
/// impl MyTrait for fn() -> ! {}
657-
/// impl MyTrait for fn() -> std::convert::Infallible {}
658-
/// ```
632+
/// # Eventual deprecation
659633
///
660-
/// With `Infallible` being an enum, this code is valid.
661-
/// However when `Infallible` becomes an alias for the never type,
662-
/// the two `impl`s will start to overlap
663-
/// and therefore will be disallowed by the language’s trait coherence rules.
634+
/// Previously, `Infallible` was defined as `enum Infallible {}`.
635+
/// Now that it is merely a type alias to `!`, we will eventually deprecate `Infallible`.
664636
///
665637
/// [`Ok`]: ../result/enum.Result.html#variant.Ok
666638
/// [`Result`]: ../result/enum.Result.html
667639
/// [`TryFrom`]: trait.TryFrom.html
668640
/// [`Into`]: trait.Into.html
669641
/// [never]: ../../std/primitive.never.html
670642
#[stable(feature = "convert_infallible", since = "1.34.0")]
671-
#[derive(Copy)]
672-
pub enum Infallible {}
673-
674-
#[stable(feature = "convert_infallible", since = "1.34.0")]
675-
impl Clone for Infallible {
676-
fn clone(&self) -> Infallible {
677-
match *self {}
678-
}
679-
}
680-
681-
#[stable(feature = "convert_infallible", since = "1.34.0")]
682-
impl fmt::Debug for Infallible {
683-
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
684-
match *self {}
685-
}
686-
}
687-
688-
#[stable(feature = "convert_infallible", since = "1.34.0")]
689-
impl fmt::Display for Infallible {
690-
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
691-
match *self {}
692-
}
693-
}
694-
695-
#[stable(feature = "convert_infallible", since = "1.34.0")]
696-
impl PartialEq for Infallible {
697-
fn eq(&self, _: &Infallible) -> bool {
698-
match *self {}
699-
}
700-
}
701-
702-
#[stable(feature = "convert_infallible", since = "1.34.0")]
703-
impl Eq for Infallible {}
704-
705-
#[stable(feature = "convert_infallible", since = "1.34.0")]
706-
impl PartialOrd for Infallible {
707-
fn partial_cmp(&self, _other: &Self) -> Option<crate::cmp::Ordering> {
708-
match *self {}
709-
}
710-
}
711-
712-
#[stable(feature = "convert_infallible", since = "1.34.0")]
713-
impl Ord for Infallible {
714-
fn cmp(&self, _other: &Self) -> crate::cmp::Ordering {
715-
match *self {}
716-
}
717-
}
718-
719-
#[stable(feature = "convert_infallible", since = "1.34.0")]
720-
impl From<!> for Infallible {
721-
fn from(x: !) -> Self {
722-
x
723-
}
724-
}
643+
pub type Infallible = !;

src/libcore/fmt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1935,14 +1935,14 @@ macro_rules! fmt_refs {
19351935

19361936
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
19371937

1938-
#[unstable(feature = "never_type", issue = "35121")]
1938+
#[stable(feature = "never_type", since = "1.41.0")]
19391939
impl Debug for ! {
19401940
fn fmt(&self, _: &mut Formatter<'_>) -> Result {
19411941
*self
19421942
}
19431943
}
19441944

1945-
#[unstable(feature = "never_type", issue = "35121")]
1945+
#[stable(feature = "never_type", since = "1.41.0")]
19461946
impl Display for ! {
19471947
fn fmt(&self, _: &mut Formatter<'_>) -> Result {
19481948
*self

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
#![feature(iter_once_with)]
8686
#![feature(lang_items)]
8787
#![feature(link_llvm_intrinsics)]
88-
#![feature(never_type)]
88+
#![cfg_attr(bootstrap, feature(never_type))]
8989
#![feature(nll)]
9090
#![feature(exhaustive_patterns)]
9191
#![feature(no_core)]

src/libcore/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ mod copy_impls {
774774
bool char
775775
}
776776

777-
#[unstable(feature = "never_type", issue = "35121")]
777+
#[stable(feature = "never_type", since = "1.41.0")]
778778
impl Copy for ! {}
779779

780780
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/num/mod.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
#![stable(feature = "rust1", since = "1.0.0")]
66

7-
use crate::convert::{TryFrom, Infallible};
7+
use crate::convert::TryFrom;
88
use crate::fmt;
99
use crate::intrinsics;
1010
use crate::mem;
@@ -4722,18 +4722,8 @@ impl fmt::Display for TryFromIntError {
47224722
}
47234723

47244724
#[stable(feature = "try_from", since = "1.34.0")]
4725-
impl From<Infallible> for TryFromIntError {
4726-
fn from(x: Infallible) -> TryFromIntError {
4727-
match x {}
4728-
}
4729-
}
4730-
4731-
#[unstable(feature = "never_type", issue = "35121")]
47324725
impl From<!> for TryFromIntError {
47334726
fn from(never: !) -> TryFromIntError {
4734-
// Match rather than coerce to make sure that code like
4735-
// `From<Infallible> for TryFromIntError` above will keep working
4736-
// when `Infallible` becomes an alias to `!`.
47374727
match never {}
47384728
}
47394729
}

src/librustc/hir/intravisit.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,9 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10861086
ExprKind::Ret(ref optional_expression) => {
10871087
walk_list!(visitor, visit_expr, optional_expression);
10881088
}
1089-
ExprKind::InlineAsm(_, ref outputs, ref inputs) => {
1090-
for expr in outputs.iter().chain(inputs.iter()) {
1091-
visitor.visit_expr(expr)
1092-
}
1089+
ExprKind::InlineAsm(ref asm) => {
1090+
walk_list!(visitor, visit_expr, &asm.outputs_exprs);
1091+
walk_list!(visitor, visit_expr, &asm.inputs_exprs);
10931092
}
10941093
ExprKind::Yield(ref subexpression, _) => {
10951094
visitor.visit_expr(subexpression);

src/librustc/hir/lowering.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -2170,6 +2170,16 @@ impl<'a> LoweringContext<'a> {
21702170
impl_trait_return_allow: bool,
21712171
make_ret_async: Option<NodeId>,
21722172
) -> P<hir::FnDecl> {
2173+
debug!("lower_fn_decl(\
2174+
fn_decl: {:?}, \
2175+
in_band_ty_params: {:?}, \
2176+
impl_trait_return_allow: {}, \
2177+
make_ret_async: {:?})",
2178+
decl,
2179+
in_band_ty_params,
2180+
impl_trait_return_allow,
2181+
make_ret_async,
2182+
);
21732183
let lt_mode = if make_ret_async.is_some() {
21742184
// In `async fn`, argument-position elided lifetimes
21752185
// must be transformed into fresh generic parameters so that
@@ -2462,7 +2472,7 @@ impl<'a> LoweringContext<'a> {
24622472

24632473
hir::FunctionRetTy::Return(P(hir::Ty {
24642474
kind: opaque_ty_ref,
2465-
span,
2475+
span: opaque_ty_span,
24662476
hir_id: self.next_id(),
24672477
}))
24682478
}
@@ -2572,7 +2582,7 @@ impl<'a> LoweringContext<'a> {
25722582
hir::Lifetime {
25732583
hir_id: self.lower_node_id(id),
25742584
span,
2575-
name: name,
2585+
name,
25762586
}
25772587
}
25782588

src/librustc/hir/lowering/expr.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ impl LoweringContext<'_> {
966966
}
967967

968968
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind {
969-
let hir_asm = hir::InlineAsm {
969+
let inner = hir::InlineAsmInner {
970970
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
971971
outputs: asm.outputs
972972
.iter()
@@ -984,18 +984,18 @@ impl LoweringContext<'_> {
984984
alignstack: asm.alignstack,
985985
dialect: asm.dialect,
986986
};
987-
988-
let outputs = asm.outputs
989-
.iter()
990-
.map(|out| self.lower_expr(&out.expr))
991-
.collect();
992-
993-
let inputs = asm.inputs
994-
.iter()
995-
.map(|&(_, ref input)| self.lower_expr(input))
996-
.collect();
997-
998-
hir::ExprKind::InlineAsm(P(hir_asm), outputs, inputs)
987+
let hir_asm = hir::InlineAsm {
988+
inner,
989+
inputs_exprs: asm.inputs
990+
.iter()
991+
.map(|&(_, ref input)| self.lower_expr(input))
992+
.collect(),
993+
outputs_exprs: asm.outputs
994+
.iter()
995+
.map(|out| self.lower_expr(&out.expr))
996+
.collect(),
997+
};
998+
hir::ExprKind::InlineAsm(P(hir_asm))
999999
}
10001000

10011001
fn lower_field(&mut self, f: &Field) -> hir::Field {

src/librustc/hir/mod.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ pub struct Expr {
14571457

14581458
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
14591459
#[cfg(target_arch = "x86_64")]
1460-
static_assert_size!(Expr, 72);
1460+
static_assert_size!(Expr, 64);
14611461

14621462
impl Expr {
14631463
pub fn precedence(&self) -> ExprPrecedence {
@@ -1656,7 +1656,7 @@ pub enum ExprKind {
16561656
Ret(Option<P<Expr>>),
16571657

16581658
/// Inline assembly (from `asm!`), with its outputs and inputs.
1659-
InlineAsm(P<InlineAsm>, HirVec<Expr>, HirVec<Expr>),
1659+
InlineAsm(P<InlineAsm>),
16601660

16611661
/// A struct or struct-like variant literal expression.
16621662
///
@@ -2063,7 +2063,7 @@ pub struct InlineAsmOutput {
20632063
// NOTE(eddyb) This is used within MIR as well, so unlike the rest of the HIR,
20642064
// it needs to be `Clone` and use plain `Vec<T>` instead of `HirVec<T>`.
20652065
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
2066-
pub struct InlineAsm {
2066+
pub struct InlineAsmInner {
20672067
pub asm: Symbol,
20682068
pub asm_str_style: StrStyle,
20692069
pub outputs: Vec<InlineAsmOutput>,
@@ -2074,6 +2074,13 @@ pub struct InlineAsm {
20742074
pub dialect: AsmDialect,
20752075
}
20762076

2077+
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
2078+
pub struct InlineAsm {
2079+
pub inner: InlineAsmInner,
2080+
pub outputs_exprs: HirVec<Expr>,
2081+
pub inputs_exprs: HirVec<Expr>,
2082+
}
2083+
20772084
/// Represents a parameter in a function header.
20782085
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
20792086
pub struct Param {

0 commit comments

Comments
 (0)