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

type parameter E/#1 (E/1) out of range when substituting #83929

Closed
tvallotton opened this issue Apr 6, 2021 · 4 comments · Fixed by #83935
Closed

type parameter E/#1 (E/1) out of range when substituting #83929

tvallotton opened this issue Apr 6, 2021 · 4 comments · Fixed by #83935
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tvallotton
Copy link
Contributor

Code

// mod structs;
// mod table;

use std::env;

type Result<T, E = impl std::error::Error> = std::result::Result<T, E>;

fn main() -> Result<()> {
    let args: Vec<String> = env::args().collect();
    

    println!("{:?}", args.get(0));
    Ok(())
}

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (673d0db5e 2021-03-23)
binary: rustc
commit-hash: 673d0db5e393e9c64897005b470bfeb6d5aec61b
commit-date: 2021-03-23
host: x86_64-apple-darwin
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output


error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:529:17: type parameter `E/#1` (E/1) out of range when substituting, substs=[()]
 --> src/main.rs:8:14
  |
8 | fn main() -> Result<()> {
  |              ^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', /rustc/673d0db5e393e9c64897005b470bfeb6d5aec61b/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.53.0-nightly (673d0db5e 2021-03-23) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [fn_sig] computing function signature of `main`
#1 [collect_mod_item_types] collecting item types in top-level module
end of query stack
error: aborting due to previous error

error: could not compile `project`
Backtrace

<backtrace>

@tvallotton tvallotton added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 6, 2021
@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 6, 2021
@tvallotton
Copy link
Contributor Author

tvallotton commented Apr 6, 2021

I tried on stable cargo 1.51.0 (43b129a20 2021-03-16), and it didn't work either.

@Aaron1011 Aaron1011 changed the title The compiler prompted me to sumbit an issue. type parameter E/#1 (E/1) out of range when substituting Apr 6, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 6, 2021

Slightly smaller:

type Result<T, E = impl std::error::Error> = std::result::Result<T, E>;

fn main() -> Result<()> {
    Ok(())
}

@SNCPlay42
Copy link
Contributor

SNCPlay42 commented Apr 6, 2021

Another version:

struct Foo<T = impl Copy>(T);

fn x() -> Foo {
    Foo(0)
}

impl Trait should probably not be allowed in generic param defaults, right?

@tvallotton
Copy link
Contributor Author

Mmm, I intended to write Box<dyn Error> instead of impl Error. Idk if it is still a bug though.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 7, 2021
… r=varkor

forbid `impl Trait` in generic param defaults

Fixes rust-lang#83929

Forbid using `impl Trait` in the default types of generic parameters, e.g. `struct Foo<T = impl Trait>`. I assume this was never supposed to be allowed - it seems no UI test used it.

Note that using `impl Trait` in this position did not hit a feature gate error; however, this *shouldn't* be a breaking change as any attempt to use it should have hit the ICE in rust-lang#83929 and/or failed to provide a defining use of the `impl Trait`.
@bors bors closed this as completed in d554385 Apr 7, 2021
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 10, 2022
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants