Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/rust
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c2804e6ec2c29a5c7368600ea173b890e2655c3d
Choose a base ref
...
head repository: rust-lang/rust
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1120c5e01df508de64fe6642f22fadeb574afd6d
Choose a head ref
Loading
Showing with 2,950 additions and 1,901 deletions.
  1. +1 −0 Cargo.lock
  2. +2 −1 compiler/rustc_ast/src/ast.rs
  3. +39 −35 compiler/rustc_ast_lowering/src/expr.rs
  4. +45 −29 compiler/rustc_ast_lowering/src/lib.rs
  5. +2 −2 compiler/rustc_ast_lowering/src/pat.rs
  6. +0 −1 compiler/rustc_borrowck/src/region_infer/mod.rs
  7. +6 −5 compiler/rustc_codegen_cranelift/src/discriminant.rs
  8. +9 −9 compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs
  9. +3 −3 compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs
  10. +1 −1 compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs
  11. +4 −4 compiler/rustc_codegen_ssa/src/mir/place.rs
  12. +1 −1 compiler/rustc_const_eval/src/interpret/intrinsics.rs
  13. +10 −10 compiler/rustc_const_eval/src/interpret/operand.rs
  14. +6 −4 compiler/rustc_const_eval/src/interpret/place.rs
  15. +15 −14 compiler/rustc_const_eval/src/transform/validate.rs
  16. +4 −0 compiler/rustc_data_structures/src/obligation_forest/mod.rs
  17. +60 −2 compiler/rustc_error_messages/locales/en-US/infer.ftl
  18. +3 −0 compiler/rustc_error_messages/locales/en-US/parser.ftl
  19. +42 −0 compiler/rustc_error_messages/locales/en-US/session.ftl
  20. +6 −1 compiler/rustc_errors/src/diagnostic.rs
  21. +3 −3 compiler/rustc_errors/src/lib.rs
  22. +1 −1 compiler/rustc_hir/src/def.rs
  23. +51 −17 compiler/rustc_hir/src/hir.rs
  24. +3 −3 compiler/rustc_hir/src/pat_util.rs
  25. +3 −2 compiler/rustc_hir_pretty/src/lib.rs
  26. +0 −254 compiler/rustc_infer/src/errors.rs
  27. +499 −0 compiler/rustc_infer/src/errors/mod.rs
  28. +179 −0 compiler/rustc_infer/src/errors/note_and_explain.rs
  29. +8 −12 compiler/rustc_infer/src/infer/combine.rs
  30. +5 −5 compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
  31. +31 −116 compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
  32. +31 −20 compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs
  33. +1 −1 compiler/rustc_lexer/src/lib.rs
  34. +19 −9 compiler/rustc_lint/src/context.rs
  35. +8 −7 compiler/rustc_lint/src/late.rs
  36. +29 −14 compiler/rustc_lint/src/lib.rs
  37. +1 −1 compiler/rustc_lint/src/passes.rs
  38. +12 −3 compiler/rustc_metadata/src/rmeta/decoder.rs
  39. +3 −3 compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
  40. +5 −2 compiler/rustc_metadata/src/rmeta/encoder.rs
  41. +1 −1 compiler/rustc_metadata/src/rmeta/mod.rs
  42. +1 −0 compiler/rustc_middle/src/lib.rs
  43. +2 −1 compiler/rustc_middle/src/metadata.rs
  44. +3 −2 compiler/rustc_middle/src/mir/syntax.rs
  45. +1 −1 compiler/rustc_middle/src/mir/terminator.rs
  46. +1 −1 compiler/rustc_middle/src/query/mod.rs
  47. +8 −4 compiler/rustc_middle/src/thir.rs
  48. +2 −2 compiler/rustc_middle/src/traits/mod.rs
  49. +1 −1 compiler/rustc_middle/src/ty/assoc.rs
  50. +1 −0 compiler/rustc_middle/src/ty/consts/kind.rs
  51. +7 −1 compiler/rustc_middle/src/ty/context.rs
  52. +13 −1 compiler/rustc_middle/src/ty/diagnostics.rs
  53. +200 −118 compiler/rustc_middle/src/ty/layout.rs
  54. +37 −24 compiler/rustc_middle/src/ty/mod.rs
  55. +2 −2 compiler/rustc_middle/src/ty/parameterized.rs
  56. +0 −4 compiler/rustc_middle/src/ty/relate.rs
  57. +1 −1 compiler/rustc_middle/src/ty/visit.rs
  58. +11 −22 compiler/{rustc_query_impl → rustc_middle}/src/values.rs
  59. +1 −1 compiler/rustc_mir_build/src/build/mod.rs
  60. +7 −2 compiler/rustc_mir_build/src/thir/pattern/mod.rs
  61. +16 −0 compiler/rustc_parse/src/parser/diagnostics.rs
  62. +4 −7 compiler/rustc_passes/src/dead.rs
  63. +5 −0 compiler/rustc_passes/src/hir_stats.rs
  64. +37 −39 compiler/rustc_privacy/src/lib.rs
  65. +0 −3 compiler/rustc_query_impl/src/lib.rs
  66. +11 −13 compiler/rustc_query_impl/src/plumbing.rs
  67. +1 −0 compiler/rustc_query_system/Cargo.toml
  68. +7 −0 compiler/rustc_query_system/src/error.rs
  69. +2 −0 compiler/rustc_query_system/src/ich/impls_syntax.rs
  70. +4 −0 compiler/rustc_query_system/src/lib.rs
  71. +3 −2 compiler/rustc_query_system/src/query/config.rs
  72. +35 −3 compiler/rustc_query_system/src/query/plumbing.rs
  73. +14 −0 compiler/rustc_query_system/src/values.rs
  74. +27 −19 compiler/rustc_resolve/src/build_reduced_graph.rs
  75. +7 −6 compiler/rustc_resolve/src/ident.rs
  76. +2 −2 compiler/rustc_resolve/src/imports.rs
  77. +11 −28 compiler/rustc_resolve/src/lib.rs
  78. +1 −1 compiler/rustc_session/src/config.rs
  79. +129 −2 compiler/rustc_session/src/errors.rs
  80. +42 −44 compiler/rustc_session/src/session.rs
  81. +6 −0 compiler/rustc_span/src/def_id.rs
  82. +39 −28 compiler/rustc_target/src/abi/mod.rs
  83. +1 −3 compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
  84. +14 −12 compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
  85. +44 −4 compiler/rustc_trait_selection/src/traits/project.rs
  86. +10 −9 compiler/rustc_trait_selection/src/traits/query/normalize.rs
  87. +9 −40 compiler/rustc_type_ir/src/lib.rs
  88. +3 −3 compiler/rustc_type_ir/src/sty.rs
  89. +2 −1 compiler/rustc_typeck/src/astconv/mod.rs
  90. +1 −1 compiler/rustc_typeck/src/check/demand.rs
  91. +2 −4 compiler/rustc_typeck/src/check/expr.rs
  92. +4 −7 compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
  93. +4 −22 compiler/rustc_typeck/src/check/method/mod.rs
  94. +1 −1 compiler/rustc_typeck/src/check/method/suggest.rs
  95. +149 −203 compiler/rustc_typeck/src/check/op.rs
  96. +5 −5 compiler/rustc_typeck/src/check/pat.rs
  97. +12 −0 library/std/src/sys/hermit/fs.rs
  98. +1 −0 src/bootstrap/Cargo.toml
  99. +6 −4 src/bootstrap/util.rs
  100. +6 −6 src/librustdoc/clean/mod.rs
  101. +2 −1 src/librustdoc/clean/types.rs
  102. +3 −3 src/test/debuginfo/msvc-pretty-enums.rs
  103. +8 −8 src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir
  104. +4 −4 src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir
  105. +1 −0 src/test/run-make/issue-71519/Makefile
  106. +1 −1 src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs
  107. +3 −3 src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs
  108. +1 −1 src/test/ui-fulldeps/auxiliary/lint-for-crate.rs
  109. +1 −1 src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs
  110. +2 −1 src/test/ui/associated-types/issue-62200.rs
  111. +2 −1 src/test/ui/associated-types/issue-62200.stderr
  112. +1 −1 src/test/ui/binop/binary-op-on-double-ref.stderr
  113. +15 −15 src/test/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr
  114. +4 −4 src/test/ui/borrowck/borrowck-describe-lvalue.stderr
  115. +3 −3 src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr
  116. +3 −3 src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr
  117. +5 −5 src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr
  118. +3 −3 src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr
  119. +10 −10 src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr
  120. +8 −8 src/test/ui/borrowck/borrowck-move-out-from-array.stderr
  121. +4 −4 src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.stderr
  122. +4 −4 src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr
  123. +1 −1 src/test/ui/borrowck/borrowck-vec-pattern-move-tail.stderr
  124. +1 −1 src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr
  125. +0 −1 src/test/ui/closures/issue-52437.rs
  126. +2 −11 src/test/ui/closures/issue-52437.stderr
  127. +1 −1 src/test/ui/generic-associated-types/missing-bounds.fixed
  128. +2 −2 src/test/ui/generic-associated-types/missing-bounds.stderr
  129. +2 −1 src/test/ui/issues/issue-47511.stderr
  130. +0 −3 src/test/ui/issues/issue-66706.rs
  131. +5 −30 src/test/ui/issues/issue-66706.stderr
  132. +2 −2 src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr
  133. +1 −1 src/test/ui/layout/zero-sized-array-enum-niche.stderr
  134. +2 −2 src/test/ui/moves/move-out-of-array-ref.stderr
  135. +4 −4 src/test/ui/moves/move-out-of-slice-2.stderr
  136. +1 −1 src/test/ui/nll/issue-51244.stderr
  137. +10 −0 src/test/ui/parser/issue-101477-enum.fixed
  138. +10 −0 src/test/ui/parser/issue-101477-enum.rs
  139. +14 −0 src/test/ui/parser/issue-101477-enum.stderr
  140. +6 −0 src/test/ui/parser/issue-101477-let.fixed
  141. +6 −0 src/test/ui/parser/issue-101477-let.rs
  142. +8 −0 src/test/ui/parser/issue-101477-let.stderr
  143. +4 −6 ...test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr
  144. +2 −3 src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr
  145. +14 −20 src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr
  146. +12 −18 src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr
  147. +14 −26 src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr
  148. +20 −29 src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr
  149. +17 −25 src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
  150. +13 −19 src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr
  151. +2 −3 src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr
  152. +1 −1 src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr
  153. +1 −1 src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.stderr
  154. +3 −3 src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
  155. +1 −0 src/test/ui/stats/hir-stats.rs
  156. +56 −55 src/test/ui/stats/hir-stats.stderr
  157. +79 −0 src/test/ui/structs-enums/type-sizes.rs
  158. +1 −1 src/test/ui/suggestions/issue-97677.fixed
  159. +2 −2 src/test/ui/suggestions/issue-97677.stderr
  160. +12 −0 src/test/ui/suggestions/restrict-type-not-param.rs
  161. +26 −0 src/test/ui/suggestions/restrict-type-not-param.stderr
  162. +2 −2 src/test/ui/traits/resolution-in-overloaded-op.stderr
  163. +20 −4 src/test/ui/type-alias-impl-trait/constrain_inputs.rs
  164. +58 −0 src/test/ui/type-alias-impl-trait/constrain_inputs.stderr
  165. +31 −0 src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.rs
  166. +9 −0 src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr
  167. +2 −2 src/test/ui/typeck/assign-non-lval-derefmut.stderr
  168. +2 −2 src/test/ui/typeck/assign-non-lval-mut-ref.stderr
  169. +4 −2 src/tools/clippy/clippy_dev/src/new_lint.rs
  170. +1 −1 src/tools/clippy/clippy_lints/src/default.rs
  171. +2 −2 src/tools/clippy/clippy_lints/src/derive.rs
  172. +3 −1 src/tools/clippy/clippy_lints/src/equatable_if_let.rs
  173. +207 −207 src/tools/clippy/clippy_lints/src/lib.rs
  174. +2 −2 src/tools/clippy/clippy_lints/src/matches/match_same_arms.rs
  175. +2 −0 src/tools/clippy/clippy_lints/src/matches/single_match.rs
  176. +2 −1 src/tools/clippy/clippy_lints/src/question_mark.rs
  177. +4 −2 src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs
  178. +1 −1 src/tools/clippy/clippy_utils/src/hir_utils.rs
  179. +2 −1 src/tools/clippy/clippy_utils/src/lib.rs
  180. +15 −3 src/tools/compiletest/src/header.rs
  181. +7 −5 src/tools/lld-wrapper/src/main.rs
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -3958,6 +3958,7 @@ dependencies = [
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_type_ir",
"smallvec",
"thin-vec",
"tracing",
3 changes: 2 additions & 1 deletion compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
@@ -3075,7 +3075,8 @@ mod size_asserts {
static_assert_size!(Block, 48);
static_assert_size!(Expr, 104);
static_assert_size!(ExprKind, 72);
static_assert_size!(Fn, 192);
#[cfg(not(bootstrap))]
static_assert_size!(Fn, 184);
static_assert_size!(ForeignItem, 96);
static_assert_size!(ForeignItemKind, 24);
static_assert_size!(GenericArg, 24);
74 changes: 39 additions & 35 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
@@ -849,21 +849,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
(body_id, generator_option)
});

let bound_generic_params = self.lower_lifetime_binder(closure_id, generic_params);
// Lower outside new scope to preserve `is_in_loop_condition`.
let fn_decl = self.lower_fn_decl(decl, None, FnDeclKind::Closure, None);

let c = self.arena.alloc(hir::Closure {
binder: binder_clause,
capture_clause,
bound_generic_params,
fn_decl,
body: body_id,
fn_decl_span: self.lower_span(fn_decl_span),
movability: generator_option,
});
self.lower_lifetime_binder(closure_id, generic_params, |lctx, bound_generic_params| {
// Lower outside new scope to preserve `is_in_loop_condition`.
let fn_decl = lctx.lower_fn_decl(decl, None, FnDeclKind::Closure, None);

let c = lctx.arena.alloc(hir::Closure {
binder: binder_clause,
capture_clause,
bound_generic_params,
fn_decl,
body: body_id,
fn_decl_span: lctx.lower_span(fn_decl_span),
movability: generator_option,
});

hir::ExprKind::Closure(c)
hir::ExprKind::Closure(c)
})
}

fn generator_movability_for_fn(
@@ -950,23 +951,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
body_id
});

let bound_generic_params = self.lower_lifetime_binder(closure_id, generic_params);

// We need to lower the declaration outside the new scope, because we
// have to conserve the state of being inside a loop condition for the
// closure argument types.
let fn_decl = self.lower_fn_decl(&outer_decl, None, FnDeclKind::Closure, None);

