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

Cargo.lock

Lines changed: 0 additions & 3 deletions
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",

src/libcore/iter/traits/collect.rs

Lines changed: 1 addition & 0 deletions
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.

src/librustc/error_codes.rs

Lines changed: 1 addition & 0 deletions
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

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 1 deletion
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
}))

src/librustc/hir/lowering/item.rs

Lines changed: 23 additions & 2 deletions
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,

src/librustc/hir/mod.rs

Lines changed: 16 additions & 0 deletions
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,

src/librustc/hir/print.rs

Lines changed: 1 addition & 3 deletions
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
}

src/librustc/ich/impls_syntax.rs

Lines changed: 7 additions & 3 deletions
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 });

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 5 deletions
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

src/librustc/ty/layout.rs

Lines changed: 4 additions & 1 deletion
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();

0 commit comments

Comments
 (0)