Skip to content

Commit

Permalink
Auto merge of #66180 - Centril:rollup-c1ji943, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #59789 (Revert two unapproved changes to rustc_typeck.)
 - #65752 (Use structured suggestions for missing associated items)
 - #65884 (syntax: ABI-oblivious grammar)
 - #65974 (A scheme for more macro-matcher friendly pre-expansion gating)
 - #66017 (Add future incompatibility lint for `array.into_iter()`)

Failed merges:

 - #66056 (rustc_metadata: Some reorganization of the module structure)

r? @ghost
  • Loading branch information
bors committed Nov 7, 2019
2 parents 7a76fe7 + c9eae9e commit 50f8aad
Show file tree
Hide file tree
Showing 82 changed files with 1,141 additions and 734 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3762,7 +3762,6 @@ dependencies = [
"rustc",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_target",
"serde_json",
"syntax",
"syntax_pos",
Expand Down Expand Up @@ -4362,7 +4361,6 @@ dependencies = [
"rustc_errors",
"rustc_index",
"rustc_lexer",
"rustc_target",
"scoped-tls",
"serialize",
"smallvec 1.0.0",
Expand All @@ -4380,7 +4378,6 @@ dependencies = [
"rustc_errors",
"rustc_index",
"rustc_lexer",
"rustc_target",
"scoped-tls",
"serialize",
"smallvec 1.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/libcore/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ pub trait FromIterator<A>: Sized {
/// .collect()
/// }
/// ```
#[rustc_diagnostic_item = "IntoIterator"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait IntoIterator {
/// The type of the elements being iterated over.
Expand Down
1 change: 1 addition & 0 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,7 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
E0657, // `impl Trait` can only capture lifetimes bound at the fn level
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
E0703, // invalid ABI
// E0707, // multiple elided lifetimes used in arguments of `async fn`
E0708, // `async` non-`move` closures with parameters are not currently
// supported
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ impl<'a> LoweringContext<'a> {
ImplTraitContext::disallowed(),
),
unsafety: this.lower_unsafety(f.unsafety),
abi: f.abi,
abi: this.lower_abi(f.abi),
decl: this.lower_fn_decl(&f.decl, None, false, None),
param_names: this.lower_fn_params_to_names(&f.decl),
}))
Expand Down
25 changes: 23 additions & 2 deletions src/librustc/hir/lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::hir::def::{Res, DefKind};
use crate::util::nodemap::NodeMap;

use rustc_data_structures::thin_vec::ThinVec;
use rustc_target::spec::abi;

use std::collections::BTreeSet;
use smallvec::SmallVec;
Expand Down Expand Up @@ -735,7 +736,7 @@ impl LoweringContext<'_> {

fn lower_foreign_mod(&mut self, fm: &ForeignMod) -> hir::ForeignMod {
hir::ForeignMod {
abi: fm.abi,
abi: self.lower_abi(fm.abi),
items: fm.items
.iter()
.map(|x| self.lower_foreign_item(x))
Expand Down Expand Up @@ -1291,10 +1292,30 @@ impl LoweringContext<'_> {
unsafety: self.lower_unsafety(h.unsafety),
asyncness: self.lower_asyncness(h.asyncness.node),
constness: self.lower_constness(h.constness),
abi: h.abi,
abi: self.lower_abi(h.abi),
}
}

pub(super) fn lower_abi(&mut self, abi: Abi) -> abi::Abi {
abi::lookup(&abi.symbol.as_str()).unwrap_or_else(|| {
self.error_on_invalid_abi(abi);
abi::Abi::Rust
})
}

fn error_on_invalid_abi(&self, abi: Abi) {
struct_span_err!(
self.sess,
abi.span,
E0703,
"invalid ABI: found `{}`",
abi.symbol
)
.span_label(abi.span, "invalid ABI")
.help(&format!("valid ABIs: {}", abi::all_names().join(", ")))
.emit();
}

