Skip to content

Commit 7cc28c1

Browse files
committedJan 30, 2022
Auto merge of #93468 - matthiaskrgr:rollup-vxullvd, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #93256 (Make `join!` description more accurate) - #93358 (Add note suggesting that predicate may be satisfied, but is not `const`) - #93362 (Do not register infer var for GAT projection in RPIT) - #93391 (rustdoc: remove tooltip from source link) - #93414 (Move unstable is_{arch}_feature_detected! macros to std::arch) - #93441 (rustdoc: load the set of in-scope traits for modules with no docstring) - #93459 (fs: Don't copy d_name from struct dirent) - #93463 (Rename _args -> args in format_args expansion) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a00e130 + 9f6d0cb commit 7cc28c1

File tree

30 files changed

+219
-48
lines changed

30 files changed

+219
-48
lines changed
 

‎compiler/rustc_builtin_macros/src/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ impl<'a, 'b> Context<'a, 'b> {
791791
// Thus in the not nicely ordered case we emit the following instead:
792792
//
793793
// match (&$arg0, &$arg1, …) {
794-
// _args => [ArgumentV1::new(_args.$i, …), ArgumentV1::new(_args.$j, …), …]
794+
// args => [ArgumentV1::new(args.$i, …), ArgumentV1::new(args.$j, …), …]
795795
// }
796796
//
797797
// for the sequence of indices $i, $j, … governed by fmt_arg_index_and_ty.
@@ -804,7 +804,7 @@ impl<'a, 'b> Context<'a, 'b> {
804804
self.ecx.expr_addr_of(expansion_span, P(e.take()))
805805
} else {
806806
let def_site = self.ecx.with_def_site_ctxt(span);
807-
let args_tuple = self.ecx.expr_ident(def_site, Ident::new(sym::_args, def_site));
807+
let args_tuple = self.ecx.expr_ident(def_site, Ident::new(sym::args, def_site));
808808
let member = Ident::new(sym::integer(arg_index), def_site);
809809
self.ecx.expr(def_site, ast::ExprKind::Field(args_tuple, member))
810810
};
@@ -828,7 +828,7 @@ impl<'a, 'b> Context<'a, 'b> {
828828
.map(|e| self.ecx.expr_addr_of(e.span.with_ctxt(self.macsp.ctxt()), e))
829829
.collect();
830830

831-
let pat = self.ecx.pat_ident(self.macsp, Ident::new(sym::_args, self.macsp));
831+
let pat = self.ecx.pat_ident(self.macsp, Ident::new(sym::args, self.macsp));
832832
let arm = self.ecx.arm(self.macsp, pat, args_array);
833833
let head = self.ecx.expr(self.macsp, ast::ExprKind::Tup(heads));
834834
self.ecx.expr_match(self.macsp, head, vec![arm])

‎compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::interpret::{
77
};
88

99
use rustc_errors::ErrorReported;
10-
use rustc_hir as hir;
1110
use rustc_hir::def::DefKind;
1211
use rustc_middle::mir;
1312
use rustc_middle::mir::interpret::ErrorHandled;
@@ -216,7 +215,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
216215
tcx: TyCtxt<'tcx>,
217216
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
218217
) -> ::rustc_middle::mir::interpret::EvalToConstValueResult<'tcx> {
219-
assert!(key.param_env.constness() == hir::Constness::Const);
218+
assert!(key.param_env.is_const());
220219
// see comment in eval_to_allocation_raw_provider for what we're doing here
221220
if key.param_env.reveal() == Reveal::All {
222221
let mut key = key;
@@ -251,7 +250,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
251250
tcx: TyCtxt<'tcx>,
252251
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
253252
) -> ::rustc_middle::mir::interpret::EvalToAllocationRawResult<'tcx> {
254-
assert!(key.param_env.constness() == hir::Constness::Const);
253+
assert!(key.param_env.is_const());
255254
// Because the constant is computed twice (once per value of `Reveal`), we are at risk of
256255
// reporting the same error twice here. To resolve this, we check whether we can evaluate the
257256
// constant in the more restrictive `Reveal::UserFacing`, which most likely already was

‎compiler/rustc_infer/src/infer/opaque_types.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,15 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
569569
let predicate = predicate.fold_with(&mut BottomUpFolder {
570570
tcx,
571571
ty_op: |ty| match ty.kind() {
572-
ty::Projection(projection_ty) => infcx.infer_projection(
573-
self.param_env,
574-
*projection_ty,
575-
traits::ObligationCause::misc(self.value_span, self.body_id),
576-
0,
577-
&mut self.obligations,
578-
),
572+
ty::Projection(projection_ty) if !projection_ty.has_escaping_bound_vars() => {
573+
infcx.infer_projection(
574+
self.param_env,
575+
*projection_ty,
576+
traits::ObligationCause::misc(self.value_span, self.body_id),
577+
0,
578+
&mut self.obligations,
579+
)
580+
}
579581
_ => ty,
580582
},
581583
lt_op: |lt| lt,

‎compiler/rustc_lint/src/traits.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,14 @@ declare_lint_pass!(
8686

8787
impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
8888
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
89-
use rustc_middle::ty;
9089
use rustc_middle::ty::PredicateKind::*;
9190

9291
let predicates = cx.tcx.explicit_predicates_of(item.def_id);
9392
for &(predicate, span) in predicates.predicates {
9493
let Trait(trait_predicate) = predicate.kind().skip_binder() else {
9594
continue
9695
};
97-
if trait_predicate.constness == ty::BoundConstness::ConstIfConst {
96+
if trait_predicate.is_const_if_const() {
9897
// `~const Drop` definitely have meanings so avoid linting here.
9998
continue;
10099
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,11 @@ impl<'tcx> TraitPredicate<'tcx> {
784784
pub fn self_ty(self) -> Ty<'tcx> {
785785
self.trait_ref.self_ty()
786786
}
787+
788+
#[inline]
789+
pub fn is_const_if_const(self) -> bool {
790+
self.constness == BoundConstness::ConstIfConst
791+
}
787792
}
788793

789794
impl<'tcx> PolyTraitPredicate<'tcx> {
@@ -803,6 +808,11 @@ impl<'tcx> PolyTraitPredicate<'tcx> {
803808
p
804809
});
805810
}
811+
812+
#[inline]
813+
pub fn is_const_if_const(self) -> bool {
814+
self.skip_binder().is_const_if_const()
815+
}
806816
}
807817

808818
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
@@ -1388,6 +1398,11 @@ impl<'tcx> ParamEnv<'tcx> {
13881398
self.packed.tag().constness
13891399
}
13901400

1401+
#[inline]
1402+
pub fn is_const(self) -> bool {
1403+
self.packed.tag().constness == hir::Constness::Const
1404+
}
1405+
13911406
/// Construct a trait environment with no where-clauses in scope
13921407
/// where the values of all `impl Trait` and other hidden types
13931408
/// are revealed. This is suitable for monomorphized, post-typeck
@@ -1503,6 +1518,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
15031518
polarity: ty::ImplPolarity::Positive,
15041519
})
15051520
}
1521+
15061522
#[inline]
15071523
pub fn without_const(self) -> PolyTraitPredicate<'tcx> {
15081524
self.with_constness(BoundConstness::NotConst)

‎compiler/rustc_span/src/symbol.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ symbols! {
272272
__H,
273273
__S,
274274
__try_var,
275-
_args,
276275
_d,
277276
_e,
278277
_task_context,
@@ -324,6 +323,7 @@ symbols! {
324323
append_const_msg,
325324
arbitrary_enum_discriminant,
326325
arbitrary_self_types,
326+
args,
327327
arith_offset,
328328
arm,
329329
arm_target_feature,

‎compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,28 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
439439
} else {
440440
err.span_label(span, explanation);
441441
}
442+
443+
if trait_predicate.is_const_if_const() && obligation.param_env.is_const() {
444+
let non_const_predicate = trait_ref.without_const();
445+
let non_const_obligation = Obligation {
446+
cause: obligation.cause.clone(),
447+
param_env: obligation.param_env.without_const(),
448+
predicate: non_const_predicate.to_predicate(tcx),
449+
recursion_depth: obligation.recursion_depth,
450+
};
451+
if self.predicate_may_hold(&non_const_obligation) {
452+
err.span_note(
453+
span,
454+
&format!(
455+
"the trait `{}` is implemented for `{}`, \
456+
but that implementation is not `const`",
457+
non_const_predicate.print_modifiers_and_trait_path(),
458+
trait_ref.skip_binder().self_ty(),
459+
),
460+
);
461+
}
462+
}
463+
442464
if let Some((msg, span)) = type_def {
443465
err.span_label(span, &msg);
444466
}

‎compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
305305
} else if lang_items.unsize_trait() == Some(def_id) {
306306
self.assemble_candidates_for_unsizing(obligation, &mut candidates);
307307
} else if lang_items.drop_trait() == Some(def_id)
308-
&& obligation.predicate.skip_binder().constness == ty::BoundConstness::ConstIfConst
308+
&& obligation.predicate.is_const_if_const()
309309
{
310310
self.assemble_const_drop_candidates(obligation, &mut candidates);
311311
} else {

‎compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
7272
// CheckPredicate(&A: Super)
7373
// CheckPredicate(A: ~const Super) // <- still const env, failure
7474
// ```
75-
if obligation.param_env.constness() == Constness::Const
76-
&& obligation.predicate.skip_binder().constness == ty::BoundConstness::NotConst
77-
{
75+
if obligation.param_env.is_const() && !obligation.predicate.is_const_if_const() {
7876
new_obligation = TraitObligation {
7977
cause: obligation.cause.clone(),
8078
param_env: obligation.param_env.without_const(),

‎compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11731173
ImplCandidate(def_id)
11741174
if tcx.impl_constness(def_id) == hir::Constness::Const => {}
11751175
// const param
1176-
ParamCandidate(trait_pred)
1177-
if trait_pred.skip_binder().constness
1178-
== ty::BoundConstness::ConstIfConst => {}
1176+
ParamCandidate(trait_pred) if trait_pred.is_const_if_const() => {}
11791177
// auto trait impl
11801178
AutoImplCandidate(..) => {}
11811179
// generator, this will raise error in other places

‎library/core/src/future/join.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::task::{Context, Poll};
99
/// Polls multiple futures simultaneously, returning a tuple
1010
/// of all results once complete.
1111
///
12-
/// While `join!(a, b)` is similar to `(a.await, b.await)`,
12+
/// While `join!(a, b).await` is similar to `(a.await, b.await)`,
1313
/// `join!` polls both futures concurrently and is therefore more efficient.
1414
///
1515
/// # Examples

‎library/std/src/fs/tests.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1504,3 +1504,19 @@ fn create_dir_long_paths() {
15041504
let path = Path::new("");
15051505
assert_eq!(path.canonicalize().unwrap_err().kind(), crate::io::ErrorKind::NotFound);
15061506
}
1507+
1508+
/// Ensure ReadDir works on large directories.
1509+
/// Regression test for https://github.com/rust-lang/rust/issues/93384.
1510+
#[test]
1511+
fn read_large_dir() {
1512+
let tmpdir = tmpdir();
1513+
1514+
let count = 32 * 1024;
1515+
for i in 0..count {
1516+
check!(fs::File::create(tmpdir.join(&i.to_string())));
1517+
}
1518+
1519+
for entry in fs::read_dir(tmpdir.path()).unwrap() {
1520+
entry.unwrap();
1521+
}
1522+
}

‎library/std/src/lib.rs

+25-19
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,6 @@ pub use alloc_crate::string;
403403
pub use alloc_crate::vec;
404404
#[stable(feature = "rust1", since = "1.0.0")]
405405
pub use core::any;
406-
#[stable(feature = "simd_arch", since = "1.27.0")]
407-
// The `no_inline`-attribute is required to make the documentation of all
408-
// targets available.
409-
// See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
410-
// more information.
411-
#[doc(no_inline)] // Note (#82861): required for correct documentation
412-
pub use core::arch;
413406
#[stable(feature = "core_array", since = "1.36.0")]
414407
pub use core::array;
415408
#[stable(feature = "rust1", since = "1.0.0")]
@@ -527,6 +520,31 @@ pub mod task {
527520
pub use alloc::task::*;
528521
}
529522

523+
#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
524+
#[stable(feature = "simd_arch", since = "1.27.0")]
525+
pub mod arch {
526+
#[stable(feature = "simd_arch", since = "1.27.0")]
527+
// The `no_inline`-attribute is required to make the documentation of all
528+
// targets available.
529+
// See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
530+
// more information.
531+
#[doc(no_inline)] // Note (#82861): required for correct documentation
532+
pub use core::arch::*;
533+
534+
#[stable(feature = "simd_x86", since = "1.27.0")]
535+
pub use std_detect::is_x86_feature_detected;
536+
#[unstable(feature = "stdsimd", issue = "48556")]
537+
pub use std_detect::{
538+
is_aarch64_feature_detected, is_arm_feature_detected, is_mips64_feature_detected,
539+
is_mips_feature_detected, is_powerpc64_feature_detected, is_powerpc_feature_detected,
540+
is_riscv_feature_detected,
541+
};
542+
}
543+
544+
// This was stabilized in the crate root so we have to keep it there.
545+
#[stable(feature = "simd_x86", since = "1.27.0")]
546+
pub use std_detect::is_x86_feature_detected;
547+
530548
// The runtime entry point and a few unstable public functions used by the
531549
// compiler
532550
#[macro_use]
@@ -545,18 +563,6 @@ mod panicking;
545563
#[allow(dead_code, unused_attributes)]
546564
mod backtrace_rs;
547565

548-
#[stable(feature = "simd_x86", since = "1.27.0")]
549-
pub use std_detect::is_x86_feature_detected;
550-
#[doc(hidden)]
551-
#[unstable(feature = "stdsimd", issue = "48556")]
552-
pub use std_detect::*;
553-
#[unstable(feature = "stdsimd", issue = "48556")]
554-
pub use std_detect::{
555-
is_aarch64_feature_detected, is_arm_feature_detected, is_mips64_feature_detected,
556-
is_mips_feature_detected, is_powerpc64_feature_detected, is_powerpc_feature_detected,
557-
is_riscv_feature_detected,
558-
};
559-
560566
// Re-export macros defined in libcore.
561567
#[stable(feature = "rust1", since = "1.0.0")]
562568
#[allow(deprecated, deprecated_in_future)]

‎library/std/src/sys/unix/fs.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,18 @@ impl Iterator for ReadDir {
489489
};
490490
}
491491

492+
// Only d_reclen bytes of *entry_ptr are valid, so we can't just copy the
493+
// whole thing (#93384). Instead, copy everything except the name.
494+
let entry_bytes = entry_ptr as *const u8;
495+
let entry_name = ptr::addr_of!((*entry_ptr).d_name) as *const u8;
496+
let name_offset = entry_name.offset_from(entry_bytes) as usize;
497+
let mut entry: dirent64 = mem::zeroed();
498+
ptr::copy_nonoverlapping(entry_bytes, &mut entry as *mut _ as *mut u8, name_offset);
499+
492500
let ret = DirEntry {
493-
entry: *entry_ptr,
501+
entry,
494502
// d_name is guaranteed to be null-terminated.
495-
name: CStr::from_ptr((*entry_ptr).d_name.as_ptr()).to_owned(),
503+
name: CStr::from_ptr(entry_name as *const _).to_owned(),
496504
dir: Arc::clone(&self.inner),
497505
};
498506
if ret.name_bytes() != b"." && ret.name_bytes() != b".." {

‎library/std/tests/run-time-detect.rs

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#[test]
1515
#[cfg(all(target_arch = "arm", any(target_os = "linux", target_os = "android")))]
1616
fn arm_linux() {
17+
use std::arch::is_arm_feature_detected;
1718
println!("neon: {}", is_arm_feature_detected!("neon"));
1819
println!("pmull: {}", is_arm_feature_detected!("pmull"));
1920
println!("crypto: {}", is_arm_feature_detected!("crypto"));
@@ -25,6 +26,7 @@ fn arm_linux() {
2526
#[test]
2627
#[cfg(all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")))]
2728
fn aarch64_linux() {
29+
use std::arch::is_aarch64_feature_detected;
2830
println!("neon: {}", is_aarch64_feature_detected!("neon"));
2931
println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
3032
println!("pmull: {}", is_aarch64_feature_detected!("pmull"));
@@ -71,6 +73,7 @@ fn aarch64_linux() {
7173
#[test]
7274
#[cfg(all(target_arch = "powerpc", target_os = "linux"))]
7375
fn powerpc_linux() {
76+
use std::arch::is_powerpc_feature_detected;
7477
println!("altivec: {}", is_powerpc_feature_detected!("altivec"));
7578
println!("vsx: {}", is_powerpc_feature_detected!("vsx"));
7679
println!("power8: {}", is_powerpc_feature_detected!("power8"));
@@ -79,6 +82,7 @@ fn powerpc_linux() {
7982
#[test]
8083
#[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
8184
fn powerpc64_linux() {
85+
use std::arch::is_powerpc64_feature_detected;
8286
println!("altivec: {}", is_powerpc64_feature_detected!("altivec"));
8387
println!("vsx: {}", is_powerpc64_feature_detected!("vsx"));
8488
println!("power8: {}", is_powerpc64_feature_detected!("power8"));
@@ -87,6 +91,8 @@ fn powerpc64_linux() {
8791
#[test]
8892
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
8993
fn x86_all() {
94+
use std::arch::is_x86_feature_detected;
95+
9096
// the below is the set of features we can test at runtime, but don't actually
9197
// use to gate anything and are thus not part of the X86_ALLOWED_FEATURES list
9298

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl StylePath {
182182

183183
fn write_srclink(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
184184
if let Some(l) = cx.src_href(item) {
185-
write!(buf, "<a class=\"srclink\" href=\"{}\" title=\"goto source code\">source</a>", l)
185+
write!(buf, "<a class=\"srclink\" href=\"{}\">source</a>", l)
186186
}
187187
}
188188

‎src/librustdoc/html/templates/print_item.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1 class="fqn"> {#- -#}
2020
{% endif %}
2121
{%- match src_href -%}
2222
{%- when Some with (href) -%}
23-
<a class="srclink" href="{{href|safe}}" title="goto source code">source</a> · {# -#}
23+
<a class="srclink" href="{{href|safe}}">source</a> · {# -#}
2424
{%- else -%}
2525
{%- endmatch -%}
2626
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs"> {#- -#}

‎src/librustdoc/passes/collect_intra_doc_links.rs

+1
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ fn trait_assoc_to_impl_assoc_item<'tcx>(
920920
///
921921
/// NOTE: this cannot be a query because more traits could be available when more crates are compiled!
922922
/// So it is not stable to serialize cross-crate.
923+
#[instrument(level = "debug", skip(cx))]
923924
fn trait_impls_for<'a>(
924925
cx: &mut DocContext<'a>,
925926
ty: Ty<'a>,

‎src/librustdoc/passes/collect_intra_doc_links/early.rs

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ crate fn early_resolve_intra_doc_links(
3232
all_trait_impls: Default::default(),
3333
};
3434

35+
// Because of the `crate::` prefix, any doc comment can reference
36+
// the crate root's set of in-scope traits. This line makes sure
37+
// it's available.
38+
loader.add_traits_in_scope(CRATE_DEF_ID.to_def_id());
39+
3540
// Overridden `visit_item` below doesn't apply to the crate root,
3641
// so we have to visit its attributes and reexports separately.
3742
loader.load_links_in_attrs(&krate.attrs, krate.span);
@@ -180,6 +185,11 @@ impl Visitor<'_> for IntraLinkCrateLoader<'_, '_> {
180185
if let ItemKind::Mod(..) = item.kind {
181186
let old_mod = mem::replace(&mut self.current_mod, self.resolver.local_def_id(item.id));
182187

188+
// A module written with a outline doc comments will resolve traits relative
189+
// to the parent module. Make sure the parent module's traits-in-scope are
190+
// loaded, even if the module itself has no doc comments.
191+
self.add_traits_in_parent_scope(self.current_mod.to_def_id());
192+
183193
self.load_links_in_attrs(&item.attrs, item.span);
184194
self.process_module_children_or_reexports(self.current_mod.to_def_id());
185195
visit::walk_item(self, item);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pub struct Test<'a> {
2+
data: &'a (),
3+
}
4+
5+
impl<'a> Test<'a> {
6+
pub fn do_test(&self) {}
7+
}
8+
9+
// @has crate_relative/demo/index.html
10+
// @has - '//a/@href' '../struct.Test.html#method.do_test'
11+
pub mod demo {
12+
//! [`crate::Test::do_test`]
13+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pub mod wrapper {
2+
3+
pub struct Test<'a> {
4+
data: &'a (),
5+
}
6+
7+
impl<'a> Test<'a> {
8+
pub fn do_test(&self) {}
9+
}
10+
11+
// @has mod_relative/wrapper/demo/index.html
12+
// @has - '//a/@href' '../struct.Test.html#method.do_test'
13+
/// [`Test::do_test`]
14+
pub mod demo {
15+
}
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// check-pass
2+
3+
#![feature(generic_associated_types)]
4+
5+
pub trait Scalar: 'static {
6+
type RefType<'a>: ScalarRef<'a>;
7+
}
8+
9+
pub trait ScalarRef<'a>: 'a {}
10+
11+
fn cmp_eq<'a, 'b, A: Scalar, B: Scalar, O: Scalar>(a: A::RefType<'a>, b: B::RefType<'b>) -> O {
12+
todo!()
13+
}
14+
15+
fn build_expression<A: Scalar, B: Scalar, O: Scalar>(
16+
) -> impl Fn(A::RefType<'_>, B::RefType<'_>) -> O {
17+
cmp_eq
18+
}
19+
20+
fn main() {}

‎src/test/ui/intrinsics/const-eval-select-bad.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ LL | const_eval_select((), || {}, || {});
77
| required by a bound introduced by this call
88
|
99
= help: the trait `~const FnOnce<()>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
10+
note: the trait `FnOnce<()>` is implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`, but that implementation is not `const`
11+
--> $DIR/const-eval-select-bad.rs:6:27
12+
|
13+
LL | const_eval_select((), || {}, || {});
14+
| ^^^^^
1015
= note: wrap the `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]` in a closure with no arguments: `|| { /* code */ }`
1116
note: required by a bound in `const_eval_select`
1217
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL

‎src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ LL | type Bar = NonConstAdd;
55
| ^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd`
66
|
77
= help: the trait `~const Add` is not implemented for `NonConstAdd`
8+
note: the trait `Add` is implemented for `NonConstAdd`, but that implementation is not `const`
9+
--> $DIR/assoc-type.rs:18:16
10+
|
11+
LL | type Bar = NonConstAdd;
12+
| ^^^^^^^^^^^
813
note: required by a bound in `Foo::Bar`
914
--> $DIR/assoc-type.rs:14:15
1015
|

‎src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ LL | pub const EQ: bool = equals_self(&S);
77
| required by a bound introduced by this call
88
|
99
= help: the trait `~const PartialEq` is not implemented for `S`
10+
note: the trait `PartialEq` is implemented for `S`, but that implementation is not `const`
11+
--> $DIR/call-generic-method-nonconst.rs:19:34
12+
|
13+
LL | pub const EQ: bool = equals_self(&S);
14+
| ^^
1015
note: required by a bound in `equals_self`
1116
--> $DIR/call-generic-method-nonconst.rs:12:25
1217
|

‎src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ LL | const _: () = check($exp);
2828
LL | ConstImplWithDropGlue(NonTrivialDrop),
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Drop` is not implemented for `NonTrivialDrop`
3030
|
31+
note: the trait `Drop` is implemented for `NonTrivialDrop`, but that implementation is not `const`
32+
--> $DIR/const-drop-fail.rs:46:5
33+
|
34+
LL | ConstImplWithDropGlue(NonTrivialDrop),
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3136
note: required because it appears within the type `ConstImplWithDropGlue`
3237
--> $DIR/const-drop-fail.rs:17:8
3338
|

‎src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ LL | const _: () = check($exp);
2828
LL | ConstImplWithDropGlue(NonTrivialDrop),
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Drop` is not implemented for `NonTrivialDrop`
3030
|
31+
note: the trait `Drop` is implemented for `NonTrivialDrop`, but that implementation is not `const`
32+
--> $DIR/const-drop-fail.rs:46:5
33+
|
34+
LL | ConstImplWithDropGlue(NonTrivialDrop),
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3136
note: required because it appears within the type `ConstImplWithDropGlue`
3237
--> $DIR/const-drop-fail.rs:17:8
3338
|

‎src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ error[E0277]: the trait bound `(): ~const Tr` is not satisfied
44
LL | foo::<()>();
55
| ^^ the trait `~const Tr` is not implemented for `()`
66
|
7+
note: the trait `Tr` is implemented for `()`, but that implementation is not `const`
8+
--> $DIR/default-method-body-is-const-body-checking.rs:12:15
9+
|
10+
LL | foo::<()>();
11+
| ^^
712
note: required by a bound in `foo`
813
--> $DIR/default-method-body-is-const-body-checking.rs:7:28
914
|

‎src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ error[E0277]: the trait bound `T: ~const Bar` is not satisfied
44
LL | T::b();
55
| ^^^^ the trait `~const Bar` is not implemented for `T`
66
|
7+
note: the trait `Bar` is implemented for `T`, but that implementation is not `const`
8+
--> $DIR/trait-where-clause.rs:14:5
9+
|
10+
LL | T::b();
11+
| ^^^^
712
note: required by a bound in `Foo::b`
813
--> $DIR/trait-where-clause.rs:8:24
914
|
@@ -20,6 +25,11 @@ error[E0277]: the trait bound `T: ~const Bar` is not satisfied
2025
LL | T::c::<T>();
2126
| ^^^^^^^^^ the trait `~const Bar` is not implemented for `T`
2227
|
28+
note: the trait `Bar` is implemented for `T`, but that implementation is not `const`
29+
--> $DIR/trait-where-clause.rs:16:5
30+
|
31+
LL | T::c::<T>();
32+
| ^^^^^^^^^
2333
note: required by a bound in `Foo::c`
2434
--> $DIR/trait-where-clause.rs:9:13
2535
|

0 commit comments

Comments
 (0)
Please sign in to comment.