Commit Graph

137 Commits

Author SHA1 Message Date
Dylan MacKenzie a6a87e8bfc Support liveness in rustc_peek tests 2020-05-03 11:36:11 -07:00
Dylan DPC ffe0a1c9fd Rollup merge of #71314 - mibac138:cfg-version, r=petrochenkov
Implement RFC 2523, `#[cfg(version(..))]`

Hi! This is my first contribution to rust, I hope I didn't miss anything. I tried to implement this feature so that `#[cfg(version(1.44.0))]` works but the parser was printing an error that I wasn't sure how to fix so I just opted for implementing `#[cfg(version("1.44.0"))]` (note the quotes).

Tracking issue: #64796
2020-05-03 14:18:00 +05:30
mibac138 90aa62a1bf Implement RFC 2523, #[cfg(version(..))] 2020-05-03 02:42:07 +02:00
Dylan DPC 97cf378f54 Rollup merge of #71787 - tshepang:rustdoc-warnings, r=varkor
fix rustdoc warnings
2020-05-02 18:27:52 +02:00
Tshepang Lekhonkhobe 3be52b5941 fix rustdoc warnings 2020-05-02 10:41:04 +02:00
LeSeulArtichaut 2474f0ed88 Allow #[target_feature] on safe functions 2020-05-01 14:17:43 +02:00
Dylan DPC 89aff5f33e Rollup merge of #71263 - shlevy:FileLoader-remove-abs_path, r=Xanewok
Remove unused abs_path method from rustc_span::source_map::FileLoader
2020-04-27 03:26:11 +02:00
bors 659951c4a0 Auto merge of #71439 - Mark-Simulacrum:stage0-next, r=jonas-schievink
Bump bootstrap compiler

This bumps the bootstrap compiler and the rustfmt that x.py fmt uses.
2020-04-25 14:15:10 +00:00
Mark Rousskov 93eed402ad Bump bootstrap compiler 2020-04-25 09:25:33 -04:00
Esteban Küber 25f8966b5a Sort MultiSpans on creation 2020-04-22 17:15:34 -07:00
Shea Levy c7899a027e Remove unused abs_path method from rustc_span::source_map::FileLoader 2020-04-17 17:58:25 -04:00
bors 4e4d49d60f Auto merge of #70831 - sfackler:shrink-future-stack, r=matthewjasper
Remove a stack frame from .await calls

The stack frames when `.await`ing one async fn from another currently look like this:

```
  12: foo::b::{{closure}}
             at src/main.rs:2
  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/sfackler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:66
  14: core::future::poll_with_context
             at /home/sfackler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:84
  15: foo::a::{{closure}}
             at src/main.rs:6
```

Since the move away from using TLS to pass the Context around, it's now easy to remove frame 14 by removing poll_with_context in favor of calling Future::poll directly. This still leaves the `GenFuture` frame, but that seems significantly harder to deal with.

It also improves diagnostics a bit since they no longer talk about the private poll_with_context function.
2020-04-16 09:13:07 +00:00
Steven Fackler 3ba3bd5dc9 Fix symbol sorting 2020-04-13 17:25:38 -07:00
Dylan DPC 0e47d69496 Rollup merge of #71053 - phansch:update_kw_sym_docs, r=Dylan-DPC
Add some basic docs to `sym` and `kw` modules

I was looking into improving some Clippy documentation but was missing a
place that explains the `kw` and `sym` modules from rustc.

This adds some very basic usage documentation to these modules.
2020-04-12 14:49:08 +02:00
Dylan DPC 9c34740e92 Rollup merge of #71048 - arlosi:normalize_ext_src, r=eddyb
Normalize source when loading external foreign source into SourceMap

The compiler normalizes source when reading files initially (removes BOMs, etc), but not when loading external sources.

This leads to the external source matching according to the `src_hash`, but differing internally because it was not normalized.

Fixes #70874.
2020-04-12 14:49:06 +02:00
Philipp Hansch ec4f7e2edf Add some basic docs to sym and kw modules
I was looking into improving some Clippy documentation but was missing a
place that explains the `kw` and `sym` modules from rustc.
2020-04-12 11:24:58 +02:00
Arlo Siemsen f41aa161c2 Normalize source when loading external foreign source into SourceMap
The compiler normalizes source when reading files initially (removes BOMs, etc), but not when loading external sources.

