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

Regression in glob imports vs. macro and type namespaces (lib bytemuck) #112860

Closed
kpreid opened this issue Jun 20, 2023 · 2 comments
Closed

Regression in glob imports vs. macro and type namespaces (lib bytemuck) #112860

kpreid opened this issue Jun 20, 2023 · 2 comments
Labels
C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@kpreid
Copy link
Contributor

kpreid commented Jun 20, 2023

I could not produce a standalone reproducer, but compiling bytemuck from the repository or as a dependency will reproduce the issue by failing to compile.

  • Version it works on: stable and nightly-2023-06-19
  • Version with regression: nightly-2023-06-20

To reproduce, run:

cargo +nightly-2023-06-20 build --features extern_crate_alloc,derive

Version with regression

rustc --version --verbose:

rustc 1.72.0-nightly (fe7454bf4 2023-06-19)
binary: rustc
commit-hash: fe7454bf439c93cbe9ac8a8f7fcfacd5a40244c2
commit-date: 2023-06-19
host: x86_64-apple-darwin
release: 1.72.0-nightly
LLVM version: 16.0.5

Compilation errors

   Compiling bytemuck v1.13.2 (/Users/kpreid/Projects/rust/reference/bytemuck)
error[E0404]: expected trait, found derive macro `NoUninit`
  --> src/allocation.rs:25:20
   |
25 | pub fn cast_box<A: NoUninit, B: AnyBitPattern>(input: Box<A>) -> Box<B> {
   |                    ^^^^^^^^ not a trait
   |
help: consider importing this trait instead
   |
12 + use crate::NoUninit;
   |

error[E0404]: expected trait, found derive macro `AnyBitPattern`
  --> src/allocation.rs:25:33
   |
25 | pub fn cast_box<A: NoUninit, B: AnyBitPattern>(input: Box<A>) -> Box<B> {
   |                                 ^^^^^^^^^^^^^ not a trait
   |
help: consider importing this trait instead
   |
12 + use crate::AnyBitPattern;
   |

and many more. The notable thing here is that NoUninit and friends are imported via use super::*;, and in super (the root), there is both a non-glob derive macro import (from the macro crate) and a glob trait import (from another module).

Failed reproducer

I tried to reproduce this import situation in a single file as follows:

#[cfg(feature = "derive")]
use scratchpad_macros::Foo; // a proc macro, nothing special

mod f {
    pub trait Foo {}
}
pub use f::*;

#[cfg(feature = "alloc")]
mod b {
    use super::*;
    pub fn bar<T: Foo>() {}
}
#[cfg(feature = "alloc")]
pub use b::*;

However, this compiles on all tested versions.

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

@kpreid kpreid added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Jun 20, 2023
@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed regression-untriaged Untriaged performance or correctness regression. labels Jun 20, 2023
@ChrisDenton
Copy link
Member

I'd assume this is a duplicate of #112831

@kpreid
Copy link
Contributor Author

kpreid commented Jun 20, 2023

Well, I'm bad at searching for prior issues today.

@kpreid kpreid closed this as completed Jun 20, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

No branches or pull requests

4 participants