Skip to content

Commit 50f8aad

Browse files
committed
Auto merge of #66180 - Centril:rollup-c1ji943, r=Centril
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
2 parents 7a76fe7 + c9eae9e commit 50f8aad

File tree

82 files changed

+1141
-734
lines changed

Some content is hidden

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

82 files changed

+1141
-734
lines changed

Diff for: Cargo.lock

-3
Original file line numberDiff line numberDiff line change
@@ -3762,7 +3762,6 @@ dependencies = [
37623762
"rustc",
37633763
"rustc_codegen_utils",
37643764
"rustc_data_structures",
3765-
"rustc_target",
37663765
"serde_json",
37673766
"syntax",
37683767
"syntax_pos",
@@ -4362,7 +4361,6 @@ dependencies = [
43624361
"rustc_errors",
43634362
"rustc_index",
43644363
"rustc_lexer",
4365-
"rustc_target",
43664364
"scoped-tls",
43674365
"serialize",
43684366
"smallvec 1.0.0",
@@ -4380,7 +4378,6 @@ dependencies = [
43804378
"rustc_errors",
43814379
"rustc_index",
43824380
"rustc_lexer",
4383-
"rustc_target",
43844381
"scoped-tls",
43854382
"serialize",
43864383
"smallvec 1.0.0",

Diff for: src/libcore/iter/traits/collect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ pub trait FromIterator<A>: Sized {
205205
/// .collect()
206206
/// }
207207
/// ```
208+
#[rustc_diagnostic_item = "IntoIterator"]
208209
#[stable(feature = "rust1", since = "1.0.0")]
209210
pub trait IntoIterator {
210211
/// The type of the elements being iterated over.

Diff for: src/librustc/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,7 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
23362336
E0657, // `impl Trait` can only capture lifetimes bound at the fn level
23372337
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
23382338
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
2339+
E0703, // invalid ABI
23392340
// E0707, // multiple elided lifetimes used in arguments of `async fn`
23402341
E0708, // `async` non-`move` closures with parameters are not currently
23412342
// supported

Diff for: src/librustc/hir/lowering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ impl<'a> LoweringContext<'a> {
12161216
ImplTraitContext::disallowed(),
12171217
),
12181218
unsafety: this.lower_unsafety(f.unsafety),
1219-
abi: f.abi,
1219+
abi: this.lower_abi(f.abi),
12201220
decl: this.lower_fn_decl(&f.decl, None, false, None),
12211221
param_names: this.lower_fn_params_to_names(&f.decl),
12221222
}))

Diff for: src/librustc/hir/lowering/item.rs

+23-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::hir::def::{Res, DefKind};
1212
use crate::util::nodemap::NodeMap;
1313

1414
use rustc_data_structures::thin_vec::ThinVec;
15+
use rustc_target::spec::abi;
1516

1617
use std::collections::BTreeSet;
1718
use smallvec::SmallVec;
@@ -735,7 +736,7 @@ impl LoweringContext<'_> {
735736

736737
fn lower_foreign_mod(&mut self, fm: &ForeignMod) -> hir::ForeignMod {
737738
hir::ForeignMod {
738-
abi: fm.abi,
739+
abi: self.lower_abi(fm.abi),
739740
items: fm.items
740741
.iter()
741742
.map(|x| self.lower_foreign_item(x))
@@ -1291,10 +1292,30 @@ impl LoweringContext<'_> {
12911292
unsafety: self.lower_unsafety(h.unsafety),
12921293
asyncness: self.lower_asyncness(h.asyncness.node),
12931294
constness: self.lower_constness(h.constness),
1294-
abi: h.abi,
1295+
abi: self.lower_abi(h.abi),
12951296
}
12961297
}
12971298

1299+
pub(super) fn lower_abi(&mut self, abi: Abi) -> abi::Abi {
1300+
abi::lookup(&abi.symbol.as_str()).unwrap_or_else(|| {
1301+
self.error_on_invalid_abi(abi);
1302+
abi::Abi::Rust
1303+
})
1304+
}
1305+
1306+
fn error_on_invalid_abi(&self, abi: Abi) {
1307+
struct_span_err!(
1308+
self.sess,
1309+
abi.span,
1310+
E0703,
1311+
"invalid ABI: found `{}`",
1312+
abi.symbol
1313+
)
1314+
.span_label(abi.span, "invalid ABI")
1315+
.help(&format!("valid ABIs: {}", abi::all_names().join(", ")))
1316+
.emit();
1317+
}
1318+
12981319
pub(super) fn lower_unsafety(&mut self, u: Unsafety) -> hir::Unsafety {
12991320
match u {
13001321
Unsafety::Unsafe => hir::Unsafety::Unsafe,

Diff for: src/librustc/hir/mod.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,13 @@ impl Mutability {
10751075
MutImmutable => MutMutable,
10761076
}
10771077
}
1078+
1079+
pub fn prefix_str(&self) -> &'static str {
1080+
match self {
1081+
MutMutable => "mut ",
1082+
MutImmutable => "",
1083+
}
1084+
}
10781085
}
10791086

10801087
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
@@ -2184,6 +2191,15 @@ pub enum Unsafety {
21842191
Normal,
21852192
}
21862193

2194+
impl Unsafety {
2195+
pub fn prefix_str(&self) -> &'static str {
2196+
match self {
2197+
Unsafety::Unsafe => "unsafe ",
2198+
Unsafety::Normal => "",
2199+
}
2200+
}
2201+
}
2202+
21872203
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
21882204
pub enum Constness {
21892205
Const,

Diff for: src/librustc/hir/print.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1734,9 +1734,7 @@ impl<'a> State<'a> {
17341734
_ => false,
17351735
};
17361736
self.s.word("&");
1737-
if mutbl == hir::MutMutable {
1738-
self.s.word("mut ");
1739-
}
1737+
self.s.word(mutbl.prefix_str());
17401738
if is_range_inner {
17411739
self.popen();
17421740
}

Diff for: src/librustc/ich/impls_syntax.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ for ::syntax::attr::StabilityLevel {
124124

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

127-
128127
impl_stable_hash_for!(enum ::syntax::attr::IntType {
129128
SignedInt(int_ty),
130129
UnsignedInt(uint_ty)
@@ -136,6 +135,11 @@ impl_stable_hash_for!(enum ::syntax::ast::LitIntType {
136135
Unsuffixed
137136
});
138137

138+
impl_stable_hash_for!(enum ::syntax::ast::LitFloatType {
139+
Suffixed(float_ty),
140+
Unsuffixed
141+
});
142+
139143
impl_stable_hash_for!(struct ::syntax::ast::Lit {
140144
kind,
141145
token,
@@ -148,8 +152,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind {
148152
Byte(value),
149153
Char(value),
150154
Int(value, lit_int_type),
151-
Float(value, float_ty),
152-
FloatUnsuffixed(value),
155+
Float(value, lit_float_type),
153156
Bool(value),
154157
Err(value)
155158
});
@@ -159,6 +162,7 @@ impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
159162
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
160163
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
161164
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
165+
impl_stable_hash_for!(enum ::rustc_target::abi::FloatTy { F32, F64 });
162166
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
163167
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
164168
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });

Diff for: src/librustc/infer/error_reporting/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -897,11 +897,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
897897
} else {
898898
r.push(' ');
899899
}
900-
s.push_highlighted(format!(
901-
"&{}{}",
902-
r,
903-
if mutbl == hir::MutMutable { "mut " } else { "" }
904-
));
900+
s.push_highlighted(format!("&{}{}", r, mutbl.prefix_str()));
905901
s.push_normal(ty.to_string());
906902
}
907903

Diff for: src/librustc/ty/layout.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
538538
ty::Uint(ity) => {
539539
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
540540
}
541-
ty::Float(fty) => scalar(Float(fty)),
541+
ty::Float(fty) => scalar(Float(match fty {
542+
ast::FloatTy::F32 => FloatTy::F32,
543+
ast::FloatTy::F64 => FloatTy::F64,
544+
})),
542545
ty::FnPtr(_) => {
543546
let mut ptr = scalar_unit(Pointer);
544547
ptr.valid_range = 1..=*ptr.valid_range.end();

Diff for: src/librustc/ty/print/obsolete.rs

+5-21
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc::ty::{self, Const, Instance, Ty, TyCtxt};
1212
use rustc::{bug, hir};
1313
use std::fmt::Write;
1414
use std::iter;
15-
use syntax::ast;
1615

1716
/// Same as `unique_type_name()` but with the result pushed onto the given
1817
/// `output` parameter.
@@ -39,20 +38,9 @@ impl DefPathBasedNames<'tcx> {
3938
ty::Char => output.push_str("char"),
4039
ty::Str => output.push_str("str"),
4140
ty::Never => output.push_str("!"),
42-
ty::Int(ast::IntTy::Isize) => output.push_str("isize"),
43-
ty::Int(ast::IntTy::I8) => output.push_str("i8"),
44-
ty::Int(ast::IntTy::I16) => output.push_str("i16"),
45-
ty::Int(ast::IntTy::I32) => output.push_str("i32"),
46-
ty::Int(ast::IntTy::I64) => output.push_str("i64"),
47-
ty::Int(ast::IntTy::I128) => output.push_str("i128"),
48-
ty::Uint(ast::UintTy::Usize) => output.push_str("usize"),
49-
ty::Uint(ast::UintTy::U8) => output.push_str("u8"),
50-
ty::Uint(ast::UintTy::U16) => output.push_str("u16"),
51-
ty::Uint(ast::UintTy::U32) => output.push_str("u32"),
52-
ty::Uint(ast::UintTy::U64) => output.push_str("u64"),
53-
ty::Uint(ast::UintTy::U128) => output.push_str("u128"),
54-
ty::Float(ast::FloatTy::F32) => output.push_str("f32"),
55-
ty::Float(ast::FloatTy::F64) => output.push_str("f64"),
41+
ty::Int(ty) => output.push_str(ty.name_str()),
42+
ty::Uint(ty) => output.push_str(ty.name_str()),
43+
ty::Float(ty) => output.push_str(ty.name_str()),
5644
ty::Adt(adt_def, substs) => {
5745
self.push_def_path(adt_def.did, output);
5846
self.push_generic_params(substs, iter::empty(), output, debug);
@@ -80,9 +68,7 @@ impl DefPathBasedNames<'tcx> {
8068
}
8169
ty::Ref(_, inner_type, mutbl) => {
8270
output.push('&');
83-
if mutbl == hir::MutMutable {
84-
output.push_str("mut ");
85-
}
71+
output.push_str(mutbl.prefix_str());
8672

8773
self.push_type_name(inner_type, output, debug);
8874
}
@@ -114,9 +100,7 @@ impl DefPathBasedNames<'tcx> {
114100
ty::Foreign(did) => self.push_def_path(did, output),
115101
ty::FnDef(..) | ty::FnPtr(_) => {
116102
let sig = t.fn_sig(self.tcx);
117-
if sig.unsafety() == hir::Unsafety::Unsafe {
118-
output.push_str("unsafe ");
119-
}
103+
output.push_str(sig.unsafety().prefix_str());
120104

121105
let abi = sig.abi();
122106
if abi != ::rustc_target::spec::abi::Abi::Rust {

Diff for: src/librustc/ty/print/pretty.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,9 @@ pub trait PrettyPrinter<'tcx>:
466466
match ty.kind {
467467
ty::Bool => p!(write("bool")),
468468
ty::Char => p!(write("char")),
469-
ty::Int(t) => p!(write("{}", t.ty_to_string())),
470-
ty::Uint(t) => p!(write("{}", t.ty_to_string())),
471-
ty::Float(t) => p!(write("{}", t.ty_to_string())),
469+
ty::Int(t) => p!(write("{}", t.name_str())),
470+
ty::Uint(t) => p!(write("{}", t.name_str())),
471+
ty::Float(t) => p!(write("{}", t.name_str())),
472472
ty::RawPtr(ref tm) => {
473473
p!(write("*{} ", match tm.mutbl {
474474
hir::MutMutable => "mut",
@@ -895,10 +895,11 @@ pub trait PrettyPrinter<'tcx>:
895895
let bit_size = Integer::from_attr(&self.tcx(), UnsignedInt(*ui)).size();
896896
let max = truncate(u128::max_value(), bit_size);
897897

898+
let ui_str = ui.name_str();
898899
if data == max {
899-
p!(write("std::{}::MAX", ui))
900+
p!(write("std::{}::MAX", ui_str))
900901
} else {
901-
p!(write("{}{}", data, ui))
902+
p!(write("{}{}", data, ui_str))
902903
};
903904
},
904905
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Int(i)) => {
@@ -911,10 +912,11 @@ pub trait PrettyPrinter<'tcx>:
911912
let size = self.tcx().layout_of(ty::ParamEnv::empty().and(ty))
912913
.unwrap()
913914
.size;
915+
let i_str = i.name_str();
914916
match data {
915-
d if d == min => p!(write("std::{}::MIN", i)),
916-
d if d == max => p!(write("std::{}::MAX", i)),
917-
_ => p!(write("{}{}", sign_extend(data, size) as i128, i))
917+
d if d == min => p!(write("std::{}::MIN", i_str)),
918+
d if d == max => p!(write("std::{}::MAX", i_str)),
919+
_ => p!(write("{}{}", sign_extend(data, size) as i128, i_str))
918920
}
919921
},
920922
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Char) =>
@@ -1666,8 +1668,7 @@ define_print_and_forward_display! {
16661668
}
16671669

16681670
ty::TypeAndMut<'tcx> {
1669-
p!(write("{}", if self.mutbl == hir::MutMutable { "mut " } else { "" }),
1670-
print(self.ty))
1671+
p!(write("{}", self.mutbl.prefix_str()), print(self.ty))
16711672
}
16721673

16731674
ty::ExistentialTraitRef<'tcx> {
@@ -1693,9 +1694,7 @@ define_print_and_forward_display! {
16931694
}
16941695

16951696
ty::FnSig<'tcx> {
1696-
if self.unsafety == hir::Unsafety::Unsafe {
1697-
p!(write("unsafe "));
1698-
}
1697+
p!(write("{}", self.unsafety.prefix_str()));
16991698

17001699
if self.abi != Abi::Rust {
17011700
p!(write("extern {} ", self.abi));

Diff for: src/librustc_codegen_llvm/debuginfo/metadata.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -843,13 +843,13 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
843843
ty::Bool => ("bool", DW_ATE_boolean),
844844
ty::Char => ("char", DW_ATE_unsigned_char),
845845
ty::Int(int_ty) => {
846-
(int_ty.ty_to_string(), DW_ATE_signed)
846+
(int_ty.name_str(), DW_ATE_signed)
847847
},
848848
ty::Uint(uint_ty) => {
849-
(uint_ty.ty_to_string(), DW_ATE_unsigned)
849+
(uint_ty.name_str(), DW_ATE_unsigned)
850850
},
851851
ty::Float(float_ty) => {
852-
(float_ty.ty_to_string(), DW_ATE_float)
852+
(float_ty.name_str(), DW_ATE_float)
853853
},
854854
_ => bug!("debuginfo::basic_type_metadata - t is invalid type")
855855
};

Diff for: src/librustc_codegen_llvm/intrinsic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive};
1818
use rustc::mir::interpret::GlobalId;
1919
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
2020
use rustc::hir;
21-
use syntax::ast::{self, FloatTy};
22-
use rustc_target::abi::HasDataLayout;
21+
use rustc_target::abi::{FloatTy, HasDataLayout};
22+
use syntax::ast;
2323

2424
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
2525
use rustc_codegen_ssa::traits::*;
@@ -1335,7 +1335,7 @@ fn generic_simd_intrinsic(
13351335
},
13361336
ty::Float(f) => {
13371337
return_error!("unsupported element type `{}` of floating-point vector `{}`",
1338-
f, in_ty);
1338+
f.name_str(), in_ty);
13391339
},
13401340
_ => {
13411341
return_error!("`{}` is not a floating-point type", in_ty);

Diff for: src/librustc_codegen_ssa/debuginfo/type_names.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ pub fn push_debuginfo_type_name<'tcx>(
3737
ty::Char => output.push_str("char"),
3838
ty::Str => output.push_str("str"),
3939
ty::Never => output.push_str("!"),
40-
ty::Int(int_ty) => output.push_str(int_ty.ty_to_string()),
41-
ty::Uint(uint_ty) => output.push_str(uint_ty.ty_to_string()),
42-
ty::Float(float_ty) => output.push_str(float_ty.ty_to_string()),
40+
ty::Int(int_ty) => output.push_str(int_ty.name_str()),
41+
ty::Uint(uint_ty) => output.push_str(uint_ty.name_str()),
42+
ty::Float(float_ty) => output.push_str(float_ty.name_str()),
4343
ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output),
4444
ty::Adt(def, substs) => {
4545
push_item_name(tcx, def.did, qualified, output);
@@ -76,9 +76,7 @@ pub fn push_debuginfo_type_name<'tcx>(
7676
if !cpp_like_names {
7777
output.push('&');
7878
}
79-
if mutbl == hir::MutMutable {
80-
output.push_str("mut ");
81-
}
79+
output.push_str(mutbl.prefix_str());
8280

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

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

141139

142140
let sig = t.fn_sig(tcx);
143-
if sig.unsafety() == hir::Unsafety::Unsafe {
144-
output.push_str("unsafe ");
145-
}
141+
output.push_str(sig.unsafety().prefix_str());
146142

147143
let abi = sig.abi();
148144
if abi != rustc_target::spec::abi::Abi::Rust {

0 commit comments

Comments
 (0)