Fixes #70874 by normalizing when loading external sources too. Adds a test to verify normalization.
2020-04-11 23:26:46 -07:00
bors f363450358 Auto merge of #70986 - marmeladema:issue70853/librustc_middle-local-def-id, r=eddyb
rustc_middle: return `LocalDefId` where possible in hir::map module

This changes the return type of the following functions to return a `LocalDefId` instead of a `DefId`:
* opt_local_def_id_from_node_id
* opt_local_def_id
* body_owner_def_id
* local_def_id_from_node_id
* get_parent_id

This is another step in the right direction for #70853

This pull request will be followed by another (substantial one) which changes the return type of `local_def_id` function but this change being more invasive, we might want to wait for #70956 or #70961 (or some other form it) to land first.
2020-04-10 23:13:13 +00:00
marmeladema b6b00578db librustc_middle: return LocalDefId instead of DefId in get_parent_did 2020-04-10 12:13:54 +01:00
Eduard-Mihai Burtescu 9d13520a6b Replace "rc"/"arc" lang items with Rc/Arc diagnostic items. 2020-04-08 10:47:41 +03:00
Steven Fackler 5dc8ec8dc3 Remove a stack frame from .await calls 2020-04-05 18:51:21 -07:00
Linus Färnstrand fcf45999f7 Stop importing int/float modules in librustc_* 2020-04-05 11:22:01 +02:00
Arlo Siemsen f86b078e2d Add hash of source files in debug info
* Adds either an MD5 or SHA1 hash to the debug info.
* Adds new unstable option `-Z src-hash-algorithm` to control the hashing algorithm.
2020-04-02 14:13:19 -07:00
Mazdak Farrokhzad 7710f2dd5c rustc -> rustc_middle part 1 2020-03-30 07:02:56 +02:00
Amanieu d'Antras d162d096dd Rename asm! to llvm_asm!
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-26 15:49:22 +00:00
Niko Matsakis 011215b2c7 pacify the merciless x.py fmt 2020-03-26 06:52:58 -04:00
Niko Matsakis fda3378e3f introduce negative_impls feature gate and document
They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.

This also adds docs in the unstable book for the current state of auto traits.
2020-03-26 06:52:55 -04:00
Esteban Küber f18a6dcec0 Rename def_span to guess_head_span 2020-03-25 16:45:12 -07:00
Mazdak Farrokhzad 5b29348cfe Rollup merge of #70318 - anyska:multiple-derives, r=Dylan-DPC
Split long derive lists into two derive attributes.
2020-03-23 19:04:57 +01:00
Mazdak Farrokhzad 560eae31c5 Rollup merge of #70199 - pnkfelix:issue-68808-dont-turn-dummy-spans-into-invalid-lines, r=estebank
Revised span-to-lines conversion to produce an empty vec on DUMMY_SP.

This required revising some of the client code to stop relying on the returned set of lines being non-empty.

Fix #68808
2020-03-23 19:04:51 +01:00
Felix S Klock II 763121d68b Update src/librustc_span/source_map.rs
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2020-03-23 13:32:23 -04:00
Ana-Maria Mihalache fcb4e771a6 Split long derive lists into two derive attributes. 2020-03-23 14:48:59 +00:00
Dylan DPC e58fec0c1c Rollup merge of #70229 - matthiaskrgr:cl3ppy, r=Mark-Simulacrum
more clippy fixes

* remove unused unit values (clippy::unused_unit)
* make some let-if-bindings more idiomatic (clippy::useless_let_if_seq)
* clarify when we pass () to functions (clippy::unit_arg)
* don't redundantly repeat field names (clippy::redundant_field_names)
* remove redundant returns (clippy::needless_return)
* use let instead of match for matches with single bindings (clippy::match_single_binding)
* don't convert results to options just for matching (clippy::if_let_some_result)
2020-03-22 15:48:35 +01:00
Dylan DPC 9890d9a9d0 Rollup merge of #70172 - eddyb:retokenize-external-src, r=petrochenkov
parse/lexer: support `StringReader::retokenize` called on external files.

This ~~should theoretically~~ fixes #69933, ~~but I'm not sure what the best way to test it is~~.
**EDIT**: see https://github.com/rust-lang/rust/issues/69933#issuecomment-602019598.

r? @petrochenkov cc @Xanewok @staktrace
2020-03-22 15:48:30 +01:00
Matthias Krüger 5566a1cee4 remove redundant returns (clippy::needless_return) 2020-03-21 15:55:34 +01:00
Dylan DPC fd3f9176c3 Rollup merge of #69901 - RalfJung:rustc_layout, r=eddyb
add #[rustc_layout(debug)]

