forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#93778 - matthiaskrgr:rollup-yfngdao, r=matthi…
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#91950 (Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`) - rust-lang#92715 (Do not suggest char literal for zero-length strings) - rust-lang#92917 (Don't constrain projection predicates with inference vars in GAT substs) - rust-lang#93206 (Use `NtCreateFile` instead of `NtOpenFile` to open a file) - rust-lang#93732 (add fut/back compat tests for implied trait bounds) - rust-lang#93764 (:arrow_up: rust-analyzer) - rust-lang#93767 (deduplicate `lcnr` in mailmap) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
19 changed files
with
210 additions
and
33 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,7 @@ Kyle J Strand <[email protected]> <[email protected]> | |
Kyle J Strand <[email protected]> <[email protected]> | ||
Kyle J Strand <[email protected]> <[email protected]> | ||
Laurențiu Nicola <[email protected]> | ||
lcnr <[email protected]> | ||
lcnr <[email protected]> <[email protected]> | ||
Lee Jeffery <[email protected]> Lee Jeffery <[email protected]> | ||
Lee Wondong <[email protected]> | ||
Lennart Kudling <[email protected]> | ||
|
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
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,30 @@ | ||
// check-fail | ||
|
||
// FIXME(generic_associated_types): We almost certaintly want this to pass, but | ||
// it's particularly difficult currently, because we need a way of specifying | ||
// that `<Self::Base as Functor>::With<T> = Self` without using that when we have | ||
// a `U`. See `https://github.com/rust-lang/rust/pull/92728` for a (hacky) | ||
// solution. This might be better to just wait for Chalk. | ||
|
||
#![feature(generic_associated_types)] | ||
|
||
pub trait Functor { | ||
type With<T>; | ||
|
||
fn fmap<T, U>(this: Self::With<T>) -> Self::With<U>; | ||
} | ||
|
||
pub trait FunctorExt<T>: Sized { | ||
type Base: Functor<With<T> = Self>; | ||
|
||
fn fmap<U>(self) { | ||
let arg: <Self::Base as Functor>::With<T>; | ||
let ret: <Self::Base as Functor>::With<U>; | ||
|
||
arg = self; | ||
ret = <Self::Base as Functor>::fmap(arg); | ||
//~^ type annotations needed | ||
} | ||
} | ||
|
||
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[E0282]: type annotations needed | ||
--> $DIR/issue-91762.rs:25:15 | ||
| | ||
LL | ret = <Self::Base as Functor>::fmap(arg); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated function `fmap` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0282`. |
51 changes: 51 additions & 0 deletions
51
src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs
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,51 @@ | ||
// A test exploiting the bug behind #25860 except with | ||
// implied trait bounds which currently don't exist without `-Zchalk`. | ||
use std::marker::PhantomData; | ||
struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>) | ||
where | ||
T: Convert<'a, 'b>; | ||
|
||
trait Convert<'a, 'b>: Sized { | ||
fn cast(&'a self) -> &'b Self; | ||
} | ||
impl<'long: 'short, 'short, T> Convert<'long, 'short> for T { | ||
fn cast(&'long self) -> &'short T { | ||
self | ||
} | ||
} | ||
|
||
// This function will compile once we add implied trait bounds. | ||
// | ||
// If we're not careful with our impl, the transformations | ||
// in `bad` would succeed, which is unsound ✨ | ||
// | ||
// FIXME: the error is pretty bad, this should say | ||
// | ||
// `T: Convert<'in_, 'out>` is not implemented | ||
// | ||
// help: needed by `Foo<'in_, 'out, T>` | ||
// | ||
// Please ping @lcnr if your changes end up causing `badboi` to compile. | ||
fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) -> &'out T { | ||
//~^ ERROR lifetime mismatch | ||
sadness.cast() | ||
} | ||
|
||
fn bad<'short, T>(value: &'short T) -> &'static T { | ||
let x: for<'in_, 'out> fn(Foo<'in_, 'out, T>, &'in_ T) -> &'out T = badboi; | ||
let x: for<'out> fn(Foo<'short, 'out, T>, &'short T) -> &'out T = x; | ||
let x: for<'out> fn(Foo<'static, 'out, T>, &'short T) -> &'out T = x; | ||
let x: fn(Foo<'static, 'static, T>, &'short T) -> &'static T = x; | ||
x(Foo(PhantomData), value) | ||
} | ||
|
||
// Use `bad` to cause a segfault. | ||
fn main() { | ||
let mut outer: Option<&'static u32> = Some(&3); | ||
let static_ref: &'static &'static u32 = match outer { | ||
Some(ref reference) => bad(reference), | ||
None => unreachable!(), | ||
}; | ||
outer = None; | ||
println!("{}", static_ref); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr
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[E0623]: lifetime mismatch | ||
--> $DIR/hrlt-implied-trait-bounds-guard.rs:29:29 | ||
| | ||
LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) -> &'out T { | ||
| ^^^^^^^^^^^^^^^^^^ ------- | ||
| | | ||
| this parameter and the return type are declared with different lifetimes... | ||
| ...but data from `x` is returned here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0623`. |
Oops, something went wrong.