Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2f6bc5d

Browse files
committedMay 9, 2023
Auto merge of rust-lang#111402 - matthiaskrgr:rollup-28cqfz5, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#97320 (Stabilize const_ptr_read) - rust-lang#110770 (Limit lifetime of format_args!() with inlined args.) - rust-lang#111021 (Move some tests) - rust-lang#111215 (Various changes to name resolution of anon consts) - rust-lang#111242 (support set `rpath` option for each target independently) - rust-lang#111282 (Remove some `assume`s from slice iterators that don't do anything) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3a37c2f + 273fbf4 commit 2f6bc5d

File tree

130 files changed

+983
-686
lines changed

Some content is hidden

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

130 files changed

+983
-686
lines changed
 

‎compiler/rustc_ast/src/ast.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ impl Path {
120120
pub fn is_global(&self) -> bool {
121121
!self.segments.is_empty() && self.segments[0].ident.name == kw::PathRoot
122122
}
123+
124+
/// If this path is a single identifier with no arguments, does not ensure
125+
/// that the path resolves to a const param, the caller should check this.
126+
pub fn is_potential_trivial_const_arg(&self) -> bool {
127+
self.segments.len() == 1 && self.segments[0].args.is_none()
128+
}
123129
}
124130

125131
/// A segment of a path: an identifier, an optional lifetime, and a set of types.
@@ -1154,7 +1160,9 @@ impl Expr {
11541160
///
11551161
/// If this is not the case, name resolution does not resolve `N` when using
11561162
/// `min_const_generics` as more complex expressions are not supported.
1157-
pub fn is_potential_trivial_const_param(&self) -> bool {
1163+
///
1164+
/// Does not ensure that the path resolves to a const param, the caller should check this.
1165+
pub fn is_potential_trivial_const_arg(&self) -> bool {
11581166
let this = if let ExprKind::Block(block, None) = &self.kind
11591167
&& block.stmts.len() == 1
11601168
&& let StmtKind::Expr(expr) = &block.stmts[0].kind
@@ -1165,8 +1173,7 @@ impl Expr {
11651173
};
11661174

11671175
if let ExprKind::Path(None, path) = &this.kind
1168-
&& path.segments.len() == 1
1169-
&& path.segments[0].args.is_none()
1176+
&& path.is_potential_trivial_const_arg()
11701177
{
11711178
true
11721179
} else {

‎compiler/rustc_ast/src/visit.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ pub trait Visitor<'ast>: Sized {
188188
fn visit_variant(&mut self, v: &'ast Variant) {
189189
walk_variant(self, v)
190190
}
191+
fn visit_variant_discr(&mut self, discr: &'ast AnonConst) {
192+
self.visit_anon_const(discr);
193+
}
191194
fn visit_label(&mut self, label: &'ast Label) {
192195
walk_label(self, label)
193196
}
@@ -380,7 +383,7 @@ where
380383
visitor.visit_ident(variant.ident);
381384
visitor.visit_vis(&variant.vis);
382385
visitor.visit_variant_data(&variant.data);
383-
walk_list!(visitor, visit_anon_const, &variant.disr_expr);
386+
walk_list!(visitor, visit_variant_discr, &variant.disr_expr);
384387
walk_list!(visitor, visit_attribute, &variant.attrs);
385388
}
386389

0 commit comments

Comments
 (0)
This repository has been archived.