Skip to content

Commit 4f6a0db

Browse files
committed
Auto merge of #152476 - Zalathar:rollup-f5mMs9g, r=<try>
Rollup of 9 pull requests try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: x86_64-mingw-1 try-job: test-various try-job: armhf-gnu try-job: aarch64-apple
2 parents d34f1f9 + a7a1ae6 commit 4f6a0db

168 files changed

Lines changed: 2815 additions & 351 deletions

File tree

Some content is hidden

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

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3431,6 +3431,7 @@ dependencies = [
34313431
"rustc_macros",
34323432
"rustc_serialize",
34333433
"rustc_span",
3434+
"serde",
34343435
"tracing",
34353436
]
34363437

@@ -4250,6 +4251,7 @@ dependencies = [
42504251
"rustc_target",
42514252
"rustc_thread_pool",
42524253
"rustc_type_ir",
4254+
"serde",
42534255
"smallvec",
42544256
"thin-vec",
42554257
"tracing",

compiler/rustc_abi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ rustc_index = { path = "../rustc_index", default-features = false }
1515
rustc_macros = { path = "../rustc_macros", optional = true }
1616
rustc_serialize = { path = "../rustc_serialize", optional = true }
1717
rustc_span = { path = "../rustc_span", optional = true }
18+
serde = { version = "1.0.125", features = ["derive"] }
1819
tracing = "0.1"
1920
# tidy-alphabetical-end
2021

compiler/rustc_abi/src/callconv/reg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl Reg {
3535

3636
reg_ctor!(f32, Float, 32);
3737
reg_ctor!(f64, Float, 64);
38+
reg_ctor!(f128, Float, 128);
3839
}
3940

4041
impl Reg {

compiler/rustc_abi/src/layout/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ rustc_index::newtype_index! {
3333
/// `b` is `FieldIdx(1)` in `VariantIdx(0)`,
3434
/// `d` is `FieldIdx(1)` in `VariantIdx(1)`, and
3535
/// `f` is `FieldIdx(1)` in `VariantIdx(0)`.
36-
#[derive(HashStable_Generic)]
36+
#[derive(HashStable_Generic, serde::Serialize)]
3737
#[encodable]
3838
#[orderable]
3939
pub struct FieldIdx {}
@@ -57,7 +57,7 @@ rustc_index::newtype_index! {
5757
///
5858
/// `struct`s, `tuples`, and `unions`s are considered to have a single variant
5959
/// with variant index zero, aka [`FIRST_VARIANT`].
60-
#[derive(HashStable_Generic)]
60+
#[derive(HashStable_Generic, serde::Serialize)]
6161
#[encodable]
6262
#[orderable]
6363
pub struct VariantIdx {

compiler/rustc_ast/src/ast.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,6 +2553,11 @@ pub enum TyKind {
25532553
/// Pattern types like `pattern_type!(u32 is 1..=)`, which is the same as `NonZero<u32>`,
25542554
/// just as part of the type system.
25552555
Pat(Box<Ty>, Box<TyPat>),
2556+
/// A `field_of` expression (e.g., `builtin # field_of(Struct, field)`).
2557+
///
2558+
/// Usually not written directly in user code but indirectly via the macro
2559+
/// `core::field::field_of!(...)`.
2560+
FieldOf(Box<Ty>, Option<Ident>, Ident),
25562561
/// Sometimes we need a dummy value when no error has occurred.
25572562
Dummy,
25582563
/// Placeholder for a kind that has failed to be defined.

compiler/rustc_ast/src/util/classify.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ fn type_trailing_braced_mac_call(mut ty: &ast::Ty) -> Option<&ast::MacCall> {
298298
| ast::TyKind::ImplicitSelf
299299
| ast::TyKind::CVarArgs
300300
| ast::TyKind::Pat(..)
301+
| ast::TyKind::FieldOf(..)
301302
| ast::TyKind::Dummy
302303
| ast::TyKind::Err(..) => break None,
303304
}

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14971497
TyKind::Pat(ty, pat) => {
14981498
hir::TyKind::Pat(self.lower_ty_alloc(ty, itctx), self.lower_ty_pat(pat, ty.span))
14991499
}
1500+
TyKind::FieldOf(ty, variant, field) => hir::TyKind::FieldOf(
1501+
self.lower_ty_alloc(ty, itctx),
1502+
self.arena.alloc(hir::TyFieldPath {
1503+
variant: variant.map(|variant| self.lower_ident(variant)),
1504+
field: self.lower_ident(*field),
1505+
}),
1506+
),
1507+
15001508
TyKind::MacCall(_) => {
15011509
span_bug!(t.span, "`TyKind::MacCall` should have been expanded by now")
15021510
}

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,23 @@ impl<'a> State<'a> {
13771377
self.word(" is ");
13781378
self.print_ty_pat(pat);
13791379
}
1380+
ast::TyKind::FieldOf(ty, variant, field) => {
1381+
self.word("builtin # field_of");
1382+
self.popen();
1383+
let ib = self.ibox(0);
1384+
self.print_type(ty);
1385+
self.word(",");
1386+
self.space();
1387+
1388+
if let Some(variant) = variant {
1389+
self.print_ident(*variant);
1390+
self.word(".");
1391+
}
1392+
self.print_ident(*field);
1393+
1394+
self.end(ib);
1395+
self.pclose();
1396+
}
13801397
}
13811398
self.end(ib);
13821399
}

compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use rustc_hir::lints::AttributeLintKind;
2+
use rustc_session::lint::builtin::AMBIGUOUS_DERIVE_HELPERS;
3+
14
use super::prelude::*;
25

36
const PROC_MACRO_ALLOWED_TARGETS: AllowedTargets =
@@ -126,6 +129,13 @@ fn parse_derive_like<S: Stage>(
126129
cx.expected_identifier(ident.span);
127130
return None;
128131
}
132+
if rustc_feature::is_builtin_attr_name(ident.name) {
133+
cx.emit_lint(
134+
AMBIGUOUS_DERIVE_HELPERS,
135+
AttributeLintKind::AmbiguousDeriveHelpers,
136+
ident.span,
137+
);
138+
}
129139
attributes.push(ident.name);
130140
}
131141
}

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_
2424
use tracing::{debug, instrument};
2525

2626
use crate::MirBorrowckCtxt;
27-
use crate::region_infer::values::RegionElement;
2827
use crate::session_diagnostics::{
2928
HigherRankedErrorCause, HigherRankedLifetimeError, HigherRankedSubtypeError,
3029
};
@@ -49,11 +48,12 @@ impl<'tcx> UniverseInfo<'tcx> {
4948
UniverseInfo::RelateTys { expected, found }
5049
}
5150

51+
/// Report an error where an element erroneously made its way into `placeholder`.
5252
pub(crate) fn report_erroneous_element(
5353
&self,
5454
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
5555
placeholder: ty::PlaceholderRegion<'tcx>,
56-
error_element: RegionElement<'tcx>,
56+
error_element: Option<ty::PlaceholderRegion<'tcx>>,
5757
cause: ObligationCause<'tcx>,
5858
) {
5959
match *self {
@@ -146,14 +146,14 @@ pub(crate) trait TypeOpInfo<'tcx> {
146146
) -> Option<Diag<'infcx>>;
147147

148148
/// Constraints require that `error_element` appear in the
149-
/// values of `placeholder`, but this cannot be proven to
149+
/// values of `placeholder`, but this cannot be proven to
150150
/// hold. Report an error.
151151
#[instrument(level = "debug", skip(self, mbcx))]
152152
fn report_erroneous_element(
153153
&self,
154154
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
155155
placeholder: ty::PlaceholderRegion<'tcx>,
156-
error_element: RegionElement<'tcx>,
156+
error_element: Option<ty::PlaceholderRegion<'tcx>>,
157157
cause: ObligationCause<'tcx>,
158158
) {
159159
let tcx = mbcx.infcx.tcx;
@@ -172,19 +172,17 @@ pub(crate) trait TypeOpInfo<'tcx> {
172172
ty::PlaceholderRegion::new(adjusted_universe.into(), placeholder.bound),
173173
);
174174

175-
let error_region =
176-
if let RegionElement::PlaceholderRegion(error_placeholder) = error_element {
177-
let adjusted_universe =
178-
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
179-
adjusted_universe.map(|adjusted| {
180-
ty::Region::new_placeholder(
181-
tcx,
182-
ty::PlaceholderRegion::new(adjusted.into(), error_placeholder.bound),
183-
)
184-
})
185-
} else {
186-
None
187-
};
175+
// FIXME: one day this should just be error_element,
176+
// and this method shouldn't do anything.
177+
let error_region = error_element.and_then(|e| {
178+
let adjusted_universe = e.universe.as_u32().checked_sub(base_universe.as_u32());
179+
adjusted_universe.map(|adjusted| {
180+
ty::Region::new_placeholder(
181+
tcx,
182+
ty::PlaceholderRegion::new(adjusted.into(), e.bound),
183+
)
184+
})
185+
});
188186

189187
debug!(?placeholder_region);
190188

0 commit comments

Comments
 (0)