diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-09-01 03:58:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-01 03:58:04 +0200 |
| commit | 07d5c250be85d3d8532369cb2aec8e15213ac956 (patch) | |
| tree | 5fb33360158bbf8aadab57b9295d8da087f13349 /compiler/rustc_ast_lowering | |
| parent | 1063c0dd37bda8913ffc5548735ffeea14eb6123 (diff) | |
| parent | f68f66538a88a377b3510723950e97373796c5c8 (diff) | |
| download | rust-07d5c250be85d3d8532369cb2aec8e15213ac956.tar.gz rust-07d5c250be85d3d8532369cb2aec8e15213ac956.zip | |
Rollup merge of #129493 - cjgillot:early-opaque-def, r=petrochenkov
Create opaque definitions in resolver. Implementing https://github.com/rust-lang/rust/issues/129023#issuecomment-2306079532 That was easier than I expected. r? `@petrochenkov`
Diffstat (limited to 'compiler/rustc_ast_lowering')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 9b46e7c46b6..754fbae4d02 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -45,7 +45,6 @@ use std::collections::hash_map::Entry; use rustc_ast::node_id::NodeMap; use rustc_ast::ptr::P; use rustc_ast::{self as ast, *}; -use rustc_ast_pretty::pprust; use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexSet; @@ -1399,24 +1398,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { self.tcx.dcx().emit_err(errors::NoPreciseCapturesOnApit { span }); } - let span = t.span; - - // HACK: pprust breaks strings with newlines when the type - // gets too long. We don't want these to show up in compiler - // output or built artifacts, so replace them here... - // Perhaps we should instead format APITs more robustly. - let ident = Ident::from_str_and_span( - &pprust::ty_to_string(t).replace('\n', " "), - span, - ); - - self.create_def( - self.current_hir_id_owner.def_id, // FIXME: should this use self.current_def_id_parent? - *def_node_id, - ident.name, - DefKind::TyParam, - span, - ); + let def_id = self.local_def_id(*def_node_id); + let name = self.tcx.item_name(def_id.to_def_id()); + let ident = Ident::new(name, span); let (param, bounds, path) = self.lower_universal_param_and_bounds( *def_node_id, span, @@ -1618,13 +1602,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { opaque_ty_span: Span, lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [hir::GenericBound<'hir>], ) -> hir::TyKind<'hir> { - let opaque_ty_def_id = self.create_def( - self.current_hir_id_owner.def_id, // FIXME: should this use self.current_def_id_parent? - opaque_ty_node_id, - kw::Empty, - DefKind::OpaqueTy, - opaque_ty_span, - ); + let opaque_ty_def_id = self.local_def_id(opaque_ty_node_id); debug!(?opaque_ty_def_id); // Map from captured (old) lifetime to synthetic (new) lifetime. |
