Skip to content

Commit e91364b

Browse files
committedMar 20, 2023
Auto merge of #109376 - matthiaskrgr:rollup-0aut57k, r=matthiaskrgr
Rollup of 13 pull requests Successful merges: - #109249 (Update names/comments for new return-position impl trait in trait lowering strategy) - #109259 (rustdoc: Fix missing private inlining) - #109269 (rustdoc: cleanup some intermediate allocs) - #109301 (fix: fix ICE in `custom-test-frameworks` feature) - #109319 (Add test for `c_variadic` in rustdoc-json) - #109323 (Ignore files in .gitignore in mir opt check) - #109331 (rustdoc: implement bag semantics for function parameter search) - #109337 (Improve `Iterator::collect_into` documentation) - #109351 (rustdoc: Remove footnote references from doc summary) - #109353 (Fix wrong crate name in custom MIR docs) - #109362 (Split `items` from `-Zmeta-stats` in two.) - #109370 (fix ClashingExternDeclarations lint ICE) - #109375 (rustdoc: Fix improper escaping of deprecation reasons) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9d0eac4 + 1309235 commit e91364b

File tree

31 files changed

+400
-162
lines changed

31 files changed

+400
-162
lines changed
 

‎compiler/rustc_builtin_macros/src/test.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,23 @@ pub fn expand_test_case(
3333
}
3434

