Skip to content

Commit 6c7f09b

Browse files
committed
Auto merge of rust-lang#2792 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 73f83ff + b76b26e commit 6c7f09b

File tree

434 files changed

+3551
-2191
lines changed

Some content is hidden

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

434 files changed

+3551
-2191
lines changed

Cargo.lock

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ dependencies = [
782782
"declare_clippy_lint",
783783
"if_chain",
784784
"itertools",
785-
"pulldown-cmark 0.9.2",
785+
"pulldown-cmark",
786786
"quine-mc_cluskey",
787787
"regex-syntax",
788788
"rustc-semver",
@@ -2555,7 +2555,7 @@ dependencies = [
25552555
"memchr",
25562556
"once_cell",
25572557
"opener",
2558-
"pulldown-cmark 0.9.2",
2558+
"pulldown-cmark",
25592559
"regex",
25602560
"serde",
25612561
"serde_json",
@@ -2572,7 +2572,7 @@ dependencies = [
25722572
"anyhow",
25732573
"handlebars 3.5.5",
25742574
"pretty_assertions",
2575-
"pulldown-cmark 0.7.2",
2575+
"pulldown-cmark",
25762576
"same-file",
25772577
"serde_json",
25782578
"url",
@@ -3269,17 +3269,6 @@ dependencies = [
32693269
"cc",
32703270
]
32713271

3272-
[[package]]
3273-
name = "pulldown-cmark"
3274-
version = "0.7.2"
3275-
source = "registry+https://github.com/rust-lang/crates.io-index"
3276-
checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55"
3277-
dependencies = [
3278-
"bitflags",
3279-
"memchr",
3280-
"unicase",
3281-
]
3282-
32833272
[[package]]
32843273
name = "pulldown-cmark"
32853274
version = "0.9.2"
@@ -4583,7 +4572,7 @@ name = "rustc_resolve"
45834572
version = "0.0.0"
45844573
dependencies = [
45854574
"bitflags",
4586-
"pulldown-cmark 0.9.2",
4575+
"pulldown-cmark",
45874576
"rustc_arena",
45884577
"rustc_ast",
45894578
"rustc_ast_pretty",

compiler/rustc_abi/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ pub struct TargetDataLayout {
171171

172172
pub instruction_address_space: AddressSpace,
173173

174-
/// Minimum size of #[repr(C)] enums (default I32 bits)
174+
/// Minimum size of #[repr(C)] enums (default c_int::BITS, usually 32)
175+
/// Note: This isn't in LLVM's data layout string, it is `short_enum`
176+
/// so the only valid spec for LLVM is c_int::BITS or 8
175177
pub c_enum_min_size: Integer,
176178
}
177179

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<'a> AstValidator<'a> {
271271

272272
self.session.emit_err(InvalidVisibility {
273273
span: vis.span,
274-
implied: if vis.kind.is_pub() { Some(vis.span) } else { None },
274+
implied: vis.kind.is_pub().then_some(vis.span),
275275
note,
276276
});
277277
}
@@ -294,27 +294,6 @@ impl<'a> AstValidator<'a> {
294294
}
295295
}
296296

297-
fn check_late_bound_lifetime_defs(&self, params: &[GenericParam]) {
298-
// Check only lifetime parameters are present and that the lifetime
299-
// parameters that are present have no bounds.
300-
let non_lt_param_spans: Vec<_> = params
301-
.iter()
302-
.filter_map(|param| match param.kind {
303-
GenericParamKind::Lifetime { .. } => {
304-
if !param.bounds.is_empty() {
305-
let spans: Vec<_> = param.bounds.iter().map(|b| b.span()).collect();
306-
self.session.emit_err(ForbiddenLifetimeBound { spans });
307-
}
308-
None
309-
}
310-
_ => Some(param.ident.span),
311-
})
312-
.collect();
313-
if !non_lt_param_spans.is_empty() {
314-
self.session.emit_err(ForbiddenNonLifetimeParam { spans: non_lt_param_spans });
315-
}
316-
}
317-
318297
fn check_fn_decl(&self, fn_decl: &FnDecl, self_semantic: SelfSemantic) {
319298
self.check_decl_num_args(fn_decl);
320299
self.check_decl_cvaradic_pos(fn_decl);
@@ -745,7 +724,6 @@ impl<'a> AstValidator<'a> {
745724
)
746725
.emit();
747726
});
748-
self.check_late_bound_lifetime_defs(&bfty.generic_params);
749727
if let Extern::Implicit(_) = bfty.ext {
750728
let sig_span = self.session.source_map().next_point(ty.span.shrink_to_lo());
751729
self.maybe_lint_missing_abi(sig_span, ty.id);
@@ -1318,9 +1296,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13181296
for predicate in &generics.where_clause.predicates {
13191297
match predicate {
13201298
WherePredicate::BoundPredicate(bound_pred) => {
1321-
// A type binding, eg `for<'c> Foo: Send+Clone+'c`
1322-
self.check_late_bound_lifetime_defs(&bound_pred.bound_generic_params);
1323-
13241299
// This is slightly complicated. Our representation for poly-trait-refs contains a single
13251300
// binder and thus we only allow a single level of quantification. However,
13261301
// the syntax of Rust permits quantification in two places in where clauses,
@@ -1396,11 +1371,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13961371
visit::walk_param_bound(self, bound)
13971372
}
13981373

1399-
fn visit_poly_trait_ref(&mut self, t: &'a PolyTraitRef) {
1400-
self.check_late_bound_lifetime_defs(&t.bound_generic_params);
1401-
visit::walk_poly_trait_ref(self, t);
1402-
}
1403-
14041374
fn visit_variant_data(&mut self, s: &'a VariantData) {
14051375
self.with_banned_assoc_ty_bound(|this| visit::walk_struct_def(this, s))
14061376
}
@@ -1437,10 +1407,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14371407
.emit();
14381408
}
14391409

1440-
if let FnKind::Closure(ClosureBinder::For { generic_params, .. }, ..) = fk {
1441-
self.check_late_bound_lifetime_defs(generic_params);
1442-
}
1443-
14441410
if let FnKind::Fn(
14451411
_,
14461412
_,

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use rustc_span::symbol::sym;
1111
use rustc_span::Span;
1212
use rustc_target::spec::abi;
1313

14+
use crate::errors::ForbiddenLifetimeBound;
15+
1416
macro_rules! gate_feature_fn {
1517
($visitor: expr, $has_feature: expr, $span: expr, $name: expr, $explain: expr, $help: expr) => {{
1618
let (visitor, has_feature, span, name, explain, help) =
@@ -136,6 +138,34 @@ impl<'a> PostExpansionVisitor<'a> {
136138
}
137139
ImplTraitVisitor { vis: self }.visit_ty(ty);
138140
}
141+
142+
fn check_late_bound_lifetime_defs(&self, params: &[ast::GenericParam]) {
143+
// Check only lifetime parameters are present and that the lifetime
144+
// parameters that are present have no bounds.
145+
let non_lt_param_spans: Vec<_> = params
146+
.iter()
147+
.filter_map(|param| match param.kind {
148+
ast::GenericParamKind::Lifetime { .. } => None,
149+
_ => Some(param.ident.span),
150+
})
151+
.collect();
152+
// FIXME: gate_feature_post doesn't really handle multispans...
153+
if !non_lt_param_spans.is_empty() && !self.features.non_lifetime_binders {
154+
feature_err(
155+
&self.sess.parse_sess,
156+
sym::non_lifetime_binders,
157+
non_lt_param_spans,
158+
rustc_errors::fluent::ast_passes_forbidden_non_lifetime_param,
159+
)
160+
.emit();
161+
}
162+
for param in params {
163+
if !param.bounds.is_empty() {
164+
let spans: Vec<_> = param.bounds.iter().map(|b| b.span()).collect();
165+
self.sess.emit_err(ForbiddenLifetimeBound { spans });
166+
}
167+
}
168+
}
139169
}
140170

141171
impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
@@ -147,7 +177,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
147177
..
148178
}) = attr_info
149179
{
150-
gate_feature_fn!(self, has_feature, attr.span, *name, descr);
180+
gate_feature_fn!(self, has_feature, attr.span, *name, *descr);
151181
}
152182
// Check unstable flavors of the `#[doc]` attribute.
153183
if attr.has_name(sym::doc) {
@@ -306,6 +336,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
306336
ast::TyKind::BareFn(bare_fn_ty) => {
307337
// Function pointers cannot be `const`
308338
self.check_extern(bare_fn_ty.ext, ast::Const::No);
339+
self.check_late_bound_lifetime_defs(&bare_fn_ty.generic_params);
309340
}
310341
ast::TyKind::Never => {
311342
gate_feature_post!(&self, never_type, ty.span, "the `!` type is experimental");
@@ -318,6 +349,19 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
318349
visit::walk_ty(self, ty)
319350
}
320351

352+
fn visit_generics(&mut self, g: &'a ast::Generics) {
353+
for predicate in &g.where_clause.predicates {
354+
match predicate {
355+
ast::WherePredicate::BoundPredicate(bound_pred) => {
356+
// A type binding, eg `for<'c> Foo: Send+Clone+'c`
357+
self.check_late_bound_lifetime_defs(&bound_pred.bound_generic_params);
358+
}
359+
_ => {}
360+
}
361+
}
362+
visit::walk_generics(self, g);
363+
}
364+
321365
fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FnRetTy) {
322366
if let ast::FnRetTy::Ty(output_ty) = ret_ty {
323367
if let ast::TyKind::Never = output_ty.kind {
@@ -437,12 +481,21 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
437481
visit::walk_pat(self, pattern)
438482
}
439483

484+
fn visit_poly_trait_ref(&mut self, t: &'a ast::PolyTraitRef) {
485+
self.check_late_bound_lifetime_defs(&t.bound_generic_params);
486+
visit::walk_poly_trait_ref(self, t);
487+
}
488+
440489
fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) {
441490
if let Some(header) = fn_kind.header() {
442491
// Stability of const fn methods are covered in `visit_assoc_item` below.
443492
self.check_extern(header.ext, header.constness);
444493
}
445494

495+
if let FnKind::Closure(ast::ClosureBinder::For { generic_params, .. }, ..) = fn_kind {
496+
self.check_late_bound_lifetime_defs(generic_params);
497+
}
498+
446499
if fn_kind.ctxt() != Some(FnCtxt::Foreign) && fn_kind.decl().c_variadic() {
447500
gate_feature_post!(&self, c_variadic, span, "C-variadic functions are unstable");
448501
}

compiler/rustc_attr/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ pub fn eval_condition(
731731
sess,
732732
sym::cfg_target_compact,
733733
cfg.span,
734-
&"compact `cfg(target(..))` is experimental and subject to change"
734+
"compact `cfg(target(..))` is experimental and subject to change"
735735
).emit();
736736
}
737737

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,20 @@ trait TypeOpInfo<'tcx> {
180180
return;
181181
};
182182

183-
let placeholder_region = tcx.mk_region(ty::RePlaceholder(ty::Placeholder {
183+
let placeholder_region = tcx.mk_re_placeholder(ty::Placeholder {
184184
name: placeholder.name,
185185
universe: adjusted_universe.into(),
186-
}));
186+
});
187187

188188
let error_region =
189189
if let RegionElement::PlaceholderRegion(error_placeholder) = error_element {
190190
let adjusted_universe =
191191
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
192192
adjusted_universe.map(|adjusted| {
193-
tcx.mk_region(ty::RePlaceholder(ty::Placeholder {
193+
tcx.mk_re_placeholder(ty::Placeholder {
194194
name: error_placeholder.name,
195195
universe: adjusted.into(),
196-
}))
196+
})
197197
})
198198
} else {
199199
None
@@ -390,7 +390,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
390390
error_region,
391391
&region_constraints,
392392
|vid| ocx.infcx.region_var_origin(vid),
393-
|vid| ocx.infcx.universe_of_region(ocx.infcx.tcx.mk_region(ty::ReVar(vid))),
393+
|vid| ocx.infcx.universe_of_region(ocx.infcx.tcx.mk_re_var(vid)),
394394
)
395395
}
396396

@@ -411,7 +411,7 @@ fn try_extract_error_from_region_constraints<'tcx>(
411411
}
412412
// FIXME: Should this check the universe of the var?
413413
Constraint::VarSubReg(vid, sup) if sup == placeholder_region => {
414-
Some((infcx.tcx.mk_region(ty::ReVar(vid)), cause.clone()))
414+
Some((infcx.tcx.mk_re_var(vid), cause.clone()))
415415
}
416416
_ => None,
417417
}

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,11 +1186,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11861186
return None;
11871187
};
11881188
debug!("checking call args for uses of inner_param: {:?}", args);
1189-
if args.contains(&Operand::Move(inner_param)) {
1190-
Some((loc, term))
1191-
} else {
1192-
None
1193-
}
1189+
args.contains(&Operand::Move(inner_param)).then_some((loc, term))
11941190
}) else {
11951191
debug!("no uses of inner_param found as a by-move call arg");
11961192
return;
@@ -2596,7 +2592,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25962592
if is_closure {
25972593
None
25982594
} else {
2599-
let ty = self.infcx.tcx.type_of(self.mir_def_id());
2595+
let ty = self.infcx.tcx.type_of(self.mir_def_id()).subst_identity();
26002596
match ty.kind() {
26012597
ty::FnDef(_, _) | ty::FnPtr(_) => self.annotate_fn_sig(
26022598
self.mir_def_id(),

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11851185
let parent_self_ty =
11861186
matches!(tcx.def_kind(parent_did), rustc_hir::def::DefKind::Impl { .. })
11871187
.then_some(parent_did)
1188-
.and_then(|did| match tcx.type_of(did).kind() {
1188+
.and_then(|did| match tcx.type_of(did).subst_identity().kind() {
11891189
ty::Adt(def, ..) => Some(def.did()),
11901190
_ => None,
11911191
});

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
575575

576576
let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty;
577577
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *output_ty.kind() {
578-
output_ty = self.infcx.tcx.type_of(def_id)
578+
output_ty = self.infcx.tcx.type_of(def_id).subst_identity()
579579
};
580580

581581
debug!("report_fnmut_error: output_ty={:?}", output_ty);
@@ -896,7 +896,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
896896
debug!(?fn_did, ?substs);
897897

898898
// Only suggest this on function calls, not closures
899-
let ty = tcx.type_of(fn_did);
899+
let ty = tcx.type_of(fn_did).subst_identity();
900900
debug!("ty: {:?}, ty.kind: {:?}", ty, ty.kind());
901901
if let ty::Closure(_, _) = ty.kind() {
902902
return;

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,10 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
280280

281281
debug!("give_region_a_name: error_region = {:?}", error_region);
282282
match *error_region {
283-
ty::ReEarlyBound(ebr) => {
284-
if ebr.has_name() {
285-
let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP);
286-
Some(RegionName {
287-
name: ebr.name,
288-
source: RegionNameSource::NamedEarlyBoundRegion(span),
289-
})
290-
} else {
291-
None
292-
}
293-
}
283+
ty::ReEarlyBound(ebr) => ebr.has_name().then(|| {
284+
let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP);
285+
RegionName { name: ebr.name, source: RegionNameSource::NamedEarlyBoundRegion(span) }
286+
}),
294287

295288
ty::ReStatic => {
296289
Some(RegionName { name: kw::StaticLifetime, source: RegionNameSource::Static })
@@ -856,8 +849,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
856849
return None;
857850
};
858851

859-
let found = tcx
860-
.any_free_region_meets(&tcx.type_of(region_parent), |r| *r == ty::ReEarlyBound(region));
852+
let found = tcx.any_free_region_meets(&tcx.type_of(region_parent).subst_identity(), |r| {
853+
*r == ty::ReEarlyBound(region)
854+
});
861855

862856
Some(RegionName {
863857
name: self.synthesize_region_name(),

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12971297
let vid = self.to_region_vid(r);
12981298
let scc = self.constraint_sccs.scc(vid);
12991299
let repr = self.scc_representatives[scc];
1300-
tcx.mk_region(ty::ReVar(repr))
1300+
tcx.mk_re_var(repr)
13011301
})
13021302
}
13031303

@@ -1719,7 +1719,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
17191719
}
17201720

17211721
// If not, report an error.
1722-
let member_region = infcx.tcx.mk_region(ty::ReVar(member_region_vid));
1722+
let member_region = infcx.tcx.mk_re_var(member_region_vid);
17231723
errors_buffer.push(RegionErrorKind::UnexpectedHiddenRegion {
17241724
span: m_c.definition_span,
17251725
hidden_ty: m_c.hidden_ty,

0 commit comments

Comments
 (0)