pub(super) fn lower_unsafety(&mut self, u: Unsafety) -> hir::Unsafety {
match u {
Unsafety::Unsafe => hir::Unsafety::Unsafe,
Expand Down
16 changes: 16 additions & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,13 @@ impl Mutability {
MutImmutable => MutMutable,
}
}

pub fn prefix_str(&self) -> &'static str {
match self {
MutMutable => "mut ",
MutImmutable => "",
}
}
}

#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
Expand Down Expand Up @@ -2184,6 +2191,15 @@ pub enum Unsafety {
Normal,
}

impl Unsafety {
pub fn prefix_str(&self) -> &'static str {
match self {
Unsafety::Unsafe => "unsafe ",
Unsafety::Normal => "",
}
}
}

#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum Constness {
Const,
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1734,9 +1734,7 @@ impl<'a> State<'a> {
_ => false,
};
self.s.word("&");
if mutbl == hir::MutMutable {
self.s.word("mut ");
}
self.s.word(mutbl.prefix_str());
if is_range_inner {
self.popen();
}
Expand Down
10 changes: 7 additions & 3 deletions src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ for ::syntax::attr::StabilityLevel {

impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion });


impl_stable_hash_for!(enum ::syntax::attr::IntType {
SignedInt(int_ty),
UnsignedInt(uint_ty)
Expand All @@ -136,6 +135,11 @@ impl_stable_hash_for!(enum ::syntax::ast::LitIntType {
Unsuffixed
});

impl_stable_hash_for!(enum ::syntax::ast::LitFloatType {
Suffixed(float_ty),
Unsuffixed
});

impl_stable_hash_for!(struct ::syntax::ast::Lit {
kind,
token,
Expand All @@ -148,8 +152,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind {
Byte(value),
Char(value),
Int(value, lit_int_type),
Float(value, float_ty),
FloatUnsuffixed(value),
Float(value, lit_float_type),
Bool(value),
Err(value)
});
Expand All @@ -159,6 +162,7 @@ impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
impl_stable_hash_for!(enum ::rustc_target::abi::FloatTy { F32, F64 });
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
Expand Down
6 changes: 1 addition & 5 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
} else {
r.push(' ');
}
s.push_highlighted(format!(
"&{}{}",
r,
if mutbl == hir::MutMutable { "mut " } else { "" }
));
s.push_highlighted(format!("&{}{}", r, mutbl.prefix_str()));
s.push_normal(ty.to_string());
}

Expand Down
5 changes: 4 additions & 1 deletion src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
ty::Uint(ity) => {
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
}
ty::Float(fty) => scalar(Float(fty)),
ty::Float(fty) => scalar(Float(match fty {
ast::FloatTy::F32 => FloatTy::F32,
ast::FloatTy::F64 => FloatTy::F64,
})),
ty::FnPtr(_) => {
let mut ptr = scalar_unit(Pointer);
ptr.valid_range = 1..=*ptr.valid_range.end();
Expand Down
26 changes: 5 additions & 21 deletions src/librustc/ty/print/obsolete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use rustc::ty::{self, Const, Instance, Ty, TyCtxt};
use rustc::{bug, hir};
use std::fmt::Write;
use std::iter;
use syntax::ast;

/// Same as `unique_type_name()` but with the result pushed onto the given
/// `output` parameter.
Expand All @@ -39,20 +38,9 @@ impl DefPathBasedNames<'tcx> {
ty::Char => output.push_str("char"),
ty::Str => output.push_str("str"),
ty::Never => output.push_str("!"),
ty::Int(ast::IntTy::Isize) => output.push_str("isize"),
ty::Int(ast::IntTy::I8) => output.push_str("i8"),
ty::Int(ast::IntTy::I16) => output.push_str("i16"),
ty::Int(ast::IntTy::I32) => output.push_str("i32"),
ty::Int(ast::IntTy::I64) => output.push_str("i64"),
ty::Int(ast::IntTy::I128) => output.push_str("i128"),
ty::Uint(ast::UintTy::Usize) => output.push_str("usize"),
ty::Uint(ast::UintTy::U8) => output.push_str("u8"),
ty::Uint(ast::UintTy::U16) => output.push_str("u16"),
ty::Uint(ast::UintTy::U32) => output.push_str("u32"),
ty::Uint(ast::UintTy::U64) => output.push_str("u64"),
ty::Uint(ast::UintTy::U128) => output.push_str("u128"),
ty::Float(ast::FloatTy::F32) => output.push_str("f32"),
ty::Float(ast::FloatTy::F64) => output.push_str("f64"),
ty::Int(ty) => output.push_str(ty.name_str()),
ty::Uint(ty) => output.push_str(ty.name_str()),
ty::Float(ty) => output.push_str(ty.name_str()),
ty::Adt(adt_def, substs) => {
self.push_def_path(adt_def.did, output);
self.push_generic_params(substs, iter::empty(), output, debug);
Expand Down Expand Up @@ -80,9 +68,7 @@ impl DefPathBasedNames<'tcx> {
}
ty::Ref(_, inner_type, mutbl) => {
output.push('&');
if mutbl == hir::MutMutable {
output.push_str("mut ");
}
output.push_str(mutbl.prefix_str());

self.push_type_name(inner_type, output, debug);
}
Expand Down Expand Up @@ -114,9 +100,7 @@ impl DefPathBasedNames<'tcx> {
ty::Foreign(did) => self.push_def_path(did, output),
ty::FnDef(..) | ty::FnPtr(_) => {
let sig = t.fn_sig(self.tcx);
if sig.unsafety() == hir::Unsafety::Unsafe {
output.push_str("unsafe ");
}
output.push_str(sig.unsafety().prefix_str());

let abi = sig.abi();
if abi != ::rustc_target::spec::abi::Abi::Rust {
Expand Down
25 changes: 12 additions & 13 deletions src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,9 @@ pub trait PrettyPrinter<'tcx>:
match ty.kind {
ty::Bool => p!(write("bool")),
ty::Char => p!(write("char")),
ty::Int(t) => p!(write("{}", t.ty_to_string())),
ty::Uint(t) => p!(write("{}", t.ty_to_string())),
ty::Float(t) => p!(write("{}", t.ty_to_string())),
ty::Int(t) => p!(write("{}", t.name_str())),
ty::Uint(t) => p!(write("{}", t.name_str())),
ty::Float(t) => p!(write("{}", t.name_str())),
ty::RawPtr(ref tm) => {
p!(write("*{} ", match tm.mutbl {
hir::MutMutable => "mut",
Expand Down Expand Up @@ -895,10 +895,11 @@ pub trait PrettyPrinter<'tcx>:
let bit_size = Integer::from_attr(&self.tcx(), UnsignedInt(*ui)).size();
let max = truncate(u128::max_value(), bit_size);

let ui_str = ui.name_str();
if data == max {
p!(write("std::{}::MAX", ui))
p!(write("std::{}::MAX", ui_str))
} else {
p!(write("{}{}", data, ui))
p!(write("{}{}", data, ui_str))
};
},
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Int(i)) => {
Expand All @@ -911,10 +912,11 @@ pub trait PrettyPrinter<'tcx>:
let size = self.tcx().layout_of(ty::ParamEnv::empty().and(ty))
.unwrap()
.size;
let i_str = i.name_str();
match data {
d if d == min => p!(write("std::{}::MIN", i)),
d if d == max => p!(write("std::{}::MAX", i)),
_ => p!(write("{}{}", sign_extend(data, size) as i128, i))
d if d == min => p!(write("std::{}::MIN", i_str)),
d if d == max => p!(write("std::{}::MAX", i_str)),
_ => p!(write("{}{}", sign_extend(data, size) as i128, i_str))
}
},
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Char) =>
Expand Down Expand Up @@ -1666,8 +1668,7 @@ define_print_and_forward_display! {
}

ty::TypeAndMut<'tcx> {
p!(write("{}", if self.mutbl == hir::MutMutable { "mut " } else { "" }),
print(self.ty))
p!(write("{}", self.mutbl.prefix_str()), print(self.ty))
}

ty::ExistentialTraitRef<'tcx> {
Expand All @@ -1693,9 +1694,7 @@ define_print_and_forward_display! {
}

ty::FnSig<'tcx> {
if self.unsafety == hir::Unsafety::Unsafe {
p!(write("unsafe "));
}
p!(write("{}", self.unsafety.prefix_str()));

if self.abi != Abi::Rust {
p!(write("extern {} ", self.abi));
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,13 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
ty::Bool => ("bool", DW_ATE_boolean),
ty::Char => ("char", DW_ATE_unsigned_char),
ty::Int(int_ty) => {
(int_ty.ty_to_string(), DW_ATE_signed)
(int_ty.name_str(), DW_ATE_signed)
},
ty::Uint(uint_ty) => {
(uint_ty.ty_to_string(), DW_ATE_unsigned)
(uint_ty.name_str(), DW_ATE_unsigned)
},
ty::Float(float_ty) => {
(float_ty.ty_to_string(), DW_ATE_float)
(float_ty.name_str(), DW_ATE_float)
},
_ => bug!("debuginfo::basic_type_metadata - t is invalid type")
};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive};
use rustc::mir::interpret::GlobalId;
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
use rustc::hir;
use syntax::ast::{self, FloatTy};
use rustc_target::abi::HasDataLayout;
use rustc_target::abi::{FloatTy, HasDataLayout};
use syntax::ast;

use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
use rustc_codegen_ssa::traits::*;
Expand Down Expand Up @@ -1335,7 +1335,7 @@ fn generic_simd_intrinsic(
},
ty::Float(f) => {
return_error!("unsupported element type `{}` of floating-point vector `{}`",
f, in_ty);
f.name_str(), in_ty);
},
_ => {
return_error!("`{}` is not a floating-point type", in_ty);
Expand Down
14 changes: 5 additions & 9 deletions src/librustc_codegen_ssa/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ pub fn push_debuginfo_type_name<'tcx>(
ty::Char => output.push_str("char"),
ty::Str => output.push_str("str"),
ty::Never => output.push_str("!"),
ty::Int(int_ty) => output.push_str(int_ty.ty_to_string()),
ty::Uint(uint_ty) => output.push_str(uint_ty.ty_to_string()),
ty::Float(float_ty) => output.push_str(float_ty.ty_to_string()),
ty::Int(int_ty) => output.push_str(int_ty.name_str()),
ty::Uint(uint_ty) => output.push_str(uint_ty.name_str()),
ty::Float(float_ty) => output.push_str(float_ty.name_str()),
ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output),
ty::Adt(def, substs) => {
push_item_name(tcx, def.did, qualified, output);
Expand Down Expand Up @@ -76,9 +76,7 @@ pub fn push_debuginfo_type_name<'tcx>(
if !cpp_like_names {
output.push('&');
}
if mutbl == hir::MutMutable {
output.push_str("mut ");
}
output.push_str(mutbl.prefix_str());

push_debuginfo_type_name(tcx, inner_type, true, output, visited);

Expand Down Expand Up @@ -140,9 +138,7 @@ pub fn push_debuginfo_type_name<'tcx>(


let sig = t.fn_sig(tcx);
if sig.unsafety() == hir::Unsafety::Unsafe {
output.push_str("unsafe ");
}
output.push_str(sig.unsafety().prefix_str());

let abi = sig.abi();
if abi != rustc_target::spec::abi::Abi::Rust {
Expand Down
Loading

0 comments on commit 50f8aad

Please sign in to comment.