about summary refs log tree commit diff
path: root/src/librustc
AgeCommit message (Collapse)AuthorLines
2019-11-04Auto merge of #65835 - Mark-Simulacrum:lockless-lintbuffer, r=nikomatsakisbors-67/+56
Remove LintBuffer from Session This moves the `LintBuffer` from `Session` into the `Resolver`, where it is used until lowering is done and then consumed by early lint passes. This also happily removes the failure mode of buffering lints too late where it would have previously lead to ICEs; it is statically no longer possible to do so. I suspect that with a bit more work a similar move could be done for the lint buffer inside `ParseSess`, but this PR doesn't touch it (in part to keep itself small). The last commit is the "interesting" commit -- the ones before it don't work (though they compile) as they sort of prepare the various crates for the lint buffer to be passed in rather than accessed through Session.
2019-11-03Delete lint buffer from SessionMark Rousskov-58/+26
2019-11-03Move crate type checking laterMark Rousskov-1/+1
This allows us to directly pass in a lint buffer
2019-11-03Utilize Resolver lint buffer during HIR loweringMark Rousskov-8/+13
2019-11-03Migrate resolver over to internal lint bufferMark Rousskov-2/+23
2019-11-03Only permit taking buffered lints inside lint internalsMark Rousskov-1/+1
2019-11-03Remove unused get_any methodMark Rousskov-5/+0
2019-11-03Make Emscripten unwinding use a valid type_infoAmanieu d'Antras-1/+1
This allows catch_panic to ignore C++ exceptions.
2019-11-03Auto merge of #65779 - kevgrasso:E0308highlight, r=estebankbors-6/+50
Highlight only relevant parts of type path in type errors Resolves #57413. Unfortunately the current Rust UI testing setup can't test that the correct colors are being used in a given output, so here's a screenshot of a small test program I wrote: ![image](https://user-images.githubusercontent.com/480789/67530063-f272af00-f68b-11e9-9f96-a211fc7666d4.png)
2019-11-01Rollup merge of #66018 - pnkfelix:issue-64872-revert-64324, r=alexcrichtonTyler Mandry-1/+7
Revert PR 64324: dylibs export generics again (for now) As discussed on PR #65781, this is a targeted attempt to undo the main semantic change from PR #64324, by putting `dylib` back in the set of crate types that export generic symbols. The main reason to do this is that PR #64324 had unanticipated side-effects that caused bugs like #64872, and in the opinion of @alexcrichton and myself, the impact of #64872 is worse than #64319. In other words, it is better for us, in the short term, to reopen #64319 as currently unfixed for now than to introduce new bugs like #64872. Fix #64872 Reopen #64319
2019-11-01Rollup merge of #65977 - ↵Tyler Mandry-5/+18
ohadravid:fix-incorrect-diagnostics-with-an-associated-type, r=estebank Fix incorrect diagnostics for expected type in E0271 with an associated type With code like the following code: ```rust #[derive(Debug)] struct Data {} fn do_stuff<'a>(iterator: impl Iterator<Item = &'a Data>) { for item in iterator { println!("{:?}", item) } } fn main() { let v = vec![Data {}]; do_stuff(v.into_iter()); } ``` the diagnostic (in nightly & stable) wrongly complains about the expected type: ``` error[E0271]: type mismatch resolving `<std::vec::IntoIter<Data> as std::iter::Iterator>::Item == &Data` --> src/main.rs:15:5 | 5 | fn do_stuff<'a>(iterator: impl Iterator<Item = &'a Data>) { | -------- --------------- required by this bound in `do_stuff` ... 15 | do_stuff(v.into_iter()); | ^^^^^^^^ expected struct `Data`, found &Data | = note: expected type `Data` found type `&Data` ``` This PR fixes this issue by flipping the expected/actual values where appropriate, so it looks like this: ``` error[E0271]: type mismatch resolving `<std::vec::IntoIter<Data> as std::iter::Iterator>::Item == &Data` --> main.rs:15:5 | 5 | fn do_stuff<'a>(iterator: impl Iterator<Item = &'a Data>) { | -------- --------------- required by this bound in `do_stuff` ... 15 | do_stuff(v.into_iter()); | ^^^^^^^^ expected &Data, found struct `Data` | = note: expected type `&Data` found type `Data` ``` This improves the output of a lot of existing tests (check out `associated-types-binding-to-type-defined-in-supertrait`!). The only change which I wasn't too sure about is in the test `associated-types-overridden-binding-2`, but I think it's an improvement and the underlying problem is with handling of `trait_alias`. Fix #57226, fix #64760, fix #58092.
2019-11-01Rollup merge of #65902 - gilescope:issue62570, r=estebankTyler Mandry-0/+54
Make ItemContext available for better diagnositcs Fix #62570
2019-11-01Rollup merge of #65470 - traxys:fix_65401, r=michaelwoeristerTyler Mandry-0/+3
Don't hide ICEs from previous incremental compiles I think this fixes #65401, the compiler does not fail to ICE after the first compilation, tested on the last snippet of [this comment](https://github.com/rust-lang/rust/issues/63154#issuecomment-541592381). I am not very sure of the fix as I don't understand much of the structure of the compiler.
2019-11-01Rollup merge of #65112 - jack-t:type-parens-lint, r=varkorTyler Mandry-1/+1
Add lint and tests for unnecessary parens around types This is my first contribution to the Rust project, so I apologize if I'm not doing things the right way. The PR fixes #64169. It adds a lint and tests for unnecessary parentheses around types. I've run `tidy` and `rustfmt` &mdash; I'm not totally sure it worked right, though &mdash; and I've tried to follow the instructions linked in the readme. I tried to think through all the variants of `ast::TyKind` to find exceptions to this lint, and I could only find the one mentioned in the original issue, which concerns types with `dyn`. I'm not a Rust expert, thought, so I may well be missing something. There's also a problem with getting this to build. The new lint catches several things in the, e.g., `core`. Because `x.py` seems to build with an equivalent of `-Werror`, what would have been warnings cause the build to break. I got it to build and the tests to pass with `--warnings warn` on my `x.py build` and `x.py test` commands.
2019-11-01targeted revert of PR rust-lang/rust#64324 (just undo change to dylib ↵Felix S. Klock II-1/+7
generics export). Includes the anticipated fallout to run-make-fulldeps test suite from this change. (We need to reopen issue 64319 as part of landing this.)
2019-10-31Fix incorrect diagnostics for expected type in E0271 with an associated typeOhad Ravid-5/+18
2019-10-31Implement dual proc macro hashingmsizanoen-0/+9
This changes the mechanism of `-Z dual-proc-macro` to record the host proc macro hash in the transistive dependency information and use it during dependency resolution instead of resolving only by name.
2019-10-31Rollup merge of #65850 - mikeyhew:patch-1, r=nikomatsakisMazdak Farrokhzad-5/+7
Update comments re type parameter hack in object safety To check if a method's receiver type is object safe, we create a new receiver type by substituting in a bogus type parameter (let's call it `U`) for `Self`, and checking that the unmodified receiver type implements `DispatchFromDyn<receiver type with Self = U>`. It would be better to use `dyn Trait` directly, and the only reason we don't is because it triggers another check that `Trait` is object safe, resulting in a query cycle. Once the feature `object_safe_for_dispatch` (tracking issue https://github.com/rust-lang/rust/issues/43561) is stabilized, this will no longer be the case, and we'll be able to use `dyn Trait` as the unsized `Self` type. I've updated the comments in object_safety.rs accordingly. cc @Centril @nikomatsakis @bovinebuddha
2019-10-30Make ItemContext available for better diagnositcs.Giles Cope-0/+54
2019-10-29Add lint for unnecessary parens around typesjack-t-1/+1
2019-10-29Make error apply only to impl/trait mismatchEsteban Küber-15/+6
2019-10-29Point at the trait item and tweak wordingEsteban Küber-3/+15
2019-10-29review commentsEsteban Küber-12/+15
2019-10-29Custom lifetime error for `impl` item doesn't conform to `trait`Esteban Küber-0/+55
2019-10-29Don't use eval_always for miri queries used from codegen.Eduard-Mihai Burtescu-2/+0
2019-10-29Rollup merge of #65809 - roblabla:eficall-abi, r=nagisaMazdak Farrokhzad-0/+2
Add new EFIAPI ABI Fixes #54527 Adds a new ABI, "efiapi", which reflects the calling convention as specified by [the current spec UEFI spec](https://uefi.org/sites/default/files/resources/UEFI%20Spec%202_7_A%20Sept%206.pdf#G6.999903). When compiling for x86_64, we should select the `win64` ABI, while on all other architectures (Itanium, x86, ARM and ARM64 and RISC-V), we should select the `C` ABI. Currently, this is done by just turning it into the C ABI everywhere except on x86_64, where it's turned into the win64 ABI. Should we prevent this ABI from being used on unsupported architectures, and if so, how would this be done?
2019-10-29Rollup merge of #65562 - Patryk27:master, r=estebankMazdak Farrokhzad-3/+11
Improve the "try using a variant of the expected type" hint. Fix https://github.com/rust-lang/rust/issues/65494. - Change type-printing output. - Use `span_to_snippet` when possible. - Change the message to `try using a variant of the expected enum`
2019-10-29Rollup merge of #65531 - tmandry:bump-backtrace, r=cramertjMazdak Farrokhzad-1/+5
Update backtrace to 0.3.40 Diff: https://github.com/rust-lang/backtrace-rs/compare/0.3.37...b5cc5b12fa4fd03cb83546a7c62b9fff40086b63 Pretty low risk, considering the only changes are in low-tier targets. r? @cramertj cc @alexcrichton
2019-10-29Rollup merge of #65318 - estebank:coherence, r=varkorMazdak Farrokhzad-30/+77
Call out the types that are non local on E0117 CC #24745.
2019-10-29Rollup merge of #65294 - varkor:lint-inline-prototype, r=matthewjasperMazdak Farrokhzad-92/+282
Lint ignored `#[inline]` on function prototypes Fixes https://github.com/rust-lang/rust/issues/51280. - Adds a `unused_attribute` lint for `#[inline]` on function prototypes. - As a consequence, foreign items, impl items and trait items now have their attributes checked, which could cause some code to no longer compile (it was previously erroneously ignored).
2019-10-28Update backtrace to 0.3.40Tyler Mandry-1/+5
2019-10-28Rollup merge of #65893 - jafern14:let-expr-stable-error-messaging, r=CentrilMazdak Farrokhzad-5/+14
Output previous stable error messaging when using stable build. Fixes #65254 As I had mentioned previously there I have the logic running right now however I'm not getting the exact same syntax highlighting as there was originally for this error. I'm currently getting the following: ``` error: expected expression, found statement (`let`) --> src/main.rs:2:14 | 2 | let x = (let y = 6); | ^^^^^^^^^ | = note: variable declaration using `let` is a statement ``` I'd like to get the following instead: ``` | let x = (let y = 6); | ^^^ ``` My current understanding is that the `span` being passed into `lower_expr_let` is coming from `lowering.rs`. I still don't know how the byte range is calculated for the erroneous syntax and need to look into it a bit more. In the meantime does anybody have any hints/tips regarding this??
2019-10-28Rollup merge of #65891 - michaelwoerister:sp-crate-metadata, r=wesleywiserMazdak Farrokhzad-0/+1
self-profiling: Record something more useful for crate metadata generation event. Before this commit, we had an event that would only track the compression step for proc-macros and Rust dylibs. After the commit we measure the time for acutally generating the crate metadata bytes. r? @wesleywiser
2019-10-28Rollup merge of #65858 - davidtwco:rfc-2203-feature-gate-in-error, ↵Mazdak Farrokhzad-4/+14
r=ecstatic-morse suggest `const_in_array_repeat_expression` flag This PR adds a suggestion to add the `#![feature(const_in_array_repeat_expression)]` attribute to the crate when a promotable expression is used in a repeat expression and the feature gate is not enabled. Unfortunately, this ended up being a little bit more complex than I anticipated, which may not have been worth it given that this would all be removed when the feature is stabilized. However, with #65732 and #65737 being open, and the feature gate having not been being suggested to potential users, the feature might not be stabilized in a while, so maybe this is worth landing. cc @Centril (addresses [this comment](https://github.com/rust-lang/rust/pull/61749#discussion_r307863857)) r? @ecstatic-morse (opened issues related to RFC 2203 recently)
2019-10-28Rollup merge of #65825 - eddyb:def-index-vec, r=varkorMazdak Farrokhzad-23/+17
rustc: use IndexVec<DefIndex, T> instead of Vec<T>. Now that `DefIndex` is a proper index type, we can do that. There was also an unnecessary `Option` I removed, I wonder if that has perf implications.
2019-10-28Rollup merge of #65643 - varkor:remove-free-regions-from-const-placeholder, ↵Mazdak Farrokhzad-7/+9
r=eddyb Correct handling of type flags with `ConstValue::Placeholder` This fixes a mistake, but not https://github.com/rust-lang/rust/issues/65623. r? @eddyb
2019-10-28Output previous stable error messaging when using stable build.Agustin Fernandez-5/+14
2019-10-28suggest `const_in_array_repeat_expression` flagDavid Wood-4/+14
This commit adds a suggestion to add the `#![feature(const_in_array_repeat_expression)]` attribute to the crate when a promotable expression is used in a repeat expression. Signed-off-by: David Wood <david@davidtw.co>
2019-10-28Improve pretty-printing for compound qualified paths.Patryk Wychowaniec-1/+11
2019-10-28Improve the "try using a variant of the expected type" hint.Patryk Wychowaniec-2/+0
2019-10-28Fix rebaseEsteban Küber-5/+5
2019-10-28add commentEsteban Küber-1/+1
2019-10-28Talk about specific types and remove lifetimes from outputEsteban Küber-22/+62
2019-10-28Use more targeted spans for orphan rule errorsEsteban Küber-6/+8
2019-10-28Call out the types that are non local on E0117Esteban Küber-3/+8
2019-10-28self-profiling: Record something more useful for crate metadata generation ↵Michael Woerister-0/+1
event. Before this commit, we had an event that would only track the compression step for proc-macros and Rust dylibs. After the commit we measure the time for acutally generating the crate metadata bytes.
2019-10-28rustc: use IndexVec<DefIndex, T> instead of Vec<T>.Eduard-Mihai Burtescu-23/+17
2019-10-28Auto merge of #65188 - matthewjasper:stabilize-const-constructor, r=Centrilbors-8/+3
Stabilize `const_constructor` # Stabilization proposal I propose that we stabilize `#![feature(const_constructor)]`. Tracking issue: https://github.com/rust-lang/rust/issues/61456 Version target: 1.40 (2019-11-05 => beta, 2019-12-19 => stable). ## What is stabilized ### User guide Tuple struct and tuple variant constructors are now considered to be constant functions. As such a call expression where the callee has a tuple struct or variant constructor "function item" type can be called: ```rust const fn make_options() { // These already work because they are special cased: Some(0); (Option::Some)(1); // These also work now: let f = Option::Some; f(2); {Option::Some}(3); <Option<_>>::Some(5); } ``` ### Motivation Consistency with other `const fn`. Consistency between syntactic path forms. This should also ensure that constructors implement `const Fn` traits and can be coerced to `const fn` function pointers, if they are introduced. ## Tests * [ui/consts/const_constructor/const-construct-call.rs](https://github.com/rust-lang/rust/blob/0d75ab2293a106eb674ac01860910cfc1580837e/src/test/ui/consts/const_constructor/const-construct-call.rs) - Tests various syntactic forms, use in both `const fn` and `const` items, and constructors in both the current and extern crates. * [ui/consts/const_constructor/const_constructor_qpath.rs](https://github.com/rust-lang/rust/blob/1850dfcdabf8258a1f023f26c2c59e96b869dd95/src/test/ui/consts/const_constructor/const_constructor_qpath.rs) - Tests that type qualified paths to enum variants are also considered to be `const fn`.(#64247) r? @oli-obk Closes #61456 Closes #64247
2019-10-28Rollup merge of #65792 - Centril:split-syntax-2, r=petrochenkovMazdak Farrokhzad-15/+13
rustc, rustc_passes: reduce deps on rustc_expand Part of #65324. r? @petrochenkov
2019-10-28Rollup merge of #65664 - anp:panic-location, r=eddybMazdak Farrokhzad-0/+17
`std::panic::Location` is a lang_item, add `core::intrinsics::caller_location` (RFC 2091 3/N) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [RFC text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) @eddyb suggested doing this intrinsic implementation ahead of actually implementing the `#[track_caller]` attribute so that there's an easily tested intermediate step between adding the shim and wiring up the attribute.