Skip to content

Commit

Permalink
Auto merge of rust-lang#3014 - RalfJung:rustup, r=RalfJung
Browse files Browse the repository at this point in the history
Rustup
  • Loading branch information
bors committed Aug 5, 2023
2 parents 646f564 + 621aeeb commit 3d9e8f1
Show file tree
Hide file tree
Showing 236 changed files with 2,823 additions and 1,677 deletions.
59 changes: 57 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,41 @@ dependencies = [
"winapi",
]

[[package]]
name = "darling"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"
dependencies = [
"darling_core",
"darling_macro",
]

[[package]]
name = "darling_core"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn 2.0.27",
]

[[package]]
name = "darling_macro"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
dependencies = [
"darling_core",
"quote",
"syn 2.0.27",
]

[[package]]
name = "datafrog"
version = "2.0.1"
Expand Down Expand Up @@ -869,6 +904,18 @@ dependencies = [
"syn 1.0.109",
]

[[package]]
name = "derive_setters"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e8ef033054e131169b8f0f9a7af8f5533a9436fadf3c500ed547f730f07090d"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 2.0.27",
]

[[package]]
name = "diff"
version = "0.1.13"
Expand Down Expand Up @@ -1740,6 +1787,12 @@ dependencies = [
"syn 1.0.109",
]

