forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#78976 - GuillaumeGomez:rollup-endkih3, r=Guil…
…laumeGomez Rollup of 5 pull requests Successful merges: - rust-lang#78916 (extend const generics test suite) - rust-lang#78921 (Improve the page title switch handling between search and doc) - rust-lang#78933 (Don't print thread ids and names in `tracing` logs) - rust-lang#78960 (Test default values for const parameters.) - rust-lang#78971 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
33 changed files
with
1,165 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule nomicon
updated
9 files
+5 −0 | .gitignore | |
+44 −44 | src/SUMMARY.md | |
+4 −3 | src/atomics.md | |
+0 −1 | src/chapter_1.md | |
+3 −0 | src/coercions.md | |
+2 −2 | src/other-reprs.md | |
+5 −5 | src/phantom-data.md | |
+2 −2 | src/send-and-sync.md | |
+9 −5 | src/transmutes.md |
Submodule reference
updated
6 files
+1 −1 | .github/workflows/main.yml | |
+2 −1 | src/expressions/field-expr.md | |
+48 −26 | src/expressions/tuple-expr.md | |
+10 −0 | src/patterns.md | |
+32 −19 | src/types/tuple.md | |
+6 −0 | triagebot.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// check-pass | ||
// edition:2018 | ||
#![feature(min_const_generics)] | ||
trait ValidTrait {} | ||
|
||
/// This has docs | ||
pub fn extern_fn<const N: usize>() -> impl Iterator<Item = [u8; N]> { | ||
loop {} | ||
} | ||
|
||
pub trait Trait<const N: usize> {} | ||
impl Trait<1> for u8 {} | ||
impl Trait<2> for u8 {} | ||
impl<const N: usize> Trait<N> for [u8; N] {} | ||
|
||
/// This also has docs | ||
pub fn test<const N: usize>() -> impl Trait<N> where u8: Trait<N> { | ||
loop {} | ||
} | ||
|
||
/// Document all the functions | ||
pub async fn a_sink<const N: usize>(v: [u8; N]) -> impl Trait<N> { | ||
loop {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// edition:2018 | ||
#![feature(min_const_generics)] | ||
|
||
pub fn extern_fn<const N: usize>() -> impl Iterator<Item = [u8; N]> { | ||
[[0; N]; N].iter().copied() | ||
} | ||
|
||
pub struct ExternTy<const N: usize> { | ||
pub inner: [u8; N], | ||
} | ||
|
||
pub type TyAlias<const N: usize> = ExternTy<N>; | ||
|
||
pub trait WTrait<const N: usize, const M: usize> { | ||
fn hey<const P: usize>() -> usize { | ||
N + M + P | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// edition:2018 | ||
// aux-build: extern_crate.rs | ||
#![feature(min_const_generics)] | ||
#![crate_name = "foo"] | ||
|
||
extern crate extern_crate; | ||
// @has foo/fn.extern_fn.html '//pre[@class="rust fn"]' \ | ||
// 'pub fn extern_fn<const N: usize>() -> impl Iterator<Item = [u8; N]>' | ||
pub use extern_crate::extern_fn; | ||
// @has foo/struct.ExternTy.html '//pre[@class="rust struct"]' \ | ||
// 'pub struct ExternTy<const N: usize> {' | ||
pub use extern_crate::ExternTy; | ||
// @has foo/type.TyAlias.html '//pre[@class="rust typedef"]' \ | ||
// 'type TyAlias<const N: usize> = ExternTy<N>;' | ||
pub use extern_crate::TyAlias; | ||
// @has foo/trait.WTrait.html '//pre[@class="rust trait"]' \ | ||
// 'pub trait WTrait<const N: usize, const M: usize>' | ||
// @has - '//*[@class="rust trait"]' 'fn hey<const P: usize>() -> usize' | ||
pub use extern_crate::WTrait; | ||
|
||
// @has foo/trait.Trait.html '//pre[@class="rust trait"]' \ | ||
// 'pub trait Trait<const N: usize>' | ||
// @has - '//*[@id="impl-Trait%3C1_usize%3E-for-u8"]//code' 'impl Trait<1_usize> for u8' | ||
// @has - '//*[@id="impl-Trait%3C2_usize%3E-for-u8"]//code' 'impl Trait<2_usize> for u8' | ||
// @has - '//*[@id="impl-Trait%3C{1%20+%202}%3E-for-u8"]//code' 'impl Trait<{1 + 2}> for u8' | ||
// @has - '//*[@id="impl-Trait%3CN%3E-for-%5Bu8%3B%20N%5D"]//code' \ | ||
// 'impl<const N: usize> Trait<N> for [u8; N]' | ||
pub trait Trait<const N: usize> {} | ||
impl Trait<1> for u8 {} | ||
impl Trait<2> for u8 {} | ||
impl Trait<{1 + 2}> for u8 {} | ||
impl<const N: usize> Trait<N> for [u8; N] {} | ||
|
||
// @has foo/struct.Foo.html '//pre[@class="rust struct"]' \ | ||
// 'pub struct Foo<const N: usize> where u8: Trait<N>' | ||
pub struct Foo<const N: usize> where u8: Trait<N>; | ||
// @has foo/struct.Bar.html '//pre[@class="rust struct"]' 'pub struct Bar<T, const N: usize>(_)' | ||
pub struct Bar<T, const N: usize>([T; N]); | ||
|
||
// @has foo/struct.Foo.html '//h3[@id="impl"]/code' 'impl<const M: usize> Foo<M> where u8: Trait<M>' | ||
impl<const M: usize> Foo<M> where u8: Trait<M> { | ||
// @has - '//*[@id="associatedconstant.FOO_ASSOC"]' 'pub const FOO_ASSOC: usize' | ||
pub const FOO_ASSOC: usize = M + 13; | ||
|
||
// @has - '//*[@id="method.hey"]' 'pub fn hey<const N: usize>(&self) -> Bar<u8, N>' | ||
pub fn hey<const N: usize>(&self) -> Bar<u8, N> { | ||
Bar([0; N]) | ||
} | ||
} | ||
|
||
// @has foo/struct.Bar.html '//h3[@id="impl"]/code' 'impl<const M: usize> Bar<u8, M>' | ||
impl<const M: usize> Bar<u8, M> { | ||
// @has - '//*[@id="method.hey"]' \ | ||
// 'pub fn hey<const N: usize>(&self) -> Foo<N> where u8: Trait<N>' | ||
pub fn hey<const N: usize>(&self) -> Foo<N> where u8: Trait<N> { | ||
Foo | ||
} | ||
} | ||
|
||
// @has foo/fn.test.html '//pre[@class="rust fn"]' \ | ||
// 'pub fn test<const N: usize>() -> impl Trait<N> where u8: Trait<N>' | ||
pub fn test<const N: usize>() -> impl Trait<N> where u8: Trait<N> { | ||
2u8 | ||
} | ||
|
||
// @has foo/fn.a_sink.html '//pre[@class="rust fn"]' \ | ||
// 'pub async fn a_sink<const N: usize>(v: [u8; N]) -> impl Trait<N>' | ||
pub async fn a_sink<const N: usize>(v: [u8; N]) -> impl Trait<N> { | ||
v | ||
} | ||
|
||
// @has foo/fn.b_sink.html '//pre[@class="rust fn"]' \ | ||
// 'pub async fn b_sink<const N: usize>(__arg0: impl Trait<N>)' | ||
// FIXME(const_generics): This should be `_` not `__arg0`. | ||
pub async fn b_sink<const N: usize>(_: impl Trait<N>) {} | ||
|
||
// @has foo/fn.concrete.html '//pre[@class="rust fn"]' \ | ||
// 'pub fn concrete() -> [u8; 22]' | ||
pub fn concrete() -> [u8; 3 + std::mem::size_of::<u64>() << 1] { | ||
Default::default() | ||
} | ||
|
||
// @has foo/type.Faz.html '//pre[@class="rust typedef"]' \ | ||
// 'type Faz<const N: usize> = [u8; N];' | ||
pub type Faz<const N: usize> = [u8; N]; | ||
// @has foo/type.Fiz.html '//pre[@class="rust typedef"]' \ | ||
// 'type Fiz<const N: usize> = [[u8; N]; 48];' | ||
pub type Fiz<const N: usize> = [[u8; N]; 3 << 4]; | ||
|
||
macro_rules! define_me { | ||
($t:tt<$q:tt>) => { | ||
pub struct $t<const $q: usize>([u8; $q]); | ||
} | ||
} | ||
|
||
// @has foo/struct.Foz.html '//pre[@class="rust struct"]' \ | ||
// 'pub struct Foz<const N: usize>(_);' | ||
define_me!(Foz<N>); | ||
|
||
trait Q { | ||
const ASSOC: usize; | ||
} | ||
|
||
impl<const N: usize> Q for [u8; N] { | ||
const ASSOC: usize = N; | ||
} | ||
|
||
// @has foo/fn.q_user.html '//pre[@class="rust fn"]' \ | ||
// 'pub fn q_user() -> [u8; 13]' | ||
pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] { | ||
[0; <[u8; 13] as Q>::ASSOC] | ||
} | ||
|
||
// @has foo/union.Union.html '//pre[@class="rust union"]' \ | ||
// 'pub union Union<const N: usize>' | ||
pub union Union<const N: usize> { | ||
// @has - //pre "pub arr: [u8; N]" | ||
pub arr: [u8; N], | ||
// @has - //pre "pub another_arr: [(); N]" | ||
pub another_arr: [(); N], | ||
} | ||
|
||
// @has foo/enum.Enum.html '//pre[@class="rust enum"]' \ | ||
// 'pub enum Enum<const N: usize>' | ||
pub enum Enum<const N: usize> { | ||
// @has - //pre "Variant([u8; N])" | ||
Variant([u8; N]), | ||
// @has - //pre "EmptyVariant" | ||
EmptyVariant, | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/const-generics/associated-type-bound-fail.full.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0277]: the trait bound `u16: Bar<N>` is not satisfied | ||
--> $DIR/associated-type-bound-fail.rs:14:5 | ||
| | ||
LL | type Assoc: Bar<N>; | ||
| ------ required by this bound in `Foo::Assoc` | ||
... | ||
LL | type Assoc = u16; | ||
| ^^^^^^^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `u16` | ||
| | ||
= help: the following implementations were found: | ||
<u16 as Bar<3_usize>> | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
15 changes: 15 additions & 0 deletions
15
src/test/ui/const-generics/associated-type-bound-fail.min.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0277]: the trait bound `u16: Bar<N>` is not satisfied | ||
--> $DIR/associated-type-bound-fail.rs:14:5 | ||
| | ||
LL | type Assoc: Bar<N>; | ||
| ------ required by this bound in `Foo::Assoc` | ||
... | ||
LL | type Assoc = u16; | ||
| ^^^^^^^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `u16` | ||
| | ||
= help: the following implementations were found: | ||
<u16 as Bar<3_usize>> | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// revisions: full min | ||
#![cfg_attr(full, allow(incomplete_features))] | ||
#![cfg_attr(full, feature(const_generics))] | ||
#![cfg_attr(min, feature(min_const_generics))] | ||
|
||
trait Bar<const N: usize> {} | ||
|
||
trait Foo<const N: usize> { | ||
type Assoc: Bar<N>; | ||
} | ||
|
||
impl Bar<3> for u16 {} | ||
impl<const N: usize> Foo<N> for i16 { | ||
type Assoc = u16; //~ ERROR the trait bound `u16: Bar<N>` | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// run-pass | ||
// revisions: full min | ||
#![cfg_attr(full, allow(incomplete_features))] | ||
#![cfg_attr(full, feature(const_generics))] | ||
#![cfg_attr(min, feature(min_const_generics))] | ||
|
||
trait Bar<const N: usize> {} | ||
|
||
trait Foo<const N: usize> { | ||
type Assoc: Bar<N>; | ||
} | ||
|
||
impl<const N: usize> Bar<N> for u8 {} | ||
impl Bar<3> for u16 {} | ||
|
||
impl<const N: usize> Foo<N> for i8 { | ||
type Assoc = u8; | ||
} | ||
|
||
impl Foo<3> for i16 { | ||
type Assoc = u16; | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// edition:2018 | ||
#![cfg_attr(full, feature(const_generics))] | ||
#![cfg_attr(full, allow(incomplete_features))] | ||
#![cfg_attr(min, feature(min_const_generics))] | ||
|
||
pub trait Foo<const N: usize> {} | ||
struct Local; | ||
impl<const N: usize> Foo<N> for Local {} | ||
|
||
pub fn out_foo<const N: usize>() -> impl Foo<N> { Local } | ||
pub fn in_foo<const N: usize>(_: impl Foo<N>) {} | ||
|
||
pub async fn async_simple<const N: usize>(_: [u8; N]) {} | ||
pub async fn async_out_foo<const N: usize>() -> impl Foo<N> { Local } | ||
pub async fn async_in_foo<const N: usize>(_: impl Foo<N>) {} | ||
|
||
pub trait Bar<const N: usize> { | ||
type Assoc: Foo<N>; | ||
} |
Oops, something went wrong.