Comments (8)
has already been reverted on beta in #125629.
from rust.
I just discovered that swapping the bounds on the Raise::Higher
causes it to work again on 1.79.0 and later.
(not working)
trait Raise{
type Higher<'lt, 'ctx, B>: for<'a, 'b> Lower<'a, 'b, Bound<'a, 'b>> + Lower<'lt, 'ctx, B, T = Self>;
}
(working)
trait Raise{
type Higher<'lt, 'ctx, B>: Lower<'lt, 'ctx, B, T = Self> + for<'a, 'b> Lower<'a, 'b, Bound<'a, 'b>>;
}
from rust.
I have simplified the code to this
fn main() {}
trait Raise{
type Higher<'lt>: for<'a> Lower<'a> + Lower<'lt, T = Self>;
}
trait Lower<'lt> {
type T: Raise<Higher<'lt> = Self>;
}
fn use_lower<'a, T: Raise>(x: T) {
use_higher::<<T as Raise>::Higher::<'a>>(x);
}
fn use_higher<'a, H: for<'b> Lower<'b>>(x: <H as Lower<'a>>::T) {}
As before switching it with
type Higher<'lt>: Lower<'lt, T = Self> + for<'a> Lower<'a>;
works
from rust.
cc @lcnr
from rust.
the unstable result depending on whether the associated type bounds are swapped is caused by
rust/compiler/rustc_trait_selection/src/traits/select/mod.rs
Lines 1965 to 1970 in a330e49
before #119820 we already discarded the non-hr item bounds - ProjectionCandidate
- before using fn candidate_should_be_dropped_in_favor_of
, causing us to always use the hr one, regardless of order.
from rust.
Here is a smaller example that doesn't use GATs.
pub trait ForLt<'a> {
type T;
}
pub trait Hrt: for<'a> ForLt<'a> {}
pub trait Other<'a> {
type Higher: Hrt + ForLt<'a>;
}
error: implementation of `ForLt` is not general enough
--> src/main.rs:10:18
|
7 | pub trait Hrt: for<'a> ForLt<'a> {}
| --------------------------------
| | |
| | doesn't satisfy where-clause
| due to a where-clause on `Hrt`...
...
10 | type Higher: Hrt + ForLt<'a>;
| ^^^
|
= note: ...`<Self as Other<'a>>::Higher` must implement `ForLt<'0>`, for any lifetime `'0`...
= note: ...but it actually implements `ForLt<'a>`
(A more meaningful example is to use type Higher: Hrt + ForLt<'a, T = i32>;
. As this actually adds a extra bound instead of it being a duplicate bound.)
Is the type Higher: ForLt<'a> + Hrt;
supposed to be allowed? I do use the stable behavior in some code and am wondering if I need to change to some other method to achieve this.
from rust.
Same as #125194 . Changes in #119820 were reverted so in theory this regression should be neutralized in the current nightly. Can you check @konnorandrews ? thanks
from rust.
I only reverted it on beta, it still affects nightly (and the new beta)
from rust.
Related Issues (20)
- `unsafe` blocks do not fire `unsafe_code` lint
- This "escapes the function body here" error could use more details
- Compiler panic in fastrand HOT 1
- ICE: macros: `entered unreachable code'` HOT 2
- Suggest dropping before reassignment of a variable with a mutable reference and a destructor
- ICE: typeck: `no index for a field` HOT 3
- Undefined behavior from stack overflow on wasm32 targets HOT 3
- Index out of bounds: the len is 229 but the index is 229
- `safe` keyword is allowed in all function contexts HOT 5
- ICE: `assertion failed: matches!(diagnostic.level, Error | Warning | Allow)` HOT 5
- Rust does not build with `llvm-unwind` HOT 2
- `safe` keyword is not feature-gated HOT 4
- Bad replacement for unsafe extern block suggestion HOT 3
- NFC normalisation of lifetimes and labels
- Migrate parser to the new span combining scheme HOT 2
- ICE: `byte index 65 is not a char boundary` HOT 1
- `x test` doesn't work for absolute paths
- Nightly regression: `panic::set_hook()` signature incompatible if used with core::panic::PanicInfo HOT 4
- `non_local_definitions` lint fires for `impl Trait for NonLocalType<SomeLocalType>`, probably shouldn't HOT 4
- Tracking Issue for `substr_range` and related methods HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.