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

Disallow generic type parameters from appearing within certain constants #68356

Conversation

BenLewis-Seequent
Copy link

This improves the diagonistics/fixes ICEs when generic parameters appear within some constants. For example of the new errors:

use std::mem::size_of;

fn foo<T>() {
    let _ = [0; size_of::<T>()]; // now errors with: type parameters can't appear within an array length expression
}

#[repr(usize)]
enum Enum<T> {
    V1 = size_of::<T>(), // now errors with: type parameters can't appear within an enum discriminant
}

Previously emitted confusing errors like:

error[E0277]: the size for values of type `T` cannot be known at compilation time
   --> src/main.rs:45:27
    |
35  | fn foo<T>() {
    |        - help: consider restricting this bound: `T: std::marker::Sized`
...
45  |     let _ = [0; size_of::<T>()];
    |                           ^ doesn't have a size known at compile-time
    |
    = help: the trait `std::marker::Sized` is not implemented for `T`

Note doesn't disallow referring to Self in either enum discriminants or array length expressions as there are cases where it can currently be sucessfully used, i.e.:

struct Foo;

impl Foo {
    const A: usize = 37;

    fn bar() -> [u8; Self::A]{
        [0; Self::A]
    }
}

I don't think that this disallows any more code that didn't either produce a compiler error before or caused an ICE.

cc #43408
cc #67945 (doesn't actually fully fix it see: #67945 (comment))

…nts. Previously

using generic type parameters within array length expressions/enum discriminants
caused ICE's or confusing diagnostics.
@rust-highfive
Copy link
Collaborator

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 18, 2020
src/librustc_error_codes/error_codes/E0747.md Outdated Show resolved Hide resolved
src/librustc_error_codes/error_codes/E0747.md Outdated Show resolved Hide resolved
src/librustc_error_codes/error_codes/E0747.md Outdated Show resolved Hide resolved
src/librustc_error_codes/error_codes/E0747.md Outdated Show resolved Hide resolved
src/librustc_error_codes/error_codes/E0747.md Outdated Show resolved Hide resolved
src/librustc_resolve/diagnostics.rs Outdated Show resolved Hide resolved
src/librustc_resolve/late.rs Outdated Show resolved Hide resolved
src/librustc_resolve/late.rs Outdated Show resolved Hide resolved
@@ -1,3 +1,4 @@
// ignore-tidy-filelength
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split things in a follow up PR?

@Centril Centril added A-lazy-normalization Area: lazy normalization (tracking issue: #60471) F-const_generics `#![feature(const_generics)]` labels Jan 19, 2020
@Centril
Copy link
Contributor

Centril commented Jan 19, 2020

cc @petrochenkov @varkor

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-18T23:15:24.5527042Z ========================== Starting Command Output ===========================
2020-01-18T23:15:24.5529323Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/9e7d26b4-287b-47c5-a7fb-4c76fb3bfab9.sh
2020-01-18T23:15:24.5529358Z 
2020-01-18T23:15:24.5533115Z ##[section]Finishing: Disable git automatic line ending conversion
2020-01-18T23:15:24.5539162Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68356/merge to s
2020-01-18T23:15:24.5604709Z Task         : Get sources
2020-01-18T23:15:24.5604743Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-01-18T23:15:24.5604938Z Version      : 1.0.0
2020-01-18T23:15:24.5604967Z Author       : Microsoft
---
2020-01-18T23:15:25.5509316Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-18T23:15:25.5524143Z ##[command]git config gc.auto 0
2020-01-18T23:15:25.5526494Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-18T23:15:25.5528760Z ##[command]git config --get-all http.proxy
2020-01-18T23:15:25.5535930Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68356/merge:refs/remotes/pull/68356/merge
---
2020-01-19T00:04:18.4882545Z .................................................................................................... 1700/9541
2020-01-19T00:04:24.0312244Z .................................................................................................... 1800/9541
2020-01-19T00:04:34.4840994Z ......................i............................................................................. 1900/9541
2020-01-19T00:04:40.8249612Z .................................................................................................... 2000/9541
2020-01-19T00:04:54.2945943Z ............iiiii................................................................................... 2100/9541
2020-01-19T00:05:03.1315662Z .................................................................................................... 2300/9541
2020-01-19T00:05:05.3999058Z .................................................................................................... 2400/9541
2020-01-19T00:05:10.4069308Z .................................................................................................... 2500/9541
2020-01-19T00:05:29.0325053Z .................................................................................................... 2600/9541
---
2020-01-19T00:07:56.6055913Z ........................................................i...............i........................... 4900/9541
2020-01-19T00:08:04.1577496Z .................................................................................................... 5000/9541
2020-01-19T00:08:11.1765497Z ...................................................................................................i 5100/9541
2020-01-19T00:08:16.3795313Z .................................................................................................... 5200/9541
2020-01-19T00:08:26.5908194Z .......................................................................ii.ii...........i............ 5300/9541
2020-01-19T00:08:34.9589236Z ........i........................................................................................... 5500/9541
2020-01-19T00:08:44.2618326Z .................................................................................................... 5600/9541
2020-01-19T00:08:50.3305807Z .........................................................i.......................................... 5700/9541
2020-01-19T00:08:56.7200543Z .................................................................................................... 5800/9541
2020-01-19T00:08:56.7200543Z .................................................................................................... 5800/9541
2020-01-19T00:09:05.7918735Z .................................................................................................... 5900/9541
2020-01-19T00:09:12.0679036Z ...............................................ii...i..ii...........i............................... 6000/9541
2020-01-19T00:09:33.0226879Z .................................................................................................... 6200/9541
2020-01-19T00:09:40.5047867Z .................................................................................................... 6300/9541
2020-01-19T00:09:40.5047867Z .................................................................................................... 6300/9541
2020-01-19T00:09:46.0677522Z ...........................................................................i..ii.................... 6400/9541
2020-01-19T00:10:10.1302119Z .................................................................................................... 6600/9541
2020-01-19T00:10:14.1985260Z ...................................................i................................................ 6700/9541
2020-01-19T00:10:16.1649405Z .................................................................................................... 6800/9541
2020-01-19T00:10:18.1641867Z ..................................................i................................................. 6900/9541
---
2020-01-19T00:11:50.5368556Z .................................................................................................... 7600/9541
2020-01-19T00:11:56.0282420Z .................................................................................................... 7700/9541
2020-01-19T00:12:02.3725337Z .................................................................................................... 7800/9541
2020-01-19T00:12:12.6965445Z .................................................................................................... 7900/9541
2020-01-19T00:12:18.2314368Z .iiiiiii............................................................................................ 8000/9541
2020-01-19T00:12:32.1467460Z .................................................................................................... 8200/9541
2020-01-19T00:12:42.2029368Z .................................................................................................... 8300/9541
2020-01-19T00:12:53.5969513Z .................................................................................................... 8400/9541
2020-01-19T00:12:59.1760085Z .................................................................................................... 8500/9541
---
2020-01-19T00:15:09.3507091Z  finished in 6.845
2020-01-19T00:15:09.3692270Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T00:15:09.5613422Z 
2020-01-19T00:15:09.5614180Z running 166 tests
2020-01-19T00:15:12.3819637Z iiii......i........ii..iiii...i....i...........i............i..i..................i....i............ 100/166
2020-01-19T00:15:14.5607642Z i.i.i...iii..iiiiiii.......................iii............ii......
2020-01-19T00:15:14.5609193Z 
2020-01-19T00:15:14.5614442Z  finished in 5.192
2020-01-19T00:15:14.5773961Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T00:15:14.7197048Z 
---
2020-01-19T00:15:16.5093313Z  finished in 1.931
2020-01-19T00:15:16.5254946Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T00:15:17.1433827Z 
2020-01-19T00:15:17.1434036Z running 9 tests
2020-01-19T00:15:17.1435145Z iiiiiiiii
2020-01-19T00:15:17.1435758Z 
2020-01-19T00:15:17.1435918Z  finished in 0.131
2020-01-19T00:15:17.1447382Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T00:15:17.1448004Z 
---
2020-01-19T00:15:35.6824004Z  finished in 19.011
2020-01-19T00:15:35.7047731Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T00:15:35.8827659Z 
2020-01-19T00:15:35.8828355Z running 116 tests
2020-01-19T00:15:57.9033630Z .iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii..........i.....i..i.......ii.i.ii 100/116
2020-01-19T00:16:00.9214084Z .....iiii.....ii
2020-01-19T00:16:00.9216066Z 
2020-01-19T00:16:00.9216992Z  finished in 25.216
2020-01-19T00:16:00.9220838Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T00:16:00.9221378Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2020-01-19T00:27:47.1161838Z 
2020-01-19T00:27:47.1164776Z    Doc-tests core
2020-01-19T00:27:51.3776093Z 
2020-01-19T00:27:51.3776354Z running 2443 tests
2020-01-19T00:27:59.9606678Z ......iiiii......................................................................................... 100/2443
2020-01-19T00:28:08.3566878Z ..................................................................................ii................ 200/2443
2020-01-19T00:28:28.4788532Z .................i.................................................................................. 400/2443
2020-01-19T00:28:28.4788532Z .................i.................................................................................. 400/2443
2020-01-19T00:28:37.5132227Z ..................................................................i..i..................iiii........ 500/2443
2020-01-19T00:28:52.5503850Z .................................................................................................... 700/2443
2020-01-19T00:29:00.6086685Z .................................................................................................... 800/2443
2020-01-19T00:29:08.4329844Z .................................................................................................... 900/2443
2020-01-19T00:29:16.3158146Z .................................................................................................... 1000/2443
---
2020-01-19T00:32:34.1225063Z 
2020-01-19T00:32:34.1225316Z running 1003 tests
2020-01-19T00:32:51.9194114Z i................................................................................................... 100/1003
2020-01-19T00:33:01.4373107Z .................................................................................................... 200/1003
2020-01-19T00:33:08.2106507Z ..................iii......i......i...i......i...................................................... 300/1003
2020-01-19T00:33:13.0224635Z .................................................................................................... 400/1003
2020-01-19T00:33:19.4104017Z ..........................................i..i.....................................ii............... 500/1003
2020-01-19T00:33:31.2467393Z .................................................................................................... 700/1003
2020-01-19T00:33:31.2467393Z .................................................................................................... 700/1003
2020-01-19T00:33:37.4294121Z .............................iiii................................................................... 800/1003
2020-01-19T00:33:50.9274470Z .................................................................................................... 900/1003
2020-01-19T00:33:57.4448159Z ...................................................iiii............................................. 1000/1003
2020-01-19T00:33:57.5242560Z test result: ok. 983 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out
2020-01-19T00:33:57.5242948Z 
2020-01-19T00:33:57.5336663Z  finished in 158.434
2020-01-19T00:33:57.5337672Z Testing term stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-01-19T00:50:26.2526271Z ---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0747 (line 13822) stdout ----
2020-01-19T00:50:26.2526578Z error[E0447]: type parameters can't appear within an array length expression
2020-01-19T00:50:26.2526827Z  --> /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md:13826:27
2020-01-19T00:50:26.2526869Z   |
2020-01-19T00:50:26.2526925Z 6 |     let _ = [0; size_of::<T>()];
2020-01-19T00:50:26.2526964Z   |                           ^ type parameter
2020-01-19T00:50:26.2527024Z error: aborting due to previous error
2020-01-19T00:50:26.2527068Z 
2020-01-19T00:50:26.2527273Z For more information about this error, try `rustc --explain E0447`.
2020-01-19T00:50:26.2527273Z For more information about this error, try `rustc --explain E0447`.
2020-01-19T00:50:26.2527317Z Some expected error codes were not found: ["E0747"]
2020-01-19T00:50:26.2527713Z error[E0308]: mismatched types
2020-01-19T00:50:26.2527953Z   --> /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md:13866:20
2020-01-19T00:50:26.2528012Z    |
2020-01-19T00:50:26.2528012Z    |
2020-01-19T00:50:26.2528050Z 12 |     const X: i32 = size_of::<T>();
2020-01-19T00:50:26.2528098Z    |                    ^^^^^^^^^^^^^^ expected `i32`, found `usize`
2020-01-19T00:50:26.2528176Z error: aborting due to previous error
2020-01-19T00:50:26.2528200Z 
2020-01-19T00:50:26.2528407Z For more information about this error, try `rustc --explain E0308`.
2020-01-19T00:50:26.2528596Z Couldn't compile the test.
---
2020-01-19T00:50:26.2551590Z   local time: Sun Jan 19 00:50:26 UTC 2020
2020-01-19T00:50:26.3707033Z   network time: Sun, 19 Jan 2020 00:50:26 GMT
2020-01-19T00:50:26.3708617Z == end clock drift check ==
2020-01-19T00:50:27.4344569Z 
2020-01-19T00:50:27.4434731Z ##[error]Bash exited with code '1'.
2020-01-19T00:50:27.4446087Z ##[section]Finishing: Run build
2020-01-19T00:50:27.4466368Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68356/merge to s
2020-01-19T00:50:27.4467998Z Task         : Get sources
2020-01-19T00:50:27.4468038Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-01-19T00:50:27.4468093Z Version      : 1.0.0
2020-01-19T00:50:27.4468128Z Author       : Microsoft
2020-01-19T00:50:27.4468128Z Author       : Microsoft
2020-01-19T00:50:27.4468166Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-01-19T00:50:27.4468224Z ==============================================================================
2020-01-19T00:50:27.8648595Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-01-19T00:50:27.8686395Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/68356/merge to s
2020-01-19T00:50:27.8797450Z Cleaning up task key
2020-01-19T00:50:27.8798091Z Start cleaning up orphan processes.
2020-01-19T00:50:27.8899445Z Terminate orphan process: pid (4513) (python)
2020-01-19T00:50:27.9176644Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-19T03:36:14.5508219Z ========================== Starting Command Output ===========================
2020-01-19T03:36:14.5510082Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/105aa98e-f14c-4ebc-aa2d-c7baa0ab4d55.sh
2020-01-19T03:36:14.5510124Z 
2020-01-19T03:36:14.5513966Z ##[section]Finishing: Disable git automatic line ending conversion
2020-01-19T03:36:14.5525360Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68356/merge to s
2020-01-19T03:36:14.5527287Z Task         : Get sources
2020-01-19T03:36:14.5527324Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-01-19T03:36:14.5527411Z Version      : 1.0.0
2020-01-19T03:36:14.5527447Z Author       : Microsoft
---
2020-01-19T03:36:15.5999060Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-19T03:36:15.6017814Z ##[command]git config gc.auto 0
2020-01-19T03:36:15.6024847Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-19T03:36:15.6030332Z ##[command]git config --get-all http.proxy
2020-01-19T03:36:15.6127666Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68356/merge:refs/remotes/pull/68356/merge
---
2020-01-19T04:35:39.1473080Z .................................................................................................... 1700/9541
2020-01-19T04:35:45.7317910Z .................................................................................................... 1800/9541
2020-01-19T04:35:58.3473068Z ......................i............................................................................. 1900/9541
2020-01-19T04:36:05.9346976Z .................................................................................................... 2000/9541
2020-01-19T04:36:22.3228824Z ............iiiii................................................................................... 2100/9541
2020-01-19T04:36:32.6962239Z .................................................................................................... 2300/9541
2020-01-19T04:36:35.2411195Z .................................................................................................... 2400/9541
2020-01-19T04:36:40.9576447Z .................................................................................................... 2500/9541
2020-01-19T04:37:03.5111729Z .................................................................................................... 2600/9541
---
2020-01-19T04:39:56.0702520Z ........................................................i...............i........................... 4900/9541
2020-01-19T04:40:04.6827203Z .................................................................................................... 5000/9541
2020-01-19T04:40:13.1487651Z ...................................................................................................i 5100/9541
2020-01-19T04:40:18.7273307Z .................................................................................................... 5200/9541
2020-01-19T04:40:30.5190000Z .......................................................................ii.ii...........i............ 5300/9541
2020-01-19T04:40:40.2258236Z ........i........................................................................................... 5500/9541
2020-01-19T04:40:51.1329055Z .................................................................................................... 5600/9541
2020-01-19T04:40:58.0350439Z .........................................................i.......................................... 5700/9541
2020-01-19T04:41:05.6082626Z .................................................................................................... 5800/9541
2020-01-19T04:41:05.6082626Z .................................................................................................... 5800/9541
2020-01-19T04:41:16.1312917Z .................................................................................................... 5900/9541
2020-01-19T04:41:23.5836773Z ...............................................ii...i..ii...........i............................... 6000/9541
2020-01-19T04:41:47.6103613Z .................................................................................................... 6200/9541
2020-01-19T04:41:56.5295313Z .................................................................................................... 6300/9541
2020-01-19T04:41:56.5295313Z .................................................................................................... 6300/9541
2020-01-19T04:42:06.8298988Z ...........................................................................i..ii.................... 6400/9541
2020-01-19T04:42:37.6374085Z .................................................................................................... 6600/9541
2020-01-19T04:42:42.7684445Z ...................................................i................................................ 6700/9541
2020-01-19T04:42:45.2044905Z .................................................................................................... 6800/9541
2020-01-19T04:42:47.6317560Z ..................................................i................................................. 6900/9541
---
2020-01-19T04:44:39.2472385Z .................................................................................................... 7600/9541
2020-01-19T04:44:45.4491270Z .................................................................................................... 7700/9541
2020-01-19T04:44:52.5975280Z .................................................................................................... 7800/9541
2020-01-19T04:45:04.5670351Z .................................................................................................... 7900/9541
2020-01-19T04:45:10.9938462Z .iiiiiii............................................................................................ 8000/9541
2020-01-19T04:45:27.3594558Z .................................................................................................... 8200/9541
2020-01-19T04:45:39.5990139Z .................................................................................................... 8300/9541
2020-01-19T04:45:53.3520149Z .................................................................................................... 8400/9541
2020-01-19T04:45:59.6485739Z .................................................................................................... 8500/9541
---
2020-01-19T04:48:34.3116401Z  finished in 7.872
2020-01-19T04:48:34.3314076Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T04:48:34.5426528Z 
2020-01-19T04:48:34.5427059Z running 166 tests
2020-01-19T04:48:37.8467753Z iiii......i........ii..iiii...i....i...........i............i..i..................i....i............ 100/166
2020-01-19T04:48:40.3174217Z i.i.i...iii..iiiiiii.......................iii............ii......
2020-01-19T04:48:40.3178715Z 
2020-01-19T04:48:40.3178800Z  finished in 5.986
2020-01-19T04:48:40.3366411Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T04:48:40.5088162Z 
---
2020-01-19T04:48:42.6210549Z  finished in 2.284
2020-01-19T04:48:42.6429831Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T04:48:42.8098741Z 
2020-01-19T04:48:42.8099618Z running 9 tests
2020-01-19T04:48:42.8100553Z iiiiiiiii
2020-01-19T04:48:42.8101518Z 
2020-01-19T04:48:42.8104270Z  finished in 0.167
2020-01-19T04:48:42.8332692Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T04:48:43.0527258Z 
---
2020-01-19T04:49:04.4221376Z  finished in 21.588
2020-01-19T04:49:04.4454835Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T04:49:04.6464703Z 
2020-01-19T04:49:04.6465058Z running 116 tests
2020-01-19T04:49:32.1854085Z .iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii..........i.....i..i.......ii.i.ii 100/116
2020-01-19T04:49:35.8846510Z .....iiii.....ii
2020-01-19T04:49:35.8847074Z 
2020-01-19T04:49:35.8851614Z  finished in 31.439
2020-01-19T04:49:35.8859596Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-19T04:49:35.8859993Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2020-01-19T05:04:00.4056304Z 
2020-01-19T05:04:00.4060374Z    Doc-tests core
2020-01-19T05:04:05.4878521Z 
2020-01-19T05:04:05.4879431Z running 2443 tests
2020-01-19T05:04:15.5594767Z ......iiiii......................................................................................... 100/2443
2020-01-19T05:04:25.2949324Z ..................................................................................ii................ 200/2443
2020-01-19T05:04:48.1866270Z .................i.................................................................................. 400/2443
2020-01-19T05:04:48.1866270Z .................i.................................................................................. 400/2443
2020-01-19T05:04:58.5037701Z ..................................................................i..i..................iiii........ 500/2443
2020-01-19T05:05:16.0515727Z .................................................................................................... 700/2443
2020-01-19T05:05:25.2058010Z .................................................................................................... 800/2443
2020-01-19T05:05:34.4588912Z .................................................................................................... 900/2443
2020-01-19T05:05:43.5768343Z .................................................................................................... 1000/2443
---
2020-01-19T05:09:24.5482990Z .................................................................................................... 500/760
2020-01-19T05:09:24.5828850Z .................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2741:22
2020-01-19T05:09:24.5856658Z ....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2778:21
2020-01-19T05:09:24.5861393Z thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', src/libstd/sync/mpsc/mod.rs:2766:17
2020-01-19T05:09:24.5876275Z .......thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2645:13
2020-01-19T05:09:24.8848174Z ..........................................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1997:22
2020-01-19T05:09:24.8869408Z ....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', src/libstd/sync/mpsc/mod.rs:2022:17
2020-01-19T05:09:24.8895272Z ...thread '<unnamed>' panicked at '.called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2034:21
2020-01-19T05:09:24.8917023Z ...thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1916:13
2020-01-19T05:09:26.9588672Z ..................thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:633:13
2020-01-19T05:09:26.9591859Z ....thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:587:13
2020-01-19T05:09:26.9600667Z ....thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:563:13
2020-01-19T05:09:26.9601750Z thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:694:13
---
2020-01-19T05:09:36.3026284Z 
2020-01-19T05:09:36.3027235Z running 1003 tests
2020-01-19T05:09:57.5943507Z i................................................................................................... 100/1003
2020-01-19T05:10:08.6498113Z .................................................................................................... 200/1003
2020-01-19T05:10:16.4724817Z ..................iii......i......i...i......i...................................................... 300/1003
2020-01-19T05:10:22.0066254Z .................................................................................................... 400/1003
2020-01-19T05:10:29.5282339Z ..........................................i..i.....................................ii............... 500/1003
2020-01-19T05:10:43.1726682Z .................................................................................................... 700/1003
2020-01-19T05:10:43.1726682Z .................................................................................................... 700/1003
2020-01-19T05:10:50.3315828Z .............................iiii................................................................... 800/1003
2020-01-19T05:11:05.9368915Z .................................................................................................... 900/1003
2020-01-19T05:11:13.8120024Z ...................................................iiii............................................. 1000/1003
2020-01-19T05:11:13.8795350Z test result: ok. 983 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out
2020-01-19T05:11:13.8796828Z 
2020-01-19T05:11:13.8930138Z  finished in 186.914
2020-01-19T05:11:13.8944529Z Testing term stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-01-19T05:31:27.6512766Z ---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0747 (line 13856) stdout ----
2020-01-19T05:31:27.6512949Z error[E0308]: mismatched types
2020-01-19T05:31:27.6513248Z   --> /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md:13866:20
2020-01-19T05:31:27.6513319Z    |
2020-01-19T05:31:27.6513363Z 12 |     const X: i32 = size_of::<T>();
2020-01-19T05:31:27.6513413Z    |                    ^^^^^^^^^^^^^^ expected `i32`, found `usize`
2020-01-19T05:31:27.6513585Z error: aborting due to previous error
2020-01-19T05:31:27.6513621Z 
2020-01-19T05:31:27.6513898Z For more information about this error, try `rustc --explain E0308`.
2020-01-19T05:31:27.6514126Z Couldn't compile the test.
---
2020-01-19T05:31:27.6519418Z   local time: Sun Jan 19 05:31:27 UTC 2020
2020-01-19T05:31:28.1744112Z   network time: Sun, 19 Jan 2020 05:31:28 GMT
2020-01-19T05:31:28.1744228Z == end clock drift check ==
2020-01-19T05:31:28.5489496Z 
2020-01-19T05:31:28.5609536Z ##[error]Bash exited with code '1'.
2020-01-19T05:31:28.5622415Z ##[section]Finishing: Run build
2020-01-19T05:31:28.5650151Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68356/merge to s
2020-01-19T05:31:28.5672720Z Task         : Get sources
2020-01-19T05:31:28.5672779Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-01-19T05:31:28.5672822Z Version      : 1.0.0
2020-01-19T05:31:28.5672861Z Author       : Microsoft
2020-01-19T05:31:28.5672861Z Author       : Microsoft
2020-01-19T05:31:28.5672912Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-01-19T05:31:28.5672960Z ==============================================================================
2020-01-19T05:31:29.0309085Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-01-19T05:31:29.0313882Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/68356/merge to s
2020-01-19T05:31:29.0456825Z Cleaning up task key
2020-01-19T05:31:29.0463294Z Start cleaning up orphan processes.
2020-01-19T05:31:29.0610370Z Terminate orphan process: pid (3582) (python)
2020-01-19T05:31:29.1026900Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@eddyb
Copy link
Member

eddyb commented Jan 19, 2020

I disagree with doing this in rustc_resolve, and the phrasing of the errors.
This is an implementation bug, they should be working (and they kind of do already with #![feature(const_generics)], but that's a bit of a hack).

The reason I didn't want this in rustc_resolve is because I didn't want to risk introducing forwards-compatibility hazards - the behavior of rustc_resolve today is the one we want to keep, if we want to error we should probably do it in rustc_typeck::astconv, perhaps by checking any generic parameter hir::Ty we're converting to Ty actually exists in the generics currently in scope (as opposed to looking it up in the parameter's parent).

(there's probably one exception to this, and that would be the enum discriminant case, but we can allow name resolution on it and error later when trying to evaluate discriminants)

For improving errors, I would prefer doing a crater run with this changed to always be Some:
(now that we've special-cased literals, it might always work in practice)

// FIXME(#43408) enable this always when we get lazy normalization.
Node::AnonConst(_) => {
// HACK(eddyb) this provides the correct generics when
// `feature(const_generics)` is enabled, so that const expressions
// used with const generics, e.g. `Foo<{N+1}>`, can work at all.
if tcx.features().const_generics {
let parent_id = tcx.hir().get_parent_item(hir_id);
Some(tcx.hir().local_def_id(parent_id))
} else {
None
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lazy-normalization Area: lazy normalization (tracking issue: #60471) F-const_generics `#![feature(const_generics)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants