Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #138177

Merged
merged 50 commits into from
Mar 7, 2025
Merged
Changes from 3 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a54bfcf
Use safe FFI for various functions in codegen_llvm
oli-obk Feb 21, 2025
d4379d2
Remove an unnecessary lifetime
oli-obk Feb 24, 2025
bfd88ce
Avoid some duplication between SimpleCx and CodegenCx
oli-obk Feb 24, 2025
75356b7
Generalize `BackendTypes` over `GenericCx`
oli-obk Feb 24, 2025
840e31b
Generalize BaseTypeCodegenMethods
oli-obk Feb 24, 2025
396baa7
Make allocator shim creation mostly use safe code
oli-obk Feb 24, 2025
29440b8
Remove an unused lifetime param
oli-obk Feb 24, 2025
241c83f
Deduplicate more functions between `SimpleCx` and `CodegenCx`
oli-obk Feb 24, 2025
f16f64b
Remove inherent function that has a trait method duplicate of a commo…
oli-obk Feb 24, 2025
3565603
Use a safe wrapper around an LLVM FFI function
oli-obk Feb 24, 2025
553828c
Mark more LLVM FFI as safe
oli-obk Feb 24, 2025
d7ed32b
Suggest struct or union to add generic that impls trait
xizheyin Mar 5, 2025
7e199b1
Add ui test: suggest-struct-or-union-add-generic-impl-trait.rs
xizheyin Mar 6, 2025
0cf8dbc
Add ergonomic_clones feature flag
spastorino Oct 29, 2024
05c5164
Implement .use keyword as an alias of clone
spastorino Oct 2, 2024
81a926c
Use closure parse code
spastorino Nov 1, 2024
57cb498
Generate the right MIR for by use closures
spastorino Dec 17, 2024
dcdfd55
Add UseCloned trait related code
spastorino Dec 11, 2024
60b6470
Fix clippy
spastorino Dec 26, 2024
8c456cb
Fix rustfmt
spastorino Dec 27, 2024
4cbca77
Separate closures, async and dotuse tests in directories
spastorino Dec 27, 2024
38b4746
Support nested use closures
spastorino Feb 10, 2025
7c17bf8
Add tests
spastorino Feb 10, 2025
292aa87
Fix use closure parsing error message
spastorino Feb 11, 2025
6eb6ff6
Allow to mutate use captures
spastorino Feb 14, 2025
aa58439
Fail gracefully if mutating on a use closure and the closure it not d…
spastorino Feb 14, 2025
18d689c
Add more tests
spastorino Feb 14, 2025
edcbc9b
Add a code example as comment in init_capture_kind_for_place
spastorino Feb 20, 2025
b43b700
Account for UseCloned on expr_use_visitor
spastorino Feb 20, 2025
2f48fce
Change feature flag error to be ergonomic clones are experimental
spastorino Feb 21, 2025
4e6407a
Give a better error message on async use in edition 2015
spastorino Feb 21, 2025
65d65e5
Parse and allow const use closures
spastorino Feb 21, 2025
1702c00
Make captures in ByUse context be always ty::UpvarCapture::ByUse
spastorino Feb 21, 2025
a68db7e
Add examples in stdlib demonstrating the use syntax
spastorino Feb 24, 2025
42b8b13
Add some code comments
spastorino Mar 6, 2025
5a6d00c
Add allow(incomplete_features) to alloc
spastorino Mar 6, 2025
d7104dc
Make feature flag incomplete
spastorino Mar 6, 2025
d2bde63
Add slight variation to feature-gate ergonomic clones test
spastorino Mar 7, 2025
69aafd2
tests: fix some typos in comment
tcpdumppy Mar 7, 2025
872ac73
Move `visit_id` calls.
nnethercote Mar 7, 2025
8a98124
Factor out repeated `visit_id` calls.
nnethercote Mar 7, 2025
e7bea57
Fix a typo in the crashtest output.
nnethercote Mar 4, 2025
7943932
Pass `Option<Symbol>` to `def_path_data`/`create_def` methods.
nnethercote Mar 4, 2025
af92a33
Make synthetic RPITIT assoc ty name handling more rigorous.
nnethercote Mar 4, 2025
f5a143f
Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=niko…
matthiaskrgr Mar 7, 2025
63c548d
Rollup merge of #137549 - oli-obk:llvm-ffi, r=davidtwco
matthiaskrgr Mar 7, 2025
0defc4f
Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorino
matthiaskrgr Mar 7, 2025
e70adad
Rollup merge of #138042 - xizheyin:issue-135759, r=nnethercote
matthiaskrgr Mar 7, 2025
282a37f
Rollup merge of #138141 - tcpdumppy:master, r=compiler-errors
matthiaskrgr Mar 7, 2025
b772fa6
Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id,…
matthiaskrgr Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 8 additions & 30 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
@@ -316,8 +316,8 @@ pub trait Visitor<'v>: Sized {
fn visit_ident(&mut self, ident: Ident) -> Self::Result {
walk_ident(self, ident)
}
fn visit_mod(&mut self, m: &'v Mod<'v>, _s: Span, n: HirId) -> Self::Result {
walk_mod(self, m, n)
fn visit_mod(&mut self, m: &'v Mod<'v>, _s: Span, _n: HirId) -> Self::Result {
walk_mod(self, m)
}
fn visit_foreign_item(&mut self, i: &'v ForeignItem<'v>) -> Self::Result {
walk_foreign_item(self, i)
@@ -464,8 +464,8 @@ pub trait Visitor<'v>: Sized {
fn visit_field_def(&mut self, s: &'v FieldDef<'v>) -> Self::Result {
walk_field_def(self, s)
}
fn visit_enum_def(&mut self, enum_definition: &'v EnumDef<'v>, item_id: HirId) -> Self::Result {
walk_enum_def(self, enum_definition, item_id)
fn visit_enum_def(&mut self, enum_definition: &'v EnumDef<'v>) -> Self::Result {
walk_enum_def(self, enum_definition)
}
fn visit_variant(&mut self, v: &'v Variant<'v>) -> Self::Result {
walk_variant(self, v)
@@ -532,28 +532,25 @@ pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) ->
}

pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::Result {
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_ident(item.ident));
match item.kind {
ItemKind::ExternCrate(orig_name) => {
try_visit!(visitor.visit_id(item.hir_id()));
visit_opt!(visitor, visit_name, orig_name);
}
ItemKind::Use(ref path, _) => {
try_visit!(visitor.visit_use(path, item.hir_id()));
}
ItemKind::Static(ref typ, _, body) => {
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_ty_unambig(typ));
try_visit!(visitor.visit_nested_body(body));
}
ItemKind::Const(ref typ, ref generics, body) => {
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_ty_unambig(typ));
try_visit!(visitor.visit_generics(generics));
try_visit!(visitor.visit_nested_body(body));
}
ItemKind::Fn { sig, generics, body: body_id, .. } => {
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_fn(
FnKind::ItemFn(item.ident, generics, sig.header),
sig.decl,
@@ -562,34 +559,27 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
item.owner_id.def_id,
));
}
ItemKind::Macro(..) => {
try_visit!(visitor.visit_id(item.hir_id()));
}
ItemKind::Macro(..) => {}
ItemKind::Mod(ref module) => {
// `visit_mod()` takes care of visiting the `Item`'s `HirId`.
try_visit!(visitor.visit_mod(module, item.span, item.hir_id()));
}
ItemKind::ForeignMod { abi: _, items } => {
try_visit!(visitor.visit_id(item.hir_id()));
walk_list!(visitor, visit_foreign_item_ref, items);
}
ItemKind::GlobalAsm { asm: _, fake_body } => {
try_visit!(visitor.visit_id(item.hir_id()));
// Visit the fake body, which contains the asm statement.
// Therefore we should not visit the asm statement again
// outside of the body, or some visitors won't have their
// typeck results set correctly.
try_visit!(visitor.visit_nested_body(fake_body));
}
ItemKind::TyAlias(ref ty, ref generics) => {
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_ty_unambig(ty));
try_visit!(visitor.visit_generics(generics));
}
ItemKind::Enum(ref enum_definition, ref generics) => {
try_visit!(visitor.visit_generics(generics));
// `visit_enum_def()` takes care of visiting the `Item`'s `HirId`.
try_visit!(visitor.visit_enum_def(enum_definition, item.hir_id()));
try_visit!(visitor.visit_enum_def(enum_definition));
}
ItemKind::Impl(Impl {
constness: _,
@@ -602,7 +592,6 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
self_ty,
items,
}) => {
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_generics(generics));
visit_opt!(visitor, visit_trait_ref, of_trait);
try_visit!(visitor.visit_ty_unambig(self_ty));
@@ -611,17 +600,14 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
ItemKind::Struct(ref struct_definition, ref generics)
| ItemKind::Union(ref struct_definition, ref generics) => {
try_visit!(visitor.visit_generics(generics));
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_variant_data(struct_definition));
}
ItemKind::Trait(.., ref generics, bounds, trait_item_refs) => {
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_generics(generics));
walk_list!(visitor, visit_param_bound, bounds);
walk_list!(visitor, visit_trait_item_ref, trait_item_refs);
}
ItemKind::TraitAlias(ref generics, bounds) => {
try_visit!(visitor.visit_id(item.hir_id()));
try_visit!(visitor.visit_generics(generics));
walk_list!(visitor, visit_param_bound, bounds);
}
@@ -638,12 +624,7 @@ pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, ident: Ident) -> V::Resul
visitor.visit_name(ident.name)
}