let c = self.arena.alloc(hir::Closure {
binder: binder_clause,
capture_clause,
bound_generic_params,
fn_decl,
body,
fn_decl_span: self.lower_span(fn_decl_span),
movability: None,
});
hir::ExprKind::Closure(c)
self.lower_lifetime_binder(closure_id, generic_params, |lctx, bound_generic_params| {
// We need to lower the declaration outside the new scope, because we
// have to conserve the state of being inside a loop condition for the
// closure argument types.
let fn_decl = lctx.lower_fn_decl(&outer_decl, None, FnDeclKind::Closure, None);

let c = lctx.arena.alloc(hir::Closure {
binder: binder_clause,
capture_clause,
bound_generic_params,
fn_decl,
body,
fn_decl_span: lctx.lower_span(fn_decl_span),
movability: None,
});
hir::ExprKind::Closure(c)
})
}

/// Destructure the LHS of complex assignments.
@@ -1128,8 +1129,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
);
// Destructure like a tuple struct.
let tuple_struct_pat =
hir::PatKind::TupleStruct(qpath, pats, rest.map(|r| r.0));
let tuple_struct_pat = hir::PatKind::TupleStruct(
qpath,
pats,
hir::DotDotPos::new(rest.map(|r| r.0)),
);
return self.pat_without_dbm(lhs.span, tuple_struct_pat);
}
}
@@ -1184,13 +1188,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
ExprKind::Tup(elements) => {
let (pats, rest) =
self.destructure_sequence(elements, "tuple", eq_sign_span, assignments);
let tuple_pat = hir::PatKind::Tuple(pats, rest.map(|r| r.0));
let tuple_pat = hir::PatKind::Tuple(pats, hir::DotDotPos::new(rest.map(|r| r.0)));
return self.pat_without_dbm(lhs.span, tuple_pat);
}
ExprKind::Paren(e) => {
// We special-case `(..)` for consistency with patterns.
if let ExprKind::Range(None, None, RangeLimits::HalfOpen) = e.kind {
let tuple_pat = hir::PatKind::Tuple(&[], Some(0));
let tuple_pat = hir::PatKind::Tuple(&[], hir::DotDotPos::new(Some(0)));
return self.pat_without_dbm(lhs.span, tuple_pat);
} else {
return self.destructure_assign_mut(e, eq_sign_span, assignments);
74 changes: 45 additions & 29 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
@@ -810,23 +810,31 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
/// name resolver owing to lifetime elision; this also populates the resolver's node-id->def-id
/// map, so that later calls to `opt_node_id_to_def_id` that refer to these extra lifetime
/// parameters will be successful.
#[instrument(level = "debug", skip(self))]
#[instrument(level = "debug", skip(self, in_binder))]
#[inline]
fn lower_lifetime_binder(
fn lower_lifetime_binder<R>(
&mut self,
binder: NodeId,
generic_params: &[GenericParam],
) -> &'hir [hir::GenericParam<'hir>] {
let mut generic_params: Vec<_> = self.lower_generic_params_mut(generic_params).collect();
in_binder: impl FnOnce(&mut Self, &'hir [hir::GenericParam<'hir>]) -> R,
) -> R {
let extra_lifetimes = self.resolver.take_extra_lifetime_params(binder);
debug!(?extra_lifetimes);
generic_params.extend(extra_lifetimes.into_iter().filter_map(|(ident, node_id, res)| {
self.lifetime_res_to_generic_param(ident, node_id, res)
}));
let extra_lifetimes: Vec<_> = extra_lifetimes
.into_iter()
.filter_map(|(ident, node_id, res)| {
self.lifetime_res_to_generic_param(ident, node_id, res)
})
.collect();

let generic_params: Vec<_> = self
.lower_generic_params_mut(generic_params)
.chain(extra_lifetimes.into_iter())
.collect();
let generic_params = self.arena.alloc_from_iter(generic_params);
debug!(?generic_params);

generic_params
in_binder(self, generic_params)
}

fn with_dyn_type_scope<T>(&mut self, in_scope: bool, f: impl FnOnce(&mut Self) -> T) -> T {
@@ -1196,7 +1204,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let lifetime_bound = this.elided_dyn_bound(t.span);
(bounds, lifetime_bound)
});
let kind = hir::TyKind::TraitObject(bounds, lifetime_bound, TraitObjectSyntax::None);
let kind = hir::TyKind::TraitObject(bounds, &lifetime_bound, TraitObjectSyntax::None);
return hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.next_id() };
}

@@ -1236,14 +1244,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::TyKind::Rptr(lifetime, self.lower_mt(mt, itctx))
}
TyKind::BareFn(ref f) => {
let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
hir::TyKind::BareFn(self.arena.alloc(hir::BareFnTy {
generic_params,
unsafety: self.lower_unsafety(f.unsafety),
abi: self.lower_extern(f.ext),
decl: self.lower_fn_decl(&f.decl, None, FnDeclKind::Pointer, None),
param_names: self.lower_fn_params_to_names(&f.decl),
}))
self.lower_lifetime_binder(t.id, &f.generic_params, |lctx, generic_params| {
hir::TyKind::BareFn(lctx.arena.alloc(hir::BareFnTy {
generic_params,
unsafety: lctx.lower_unsafety(f.unsafety),
abi: lctx.lower_extern(f.ext),
decl: lctx.lower_fn_decl(&f.decl, None, FnDeclKind::Pointer, None),
param_names: lctx.lower_fn_params_to_names(&f.decl),
}))
})
}
TyKind::Never => hir::TyKind::Never,
TyKind::Tup(ref tys) => hir::TyKind::Tup(
@@ -1934,8 +1943,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let res = res.unwrap_or(
self.resolver.get_lifetime_res(lifetime.id).unwrap_or(LifetimeRes::Error),
);
let l = self.new_named_lifetime_with_res(id, span, ident, res);
hir::GenericArg::Lifetime(l)
hir::GenericArg::Lifetime(self.new_named_lifetime_with_res(id, span, ident, res))
},
));

