-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Properly bubble up ambiguity in normalize query #102858
Closed
compiler-errors
wants to merge
3
commits into
rust-lang:master
from
compiler-errors:normalization-ambiguity-in-rustdoc
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// compile-flags: -Znormalize-docs | ||
|
||
#![feature(type_alias_impl_trait)] | ||
|
||
trait Allocator { | ||
type Buffer; | ||
} | ||
|
||
struct DefaultAllocator; | ||
|
||
impl<T> Allocator for DefaultAllocator { | ||
type Buffer = (); | ||
} | ||
|
||
type A = impl Fn(<DefaultAllocator as Allocator>::Buffer); | ||
|
||
fn foo() -> A { | ||
|_| () | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// edition:2021 | ||
|
||
mod hyper { | ||
use std::{fmt::Debug, future::Future, marker::PhantomData, pin::Pin, task::Poll}; | ||
|
||
pub trait HttpBody { | ||
type Error; | ||
} | ||
impl HttpBody for () { | ||
//~^ ERROR not all trait items implemented, missing: `Error` | ||
// don't implement `Error` here for the ICE | ||
} | ||
|
||
pub struct Server<I, S>(I, S); | ||
|
||
pub fn serve<I, S>(_: S) -> Server<I, S> { | ||
todo!() | ||
} | ||
|
||
impl<S, B> Future for Server<(), S> | ||
where | ||
S: MakeServiceRef<(), (), ResBody = B>, | ||
B: HttpBody, | ||
B::Error: Debug, | ||
{ | ||
type Output = (); | ||
|
||
fn poll(self: Pin<&mut Self>, _: &mut std::task::Context<'_>) -> Poll<Self::Output> { | ||
todo!() | ||
} | ||
} | ||
|
||
pub trait MakeServiceRef<Target, ReqBody> { | ||
type ResBody; | ||
} | ||
|
||
impl<T, S> MakeServiceRef<(), ()> for T | ||
where | ||
T: for<'a> Service<&'a (), Response = S>, | ||
S: Service<()>, | ||
{ | ||
type ResBody = (); | ||
} | ||
|
||
pub struct MakeServiceFn<F>(pub F); | ||
pub struct ServiceFn<F, R>(pub PhantomData<(F, R)>); | ||
|
||
pub trait Service<Request> { | ||
type Response; | ||
} | ||
|
||
impl<'t, F, Ret, Target, Svc> Service<&'t Target> for MakeServiceFn<F> | ||
where | ||
F: Fn() -> Ret, | ||
Ret: Future<Output = Result<Svc, ()>>, | ||
{ | ||
type Response = Svc; | ||
} | ||
|
||
impl<F, ReqBody, Ret, ResBody, E> Service<ReqBody> for ServiceFn<F, ReqBody> | ||
where | ||
F: Fn() -> Ret, | ||
Ret: Future<Output = Result<ResBody, E>>, | ||
{ | ||
type Response = ResBody; | ||
} | ||
} | ||
|
||
async fn smarvice() -> Result<(), ()> { | ||
Ok(()) | ||
} | ||
|
||
fn service_fn<F, R, S>(f: F) -> hyper::ServiceFn<F, R> | ||
where | ||
F: Fn() -> S, | ||
{ | ||
hyper::ServiceFn(std::marker::PhantomData) | ||
} | ||
|
||
async fn iceice() { | ||
let service = hyper::MakeServiceFn(|| async { Ok::<_, ()>(service_fn(|| smarvice())) }); | ||
hyper::serve::<(), _>(service).await; | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0046]: not all trait items implemented, missing: `Error` | ||
--> $DIR/issue-103181-1.rs:9:5 | ||
| | ||
LL | type Error; | ||
| ---------- `Error` from trait | ||
LL | } | ||
LL | impl HttpBody for () { | ||
| ^^^^^^^^^^^^^^^^^^^^ missing `Error` in implementation | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// edition:2021 | ||
|
||
trait SendFuture: Send { | ||
type Output; | ||
} | ||
|
||
impl<Fut: Send> SendFuture for Fut { | ||
type Output = (); | ||
} | ||
|
||
async fn broken_fut() { | ||
ident_error; | ||
//~^ ERROR cannot find value `ident_error` in this scope | ||
} | ||
|
||
// triggers normalization of `<Fut as SendFuture>::Output`, | ||
// which requires `Fut: Send`. | ||
fn normalize<Fut: SendFuture>(_: Fut, _: Fut::Output) {} | ||
|
||
async fn iceice<A, B>() | ||
// <- async fn is necessary | ||
where | ||
A: Send, | ||
B: Send, // <- a second bound | ||
{ | ||
normalize(broken_fut(), ()); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0425]: cannot find value `ident_error` in this scope | ||
--> $DIR/issue-103181-2.rs:12:5 | ||
| | ||
LL | ident_error; | ||
| ^^^^^^^^^^^ not found in this scope | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0425`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you name this file something more descriptive? Something like "normalize-ambiguous-item-not-fatal.rs"?