pub fn walk_mod<'v, V: Visitor<'v>>(
visitor: &mut V,
module: &'v Mod<'v>,
mod_hir_id: HirId,
) -> V::Result {
try_visit!(visitor.visit_id(mod_hir_id));
pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod<'v>) -> V::Result {
walk_list!(visitor, visit_nested_item, module.item_ids.iter().copied());
V::Result::output()
}
@@ -1148,7 +1129,6 @@ pub fn walk_use<'v, V: Visitor<'v>>(
path: &'v UsePath<'v>,
hir_id: HirId,
) -> V::Result {
try_visit!(visitor.visit_id(hir_id));
let UsePath { segments, ref res, span } = *path;
for &res in res {
try_visit!(visitor.visit_path(&Path { segments, res, span }, hir_id));
@@ -1329,9 +1309,7 @@ pub fn walk_field_def<'v, V: Visitor<'v>>(
pub fn walk_enum_def<'v, V: Visitor<'v>>(
visitor: &mut V,
enum_definition: &'v EnumDef<'v>,
item_id: HirId,
) -> V::Result {
try_visit!(visitor.visit_id(item_id));
walk_list!(visitor, visit_variant, enum_definition.variants);
V::Result::output()
}
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/late.rs
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {

fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, n: HirId) {
lint_callback!(self, check_mod, m, n);
hir_visit::walk_mod(self, m, n);
hir_visit::walk_mod(self, m);
}
}

2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/hir/map.rs
Original file line number Diff line number Diff line change
@@ -1356,7 +1356,7 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
self.submodules.push(item.owner_id);
// A module collector does not recurse inside nested modules.
if self.crate_collector {
intravisit::walk_mod(self, module, item.hir_id());
intravisit::walk_mod(self, module);
}
} else {
intravisit::walk_item(self, item)
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/input_stats.rs
Original file line number Diff line number Diff line change
@@ -255,9 +255,9 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
hir_visit::walk_body(self, b);
}

fn visit_mod(&mut self, m: &'v hir::Mod<'v>, _s: Span, n: HirId) {
fn visit_mod(&mut self, m: &'v hir::Mod<'v>, _s: Span, _n: HirId) {
self.record("Mod", None, m);
hir_visit::walk_mod(self, m, n)
hir_visit::walk_mod(self, m)
}

fn visit_foreign_item(&mut self, i: &'v hir::ForeignItem<'v>) {
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/span_map.rs
Original file line number Diff line number Diff line change
@@ -251,7 +251,7 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
// If it's a "mod foo {}", we want to look to its documentation page.
self.extract_info_from_hir_id(id);
}
intravisit::walk_mod(self, m, id);
intravisit::walk_mod(self, m);
}

fn visit_expr(&mut self, expr: &'tcx rustc_hir::Expr<'tcx>) {