@@ -2004,7 +2012,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}

fn lower_lifetime(&mut self, l: &Lifetime) -> hir::Lifetime {
fn lower_lifetime(&mut self, l: &Lifetime) -> &'hir hir::Lifetime {
let span = self.lower_span(l.ident.span);
let ident = self.lower_ident(l.ident);
self.new_named_lifetime(l.id, l.id, span, ident)
@@ -2017,7 +2025,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
span: Span,
ident: Ident,
res: LifetimeRes,
) -> hir::Lifetime {
) -> &'hir hir::Lifetime {
let name = match res {
LifetimeRes::Param { param, .. } => {
let p_name = ParamName::Plain(ident);
@@ -2038,7 +2046,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
};

debug!(?name);
hir::Lifetime { hir_id: self.lower_node_id(id), span: self.lower_span(span), name }
self.arena.alloc(hir::Lifetime {
hir_id: self.lower_node_id(id),
span: self.lower_span(span),
name,
})
}

#[instrument(level = "debug", skip(self))]
@@ -2048,7 +2060,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
new_id: NodeId,
span: Span,
ident: Ident,
) -> hir::Lifetime {
) -> &'hir hir::Lifetime {
let res = self.resolver.get_lifetime_res(id).unwrap_or(LifetimeRes::Error);
self.new_named_lifetime_with_res(new_id, span, ident, res)
}
@@ -2140,10 +2152,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
p: &PolyTraitRef,
itctx: &mut ImplTraitContext,
) -> hir::PolyTraitRef<'hir> {
let bound_generic_params =
self.lower_lifetime_binder(p.trait_ref.ref_id, &p.bound_generic_params);
let trait_ref = self.lower_trait_ref(&p.trait_ref, itctx);
hir::PolyTraitRef { bound_generic_params, trait_ref, span: self.lower_span(p.span) }
self.lower_lifetime_binder(
p.trait_ref.ref_id,
&p.bound_generic_params,
|lctx, bound_generic_params| {
let trait_ref = lctx.lower_trait_ref(&p.trait_ref, itctx);
hir::PolyTraitRef { bound_generic_params, trait_ref, span: lctx.lower_span(p.span) }
},
)
}

