-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Update(fmease, 2024-01-24): #94321 (comment):
This issue goes away if the doc tests have the
#![feature(generic_const_exprs)]flag enabled.
I realized thanks to #94287 (comment); maybe a better diagnostic could help here.
The doc test for foo and the test tests::test contain the same code (the only difference is the use statement which has to be different). The lib test passes but the doc test fails to compile.
#![feature(generic_const_exprs)]
pub struct If<const CONDITION: bool>;
pub trait True {}
impl True for If<true> {}
pub struct FixedU64<const FRAC: u32>;
/// ```rust
/// use fcg5::{foo, FixedU64};
/// foo(FixedU64::<4>);
/// ```
pub fn foo<const FRAC: u32>(_fixed: FixedU64<FRAC>)
where
If<{ FRAC <= 64 }>: True,
{
}
#[cfg(test)]
mod tests {
#[test]
fn test() {
use crate::{foo, FixedU64};
foo(FixedU64::<4>);
}
}cargo +nightly test:
Compiling fcg5 v0.1.0 (/home/trevor/try/fcg5)
...
Finished test [unoptimized + debuginfo] target(s) in 0.44s
Running unittests src/lib.rs (target/debug/deps/fcg5-877f755fe1bd39e7)
running 1 test
test tests::test ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests fcg5
...
running 1 test
test src/lib.rs - foo (line 9) ... FAILED
failures:
---- src/lib.rs - foo (line 9) stdout ----
error[E0277]: the trait bound `If<{_: bool}>: True` is not satisfied
--> src/lib.rs:11:1
|
5 | foo(FixedU64::<4>);
| ^^^ the trait `True` is not implemented for `If<{_: bool}>`
|
= help: the following implementations were found:
<If<true> as True>
note: required by a bound in `foo`
--> /home/trevor/try/fcg5/src/lib.rs:15:25
|
15 | If<{ FRAC <= 64 }>: True,
| ^^^^ required by this bound in `foo`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
Couldn't compile the test.
failures:
src/lib.rs - foo (line 9)
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
error: test failed, to rerun pass '--doc'
Meta
rustc +nightly --version --verbose:
rustc 1.61.0-nightly (532d3cda9 2022-02-23)
binary: rustc
commit-hash: 532d3cda90b8a729cd982548649d32803d265052
commit-date: 2022-02-23
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.