Skip to content

lazy_type_alias: causes error no nominal type found for inherent implementation #114216

Closed

Description

I tried this code:
tests/rustdoc/deref/deref-typedef.rs

#![crate_name = "foo"]

// @has 'foo/struct.Bar.html'
// @has '-' '//*[@id="deref-methods-FooJ"]' 'Methods from Deref<Target = FooJ>'
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_a"]' 'pub fn foo_a(&self)'
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)'
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)'
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)'
// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-FooJ"]' 'Methods from Deref<Target=FooJ>'
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_a"]' 'foo_a'
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_b"]' 'foo_b'
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_c"]' 'foo_c'
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_j"]' 'foo_j'

pub struct FooA;
pub type FooB = FooA;
pub type FooC = FooB;
pub type FooD = FooC;
pub type FooE = FooD;
pub type FooF = FooE;
pub type FooG = FooF;
pub type FooH = FooG;
pub type FooI = FooH;
pub type FooJ = FooI;

impl FooA {
    pub fn foo_a(&self) {}
}

impl FooB {
    pub fn foo_b(&self) {}
}

impl FooC {
    pub fn foo_c(&self) {}
}

impl FooJ {
    pub fn foo_j(&self) {}
}

pub struct Bar;
impl std::ops::Deref for Bar {
    type Target = FooJ;
    fn deref(&self) -> &Self::Target { unimplemented!() }
}

without `-Zcrate-attr=feature(lazy_type_alias)´: no warnings

with -Zcrate-attr=feature(lazy_type_alias):

error[E0118]: no nominal type found for inherent implementation
  --> tests/rustdoc/deref/deref-typedef.rs:30:1
   |
30 | impl FooB {
   | ^^^^^^^^^ impl requires a nominal type
   |
   = note: either implement a trait on it or create a newtype to wrap it instead

error[E0118]: no nominal type found for inherent implementation
  --> tests/rustdoc/deref/deref-typedef.rs:34:1
   |
34 | impl FooC {
   | ^^^^^^^^^ impl requires a nominal type
   |
   = note: either implement a trait on it or create a newtype to wrap it instead

error[E0118]: no nominal type found for inherent implementation
  --> tests/rustdoc/deref/deref-typedef.rs:38:1
   |
38 | impl FooJ {
   | ^^^^^^^^^ impl requires a nominal type
   |
   = note: either implement a trait on it or create a newtype to wrap it instead

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0118`.
rustc 1.73.0-nightly (04abc370b 2023-07-28)
binary: rustc
commit-hash: 04abc370b9f3855b28172b65a7f7d5a433f41412
commit-date: 2023-07-28
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-lazy_type_alias`#![feature(lazy_type_alias)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions