Skip to content

Commit 3d9e8f1

Browse files
committed
Auto merge of rust-lang#3014 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 646f564 + 621aeeb commit 3d9e8f1

File tree

236 files changed

+2823
-1677
lines changed

Some content is hidden

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

236 files changed

+2823
-1677
lines changed

Cargo.lock

+57-2
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,41 @@ dependencies = [
830830
"winapi",
831831
]
832832

833+
[[package]]
834+
name = "darling"
835+
version = "0.20.3"
836+
source = "registry+https://github.com/rust-lang/crates.io-index"
837+
checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"
838+
dependencies = [
839+
"darling_core",
840+
"darling_macro",
841+
]
842+
843+
[[package]]
844+
name = "darling_core"
845+
version = "0.20.3"
846+
source = "registry+https://github.com/rust-lang/crates.io-index"
847+
checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621"
848+
dependencies = [
849+
"fnv",
850+
"ident_case",
851+
"proc-macro2",
852+
"quote",
853+
"strsim",
854+
"syn 2.0.27",
855+
]
856+
857+
[[package]]
858+
name = "darling_macro"
859+
version = "0.20.3"
860+
source = "registry+https://github.com/rust-lang/crates.io-index"
861+
checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
862+
dependencies = [
863+
"darling_core",
864+
"quote",
865+
"syn 2.0.27",
866+
]
867+
833868
[[package]]
834869
name = "datafrog"
835870
version = "2.0.1"
@@ -869,6 +904,18 @@ dependencies = [
869904
"syn 1.0.109",
870905
]
871906

907+
[[package]]
908+
name = "derive_setters"
909+
version = "0.1.6"
910+
source = "registry+https://github.com/rust-lang/crates.io-index"
911+
checksum = "4e8ef033054e131169b8f0f9a7af8f5533a9436fadf3c500ed547f730f07090d"
912+
dependencies = [
913+
"darling",
914+
"proc-macro2",
915+
"quote",
916+
"syn 2.0.27",
917+
]
918+
872919
[[package]]
873920
name = "diff"
874921
version = "0.1.13"
@@ -1740,6 +1787,12 @@ dependencies = [
17401787
"syn 1.0.109",
17411788
]
17421789

