Skip to content

Commit ef76606

Browse files
committed
Auto merge of #156190 - JonathanBrouwer:rollup-db0KRf1, r=JonathanBrouwer
Rollup of 7 pull requests Successful merges: - #156014 (resolve: Catch "cannot reexport" errors from macros 2.0 better) - #156058 (Print HRTB binders before fn qualifiers) - #156172 (Implement a new flag `-Zdisable-fast-paths` in trait solving) - #156184 (Revert "remove `MethodReceiverExpr` special-casing") - #155957 (Revert const hacks and use const closures in std) - #156127 (Update `askama` version to `0.16.0`) - #156183 (Remove duplicate debug assert)
2 parents 4feb722 + e20ac1b commit ef76606

40 files changed

Lines changed: 369 additions & 193 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
174174

175175
[[package]]
176176
name = "askama"
177-
version = "0.15.4"
177+
version = "0.16.0"
178178
source = "registry+https://github.com/rust-lang/crates.io-index"
179-
checksum = "08e1676b346cadfec169374f949d7490fd80a24193d37d2afce0c047cf695e57"
179+
checksum = "f1bf825125edd887a019d0a3a837dcc5499a68b0d034cc3eb594070c3e18addc"
180180
dependencies = [
181181
"askama_macros",
182182
"itoa",
@@ -187,12 +187,13 @@ dependencies = [
187187

188188
[[package]]
189189
name = "askama_derive"
190-
version = "0.15.4"
190+
version = "0.16.0"
191191
source = "registry+https://github.com/rust-lang/crates.io-index"
192-
checksum = "7661ff56517787343f376f75db037426facd7c8d3049cef8911f1e75016f3a37"
192+
checksum = "e1c7065972a130eafa84215f21352ae15b4a7393da48c1f5e103904490736738"
193193
dependencies = [
194194
"askama_parser",
195195
"basic-toml",
196+
"glob",
196197
"memchr",
197198
"proc-macro2",
198199
"quote",
@@ -204,24 +205,24 @@ dependencies = [
204205

205206
[[package]]
206207
name = "askama_macros"
207-
version = "0.15.4"
208+
version = "0.16.0"
208209
source = "registry+https://github.com/rust-lang/crates.io-index"
209-
checksum = "713ee4dbfd1eb719c2dab859465b01fa1d21cb566684614a713a6b7a99a4e47b"
210+
checksum = "0e23b1d2c4bd39a41971f6124cef4cc6fd0540913ecb90919b69ab3bbe44ae1a"
210211
dependencies = [
211212
"askama_derive",
212213
]
213214

214215
[[package]]
215216
name = "askama_parser"
216-
version = "0.15.4"
217+
version = "0.16.0"
217218
source = "registry+https://github.com/rust-lang/crates.io-index"
218-
checksum = "1d62d674238a526418b30c0def480d5beadb9d8964e7f38d635b03bf639c704c"
219+
checksum = "7db09fde9143e7ac4513358fb32ee32847125b63b18ea715afd487956da715da"
219220
dependencies = [
220221
"rustc-hash 2.1.1",
221222
"serde",
222223
"serde_derive",
223224
"unicode-ident",
224-
"winnow 0.7.13",
225+
"winnow 1.0.0",
225226
]
226227

227228
[[package]]
@@ -756,7 +757,7 @@ checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681"
756757
dependencies = [
757758
"serde",
758759
"termcolor",
759-
"unicode-width 0.1.14",
760+
"unicode-width 0.2.2",
760761
]
761762

762763
[[package]]
@@ -6625,6 +6626,9 @@ name = "winnow"
66256626
version = "1.0.0"
66266627
source = "registry+https://github.com/rust-lang/crates.io-index"
66276628
checksum = "a90e88e4667264a994d34e6d1ab2d26d398dcdca8b7f52bec8668957517fc7d8"
6629+
dependencies = [
6630+
"memchr",
6631+
]
66286632

66296633
[[package]]
66306634
name = "winsplit"

compiler/rustc_expand/src/base.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,6 @@ pub trait MacResult {
423423
None
424424
}
425425

426-
fn make_method_receiver_expr(self: Box<Self>) -> Option<Box<ast::Expr>> {
427-
self.make_expr()
428-
}
429-
430426
/// Creates zero or more items.
431427
fn make_items(self: Box<Self>) -> Option<SmallVec<[Box<ast::Item>; 1]>> {
432428
None

compiler/rustc_expand/src/expand.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,23 @@ macro_rules! ast_fragments {
6868
/// Can also serve as an input and intermediate result for macro expansion operations.
6969
pub enum AstFragment {
7070
OptExpr(Option<Box<ast::Expr>>),
71+
MethodReceiverExpr(Box<ast::Expr>),
7172
$($Kind($AstTy),)*
7273
}
7374

7475
/// "Discriminant" of an AST fragment.
7576
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
7677
pub enum AstFragmentKind {
7778
OptExpr,
79+
MethodReceiverExpr,
7880
$($Kind,)*
7981
}
8082

8183
impl AstFragmentKind {
8284
pub fn name(self) -> &'static str {
8385
match self {
8486
AstFragmentKind::OptExpr => "expression",
87+
AstFragmentKind::MethodReceiverExpr => "expression",
8588
$(AstFragmentKind::$Kind => $kind_name,)*
8689
}
8790
}
@@ -90,6 +93,8 @@ macro_rules! ast_fragments {
9093
match self {
9194
AstFragmentKind::OptExpr =>
9295
result.make_expr().map(Some).map(AstFragment::OptExpr),
96+
AstFragmentKind::MethodReceiverExpr =>
97+
result.make_expr().map(AstFragment::MethodReceiverExpr),
9398
$(AstFragmentKind::$Kind => result.$make_ast().map(AstFragment::$Kind),)*
9499
}
95100
}
@@ -116,6 +121,13 @@ macro_rules! ast_fragments {
116121
}
117122
}
118123

124+
pub(crate) fn make_method_receiver_expr(self) -> Box<ast::Expr> {
125+
match self {
126+
AstFragment::MethodReceiverExpr(expr) => expr,
127+
_ => panic!("AstFragment::make_method_receiver_expr called on the wrong kind of fragment"),
128+
}
129+
}
130+
119131
$(pub fn $make_ast(self) -> $AstTy {
120132
match self {
121133
AstFragment::$Kind(ast) => ast,
@@ -134,6 +146,7 @@ macro_rules! ast_fragments {
134146
*opt_expr = vis.filter_map_expr(expr)
135147
}
136148
}
149+
AstFragment::MethodReceiverExpr(expr) => vis.visit_method_receiver_expr(expr),
137150
$($(AstFragment::$Kind(ast) => vis.$visit_ast(ast),)?)*
138151
$($(AstFragment::$Kind(ast) =>
139152
ast.flat_map_in_place(|ast| vis.$flat_map_ast_elt(ast, $($args)*)),)?)*
@@ -144,6 +157,7 @@ macro_rules! ast_fragments {
144157
match self {
145158
AstFragment::OptExpr(Some(expr)) => try_visit!(visitor.visit_expr(expr)),
146159
AstFragment::OptExpr(None) => {}
160+
AstFragment::MethodReceiverExpr(expr) => try_visit!(visitor.visit_method_receiver_expr(expr)),
147161
$($(AstFragment::$Kind(ast) => try_visit!(visitor.$visit_ast(ast)),)?)*
148162
$($(AstFragment::$Kind(ast) => walk_list!(visitor, $visit_ast_elt, &ast[..], $($args)*),)?)*
149163
}
@@ -166,11 +180,6 @@ ast_fragments! {
166180
one fn visit_expr;
167181
fn make_expr;
168182
}
169-
MethodReceiverExpr(Box<ast::Expr>) {
170-
"expression";
171-
one fn visit_method_receiver_expr;
172-
fn make_method_receiver_expr;
173-
}
174183
Pat(Box<ast::Pat>) {
175184
"pattern";
176185
one fn visit_pat;

compiler/rustc_infer/src/infer/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
2222
self.next_trait_solver
2323
}
2424

25+
fn disable_trait_solver_fast_paths(&self) -> bool {
26+
self.disable_trait_solver_fast_paths()
27+
}
28+
2529
fn typing_mode(&self) -> ty::TypingMode<'tcx> {
2630
self.typing_mode()
2731
}

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,11 @@ impl<'tcx> InferCtxt<'tcx> {
640640
self.next_trait_solver
641641
}
642642

643+
#[inline(always)]
644+
pub fn disable_trait_solver_fast_paths(&self) -> bool {
645+
self.tcx.disable_trait_solver_fast_paths()
646+
}
647+
643648
#[inline(always)]
644649
pub fn typing_mode(&self) -> TypingMode<'tcx> {
645650
self.typing_mode

compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,10 @@ impl<'tcx> TyCtxt<'tcx> {
26572657
self.sess.opts.unstable_opts.next_solver.coherence
26582658
}
26592659

2660+
pub fn disable_trait_solver_fast_paths(self) -> bool {
2661+
self.sess.opts.unstable_opts.disable_fast_paths
2662+
}
2663+
26602664
#[allow(rustc::bad_opt_access)]
26612665
pub fn use_typing_mode_borrowck(self) -> bool {
26622666
self.next_trait_solver_globally() || self.sess.opts.unstable_opts.typing_mode_borrowck

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ where
447447
ref sub_roots,
448448
stalled_certainty,
449449
}) = stalled_on
450+
&& !self.delegate.disable_trait_solver_fast_paths()
450451
&& !stalled_vars.iter().any(|value| self.delegate.is_changed_arg(*value))
451452
&& !sub_roots
452453
.iter()
@@ -666,7 +667,10 @@ where
666667
// If this loop did not result in any progress, what's our final certainty.
667668
let mut unchanged_certainty = Some(Certainty::Yes);
668669
for (source, goal, stalled_on) in mem::take(&mut self.nested_goals) {
669-
if let Some(certainty) = self.delegate.compute_goal_fast_path(goal, self.origin_span) {
670+
if !self.delegate.disable_trait_solver_fast_paths()
671+
&& let Some(certainty) =
672+
self.delegate.compute_goal_fast_path(goal, self.origin_span)
673+
{
670674
match certainty {
671675
Certainty::Yes => {}
672676
Certainty::Maybe { .. } => {

compiler/rustc_passes/src/stability.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ fn inherit_const_stability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
5454
match def_kind {
5555
DefKind::AssocFn | DefKind::AssocTy | DefKind::AssocConst { .. } => {
5656
match tcx.def_kind(tcx.local_parent(def_id)) {
57-
DefKind::Impl { .. } => true,
57+
DefKind::Trait | DefKind::Impl { .. } => true,
5858
_ => false,
5959
}
6060
}
61+
DefKind::Closure => true,
6162
_ => false,
6263
}
6364
}

0 commit comments

Comments
 (0)