Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust ast lowering doc tests #106486

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions compiler/rustc_ast_lowering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name = "rustc_ast_lowering"
version = "0.0.0"
edition = "2021"

[lib]
doctest = false


[dependencies]
rustc_arena = { path = "../rustc_arena" }
Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,21 +1418,24 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
/// Given a function definition like:
///
/// ```rust
/// use std::fmt::Debug;
/// fn test<'a, T: Debug>(x: &'a T) -> impl Debug + 'a {
/// x
/// }
/// ```
///
/// we will create a TAIT definition in the HIR like
///
/// ```
/// ```ignore (cannot-test-this-because-type)
/// type TestReturn<'a, T, 'x> = impl Debug + 'x
/// ```
///
/// and return a type like `TestReturn<'static, T, 'a>`, so that the function looks like:
/// and return a type like `TestReturn<'a, 'x, 'T>`, so that the function looks like:
///
/// ```rust
/// fn test<'a, T: Debug>(x: &'a T) -> TestReturn<'static, T, 'a>
/// #![feature(type_alias_impl_trait)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also ignore this here?

/// use std::fmt::Debug;
/// type TestReturn<'a, 'x, T> = impl Debug + 'x;
/// fn test<'a, 'x, T: Debug>(x: &'a T) -> TestReturn<'a, 'x, T>{}
/// ```
///
/// Note the subtlety around type parameters! The new TAIT, `TestReturn`, inherits all the
Expand Down