Skip to content

"can't use generic parameters from outer function" only when in nightly #111541

Closed
@b-paul

Description

@b-paul

Code

I made a blank cargo project (ran cargo init in an empty directory), and added dependencies to my Cargo.toml like so:

[package]
name = "typst-test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
typst = { git = "https://github.com/typst/typst.git" }
typst-library = { git = "https://github.com/typst/typst.git" }

Originally when I went to run RUSTFLAGS="-Z macro-backtrace" cargo build, I was in nightly, and got a compile error error[E0401]: can't use generic parameters from outer function (full error below). Then, when i switched to stable, there was no error and everything built fine!

 > RUSTFLAGS="-Z macro-backtrace" cargo b
   Compiling hayagriva v0.3.0
   Compiling typst v0.3.0 (https://github.com/typst/typst.git#4b17c3f5)
error[E0401]: can't use generic parameters from outer function
   --> /home/bpaul/.cargo/git/checkouts/typst-6808799b0d8fdaa9/4b17c3f/src/model/content.rs:545:1
    |
545 | #[element]
    | ^^^^^^^^^^
    | |
    | use of generic parameter from outer function
    | can't use `Self` here
    | in this procedural macro expansion
    |
   ::: /home/bpaul/.cargo/git/checkouts/typst-6808799b0d8fdaa9/4b17c3f/macros/src/lib.rs:31:1
    |
31  | pub fn element(stream: BoundaryStream, item: BoundaryStream) -> BoundaryStream {
    | ------------------------------------------------------------------------------ in this expansion of `#[element]`

error[E0401]: can't use generic parameters from outer function
   --> /home/bpaul/.cargo/git/checkouts/typst-6808799b0d8fdaa9/4b17c3f/src/model/content.rs:550:1
    |
550 | #[element]
    | ^^^^^^^^^^
    | |
    | use of generic parameter from outer function
    | can't use `Self` here
    | in this procedural macro expansion
    |
   ::: /home/bpaul/.cargo/git/checkouts/typst-6808799b0d8fdaa9/4b17c3f/macros/src/lib.rs:31:1
    |
31  | pub fn element(stream: BoundaryStream, item: BoundaryStream) -> BoundaryStream {
    | ------------------------------------------------------------------------------ in this expansion of `#[element]`

error[E0401]: can't use generic parameters from outer function
   --> /home/bpaul/.cargo/git/checkouts/typst-6808799b0d8fdaa9/4b17c3f/src/model/content.rs:557:1
    |
557 | #[element(Behave)]
    | ^^^^^^^^^^^^^^^^^^
    | |
    | use of generic parameter from outer function
    | can't use `Self` here
    | in this procedural macro expansion
    |
   ::: /home/bpaul/.cargo/git/checkouts/typst-6808799b0d8fdaa9/4b17c3f/macros/src/lib.rs:31:1
    |
31  | pub fn element(stream: BoundaryStream, item: BoundaryStream) -> BoundaryStream {
    | ------------------------------------------------------------------------------ in this expansion of `#[element]`

For more information about this error, try `rustc --explain E0401`.
error: could not compile `typst` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...

Version it worked on

It most recently worked on: Rust 1.69

Version with regression

rustc --version --verbose:

rustc 1.71.0-nightly (4a59ba4d5 2023-05-12)
binary: rustc
commit-hash: 4a59ba4d54a3ec0d8ea1e82b7eeb5c8b0162de04
commit-date: 2023-05-12
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions