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