You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #145563 - Kobzol:remove-from-from-prelude, r=petrochenkov
Remove the `From` derive macro from prelude
The new `#[derive(From)]` functionality (implemented in #144922) caused name resolution ambiguity issues (#145524). The reproducer looks e.g. like this:
```rust
mod foo {
pub use derive_more::From;
}
use foo::*;
#[derive(From)] // ERROR: `From` is ambiguous
struct S(u32);
```
It's pretty unfortunate that it works like this, but I guess that there's not much to be done here, and we'll have to wait for the next edition to put the `From` macro into the prelude. That will probably require #139493 to land.
I created a new module in core (and re-exported it in std) called `from`, where I re-exported the `From` macro. I *think* that since this is a new module, it should not have the same backwards incompatibility issue.
Happy to hear suggestions about the naming - maybe it would make sense as `core::macros::from::From`? But we already had a precedent in the `core::assert_matches` module, so I just followed suit.
Fixes: #145524
r? ``@petrochenkov``
Copy file name to clipboardExpand all lines: tests/ui/feature-gates/feature-gate-derive-from.stderr
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,16 @@ LL | #[derive(From)]
8
8
= help: add `#![feature(derive_from)]` to the crate attributes to enable
9
9
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10
10
11
-
error: aborting due to 1 previous error
11
+
error[E0658]: use of unstable library feature `derive_from`
12
+
--> $DIR/feature-gate-derive-from.rs:1:5
13
+
|
14
+
LL | use std::from::From;
15
+
| ^^^^^^^^^^^^^^^
16
+
|
17
+
= note: see issue #144889 <https://github.com/rust-lang/rust/issues/144889> for more information
18
+
= help: add `#![feature(derive_from)]` to the crate attributes to enable
19
+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20
+
21
+
error: aborting due to 2 previous errors
12
22
13
23
For more information about this error, try `rustc --explain E0658`.
0 commit comments