fn lower_mt(&mut self, mt: &MutTy, itctx: &mut ImplTraitContext) -> hir::MutTy<'hir> {
@@ -2462,14 +2478,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
/// bound, like the bound in `Box<dyn Debug>`. This method is not invoked
/// when the bound is written, even if it is written with `'_` like in
/// `Box<dyn Debug + '_>`. In those cases, `lower_lifetime` is invoked.
fn elided_dyn_bound(&mut self, span: Span) -> hir::Lifetime {
fn elided_dyn_bound(&mut self, span: Span) -> &'hir hir::Lifetime {
let r = hir::Lifetime {
hir_id: self.next_id(),
span: self.lower_span(span),
name: hir::LifetimeName::ImplicitObjectLifetimeDefault,
};
debug!("elided_dyn_bound: r={:?}", r);
r
self.arena.alloc(r)
}
}

4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/pat.rs
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&mut self,
pats: &[P<Pat>],
ctx: &str,
) -> (&'hir [hir::Pat<'hir>], Option<usize>) {
) -> (&'hir [hir::Pat<'hir>], hir::DotDotPos) {
let mut elems = Vec::with_capacity(pats.len());
let mut rest = None;

@@ -160,7 +160,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}

(self.arena.alloc_from_iter(elems), rest.map(|(ddpos, _)| ddpos))
(self.arena.alloc_from_iter(elems), hir::DotDotPos::new(rest.map(|(ddpos, _)| ddpos)))
}

/// Lower a slice pattern of form `[pat_0, ..., pat_n]` into
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
@@ -135,7 +135,6 @@ pub struct RegionInferenceContext<'tcx> {
/// adds a new lower bound to the SCC it is analyzing: so you wind up
/// with `'R: 'O` where `'R` is the pick-region and `'O` is the
/// minimal viable option.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub(crate) struct AppliedMemberConstraint {
/// The SCC that was affected. (The "member region".)
///
11 changes: 6 additions & 5 deletions compiler/rustc_codegen_cranelift/src/discriminant.rs
Original file line number Diff line number Diff line change
@@ -42,10 +42,10 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
Variants::Multiple {
tag: _,
tag_field,
tag_encoding: TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start },
tag_encoding: TagEncoding::Niche { untagged_variant, ref niche_variants, niche_start },
variants: _,
} => {
if variant_index != dataful_variant {
if variant_index != untagged_variant {
let niche = place.place_field(fx, mir::Field::new(tag_field));
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
let niche_value = ty::ScalarInt::try_from_uint(
@@ -113,7 +113,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
let res = CValue::by_val(val, dest_layout);
dest.write_cvalue(fx, res);
}
TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start } => {
TagEncoding::Niche { untagged_variant, ref niche_variants, niche_start } => {
// Rebase from niche values to discriminants, and check
// whether the result is in range for the niche variants.

@@ -169,8 +169,9 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
fx.bcx.ins().iadd_imm(relative_discr, i64::from(niche_variants.start().as_u32()))
};

let dataful_variant = fx.bcx.ins().iconst(cast_to, i64::from(dataful_variant.as_u32()));
let discr = fx.bcx.ins().select(is_niche, niche_discr, dataful_variant);
let untagged_variant =
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32()));
let discr = fx.bcx.ins().select(is_niche, niche_discr, untagged_variant);
let res = CValue::by_val(discr, dest_layout);
dest.write_cvalue(fx, res);
}
Loading