1790+
[[package]]
1791+
name = "ident_case"
1792+
version = "1.0.1"
1793+
source = "registry+https://github.com/rust-lang/crates.io-index"
1794+
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
1795+
17431796
[[package]]
17441797
name = "idna"
17451798
version = "0.4.0"
@@ -3416,7 +3469,7 @@ dependencies = [
34163469
"libc",
34173470
"measureme",
34183471
"memmap2",
3419-
"parking_lot 0.11.2",
3472+
"parking_lot 0.12.1",
34203473
"rustc-hash",
34213474
"rustc-rayon",
34223475
"rustc-rayon-core",
@@ -3524,6 +3577,7 @@ name = "rustc_errors"
35243577
version = "0.0.0"
35253578
dependencies = [
35263579
"annotate-snippets",
3580+
"derive_setters",
35273581
"rustc_ast",
35283582
"rustc_ast_pretty",
35293583
"rustc_data_structures",
@@ -3566,6 +3620,7 @@ dependencies = [
35663620
"rustc_session",
35673621
"rustc_span",
35683622
"smallvec",
3623+
"termcolor",
35693624
"thin-vec",
35703625
"tracing",
35713626
]
@@ -4135,7 +4190,7 @@ dependencies = [
41354190
name = "rustc_query_system"
41364191
version = "0.0.0"
41374192
dependencies = [
4138-
"parking_lot 0.11.2",
4193+
"parking_lot 0.12.1",
41394194
"rustc-rayon-core",
41404195
"rustc_ast",
41414196
"rustc_data_structures",

compiler/rustc_ast/src/ast.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,8 @@ pub enum ExprKind {
14621462
/// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct field.
14631463
Field(P<Expr>, Ident),
14641464
/// An indexing operation (e.g., `foo[2]`).
1465-
Index(P<Expr>, P<Expr>),
1465+
/// The span represents the span of the `[2]`, including brackets.
1466+
Index(P<Expr>, P<Expr>, Span),
14661467
/// A range (e.g., `1..2`, `1..`, `..2`, `1..=2`, `..=2`; and `..` in destructuring assignment).
14671468
Range(Option<P<Expr>>, Option<P<Expr>>, RangeLimits),
14681469
/// An underscore, used in destructuring assignment to ignore a value.

compiler/rustc_ast/src/mut_visit.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1400,14 +1400,15 @@ pub fn noop_visit_expr<T: MutVisitor>(
14001400
fn_decl,
14011401
body,
14021402
fn_decl_span,
1403-
fn_arg_span: _,
1403+
fn_arg_span,
14041404
}) => {
14051405
vis.visit_closure_binder(binder);
14061406
visit_constness(constness, vis);
14071407
vis.visit_asyncness(asyncness);
14081408
vis.visit_fn_decl(fn_decl);
14091409
vis.visit_expr(body);
14101410
vis.visit_span(fn_decl_span);
1411+
vis.visit_span(fn_arg_span);
14111412
}
14121413
ExprKind::Block(blk, label) => {
14131414
vis.visit_block(blk);
@@ -1420,9 +1421,10 @@ pub fn noop_visit_expr<T: MutVisitor>(
14201421
vis.visit_expr(expr);
14211422
vis.visit_span(await_kw_span);
14221423
}
1423-
ExprKind::Assign(el, er, _) => {
1424+
ExprKind::Assign(el, er, span) => {
14241425
vis.visit_expr(el);
14251426
vis.visit_expr(er);
1427+
vis.visit_span(span);
14261428
}
14271429
ExprKind::AssignOp(_op, el, er) => {
14281430
vis.visit_expr(el);
@@ -1432,9 +1434,10 @@ pub fn noop_visit_expr<T: MutVisitor>(
14321434
vis.visit_expr(el);
14331435
vis.visit_ident(ident);
14341436
}
1435-
ExprKind::Index(el, er) => {
1437+
ExprKind::Index(el, er, brackets_span) => {
14361438
vis.visit_expr(el);
14371439
vis.visit_expr(er);
1440+
vis.visit_span(brackets_span);
14381441
}
14391442
ExprKind::Range(e1, e2, _lim) => {
14401443
visit_opt(e1, |e1| vis.visit_expr(e1));

compiler/rustc_ast/src/util/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
390390
| ast::ExprKind::Cast(x, _)
391391
| ast::ExprKind::Type(x, _)
392392
| ast::ExprKind::Field(x, _)
393-
| ast::ExprKind::Index(x, _) => {
393+
| ast::ExprKind::Index(x, _, _) => {
394394
// &X { y: 1 }, X { y: 1 }.y
395395
contains_exterior_struct_lit(x)
396396
}

compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
885885
visitor.visit_expr(subexpression);
886886
visitor.visit_ident(*ident);
887887
}
888-
ExprKind::Index(main_expression, index_expression) => {
888+
ExprKind::Index(main_expression, index_expression, _) => {
889889
visitor.visit_expr(main_expression);
890890
visitor.visit_expr(index_expression)
891891
}

compiler/rustc_ast_lowering/src/expr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
240240
ExprKind::Field(el, ident) => {
241241
hir::ExprKind::Field(self.lower_expr(el), self.lower_ident(*ident))
242242
}
243-
ExprKind::Index(el, er) => {
244-
hir::ExprKind::Index(self.lower_expr(el), self.lower_expr(er))
243+
ExprKind::Index(el, er, brackets_span) => {
244+
hir::ExprKind::Index(self.lower_expr(el), self.lower_expr(er), *brackets_span)
245245
}
246246
ExprKind::Range(Some(e1), Some(e2), RangeLimits::Closed) => {
247247
self.lower_expr_range_closed(e.span, e1, e2)
@@ -657,14 +657,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
657657
}
658658

659659
/// Forwards a possible `#[track_caller]` annotation from `outer_hir_id` to
660-
/// `inner_hir_id` in case the `closure_track_caller` feature is enabled.
660+
/// `inner_hir_id` in case the `async_fn_track_caller` feature is enabled.
661661
pub(super) fn maybe_forward_track_caller(
662662
&mut self,
663663
span: Span,
664664
outer_hir_id: hir::HirId,
665665
inner_hir_id: hir::HirId,
666666
) {
667-
if self.tcx.features().closure_track_caller
667+
if self.tcx.features().async_fn_track_caller
668668
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
669669
&& attrs.into_iter().any(|attr| attr.has_name(sym::track_caller))
670670
{

compiler/rustc_ast_lowering/src/item.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
5656
owner: NodeId,
5757
f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
5858
) {
59+
let allow_gen_future = Some(if self.tcx.features().async_fn_track_caller {
60+
[sym::gen_future, sym::closure_track_caller][..].into()
61+
} else {
62+
[sym::gen_future][..].into()
63+
});
5964
let mut lctx = LoweringContext {
6065
// Pseudo-globals.
6166
tcx: self.tcx,
@@ -83,7 +88,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
8388
impl_trait_defs: Vec::new(),
8489
impl_trait_bounds: Vec::new(),
8590
allow_try_trait: Some([sym::try_trait_v2, sym::yeet_desugar_details][..].into()),
86-
allow_gen_future: Some([sym::gen_future, sym::closure_track_caller][..].into()),
91+
allow_gen_future,
8792
generics_def_id_map: Default::default(),
8893
};
8994
lctx.with_hir_id_owner(owner, |lctx| f(lctx));

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ impl<'a> State<'a> {
477477
self.word(".");
478478
self.print_ident(*ident);
479479
}
480-
ast::ExprKind::Index(expr, index) => {
480+
ast::ExprKind::Index(expr, index, _) => {
481481
self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX);
482482
self.word("[");
483483
self.print_expr(index);

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,19 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
751751
)
752752
.must_apply_modulo_regions()
753753
{
754+
let msg = if let ty::Adt(def, _) = ty.kind()
755+
&& [
756+
tcx.get_diagnostic_item(sym::Arc),
757+
tcx.get_diagnostic_item(sym::Rc),
758+
].contains(&Some(def.did()))
759+
{
760+
"clone the value to increment its reference count"
761+
} else {
762+
"consider cloning the value if the performance cost is acceptable"
763+
};
754764
err.span_suggestion_verbose(
755765
span.shrink_to_hi(),
756-
"consider cloning the value if the performance cost is acceptable",
766+
msg,
757767
suggestion,
758768
Applicability::MachineApplicable,
759769
);

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
7979
| hir::ExprKind::Unary(hir::UnOp::Deref, inner)
8080
| hir::ExprKind::Field(inner, _)
8181
| hir::ExprKind::MethodCall(_, inner, _, _)
82-
| hir::ExprKind::Index(inner, _) = &expr.kind
82+
| hir::ExprKind::Index(inner, _, _) = &expr.kind
8383
{
8484
expr = inner;
8585
}

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
567567
}
568568
};
569569
if let hir::ExprKind::Assign(place, rv, _sp) = expr.kind
570-
&& let hir::ExprKind::Index(val, index) = place.kind
570+
&& let hir::ExprKind::Index(val, index, _) = place.kind
571571
&& (expr.span == self.assign_span || place.span == self.assign_span)
572572
{
573573
// val[index] = rv;
@@ -620,7 +620,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
620620
);
621621
self.suggested = true;
622622
} else if let hir::ExprKind::MethodCall(_path, receiver, _, sp) = expr.kind
623-
&& let hir::ExprKind::Index(val, index) = receiver.kind
623+
&& let hir::ExprKind::Index(val, index, _) = receiver.kind
624624
&& expr.span == self.assign_span
625625
{
626626
// val[index].path(args..);

compiler/rustc_borrowck/src/region_infer/mod.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -784,13 +784,20 @@ impl<'tcx> RegionInferenceContext<'tcx> {
784784
/// is considered a *lower bound*. If possible, we will modify
785785
/// the constraint to set it equal to one of the option regions.
786786
/// If we make any changes, returns true, else false.
787+
///
788+
/// This function only adds the member constraints to the region graph,
789+
/// it does not check them. They are later checked in
790+
/// `check_member_constraints` after the region graph has been computed.
787791
#[instrument(skip(self, member_constraint_index), level = "debug")]
788792
fn apply_member_constraint(
789793
&mut self,
790794
scc: ConstraintSccIndex,
791795
member_constraint_index: NllMemberConstraintIndex,
792796
choice_regions: &[ty::RegionVid],
793-
) -> bool {
797+
) {
798+
// Lazily compute the reverse graph, we'll need it later.
799+
self.compute_reverse_scc_graph();
800+
794801
// Create a mutable vector of the options. We'll try to winnow
795802
// them down.
796803
let mut choice_regions: Vec<ty::RegionVid> = choice_regions.to_vec();
@@ -805,10 +812,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
805812
*c_r = self.scc_representatives[scc];
806813
}
807814

808-
// The 'member region' in a member constraint is part of the
809-
// hidden type, which must be in the root universe. Therefore,
810-
// it cannot have any placeholders in its value.
811-
assert!(self.scc_universes[scc] == ty::UniverseIndex::ROOT);
815+
// If the member region lives in a higher universe, we currently choose
816+
// the most conservative option by leaving it unchanged.
817+
if self.scc_universes[scc] != ty::UniverseIndex::ROOT {
818+
return;
819+
}
812820
debug_assert!(
813821
self.scc_values.placeholders_contained_in(scc).next().is_none(),
814822
"scc {:?} in a member constraint has placeholder value: {:?}",
@@ -832,7 +840,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
832840
// free region that must outlive the member region `R0` (`UB:
833841
// R0`). Therefore, we need only keep an option `O` if `UB: O`
834842
// for all UB.
835-
self.compute_reverse_scc_graph();
836843
let universal_region_relations = &self.universal_region_relations;
837844
for ub in self.rev_scc_graph.as_ref().unwrap().upper_bounds(scc) {
838845
debug!(?ub);
@@ -867,7 +874,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
867874
}
868875
}) else {
869876
debug!("no unique minimum choice");
870-
return false;
877+
return;
871878
};
872879

873880
let min_choice_scc = self.constraint_sccs.scc(min_choice);
@@ -878,10 +885,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
878885
min_choice,
879886
member_constraint_index,
880887
});
881-
882-
true
883-
} else {
884-
false
885888
}
886889
}
887890

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+15
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,21 @@ impl<'tcx> RegionInferenceContext<'tcx> {
185185
{
186186
tcx.fold_regions(ty, |region, _| match *region {
187187
ty::ReVar(vid) => {
188+
let scc = self.constraint_sccs.scc(vid);
189+
190+
// Special handling of higher-ranked regions.
191+
if self.scc_universes[scc] != ty::UniverseIndex::ROOT {
192+
match self.scc_values.placeholders_contained_in(scc).enumerate().last() {
193+
// If the region contains a single placeholder then they're equal.
194+
Some((0, placeholder)) => {
195+
return ty::Region::new_placeholder(tcx, placeholder);
196+
}
197+
198+
// Fallback: this will produce a cryptic error message.
199+
_ => return region,
200+
}
201+
}
202+
188203
// Find something that we can name
189204
let upper_bound = self.approx_universal_upper_bound(vid);
190205
let upper_bound = &self.definitions[upper_bound];

0 commit comments

Comments
 (0)