@eddyb recently told me about the `#[rustc_layout]` attribute, and I think it would be very useful if it could be used to print all the layout information Rust has about a type. When working with layouts (e.g. in Miri), it is often not clear how certain surface language features get represented internally. I have some awful hacks locally to be able to dump this debug information; with this attribute I could get it on the playground which is so much better. :)
2020-03-21 13:06:35 +01:00
Mazdak Farrokhzad 3e6b1ac964 Rollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-Simulacrum
more clippy fixes

    * remove redundant returns (clippy::needless_return)
    * remove redundant import (clippy::single_component_path_imports)
    * remove redundant format!() call (clippy::useless_format)
    * don't use ok() before calling expect() (clippy::ok_expect)
2020-03-21 05:33:31 +01:00
Mazdak Farrokhzad ef7c8a158f Rollup merge of #69033 - jonas-schievink:resume-with-context, r=tmandry
Use generator resume arguments in the async/await lowering

This removes the TLS requirement from async/await and enables it in `#![no_std]` crates.

Closes https://github.com/rust-lang/rust/issues/56974

I'm not confident the HIR lowering is completely correct, there seem to be quite a few undocumented invariants in there. The `async-std` and tokio test suites are passing with these changes though.
2020-03-21 05:33:15 +01:00
Matthias Krüger ad00e91887 remove redundant returns (clippy::needless_return) 2020-03-20 20:23:03 +01:00
Felix S. Klock II ebf27fac81 Revised span-to-lines conversion to produce an empty vec on DUMMY_SP.
This required revising some of the client code to stop relying on
the returned set of lines being non-empty.
2020-03-20 14:11:16 -04:00
Ralf Jung 55c2cf2a32 add debug option to #[rustc_layout] 2020-03-20 17:25:03 +01:00
Eduard-Mihai Burtescu 6f6fe38b19 parse/lexer: support StringReader::retokenize called on external files. 2020-03-20 08:00:06 +02:00
Eduard-Mihai Burtescu f3ec069886 rustc: use LocalDefId instead of DefIndex in HirId. 2020-03-19 11:16:08 +02:00
Eduard-Mihai Burtescu 42b2adfab0 rustc: introduce DefId::as_local(self) -> Option<LocalDefId> and use it. 2020-03-19 11:15:35 +02:00
Eduard-Mihai Burtescu 0c692797d7 rustc: rename DefId::to_local to expect_local and use it instead of LocalDefId::from_def_id. 2020-03-19 11:15:35 +02:00
Eduard-Mihai Burtescu 55ed19fe1b rustc: make LocalDefId's index field public like DefId's is. 2020-03-19 11:15:35 +02:00
Aaron Hill 5e2856122a Properly handle Spans that reference imported SourceFiles
Previously, metadata encoding used DUMMY_SP to represent any spans that
referenced an 'imported' SourceFile - e.g. a SourceFile from an upstream
dependency. These leads to sub-optimal error messages in certain cases
(see the included test).

This PR changes how we encode and decode spans in crate metadata. We
encode spans in one of two ways:

* 'Local' spans, which reference non-imported SourceFiles, are encoded
  exactly as before.
* 'Foreign' spans, which reference imported SourceFiles, are encoded
  with the CrateNum of their 'originating' crate. Additionally, their
'lo' and 'high' values are rebased on top of the 'originating' crate,
which allows them to be used with the SourceMap data encoded for that
crate.

The `ExternalSource` enum is renamed to `ExternalSourceKind`. There is
now a struct called `ExternalSource`, which holds an
`ExternalSourceKind` along with the original line number information for
the file. This is used during `Span` serialization to rebase spans onto
their 'owning' crate.
2020-03-18 23:56:42 -04:00
Mazdak Farrokhzad 252184969b Rollup merge of #69899 - ecstatic-morse:const-idx-methods, r=oli-obk
Make methods declared by `newtype_index` macro `const`

Crates that use the macro to define an `Idx` type need to enable `#![feature(const_if_match, const_panic)]`.
2020-03-18 18:03:42 +01:00
Jonas Schievink dfcfa170f5 Make async/await lowering use resume arguments 2020-03-17 22:17:31 +01:00
Dylan MacKenzie cc4a5770fa Add requisite feature gates for const assert 2020-03-17 11:15:40 -07:00