[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"

[[package]]
name = "idna"
version = "0.4.0"
Expand Down Expand Up @@ -3416,7 +3469,7 @@ dependencies = [
"libc",
"measureme",
"memmap2",
"parking_lot 0.11.2",
"parking_lot 0.12.1",
"rustc-hash",
"rustc-rayon",
"rustc-rayon-core",
Expand Down Expand Up @@ -3524,6 +3577,7 @@ name = "rustc_errors"
version = "0.0.0"
dependencies = [
"annotate-snippets",
"derive_setters",
"rustc_ast",
"rustc_ast_pretty",
"rustc_data_structures",
Expand Down Expand Up @@ -3566,6 +3620,7 @@ dependencies = [
"rustc_session",
"rustc_span",
"smallvec",
"termcolor",
"thin-vec",
"tracing",
]
Expand Down Expand Up @@ -4135,7 +4190,7 @@ dependencies = [
name = "rustc_query_system"
version = "0.0.0"
dependencies = [
"parking_lot 0.11.2",
"parking_lot 0.12.1",
"rustc-rayon-core",
"rustc_ast",
"rustc_data_structures",
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,8 @@ pub enum ExprKind {
/// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct field.
Field(P<Expr>, Ident),
/// An indexing operation (e.g., `foo[2]`).
Index(P<Expr>, P<Expr>),
/// The span represents the span of the `[2]`, including brackets.
Index(P<Expr>, P<Expr>, Span),
/// A range (e.g., `1..2`, `1..`, `..2`, `1..=2`, `..=2`; and `..` in destructuring assignment).
Range(Option<P<Expr>>, Option<P<Expr>>, RangeLimits),
/// An underscore, used in destructuring assignment to ignore a value.
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1400,14 +1400,15 @@ pub fn noop_visit_expr<T: MutVisitor>(
fn_decl,
body,
fn_decl_span,
fn_arg_span: _,
fn_arg_span,
}) => {
vis.visit_closure_binder(binder);
visit_constness(constness, vis);
vis.visit_asyncness(asyncness);
vis.visit_fn_decl(fn_decl);
vis.visit_expr(body);
vis.visit_span(fn_decl_span);
vis.visit_span(fn_arg_span);
}
ExprKind::Block(blk, label) => {
vis.visit_block(blk);
Expand All @@ -1420,9 +1421,10 @@ pub fn noop_visit_expr<T: MutVisitor>(
vis.visit_expr(expr);
vis.visit_span(await_kw_span);
}
ExprKind::Assign(el, er, _) => {
ExprKind::Assign(el, er, span) => {
vis.visit_expr(el);
vis.visit_expr(er);
vis.visit_span(span);
}
ExprKind::AssignOp(_op, el, er) => {
vis.visit_expr(el);
Expand All @@ -1432,9 +1434,10 @@ pub fn noop_visit_expr<T: MutVisitor>(
vis.visit_expr(el);
vis.visit_ident(ident);
}
ExprKind::Index(el, er) => {
ExprKind::Index(el, er, brackets_span) => {
vis.visit_expr(el);
vis.visit_expr(er);
vis.visit_span(brackets_span);
}
ExprKind::Range(e1, e2, _lim) => {
visit_opt(e1, |e1| vis.visit_expr(e1));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/util/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
| ast::ExprKind::Cast(x, _)
| ast::ExprKind::Type(x, _)
| ast::ExprKind::Field(x, _)
| ast::ExprKind::Index(x, _) => {
| ast::ExprKind::Index(x, _, _) => {
// &X { y: 1 }, X { y: 1 }.y
contains_exterior_struct_lit(x)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
visitor.visit_expr(subexpression);
visitor.visit_ident(*ident);
}
ExprKind::Index(main_expression, index_expression) => {
ExprKind::Index(main_expression, index_expression, _) => {
visitor.visit_expr(main_expression);
visitor.visit_expr(index_expression)
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
ExprKind::Field(el, ident) => {
hir::ExprKind::Field(self.lower_expr(el), self.lower_ident(*ident))
}
ExprKind::Index(el, er) => {
hir::ExprKind::Index(self.lower_expr(el), self.lower_expr(er))
ExprKind::Index(el, er, brackets_span) => {
hir::ExprKind::Index(self.lower_expr(el), self.lower_expr(er), *brackets_span)
}
ExprKind::Range(Some(e1), Some(e2), RangeLimits::Closed) => {
self.lower_expr_range_closed(e.span, e1, e2)
Expand Down Expand Up @@ -657,14 +657,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

/// Forwards a possible `#[track_caller]` annotation from `outer_hir_id` to
/// `inner_hir_id` in case the `closure_track_caller` feature is enabled.
/// `inner_hir_id` in case the `async_fn_track_caller` feature is enabled.
pub(super) fn maybe_forward_track_caller(
&mut self,
span: Span,
outer_hir_id: hir::HirId,
inner_hir_id: hir::HirId,
) {
if self.tcx.features().closure_track_caller
if self.tcx.features().async_fn_track_caller
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
&& attrs.into_iter().any(|attr| attr.has_name(sym::track_caller))
{
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
owner: NodeId,
f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
) {
let allow_gen_future = Some(if self.tcx.features().async_fn_track_caller {
[sym::gen_future, sym::closure_track_caller][..].into()
} else {
[sym::gen_future][..].into()
});
let mut lctx = LoweringContext {
// Pseudo-globals.
tcx: self.tcx,
Expand Down Expand Up @@ -83,7 +88,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
impl_trait_defs: Vec::new(),
impl_trait_bounds: Vec::new(),
allow_try_trait: Some([sym::try_trait_v2, sym::yeet_desugar_details][..].into()),
allow_gen_future: Some([sym::gen_future, sym::closure_track_caller][..].into()),
allow_gen_future,
generics_def_id_map: Default::default(),
};
lctx.with_hir_id_owner(owner, |lctx| f(lctx));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pprust/state/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ impl<'a> State<'a> {
self.word(".");
self.print_ident(*ident);
}
ast::ExprKind::Index(expr, index) => {
ast::ExprKind::Index(expr, index, _) => {
self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX);
self.word("[");
self.print_expr(index);
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,19 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
)
.must_apply_modulo_regions()
{
let msg = if let ty::Adt(def, _) = ty.kind()
&& [
tcx.get_diagnostic_item(sym::Arc),
tcx.get_diagnostic_item(sym::Rc),
].contains(&Some(def.did()))
{
"clone the value to increment its reference count"
} else {
"consider cloning the value if the performance cost is acceptable"
};
err.span_suggestion_verbose(
span.shrink_to_hi(),
"consider cloning the value if the performance cost is acceptable",
msg,
suggestion,
Applicability::MachineApplicable,
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
| hir::ExprKind::Unary(hir::UnOp::Deref, inner)
| hir::ExprKind::Field(inner, _)
| hir::ExprKind::MethodCall(_, inner, _, _)
| hir::ExprKind::Index(inner, _) = &expr.kind
| hir::ExprKind::Index(inner, _, _) = &expr.kind
{
expr = inner;
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
};
if let hir::ExprKind::Assign(place, rv, _sp) = expr.kind
&& let hir::ExprKind::Index(val, index) = place.kind
&& let hir::ExprKind::Index(val, index, _) = place.kind
&& (expr.span == self.assign_span || place.span == self.assign_span)
{
// val[index] = rv;
Expand Down Expand Up @@ -620,7 +620,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
);
self.suggested = true;
} else if let hir::ExprKind::MethodCall(_path, receiver, _, sp) = expr.kind
&& let hir::ExprKind::Index(val, index) = receiver.kind
&& let hir::ExprKind::Index(val, index, _) = receiver.kind
&& expr.span == self.assign_span
{
// val[index].path(args..);
Expand Down
25 changes: 14 additions & 11 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,13 +784,20 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// is considered a *lower bound*. If possible, we will modify
/// the constraint to set it equal to one of the option regions.
/// If we make any changes, returns true, else false.
///
/// This function only adds the member constraints to the region graph,
/// it does not check them. They are later checked in
/// `check_member_constraints` after the region graph has been computed.
#[instrument(skip(self, member_constraint_index), level = "debug")]
fn apply_member_constraint(
&mut self,
scc: ConstraintSccIndex,
member_constraint_index: NllMemberConstraintIndex,
choice_regions: &[ty::RegionVid],
) -> bool {
) {
// Lazily compute the reverse graph, we'll need it later.
self.compute_reverse_scc_graph();

// Create a mutable vector of the options. We'll try to winnow
// them down.
let mut choice_regions: Vec<ty::RegionVid> = choice_regions.to_vec();
Expand All @@ -805,10 +812,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
*c_r = self.scc_representatives[scc];
}

// The 'member region' in a member constraint is part of the
// hidden type, which must be in the root universe. Therefore,
// it cannot have any placeholders in its value.
assert!(self.scc_universes[scc] == ty::UniverseIndex::ROOT);
// If the member region lives in a higher universe, we currently choose
// the most conservative option by leaving it unchanged.
if self.scc_universes[scc] != ty::UniverseIndex::ROOT {
return;
}
debug_assert!(
self.scc_values.placeholders_contained_in(scc).next().is_none(),
"scc {:?} in a member constraint has placeholder value: {:?}",
Expand All @@ -832,7 +840,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// free region that must outlive the member region `R0` (`UB:
// R0`). Therefore, we need only keep an option `O` if `UB: O`
// for all UB.
self.compute_reverse_scc_graph();
let universal_region_relations = &self.universal_region_relations;
for ub in self.rev_scc_graph.as_ref().unwrap().upper_bounds(scc) {
debug!(?ub);
Expand Down Expand Up @@ -867,7 +874,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}
}) else {
debug!("no unique minimum choice");
return false;
return;
};

let min_choice_scc = self.constraint_sccs.scc(min_choice);
Expand All @@ -878,10 +885,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
min_choice,
member_constraint_index,
});

true
} else {
false
}
}

Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ impl<'tcx> RegionInferenceContext<'tcx> {
{
tcx.fold_regions(ty, |region, _| match *region {
ty::ReVar(vid) => {
let scc = self.constraint_sccs.scc(vid);

// Special handling of higher-ranked regions.
if self.scc_universes[scc] != ty::UniverseIndex::ROOT {
match self.scc_values.placeholders_contained_in(scc).enumerate().last() {
// If the region contains a single placeholder then they're equal.
Some((0, placeholder)) => {
return ty::Region::new_placeholder(tcx, placeholder);
}

// Fallback: this will produce a cryptic error message.
_ => return region,
}
}

// Find something that we can name
let upper_bound = self.approx_universal_upper_bound(vid);
let upper_bound = &self.definitions[upper_bound];
Expand Down
Loading

0 comments on commit 3d9e8f1

Please sign in to comment.