Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4333091
Update E0637 description to mention `&` w/o an explicit lifetime name
JohnTitor Oct 15, 2021
d2470e7
rustc_ast: Turn `MutVisitor::token_visiting_enabled` into a constant
petrochenkov Oct 17, 2021
7581bae
Fix const qualification when executed after promotion
tmiasko Oct 19, 2021
21d02bf
Add a regression test for issue-83479
JohnTitor Oct 20, 2021
396a4f4
Increase `ROOT_ENTRY_LIMIT` to 1331
JohnTitor Oct 20, 2021
6469fba
Trait objects
BoxyUwU Oct 20, 2021
a81e489
Return pos impl trait
BoxyUwU Oct 20, 2021
83a1834
Wfness
BoxyUwU Oct 20, 2021
8f23779
Inference
BoxyUwU Oct 20, 2021
7a8bd2d
add fixme
BoxyUwU Oct 20, 2021
c75d8cb
Ordering
BoxyUwU Oct 20, 2021
e7a9e82
*dust dust*
BoxyUwU Oct 20, 2021
74c6636
Verify that only NeedsNonConstDrop expects promoteds
tmiasko Oct 21, 2021
ab44e46
Add test for issue #78561
samlich Oct 20, 2021
d50832b
triagebot: Treat `I-*nominated` like `I-nominated`
joshtriplett Oct 21, 2021
04c1ec5
Clarify undefined behaviour for binary heap, btree and hashset
Wilfred Jul 28, 2021
a1cf430
Rollup merge of #87537 - Wilfred:improve-min-heap-docs, r=Mark-Simula…
matthiaskrgr Oct 22, 2021
42e4846
Rollup merge of #89922 - JohnTitor:update-e0637, r=jackh726
matthiaskrgr Oct 22, 2021
fd1a3c9
Rollup merge of #89991 - petrochenkov:visitok2, r=jackh726
matthiaskrgr Oct 22, 2021
089f754
Rollup merge of #90069 - tmiasko:promoted-const-qualif, r=oli-obk
matthiaskrgr Oct 22, 2021
1b1fa74
Rollup merge of #90078 - JohnTitor:test-83479, r=Mark-Simulacrum
matthiaskrgr Oct 22, 2021
4998ce1
Rollup merge of #90114 - BoxyUwU:cg_defaults_tests, r=lcnr
matthiaskrgr Oct 22, 2021
f80d02b
Rollup merge of #90115 - samlich:test-issue-78561, r=oli-obk
matthiaskrgr Oct 22, 2021
d3b9a1a
Rollup merge of #90129 - joshtriplett:triagebot-nominated, r=Mark-Sim…
matthiaskrgr Oct 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Trait objects
  • Loading branch information
BoxyUwU committed Oct 20, 2021
commit 6469fba44ed6873e85cc916cf1aa51d4d1b2cb46
45 changes: 45 additions & 0 deletions src/test/ui/const-generics/defaults/trait_objects.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// run-pass
#![feature(const_generics_defaults)]

trait Trait<const N: u8 = 12> {
fn uwu(&self) -> u8 {
N
}
}

impl Trait for u32 {}

impl Trait<12> for u64 {
fn uwu(&self) -> u8 {
*self as u8
}
}

fn foo(arg: &dyn Trait) -> u8 {
arg.uwu()
}

trait Traitor<const N: u8 = 1, const M: u8 = N> {
fn owo(&self) -> u8 {
M
}
}

impl Traitor<2> for bool { }
impl Traitor for u8 {
fn owo(&self) -> u8 {
*self
}
}

fn bar<const N: u8>(arg: &dyn Traitor<N>) -> u8 {
arg.owo()
}

fn main() {
assert_eq!(foo(&10_u32), 12);
assert_eq!(foo(&3_u64), 3);

assert_eq!(bar(&true), 2);
assert_eq!(bar(&1_u8), 1);
}
32 changes: 32 additions & 0 deletions src/test/ui/const-generics/defaults/trait_objects_fail.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![feature(const_generics_defaults)]

trait Trait<const N: u8 = 12> {
fn uwu(&self) -> u8 {
N
}
}

impl Trait<2> for u32 {}

fn foo(arg: &dyn Trait) -> u8 {
arg.uwu()
}

trait Traitor<const N: u8 = 1, const M: u8 = N> {
fn owo(&self) -> u8 {
M
}
}

impl Traitor<2, 3> for bool { }

fn bar<const N: u8>(arg: &dyn Traitor<N>) -> u8 {
arg.owo()
}

fn main() {
foo(&10_u32);
//~^ error: the trait bound `u32: Trait` is not satisfied
bar(&true);
//~^ error: the trait bound `bool: Traitor<{_: u8}, {_: u8}>` is not satisfied
}
27 changes: 27 additions & 0 deletions src/test/ui/const-generics/defaults/trait_objects_fail.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0277]: the trait bound `u32: Trait` is not satisfied
--> $DIR/trait_objects_fail.rs:28:9
|
LL | foo(&10_u32);
| --- ^^^^^^^ the trait `Trait` is not implemented for `u32`
| |
| required by a bound introduced by this call
|
= help: the following implementations were found:
<u32 as Trait<2_u8>>
= note: required for the cast to the object type `dyn Trait`

error[E0277]: the trait bound `bool: Traitor<{_: u8}, {_: u8}>` is not satisfied
--> $DIR/trait_objects_fail.rs:30:9
|
LL | bar(&true);
| --- ^^^^^ the trait `Traitor<{_: u8}, {_: u8}>` is not implemented for `bool`
| |
| required by a bound introduced by this call
|
= help: the following implementations were found:
<bool as Traitor<2_u8, 3_u8>>
= note: required for the cast to the object type `dyn Traitor<{_: u8}, {_: u8}>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.