2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_variables)]
|
2015-05-26 09:57:40 -05:00
|
|
|
// Issue #24644 - block causes a &Trait -> &Trait coercion:
|
|
|
|
trait Trait {}
|
|
|
|
|
|
|
|
struct Bar;
|
|
|
|
impl Trait for Bar {}
|
|
|
|
|
|
|
|
fn main() {
|
2019-05-28 13:47:21 -05:00
|
|
|
let x: &[&dyn Trait] = &[{ &Bar }];
|
2015-05-26 09:57:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Issue #25748 - the cast causes an &Encoding -> &Encoding coercion:
|
|
|
|
pub struct UTF8Encoding;
|
|
|
|
pub const UTF_8: &'static UTF8Encoding = &UTF8Encoding;
|
|
|
|
pub trait Encoding {}
|
|
|
|
impl Encoding for UTF8Encoding {}
|
2019-05-28 13:47:21 -05:00
|
|
|
pub fn f() -> &'static dyn Encoding { UTF_8 as &'static dyn Encoding }
|
2015-05-26 09:57:40 -05:00
|
|
|
|
|
|
|
// Root of the problem: &Trait -> &Trait coercions:
|
2019-05-28 13:47:21 -05:00
|
|
|
const FOO: &'static dyn Trait = &Bar;
|
|
|
|
const BAR: &'static dyn Trait = FOO;
|
2015-05-26 09:57:40 -05:00
|
|
|
fn foo() { let _x = BAR; }
|