Skip to content

Commit 80aa442

Browse files
authored
Unrolled build for rust-lang#128226
Rollup merge of rust-lang#128226 - oli-obk:option_vs_empty_slice, r=petrochenkov Remove redundant option that was just encoding that a slice was empty There is already a sanity check ensuring we don't put empty attribute lists into the HIR: https://github.com/rust-lang/rust/blob/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/compiler/rustc_ast_lowering/src/lib.rs#L661-L667
2 parents 7c2012d + 33b98bf commit 80aa442

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/rustc_ast_lowering/src/item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
172172
id: NodeId,
173173
hir_id: hir::HirId,
174174
ident: &mut Ident,
175-
attrs: Option<&'hir [Attribute]>,
175+
attrs: &'hir [Attribute],
176176
vis_span: Span,
177177
i: &ItemKind,
178178
) -> hir::ItemKind<'hir> {
@@ -488,7 +488,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
488488
id: NodeId,
489489
vis_span: Span,
490490
ident: &mut Ident,
491-
attrs: Option<&'hir [Attribute]>,
491+
attrs: &'hir [Attribute],
492492
) -> hir::ItemKind<'hir> {
493493
let path = &tree.prefix;
494494
let segments = prefix.segments.iter().chain(path.segments.iter()).cloned().collect();
@@ -566,7 +566,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
566566
// `ItemLocalId` and the new owner. (See `lower_node_id`)
567567
let kind =
568568
this.lower_use_tree(use_tree, &prefix, id, vis_span, &mut ident, attrs);
569-
if let Some(attrs) = attrs {
569+
if !attrs.is_empty() {
570570
this.attrs.insert(hir::ItemLocalId::ZERO, attrs);
571571
}
572572

compiler/rustc_ast_lowering/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -913,15 +913,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
913913
ret
914914
}
915915

916-
fn lower_attrs(&mut self, id: HirId, attrs: &[Attribute]) -> Option<&'hir [Attribute]> {
916+
fn lower_attrs(&mut self, id: HirId, attrs: &[Attribute]) -> &'hir [Attribute] {
917917
if attrs.is_empty() {
918-
None
918+
&[]
919919
} else {
920920
debug_assert_eq!(id.owner, self.current_hir_id_owner);
921921
let ret = self.arena.alloc_from_iter(attrs.iter().map(|a| self.lower_attr(a)));
922922
debug_assert!(!ret.is_empty());
923923
self.attrs.insert(id.local_id, ret);
924-
Some(ret)
924+
ret
925925
}
926926
}
927927

0 commit comments

Comments
 (0)