3535
let sp = ecx.with_def_site_ctxt(attr_sp);
36-
let mut item = anno_item.expect_item();
36+
let (mut item, is_stmt) = match anno_item {
37+
Annotatable::Item(item) => (item, false),
38+
Annotatable::Stmt(stmt) if let ast::StmtKind::Item(_) = stmt.kind => if let ast::StmtKind::Item(i) = stmt.into_inner().kind {
39+
(i, true)
40+
} else {
41+
unreachable!()
42+
},
43+
_ => {
44+
ecx.struct_span_err(
45+
anno_item.span(),
46+
"`#[test_case]` attribute is only allowed on items",
47+
)
48+
.emit();
49+
50+
return vec![];
51+
}
52+
};
3753
item = item.map(|mut item| {
3854
let test_path_symbol = Symbol::intern(&item_path(
3955
// skip the name of the root module
@@ -50,7 +66,13 @@ pub fn expand_test_case(
5066
item
5167
});
5268

53-
return vec![Annotatable::Item(item)];
69+
let ret = if is_stmt {
70+
Annotatable::Stmt(P(ecx.stmt_item(item.span, item)))
71+
} else {
72+
Annotatable::Item(item)
73+
};
74+
75+
vec![ret]
5476
}
5577

5678
pub fn expand_test(

‎compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
30683068
// generate the def_id of an associated type for the trait and return as
30693069
// type a projection.
30703070
let def_id = if in_trait && tcx.lower_impl_trait_in_trait_to_assoc_ty() {
3071-
tcx.associated_item_for_impl_trait_in_trait(local_def_id).to_def_id()
3071+
tcx.associated_type_for_impl_trait_in_trait(local_def_id).to_def_id()
30723072
} else {
30733073
local_def_id.to_def_id()
30743074
};

‎compiler/rustc_lint/src/builtin.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,8 +2781,7 @@ impl ClashingExternDeclarations {
27812781

27822782
// Given a transparent newtype, reach through and grab the inner
27832783
// type unless the newtype makes the type non-null.
2784-
let non_transparent_ty = |ty: Ty<'tcx>| -> Ty<'tcx> {
2785-
let mut ty = ty;
2784+
let non_transparent_ty = |mut ty: Ty<'tcx>| -> Ty<'tcx> {
27862785
loop {
27872786
if let ty::Adt(def, substs) = *ty.kind() {
27882787
let is_transparent = def.repr().transparent();
@@ -2792,14 +2791,14 @@ impl ClashingExternDeclarations {
27922791
ty, is_transparent, is_non_null
27932792
);
27942793
if is_transparent && !is_non_null {
2795-
debug_assert!(def.variants().len() == 1);
2794+
debug_assert_eq!(def.variants().len(), 1);
27962795
let v = &def.variant(VariantIdx::new(0));
2797-
ty = transparent_newtype_field(tcx, v)
2798-
.expect(
2799-
"single-variant transparent structure with zero-sized field",
2800-
)
2801-
.ty(tcx, substs);
2802-
continue;
2796+
// continue with `ty`'s non-ZST field,
2797+
// otherwise `ty` is a ZST and we can return
2798+
if let Some(field) = transparent_newtype_field(tcx, v) {
2799+
ty = field.ty(tcx, substs);
2800+
continue;
2801+
}
28032802
}
28042803
}
28052804
debug!("non_transparent_ty -> {:?}", ty);
@@ -2813,10 +2812,8 @@ impl ClashingExternDeclarations {
28132812
if !seen_types.insert((a, b)) {
28142813
// We've encountered a cycle. There's no point going any further -- the types are
28152814
// structurally the same.
2816-
return true;
2817-
}
2818-
let tcx = cx.tcx;
2819-
if a == b {
2815+
true
2816+
} else if a == b {
28202817
// All nominally-same types are structurally same, too.
28212818
true
28222819
} else {

‎compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ provide! { tcx, def_id, other, cdata,
254254
.process_decoded(tcx, || panic!("{def_id:?} does not have trait_impl_trait_tys")))
255255
}
256256

257-
associated_items_for_impl_trait_in_trait => { table_defaulted_array }
257+
associated_types_for_impl_traits_in_associated_fn => { table_defaulted_array }
258258

259259
visibility => { cdata.get_visibility(def_id.index) }
260260
adt_def => { cdata.get_adt_def(def_id.index, tcx) }

‎compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
609609

610610
_ = stat!("mir", || self.encode_mir());
611611

612-
_ = stat!("items", || {
613-
self.encode_def_ids();
614-
self.encode_info_for_items();
615-
});
612+
_ = stat!("def-ids", || self.encode_def_ids());
613+
614+
_ = stat!("items", || self.encode_info_for_items());
616615

617616
let interpret_alloc_index = stat!("interpret-alloc-index", || {
618617
let mut interpret_alloc_index = Vec::new();
@@ -1198,8 +1197,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
11981197
record!(self.tables.trait_impl_trait_tys[def_id] <- table);
11991198
}
12001199
if should_encode_fn_impl_trait_in_trait(tcx, def_id) {
1201-
let table = tcx.associated_items_for_impl_trait_in_trait(def_id);
1202-
record_defaulted_array!(self.tables.associated_items_for_impl_trait_in_trait[def_id] <- table);
1200+
let table = tcx.associated_types_for_impl_traits_in_associated_fn(def_id);
1201+
record_defaulted_array!(self.tables.associated_types_for_impl_traits_in_associated_fn[def_id] <- table);
12031202
}
12041203
}
12051204

‎compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ define_tables! {
354354
explicit_item_bounds: Table<DefIndex, LazyArray<(ty::Predicate<'static>, Span)>>,
355355
inferred_outlives_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
356356
inherent_impls: Table<DefIndex, LazyArray<DefIndex>>,
357-
associated_items_for_impl_trait_in_trait: Table<DefIndex, LazyArray<DefId>>,
357+
associated_types_for_impl_traits_in_associated_fn: Table<DefIndex, LazyArray<DefId>>,
358358
opt_rpitit_info: Table<DefIndex, Option<LazyValue<ty::ImplTraitInTraitData>>>,
359359
unused_generic_params: Table<DefIndex, UnusedGenericParams>,
360360

‎compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,15 +785,15 @@ rustc_queries! {
785785
/// if `fn_def_id` is the def id of a function defined inside an impl that implements a trait, then it
786786
/// creates and returns the associated items that correspond to each impl trait in return position
787787
/// of the implemented trait.
788-
query associated_items_for_impl_trait_in_trait(fn_def_id: DefId) -> &'tcx [DefId] {
788+
query associated_types_for_impl_traits_in_associated_fn(fn_def_id: DefId) -> &'tcx [DefId] {
789789
desc { |tcx| "creating associated items for impl trait in trait returned by `{}`", tcx.def_path_str(fn_def_id) }
790790
cache_on_disk_if { fn_def_id.is_local() }
791791
separate_provide_extern
792792
}
793793

794794
/// Given an impl trait in trait `opaque_ty_def_id`, create and return the corresponding
795795
/// associated item.
796-
query associated_item_for_impl_trait_in_trait(opaque_ty_def_id: LocalDefId) -> LocalDefId {
796+
query associated_type_for_impl_trait_in_trait(opaque_ty_def_id: LocalDefId) -> LocalDefId {
797797
desc { |tcx| "creates the associated item corresponding to the opaque type `{}`", tcx.def_path_str(opaque_ty_def_id.to_def_id()) }
798798
cache_on_disk_if { true }
799799
separate_provide_extern

‎compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,9 @@ impl<'tcx> TyCtxt<'tcx> {
25792579
let Some(trait_item_def_id) = item.trait_item_def_id else { return false; };
25802580

25812581
if self.lower_impl_trait_in_trait_to_assoc_ty() {
2582-
return !self.associated_items_for_impl_trait_in_trait(trait_item_def_id).is_empty();
2582+
return !self
2583+
.associated_types_for_impl_traits_in_associated_fn(trait_item_def_id)
2584+
.is_empty();
25832585
}
25842586

25852587
// FIXME(RPITIT): This does a somewhat manual walk through the signature

‎compiler/rustc_ty_utils/src/assoc.rs

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub fn provide(providers: &mut ty::query::Providers) {
1111
associated_item,
1212
associated_item_def_ids,
1313
associated_items,
14-
associated_items_for_impl_trait_in_trait,
15-
associated_item_for_impl_trait_in_trait,
14+
associated_types_for_impl_traits_in_associated_fn,
15+
associated_type_for_impl_trait_in_trait,
1616
impl_item_implementor_ids,
1717
..*providers
1818
};
@@ -24,7 +24,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
2424
hir::ItemKind::Trait(.., ref trait_item_refs) => {
2525
if tcx.lower_impl_trait_in_trait_to_assoc_ty() {
2626
// We collect RPITITs for each trait method's return type and create a
27-
// corresponding associated item using associated_items_for_impl_trait_in_trait
27+
// corresponding associated item using associated_types_for_impl_traits_in_associated_fn
2828
// query.
2929
tcx.arena.alloc_from_iter(
3030
trait_item_refs
@@ -39,7 +39,9 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
3939
.flat_map(|trait_item_ref| {
4040
let trait_fn_def_id =
4141
trait_item_ref.id.owner_id.def_id.to_def_id();
42-
tcx.associated_items_for_impl_trait_in_trait(trait_fn_def_id)
42+
tcx.associated_types_for_impl_traits_in_associated_fn(
43+
trait_fn_def_id,
44+
)
4345
})
4446
.map(|def_id| *def_id),
4547
),
@@ -56,7 +58,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
5658
if tcx.lower_impl_trait_in_trait_to_assoc_ty() {
5759
// We collect RPITITs for each trait method's return type, on the impl side too and
5860
// create a corresponding associated item using
59-
// associated_items_for_impl_trait_in_trait query.
61+
// associated_types_for_impl_traits_in_associated_fn query.
6062
tcx.arena.alloc_from_iter(
6163
impl_
6264
.items
@@ -72,7 +74,9 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
7274
.flat_map(|impl_item_ref| {
7375
let impl_fn_def_id =
7476
impl_item_ref.id.owner_id.def_id.to_def_id();
75-
tcx.associated_items_for_impl_trait_in_trait(impl_fn_def_id)
77+
tcx.associated_types_for_impl_traits_in_associated_fn(
78+
impl_fn_def_id,
79+
)
7680
})
7781
.map(|def_id| *def_id)
7882
})),
@@ -176,13 +180,19 @@ fn associated_item_from_impl_item_ref(impl_item_ref: &hir::ImplItemRef) -> ty::A
176180
}
177181
}
178182

179-
/// Given an `fn_def_id` of a trait or of an impl that implements a given trait:
180-
/// if `fn_def_id` is the def id of a function defined inside a trait, then it creates and returns
181-
/// the associated items that correspond to each impl trait in return position for that trait.
182-
/// if `fn_def_id` is the def id of a function defined inside an impl that implements a trait, then it
183-
/// creates and returns the associated items that correspond to each impl trait in return position
184-
/// of the implemented trait.
185-
fn associated_items_for_impl_trait_in_trait(tcx: TyCtxt<'_>, fn_def_id: DefId) -> &'_ [DefId] {
183+
/// Given an `fn_def_id` of a trait or a trait implementation:
184+
///
185+
/// if `fn_def_id` is a function defined inside a trait, then it synthesizes
186+
/// a new def id corresponding to a new associated type for each return-
187+
/// position `impl Trait` in the signature.
188+
///
189+
/// if `fn_def_id` is a function inside of an impl, then for each synthetic
190+
/// associated type generated for the corresponding trait function described
191+
/// above, synthesize a corresponding associated type in the impl.
192+
fn associated_types_for_impl_traits_in_associated_fn(
193+
tcx: TyCtxt<'_>,
194+
fn_def_id: DefId,
195+
) -> &'_ [DefId] {
186196
let parent_def_id = tcx.parent(fn_def_id);
187197

188198
match tcx.def_kind(parent_def_id) {
@@ -206,7 +216,7 @@ fn associated_items_for_impl_trait_in_trait(tcx: TyCtxt<'_>, fn_def_id: DefId) -
206216
visitor.visit_fn_ret_ty(output);
207217

208218
tcx.arena.alloc_from_iter(visitor.rpits.iter().map(|opaque_ty_def_id| {
209-
tcx.associated_item_for_impl_trait_in_trait(opaque_ty_def_id).to_def_id()
219+
tcx.associated_type_for_impl_trait_in_trait(opaque_ty_def_id).to_def_id()
210220
}))
211221
} else {
212222
&[]
@@ -217,9 +227,9 @@ fn associated_items_for_impl_trait_in_trait(tcx: TyCtxt<'_>, fn_def_id: DefId) -
217227
let Some(trait_fn_def_id) = tcx.associated_item(fn_def_id).trait_item_def_id else { return &[] };
218228

219229
tcx.arena.alloc_from_iter(
220-
tcx.associated_items_for_impl_trait_in_trait(trait_fn_def_id).iter().map(
230+
tcx.associated_types_for_impl_traits_in_associated_fn(trait_fn_def_id).iter().map(
221231
move |trait_assoc_def_id| {
222-
impl_associated_item_for_impl_trait_in_trait(
232+
associated_type_for_impl_trait_in_impl(
223233
tcx,
224234
trait_assoc_def_id.expect_local(),
225235
fn_def_id.expect_local(),
@@ -231,16 +241,17 @@ fn associated_items_for_impl_trait_in_trait(tcx: TyCtxt<'_>, fn_def_id: DefId) -
231241
}
232242

233243
def_kind => bug!(
234-
"associated_items_for_impl_trait_in_trait: {:?} should be Trait or Impl but is {:?}",
244+
"associated_types_for_impl_traits_in_associated_fn: {:?} should be Trait or Impl but is {:?}",
235245
parent_def_id,
236246
def_kind
237247
),
238248
}
239249
}
240250

241-
/// Given an `opaque_ty_def_id` corresponding to an impl trait in trait, create and return the
242-
/// corresponding associated item.
243-
fn associated_item_for_impl_trait_in_trait(
251+
/// Given an `opaque_ty_def_id` corresponding to an `impl Trait` in an associated
252+
/// function from a trait, synthesize an associated type for that `impl Trait`
253+
/// that inherits properties that we infer from the method and the opaque type.
254+
fn associated_type_for_impl_trait_in_trait(
244255
tcx: TyCtxt<'_>,
245256
opaque_ty_def_id: LocalDefId,
246257
) -> LocalDefId {
@@ -335,10 +346,12 @@ fn associated_item_for_impl_trait_in_trait(
335346
local_def_id
336347
}
337348

338-
/// Given an `trait_assoc_def_id` that corresponds to a previously synthesized impl trait in trait
339-
/// into an associated type and an `impl_def_id` corresponding to an impl block, create and return
340-
/// the corresponding associated item inside the impl block.
341-
fn impl_associated_item_for_impl_trait_in_trait(
349+
/// Given an `trait_assoc_def_id` corresponding to an associated item synthesized
350+
/// from an `impl Trait` in an associated function from a trait, and an
351+
/// `impl_fn_def_id` that represents an implementation of the associated function
352+
/// that the `impl Trait` comes from, synthesize an associated type for that `impl Trait`
353+
/// that inherits properties that we infer from the method and the associated type.
354+
fn associated_type_for_impl_trait_in_impl(
342355
tcx: TyCtxt<'_>,
343356
trait_assoc_def_id: LocalDefId,
344357
impl_fn_def_id: LocalDefId,

‎library/core/src/intrinsics/mir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//!
99
//! The documentation for this module describes how to use this feature. If you are interested in
1010
//! hacking on the implementation, most of that documentation lives at
11-
//! `rustc_mir_building/src/build/custom/mod.rs`.
11+
//! `rustc_mir_build/src/build/custom/mod.rs`.
1212
//!
1313
//! Typical usage will look like this:
1414
//!

‎library/core/src/iter/traits/iterator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ pub trait Iterator {
20032003
/// a.iter().map(|&x| x * 2).collect_into(&mut vec);
20042004
/// a.iter().map(|&x| x * 10).collect_into(&mut vec);
20052005
///
2006-
/// assert_eq!(vec![0, 1, 2, 4, 6, 10, 20, 30], vec);
2006+
/// assert_eq!(vec, vec![0, 1, 2, 4, 6, 10, 20, 30]);
20072007
/// ```
20082008
///
20092009
/// `Vec` can have a manual set capacity to avoid reallocating it:
@@ -2018,7 +2018,7 @@ pub trait Iterator {
20182018
/// a.iter().map(|&x| x * 10).collect_into(&mut vec);
20192019
///
20202020
/// assert_eq!(6, vec.capacity());
2021-
/// println!("{:?}", vec);
2021+
/// assert_eq!(vec, vec![2, 4, 6, 10, 20, 30]);
20222022
/// ```
20232023
///
20242024
/// The returned mutable reference can be used to continue the call chain:
@@ -2032,12 +2032,12 @@ pub trait Iterator {
20322032
/// let count = a.iter().collect_into(&mut vec).iter().count();
20332033
///
20342034
/// assert_eq!(count, vec.len());
2035-
/// println!("Vec len is {}", count);
2035+
/// assert_eq!(vec, vec![1, 2, 3]);
20362036
///
20372037
/// let count = a.iter().collect_into(&mut vec).iter().count();
20382038
///
20392039
/// assert_eq!(count, vec.len());
2040-
/// println!("Vec len now is {}", count);
2040+
/// assert_eq!(vec, vec![1, 2, 3, 1, 2, 3]);
20412041
/// ```
20422042
#[inline]
20432043
#[unstable(feature = "iter_collect_into", reason = "new API", issue = "94780")]

‎src/librustdoc/html/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>(
14801480
debug!("path={:?}", path);
14811481
// modified from `resolved_path()` to work with `DefPathData`
14821482
let last_name = path.data.last().unwrap().data.get_opt_name().unwrap();
1483-
let anchor = anchor(vis_did, last_name, cx).to_string();
1483+
let anchor = anchor(vis_did, last_name, cx);
14841484

14851485
let mut s = "pub(in ".to_owned();
14861486
for seg in &path.data[..path.data.len() - 1] {

‎src/librustdoc/html/markdown.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,15 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
556556
}
557557

558558
fn is_forbidden_tag(t: &Tag<'_>) -> bool {
559-
matches!(t, Tag::CodeBlock(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell)
559+
matches!(
560+
t,
561+
Tag::CodeBlock(_)
562+
| Tag::Table(_)
563+
| Tag::TableHead
564+
| Tag::TableRow
565+
| Tag::TableCell
566+
| Tag::FootnoteDefinition(_)
567+
)
560568
}
561569

562570
impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
@@ -589,6 +597,10 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
589597
is_start = false;
590598
check_if_allowed_tag(c)
591599
}
600+
Event::FootnoteReference(_) => {
601+
self.skipped_tags += 1;
602+
false
603+
}
592604
_ => true,
593605
};
594606
if !is_allowed_tag {

‎src/librustdoc/html/render/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl<'tcx> Context<'tcx> {
352352
},
353353
);
354354

355-
path = href.into_inner().to_string_lossy().to_string();
355+
path = href.into_inner().to_string_lossy().into_owned();
356356

357357
if let Some(c) = path.as_bytes().last() && *c != b'/' {
358358
path.push('/');

‎src/librustdoc/html/render/print_item.rs

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use clean::AttributesExt;
22

3+
use rustc_data_structures::captures::Captures;
34
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
45
use rustc_hir as hir;
56
use rustc_hir::def::CtorKind;
@@ -28,8 +29,8 @@ use crate::formats::item_type::ItemType;
2829
use crate::formats::{AssocItemRender, Impl, RenderMode};
2930
use crate::html::escape::Escape;
3031
use crate::html::format::{
31-
join_with_double_colon, print_abi_with_space, print_constness_with_space, print_where_clause,
32-
visibility_print_with_space, Buffer, Ending, PrintWithSpace,
32+
display_fn, join_with_double_colon, print_abi_with_space, print_constness_with_space,
33+
print_where_clause, visibility_print_with_space, Buffer, Ending, PrintWithSpace,
3334
};
3435
use crate::html::layout::Page;
3536
use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine};
@@ -367,7 +368,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
367368
..myitem.clone()
368369
};
369370

370-
let stab_tags = Some(extra_info_tags(&import_item, item, cx.tcx()));
371+
let stab_tags = Some(extra_info_tags(&import_item, item, cx.tcx()).to_string());
371372
stab_tags
372373
} else {
373374
None
@@ -461,42 +462,62 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
461462

462463
/// Render the stability, deprecation and portability tags that are displayed in the item's summary
463464
/// at the module level.
464-
fn extra_info_tags(item: &clean::Item, parent: &clean::Item, tcx: TyCtxt<'_>) -> String {
465-
let mut tags = String::new();
466-
467-
fn tag_html(class: &str, title: &str, contents: &str) -> String {
468-
format!(r#"<span class="stab {}" title="{}">{}</span>"#, class, Escape(title), contents)
469-
}
470-
471-
// The trailing space after each tag is to space it properly against the rest of the docs.
472-
if let Some(depr) = &item.deprecation(tcx) {
473-
let message = if stability::deprecation_in_effect(depr) {
474-
"Deprecated"
475-
} else {
476-
"Deprecation planned"
477-
};
478-
tags += &tag_html("deprecated", "", message);
479-
}
465+
fn extra_info_tags<'a, 'tcx: 'a>(
466+
item: &'a clean::Item,
467+
parent: &'a clean::Item,
468+
tcx: TyCtxt<'tcx>,
469+
) -> impl fmt::Display + 'a + Captures<'tcx> {
470+
display_fn(move |f| {
471+
fn tag_html<'a>(
472+
class: &'a str,
473+
title: &'a str,
474+
contents: &'a str,
475+
) -> impl fmt::Display + 'a {
476+
display_fn(move |f| {
477+
write!(
478+
f,
479+
r#"<span class="stab {}" title="{}">{}</span>"#,
480+
class,
481+
Escape(title),
482+
contents
483+
)
484+
})
485+
}
480486

481-
// The "rustc_private" crates are permanently unstable so it makes no sense
482-
// to render "unstable" everywhere.
483-
if item.stability(tcx).as_ref().map(|s| s.is_unstable() && s.feature != sym::rustc_private)
484-
== Some(true)
485-
{
486-
tags += &tag_html("unstable", "", "Experimental");
487-
}
487+
// The trailing space after each tag is to space it properly against the rest of the docs.
488+
if let Some(depr) = &item.deprecation(tcx) {
489+
let message = if stability::deprecation_in_effect(depr) {
490+
"Deprecated"
491+
} else {
492+
"Deprecation planned"
493+
};
494+
write!(f, "{}", tag_html("deprecated", "", message))?;
495+
}
488496

489-
let cfg = match (&item.cfg, parent.cfg.as_ref()) {
490-
(Some(cfg), Some(parent_cfg)) => cfg.simplify_with(parent_cfg),
491-
(cfg, _) => cfg.as_deref().cloned(),
492-
};
497+
// The "rustc_private" crates are permanently unstable so it makes no sense
498+
// to render "unstable" everywhere.
499+
if item.stability(tcx).as_ref().map(|s| s.is_unstable() && s.feature != sym::rustc_private)
500+
== Some(true)
501+
{
502+
write!(f, "{}", tag_html("unstable", "", "Experimental"))?;
503+
}
493504

494-
debug!("Portability name={:?} {:?} - {:?} = {:?}", item.name, item.cfg, parent.cfg, cfg);
495-
if let Some(ref cfg) = cfg {
496-
tags += &tag_html("portability", &cfg.render_long_plain(), &cfg.render_short_html());
497-
}
505+
let cfg = match (&item.cfg, parent.cfg.as_ref()) {
506+
(Some(cfg), Some(parent_cfg)) => cfg.simplify_with(parent_cfg),
507+
(cfg, _) => cfg.as_deref().cloned(),
508+
};
498509

499-
tags
510+
debug!("Portability name={:?} {:?} - {:?} = {:?}", item.name, item.cfg, parent.cfg, cfg);
511+
if let Some(ref cfg) = cfg {
512+
write!(
513+
f,
514+
"{}",
515+
tag_html("portability", &cfg.render_long_plain(), &cfg.render_short_html())
516+
)
517+
} else {
518+
Ok(())
519+
}
520+
})
500521
}
501522

502523
fn item_function(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, f: &clean::Function) {

‎src/librustdoc/html/sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl LocalSourcesCollector<'_, '_> {
8585
},
8686
);
8787

88-
let mut href = href.into_inner().to_string_lossy().to_string();
88+
let mut href = href.into_inner().to_string_lossy().into_owned();
8989
if let Some(c) = href.as_bytes().last() && *c != b'/' {
9090
href.push('/');
9191
}

‎src/librustdoc/html/static/js/search.js

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,28 +1202,42 @@ function initSearch(rawSearchIndex) {
12021202
* @param {Row} row
12031203
* @param {QueryElement} elem - The element from the parsed query.
12041204
* @param {integer} typeFilter
1205+
* @param {Array<integer>} skipPositions - Do not return one of these positions.
12051206
*
1206-
* @return {integer} - Returns an edit distance to the best match. If there is no
1207-
* match, returns `maxEditDistance + 1`.
1207+
* @return {dist: integer, position: integer} - Returns an edit distance to the best match.
1208+
* If there is no match, returns
1209+
* `maxEditDistance + 1` and position: -1.
12081210
*/
1209-
function findArg(row, elem, typeFilter, maxEditDistance) {
1211+
function findArg(row, elem, typeFilter, maxEditDistance, skipPositions) {
12101212
let dist = maxEditDistance + 1;
1213+
let position = -1;
12111214

12121215
if (row && row.type && row.type.inputs && row.type.inputs.length > 0) {
1216+
let i = 0;
12131217
for (const input of row.type.inputs) {
1214-
if (!typePassesFilter(typeFilter, input.ty)) {
1218+
if (!typePassesFilter(typeFilter, input.ty) ||
1219+
skipPositions.indexOf(i) !== -1) {
1220+
i += 1;
12151221
continue;
12161222
}
1217-
dist = Math.min(
1218-
dist,
1219-
checkType(input, elem, parsedQuery.literalSearch, maxEditDistance)
1223+
const typeDist = checkType(
1224+
input,
1225+
elem,
1226+
parsedQuery.literalSearch,
1227+
maxEditDistance
12201228
);
1221-
if (dist === 0) {
1222-
return 0;
1229+
if (typeDist === 0) {
1230+
return {dist: 0, position: i};
1231+
}
1232+
if (typeDist < dist) {
1233+
dist = typeDist;
1234+
position = i;
12231235
}
1236+
i += 1;
12241237
}
12251238
}
1226-
return parsedQuery.literalSearch ? maxEditDistance + 1 : dist;
1239+
dist = parsedQuery.literalSearch ? maxEditDistance + 1 : dist;
1240+
return {dist, position};
12271241
}
12281242

12291243
/**
@@ -1232,29 +1246,43 @@ function initSearch(rawSearchIndex) {
12321246
* @param {Row} row
12331247
* @param {QueryElement} elem - The element from the parsed query.
12341248
* @param {integer} typeFilter
1249+
* @param {Array<integer>} skipPositions - Do not return one of these positions.
12351250
*
1236-
* @return {integer} - Returns an edit distance to the best match. If there is no
1237-
* match, returns `maxEditDistance + 1`.
1251+
* @return {dist: integer, position: integer} - Returns an edit distance to the best match.
1252+
* If there is no match, returns
1253+
* `maxEditDistance + 1` and position: -1.
12381254
*/
1239-
function checkReturned(row, elem, typeFilter, maxEditDistance) {
1255+
function checkReturned(row, elem, typeFilter, maxEditDistance, skipPositions) {
12401256
let dist = maxEditDistance + 1;
1257+
let position = -1;
12411258

12421259
if (row && row.type && row.type.output.length > 0) {
12431260
const ret = row.type.output;
1261+
let i = 0;
12441262
for (const ret_ty of ret) {
1245-
if (!typePassesFilter(typeFilter, ret_ty.ty)) {
1263+
if (!typePassesFilter(typeFilter, ret_ty.ty) ||
1264+
skipPositions.indexOf(i) !== -1) {
1265+
i += 1;
12461266
continue;
12471267
}
1248-
dist = Math.min(
1249-
dist,
1250-
checkType(ret_ty, elem, parsedQuery.literalSearch, maxEditDistance)
1268+
const typeDist = checkType(
1269+
ret_ty,
1270+
elem,
1271+
parsedQuery.literalSearch,
1272+
maxEditDistance
12511273
);
1252-
if (dist === 0) {
1253-
return 0;
1274+
if (typeDist === 0) {
1275+
return {dist: 0, position: i};
12541276
}
1277+
if (typeDist < dist) {
1278+
dist = typeDist;
1279+
position = i;
1280+
}
1281+
i += 1;
12551282
}
12561283
}
1257-
return parsedQuery.literalSearch ? maxEditDistance + 1 : dist;
1284+
dist = parsedQuery.literalSearch ? maxEditDistance + 1 : dist;
1285+
return {dist, position};
12581286
}
12591287

12601288
function checkPath(contains, ty, maxEditDistance) {
@@ -1455,13 +1483,13 @@ function initSearch(rawSearchIndex) {
14551483
const fullId = row.id;
14561484
const searchWord = searchWords[pos];
14571485

1458-
const in_args = findArg(row, elem, parsedQuery.typeFilter, maxEditDistance);
1459-
const returned = checkReturned(row, elem, parsedQuery.typeFilter, maxEditDistance);
1486+
const in_args = findArg(row, elem, parsedQuery.typeFilter, maxEditDistance, []);
1487+
const returned = checkReturned(row, elem, parsedQuery.typeFilter, maxEditDistance, []);
14601488

14611489
// path_dist is 0 because no parent path information is currently stored
14621490
// in the search index
1463-
addIntoResults(results_in_args, fullId, pos, -1, in_args, 0, maxEditDistance);
1464-
addIntoResults(results_returned, fullId, pos, -1, returned, 0, maxEditDistance);
1491+
addIntoResults(results_in_args, fullId, pos, -1, in_args.dist, 0, maxEditDistance);
1492+
addIntoResults(results_returned, fullId, pos, -1, returned.dist, 0, maxEditDistance);
14651493

14661494
if (!typePassesFilter(parsedQuery.typeFilter, row.ty)) {
14671495
return;
@@ -1534,12 +1562,20 @@ function initSearch(rawSearchIndex) {
15341562

15351563
// If the result is too "bad", we return false and it ends this search.
15361564
function checkArgs(elems, callback) {
1565+
const skipPositions = [];
15371566
for (const elem of elems) {
15381567
// There is more than one parameter to the query so all checks should be "exact"
1539-
const dist = callback(row, elem, NO_TYPE_FILTER, maxEditDistance);
1568+
const { dist, position } = callback(
1569+
row,
1570+
elem,
1571+
NO_TYPE_FILTER,
1572+
maxEditDistance,
1573+
skipPositions
1574+
);
15401575
if (dist <= 1) {
15411576
nbDist += 1;
15421577
totalDist += dist;
1578+
skipPositions.push(position);
15431579
} else {
15441580
return false;
15451581
}
@@ -1597,9 +1633,17 @@ function initSearch(rawSearchIndex) {
15971633
row,
15981634
elem,
15991635
parsedQuery.typeFilter,
1636+
maxEditDistance,
1637+
[]
1638+
);
1639+
addIntoResults(
1640+
results_others,
1641+
row.id,
1642+
i,
1643+
-1,
1644+
in_returned.dist,
16001645
maxEditDistance
16011646
);
1602-
addIntoResults(results_others, row.id, i, -1, in_returned, maxEditDistance);
16031647
}
16041648
}
16051649
} else if (parsedQuery.foundElems > 0) {

‎src/librustdoc/html/templates/short_item_info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% when Self::Deprecation with { message } %}
33
<div class="stab deprecated"> {# #}
44
<span class="emoji">👎</span> {# #}
5-
<span>{{message}}</span> {# #}
5+
<span>{{message|safe}}</span> {# #}
66
</div> {# #}
77
{% when Self::Unstable with { feature, tracking } %}
88
<div class="stab unstable"> {# #}

‎src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
286286
split.next().map(|f| Symbol::intern(f)).ok_or_else(no_res)?;
287287
let path = split
288288
.next()
289-
.map(|f| f.to_owned())
290289
// If there's no third component, we saw `[a::b]` before and it failed to resolve.
291290
// So there's no partial res.
292291
.ok_or_else(no_res)?;
@@ -429,7 +428,6 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
429428
let item_name = Symbol::intern(item_str);
430429
let path_root = split
431430
.next()
432-
.map(|f| f.to_owned())
433431
// If there's no `::`, it's not an associated item.
434432
// So we can be sure that `rustc_resolve` was accurate when it said it wasn't resolved.
435433
.ok_or_else(|| {

‎src/librustdoc/visit_ast.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
265265
return false;
266266
}
267267

268-
if !self.view_item_stack.insert(res_did) {
269-
return false;
270-
}
271-
272268
if !please_inline &&
273269
let mut visitor = OneLevelVisitor::new(self.cx.tcx.hir(), res_did) &&
274270
let Some(item) = visitor.find_target(self.cx.tcx, def_id.to_def_id(), path) &&
@@ -285,6 +281,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
285281
return false;
286282
}
287283

284+
if !self.view_item_stack.insert(res_did) {
285+
return false;
286+
}
287+
288288
let ret = match tcx.hir().get_by_def_id(res_did) {
289289
Node::Item(&hir::Item { kind: hir::ItemKind::Mod(ref m), .. }) if glob => {
290290
let prev = mem::replace(&mut self.inlining, true);

‎src/tools/tidy/src/mir_opt_tests.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@
33
use std::collections::HashSet;
44
use std::path::{Path, PathBuf};
55

6+
use crate::walk::walk_no_read;
7+
68
fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
79
let mut rs_files = Vec::<PathBuf>::new();
810
let mut output_files = HashSet::<PathBuf>::new();
9-
let files = walkdir::WalkDir::new(&path.join("mir-opt")).into_iter();
1011

11-
for file in files.filter_map(Result::ok).filter(|e| e.file_type().is_file()) {
12-
let filepath = file.path();
13-
if filepath.extension() == Some("rs".as_ref()) {
14-
rs_files.push(filepath.to_owned());
15-
} else {
16-
output_files.insert(filepath.to_owned());
17-
}
18-
}
12+
walk_no_read(
13+
&[&path.join("mir-opt")],
14+
|path| path.file_name() == Some("README.md".as_ref()),
15+
&mut |file| {
16+
let filepath = file.path();
17+
if filepath.extension() == Some("rs".as_ref()) {
18+
rs_files.push(filepath.to_owned());
19+
} else {
20+
output_files.insert(filepath.to_owned());
21+
}
22+
},
23+
);
1924

2025
for file in rs_files {
2126
for bw in [32, 64] {
@@ -26,16 +31,14 @@ fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
2631
}
2732

2833
for extra in output_files {
29-
if extra.file_name() != Some("README.md".as_ref()) {
30-
if !bless {
31-
tidy_error!(
32-
bad,
33-
"the following output file is not associated with any mir-opt test, you can remove it: {}",
34-
extra.display()
35-
);
36-
} else {
37-
let _ = std::fs::remove_file(extra);
38-
}
34+
if !bless {
35+
tidy_error!(
36+
bad,
37+
"the following output file is not associated with any mir-opt test, you can remove it: {}",
38+
extra.display()
39+
);
40+
} else {
41+
let _ = std::fs::remove_file(extra);
3942
}
4043
}
4144
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// exact-check
2+
3+
const QUERY = [
4+
'P',
5+
'P, P',
6+
];
7+
8+
const EXPECTED = [
9+
{
10+
'in_args': [
11+
{ 'path': 'search_bag_semantics', 'name': 'alacazam' },
12+
{ 'path': 'search_bag_semantics', 'name': 'abracadabra' },
13+
],
14+
},
15+
{
16+
'others': [
17+
{ 'path': 'search_bag_semantics', 'name': 'abracadabra' },
18+
],
19+
},
20+
];
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub struct P;
2+
3+
pub fn abracadabra(a: P, b: P) {}
4+
pub fn alacazam(a: P) {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(no_core)]
2+
#![no_core]
3+
4+
extern "C" {
5+
// @is "$.index[*][?(@.name == 'not_variadic')].inner.decl.c_variadic" false
6+
pub fn not_variadic(_: i32);
7+
// @is "$.index[*][?(@.name == 'variadic')].inner.decl.c_variadic" true
8+
pub fn variadic(_: i32, ...);
9+
}

‎tests/rustdoc/deprecated.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ pub struct V;
2828
pub struct W;
2929

3030
// @matches deprecated/struct.X.html '//*[@class="stab deprecated"]' \
31-
// 'Deprecated: shorthand reason$'
32-
#[deprecated = "shorthand reason"]
31+
// 'Deprecated: shorthand reason: code$'
32+
#[deprecated = "shorthand reason: `code`"]
3333
pub struct X;

‎tests/rustdoc/footnote-in-summary.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This test ensures that no footnote reference is generated inside
2+
// summary doc.
3+
4+
#![crate_name = "foo"]
5+
6+
// @has 'foo/index.html'
7+
// @has - '//*[@class="desc docblock-short"]' 'hello bla'
8+
// @!has - '//*[@class="desc docblock-short"]/sup' '1'
9+
10+
// @has 'foo/struct.S.html'
11+
// @has - '//*[@class="docblock"]//sup' '1'
12+
// @has - '//*[@class="docblock"]' 'hello 1 bla'
13+
14+
/// hello [^foot] bla
15+
///
16+
/// [^foot]: blabla
17+
pub struct S;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/109258>.
2+
3+
#![crate_name = "foo"]
4+
5+
// @has 'foo/index.html'
6+
// We should only have a "Re-exports" and a "Modules" headers.
7+
// @count - '//*[@id="main-content"]/h2[@class="small-section-header"]' 2
8+
// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Re-exports'
9+
// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Modules'
10+
11+
// @has - '//*[@id="reexport.Foo"]' 'pub use crate::issue_109258::Foo;'
12+
// @has - '//*[@id="reexport.Foo"]//a[@href="issue_109258/struct.Foo.html"]' 'Foo'
13+
// @!has 'foo/struct.Foo.html'
14+
pub use crate::issue_109258::Foo;
15+
16+
// @has 'foo/issue_109258/index.html'
17+
// We should only have a "Structs" header.
18+
// @count - '//*[@id="main-content"]/h2[@class="small-section-header"]' 1
19+
// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Structs'
20+
// @has - '//*[@id="main-content"]//a[@href="struct.Foo.html"]' 'Foo'
21+
// @has 'foo/issue_109258/struct.Foo.html'
22+
pub mod issue_109258 {
23+
mod priv_mod {
24+
pub struct Foo;
25+
}
26+
pub use self::priv_mod::Foo;
27+
}

‎tests/ui/lint/clashing-extern-fn.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ mod banana {
122122
weight: u32,
123123
length: u16,
124124
} // note: distinct type
125-
// This should not trigger the lint because two::Banana is structurally equivalent to
126-
// one::Banana.
125+
// This should not trigger the lint because two::Banana is structurally equivalent to
126+
// one::Banana.
127127
extern "C" {
128128
fn weigh_banana(count: *const Banana) -> u64;
129129
}
@@ -223,6 +223,27 @@ mod transparent {
223223
}
224224
}
225225

226+
#[allow(improper_ctypes)]
227+
mod zst {
228+
mod transparent {
229+
#[repr(transparent)]
230+
struct TransparentZst(());
231+
extern "C" {
232+
fn zst() -> ();
233+
fn transparent_zst() -> TransparentZst;
234+
}
235+
}
236+
237+
mod not_transparent {
238+
struct NotTransparentZst(());
239+
extern "C" {
240+
// These shouldn't warn since all return types are zero sized
241+
fn zst() -> NotTransparentZst;
242+
fn transparent_zst() -> NotTransparentZst;
243+
}
244+
}
245+
}
246+
226247
mod missing_return_type {
227248
mod a {
228249
extern "C" {
@@ -397,10 +418,14 @@ mod hidden_niche {
397418
use std::num::NonZeroUsize;
398419

399420
#[repr(transparent)]
400-
struct Transparent { x: NonZeroUsize }
421+
struct Transparent {
422+
x: NonZeroUsize,
423+
}
401424

402425
#[repr(transparent)]
403-
struct TransparentNoNiche { y: UnsafeCell<NonZeroUsize> }
426+
struct TransparentNoNiche {
427+
y: UnsafeCell<NonZeroUsize>,
428+
}
404429

405430
extern "C" {
406431
fn hidden_niche_transparent() -> Option<Transparent>;

‎tests/ui/lint/clashing-extern-fn.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ LL | fn transparent_incorrect() -> isize;
130130
found `unsafe extern "C" fn() -> isize`
131131

132132
warning: `missing_return_type` redeclared with a different signature
133-
--> $DIR/clashing-extern-fn.rs:238:13
133+
--> $DIR/clashing-extern-fn.rs:259:13
134134
|
135135
LL | fn missing_return_type() -> usize;
136136
| ---------------------------------- `missing_return_type` previously declared here
@@ -142,7 +142,7 @@ LL | fn missing_return_type();
142142
found `unsafe extern "C" fn()`
143143

144144
warning: `non_zero_usize` redeclared with a different signature
145-
--> $DIR/clashing-extern-fn.rs:256:13
145+
--> $DIR/clashing-extern-fn.rs:277:13
146146
|
147147
LL | fn non_zero_usize() -> core::num::NonZeroUsize;
148148
| ----------------------------------------------- `non_zero_usize` previously declared here
@@ -154,7 +154,7 @@ LL | fn non_zero_usize() -> usize;
154154
found `unsafe extern "C" fn() -> usize`
155155

156156
warning: `non_null_ptr` redeclared with a different signature
157-
--> $DIR/clashing-extern-fn.rs:258:13
157+
--> $DIR/clashing-extern-fn.rs:279:13
158158
|
159159
LL | fn non_null_ptr() -> core::ptr::NonNull<usize>;
160160
| ----------------------------------------------- `non_null_ptr` previously declared here
@@ -166,7 +166,7 @@ LL | fn non_null_ptr() -> *const usize;
166166
found `unsafe extern "C" fn() -> *const usize`
167167

168168
warning: `option_non_zero_usize_incorrect` redeclared with a different signature
169-
--> $DIR/clashing-extern-fn.rs:356:13
169+
--> $DIR/clashing-extern-fn.rs:377:13
170170
|
171171
LL | fn option_non_zero_usize_incorrect() -> usize;
172172
| ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here
@@ -178,7 +178,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize;
178178
found `unsafe extern "C" fn() -> isize`
179179

180180
warning: `option_non_null_ptr_incorrect` redeclared with a different signature
181-
--> $DIR/clashing-extern-fn.rs:358:13
181+
--> $DIR/clashing-extern-fn.rs:379:13
182182
|
183183
LL | fn option_non_null_ptr_incorrect() -> *const usize;
184184
| --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here
@@ -190,7 +190,7 @@ LL | fn option_non_null_ptr_incorrect() -> *const isize;
190190
found `unsafe extern "C" fn() -> *const isize`
191191

192192
warning: `hidden_niche_transparent_no_niche` redeclared with a different signature
193-
--> $DIR/clashing-extern-fn.rs:408:13
193+
--> $DIR/clashing-extern-fn.rs:433:13
194194
|
195195
LL | fn hidden_niche_transparent_no_niche() -> usize;
196196
| ------------------------------------------------ `hidden_niche_transparent_no_niche` previously declared here
@@ -202,7 +202,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoN
202202
found `unsafe extern "C" fn() -> Option<TransparentNoNiche>`
203203

204204
warning: `hidden_niche_unsafe_cell` redeclared with a different signature
205-
--> $DIR/clashing-extern-fn.rs:412:13
205+
--> $DIR/clashing-extern-fn.rs:437:13
206206
|
207207
LL | fn hidden_niche_unsafe_cell() -> usize;
208208
| --------------------------------------- `hidden_niche_unsafe_cell` previously declared here
@@ -214,7 +214,7 @@ LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize
214214
found `unsafe extern "C" fn() -> Option<UnsafeCell<NonZeroUsize>>`
215215

216216
warning: `extern` block uses type `Option<TransparentNoNiche>`, which is not FFI-safe
217-
--> $DIR/clashing-extern-fn.rs:408:55
217+
--> $DIR/clashing-extern-fn.rs:433:55
218218
|
219219
LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoNiche>;
220220
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -224,7 +224,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoN
224224
= note: `#[warn(improper_ctypes)]` on by default
225225

226226
warning: `extern` block uses type `Option<UnsafeCell<NonZeroUsize>>`, which is not FFI-safe
227-
--> $DIR/clashing-extern-fn.rs:412:46
227+
--> $DIR/clashing-extern-fn.rs:437:46
228228
|
229229
LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>;
230230
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compile-flags: --test
2+
3+
#![feature(custom_test_frameworks)]
4+
#![deny(unnameable_test_items)]
5+
6+
fn foo() {
7+
#[test_case]
8+
//~^ ERROR cannot test inner items [unnameable_test_items]
9+
fn test2() {}
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: cannot test inner items
2+
--> $DIR/issue-107454.rs:7:5
3+
|
4+
LL | #[test_case]
5+
| ^^^^^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/issue-107454.rs:4:9
9+
|
10+
LL | #![deny(unnameable_test_items)]
11+
| ^^^^^^^^^^^^^^^^^^^^^
12+
= note: this error originates in the attribute macro `test_case` (in Nightly builds, run with -Z macro-backtrace for more info)
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)
Please sign in to comment.