about summary refs log tree commit diff
path: root/src/librustc_passes
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-7577/+0
2020-08-28Auto merge of #70212 - Amanieu:catch_foreign, r=Mark-Simulacrumbors-0/+3
Abort when foreign exceptions are caught by catch_unwind Prior to this PR, foreign exceptions were not caught by catch_unwind, and instead passed through invisibly. This represented a painful soundness hole in some libraries ([take_mut](https://github.com/Sgeo/take_mut/blob/master/src/lib.rs#L37)), which relied on `catch_unwind` to handle all possible exit paths from a closure. With this PR, foreign exceptions are now caught by `catch_unwind` and will trigger an abort since catching foreign exceptions is currently UB according to the latest proposals by the FFI unwind project group. cc @rust-lang/wg-ffi-unwind
2020-08-27Abort when catch_unwind catches a foreign exceptionAmanieu d'Antras-0/+3
2020-08-26Point to a move-related span when pointing to closure upvarsAaron Hill-2/+2
Fixes #75904 When emitting move/borrow errors, we may point into a closure to indicate why an upvar is used in the closure. However, we use the 'upvar span', which is just an arbitrary usage of the upvar. If the upvar is used in multiple places (e.g. a borrow and a move), we may end up pointing to the borrow. If the overall error is a move error, this can be confusing. This PR tracks the span that caused an upvar to become captured by-value instead of by-ref (assuming that it's not a `move` closure). We use this span instead of the 'upvar' span when we need to point to an upvar usage during borrow checking.
2020-08-24hir: consistent use and naming of lang itemsDavid Wood-5/+5
This commit adjusts the naming of various lang items so that they are consistent and don't include prefixes containing the target or "LangItem". In addition, lang item variants are no longer exported from the `lang_items` module. Signed-off-by: David Wood <david@davidtw.co>
2020-08-19Auto merge of #75563 - richkadel:llvm-coverage-map-gen-5.4, r=wesleywiserbors-12/+2
Moved coverage counter injection from BasicBlock to Statement. As discussed on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Implement.20LLVM-compatible.20source-based.20cod.20compiler-team.23278
2020-08-19Auto merge of #74098 - GuillaumeGomez:doc-alias-checks, r=ollie27bors-2/+24
Doc alias checks: ensure only items appearing in search index can use it Following the discussion in #73721, I added checks to ensure that only items appearing in the search are allowed to have doc alias. r? @ollie27
2020-08-18Moved coverage counter injection from BasicBlock to Statement.Rich Kadel-12/+2
2020-08-17Auto merge of #75120 - JulianKnodt:rm_reps, r=oli-obkbors-10/+10
rust_ast::ast => rustc_ast Rework of #71199 which is a rework #70621 Still working on this but just made the PR to track progress r? @Dylan-DPC
2020-08-17Auto merge of #75145 - ↵bors-3/+11
davidtwco:issue-60607-preallocate-defid-for-lang-items, r=petrochenkov Reference lang items during AST lowering Fixes #60607 and fixes #61019. This PR introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols: - Credit for much of this work goes to @matthewjasper, I basically just [rebased their earlier work](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#diff-c0f791ead38d2d02916faaad0f56f41d). - ~~Changes to Clippy might not be correct, they compile but attempting to run tests through `./x.py` produced failures which appeared spurious, so I didn't run any clippy tests.~~ - Changes to save analysis might not be correct - tests pass but I don't have a lot of confidence in those changes being correct. - I've used `GenericBounds::LangItemTrait` rather than changing `PolyTraitRef`, as suggested by @matthewjasper [in this comment](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#r40107992) but I'd prefer that be left for a follow-up. - I've split things into smaller commits fairly arbitrarily to make the diff easier to review, each commit should compile but might not pass tests until the final commit. r? @oli-obk cc @matthewjasper
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-10/+10
2020-08-16Use LocalDefId instead of HirId for reachable_set elements.Eduard-Mihai Burtescu-50/+49
2020-08-16hir: introduce `QPath::LangItem`David Wood-2/+4
This commit introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols. This might be better for performance, but is also much cleaner as the previous approach is fragile. In addition, it resolves a bug (#61019) where an extern crate imported as "std" would result in the paths created during AST lowering being resolved incorrectly (or not at all). Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
2020-08-16lang_items: add support for lang items on variantsDavid Wood-1/+7
This commit adds support for lang items (`#[lang = "..."]` attributes) on enum variants. Signed-off-by: David Wood <david@davidtw.co>
2020-08-15replaced log with tracingGurpreet Singh-2/+2
2020-08-13merge `as_local_hir_id` with `local_def_id_to_hir_id`Bastian Kauschke-15/+17
2020-08-12Allow #[doc(alias)] on impl const itemsGuillaume Gomez-6/+2
2020-08-11Move #[doc(alias)] attribute checks in rustcGuillaume Gomez-2/+28
2020-08-08Eliminate `librustc_hir`'s dependency on `librustc_session`.Nicholas Nethercote-2/+4
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-43/+41
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-08-04rustc_ast: `(Nested)MetaItem::check_name` -> `has_name`Vadim Petrochenkov-1/+1
For consistency with `Attribute::has_name` which doesn't mark the attribute as used either. Replace all uses of `check_name` with `has_name` outside of rustc
2020-07-31Move from `log` to `tracing`Oliver Scherer-1/+1
2020-07-31Auto merge of #65989 - Aaron1011:fix/normalize-param-env, r=nikomatsakisbors-2/+4
Normalize all opaque types when converting ParamEnv to Reveal::All When we normalize a type using a ParamEnv with a reveal mode of RevealMode::All, we will normalize opaque types to their underlying types (e.g. `type MyOpaque = impl Foo` -> `StructThatImplsFoo`). However, the ParamEnv may still have predicates referring to the un-normalized opaque type (e.g. `<T as MyTrait<MyOpaque>>`). This can cause trait projection to fail, since a type containing normalized opaque types will not match up with the un-normalized type in the `ParamEnv`. To fix this, we now explicitly normalize all opaque types in caller_bounds of a `ParamEnv` when changing its mode to `RevealMode::All`. This ensures that all predicatse will refer to the underlying types of any opaque types involved, allowing them to be matched up properly during projection. To reflect the fact that normalization is occuring, `ParamEnv::with_reveal_all` is renamed to `ParamEnv::with_reveal_all_normalized` Fixes #65918
2020-07-22Fix rebase falloutAaron Hill-2/+4
2020-07-20Migrate rustc_depr uses to use deprecation attributeMark Rousskov-53/+75
This should not be a change in behavior.
2020-07-19Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandrybors-11/+9
Generating the coverage map @tmandry @wesleywiser rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example commands to generate a coverage report: ```shell $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main ``` ![rust coverage report only 20200706](https://user-images.githubusercontent.com/3827298/86697299-1cbe8f80-bfc3-11ea-8955-451b48626991.png) r? @wesleywiser Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-17Generating the coverage mapRich Kadel-11/+9
rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example: $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main 1| 1|pub fn will_be_called() { 2| 1| println!("called"); 3| 1|} 4| | 5| 0|pub fn will_not_be_called() { 6| 0| println!("should not have been called"); 7| 0|} 8| | 9| 1|fn main() { 10| 1| let less = 1; 11| 1| let more = 100; 12| 1| 13| 1| if less < more { 14| 1| will_be_called(); 15| 1| } else { 16| 1| will_not_be_called(); 17| 1| } 18| 1|}
2020-07-17Auto merge of #72983 - Lezzz:rename-typeck, r=nikomatsakisbors-45/+51
Rename TypeckTables to TypeckResults. Originally suggested by @eddyb.
2020-07-17Rename TypeckTables to TypeckResults.Valentin Lazureanu-45/+51
2020-07-17Auto merge of #74395 - Mark-Simulacrum:stage0-next, r=pietroalbinibors-1/+0
Bump version to 1.47 This also bumps to a more recent rustfmt version, just to keep us relatively up to date (though almost nothing has changed in rustfmt we use beyond bumps to the parser infra). No formatting changes as a result of this. r? @pietroalbini
2020-07-16Rollup merge of #74033 - ehuss:std-compile-all-platforms, r=Mark-SimulacrumManish Goregaokar-1/+2
Add build support for Cargo's build-std feature. This makes some changes to the standard library to make it easier to use with Cargo's build-std feature. The primary goal is to make it so that Cargo and its users do not need to know which crates to build and which features to use for every platform. Conditional cfgs are adjusted so that there is usually a fall-through for unsupported platforms. Additionally, there is a "restricted-std" feature to mark `std` as unstable when used with build-std on no_std platforms. There is no intent to stabilize this feature for the foreseeable future. This borrows some of the implementation for wasm which already does what this needs. More code sharing can be done with some other platforms (there is a lot of duplication with cloudabi, hermit, and sgx), but I figure that can be done in a future PR. There are some small changes to stable behavior in this PR: - `std::env::consts::ARCH` on asmjs now reports "wasm32", to match its actual architecture. - Some of the wasm error messages for unsupported features report a slightly different error message so that the code can be reused. There should otherwise not be any changes to how std is built for distribution via bootstrap. This does not yet support all platforms when used with build-std. - It doesn't work with 16-bit targets (hashbrown does not support that). - It does not work with JSON spec targets. - In particular, all target triple snooping will need to be replaced with appropriate target option checking. - Switching to gimli (#73441) will make cross-building *much* easier. - There are still a ton of issues on the Cargo side to resolve. A big one is panic strategy support. Future PRs are intended to address some of these issues.
2020-07-16apply bootstrap cfgsMark Rousskov-1/+0
2020-07-16Rollup merge of #74148 - GuillaumeGomez:doc-alias-check, r=ManishearthManish Goregaokar-0/+30
Move #[doc(alias)] check in rustc Part of #73721. r? @ollie27
2020-07-15Introduce restricted-std feature.Eric Huss-1/+2
2020-07-15Add and use more static symbols.Nicholas Nethercote-3/+3
Note that the output of `unpretty-debug.stdout` has changed. In that test the hash values are normalized from a symbol numbers to small numbers like "0#0" and "0#1". The increase in the number of static symbols must have caused the original numbers to contain more digits, resulting in different pretty-printing prior to normalization.
2020-07-10Rollup merge of #74127 - tamird:allowlist, r=oli-obkManish Goregaokar-2/+2
Avoid "whitelist" Other terms are more inclusive and precise.
2020-07-10Rollup merge of #74109 - nbdd0121:issue-74082, r=petrochenkovManish Goregaokar-0/+2
Only allow `repr(i128/u128)` on enum Fixes #74082
2020-07-10Avoid "whitelist"Tamir Duberstein-2/+2
Other terms are more inclusive and precise.
2020-07-08Move #[doc(alias)] check in rustcGuillaume Gomez-0/+30
2020-07-06Only allow `repr(i128/u128)` on enumGary Guo-0/+2
2020-07-05Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.Eduard-Mihai Burtescu-14/+14
2020-07-02Rollup merge of #73753 - eddyb:extraneous-lifetime, r=ManishearthManish Goregaokar-4/+4
Use 'tcx for references to AccessLevels wherever possible. Most of the changes are just fallout from removing a lifetime parameter from structs, and mostly in clippy. r? @Manishearth
2020-07-02Rollup merge of #73726 - ↵Manish Goregaokar-10/+1
davidtwco:issue-73541-labelled-break-through-closure-async, r=petrochenkov resolve: disallow labelled breaks/continues through closures/async blocks Fixes #73541. This PR modifies name resolution to prohibit labelled breaks/continues through closures or async blocks, fixing an ICE. In addition, it improves the diagnostics surrounding labelled breaks/continues through closures or async blocks by informing the user if the label exists in an parent scope and telling them that won't work. r? @petrochenkov (resolve) cc @estebank (diagnostic changes) @tmandry (issue is from `wg-async-foundations`)
2020-07-03Use 'tcx for references to AccessLevels wherever possible.Eduard-Mihai Burtescu-4/+4
2020-07-02Auto merge of #73751 - eddyb:no-empty-tables, r=nikomatsakisbors-29/+44
Remove `TypeckTables::empty(None)` and make hir_owner non-optional. Each commit before the last one removes uses of `TypeckTables::empty(None)`, replacing the empty tables with having `Option` around the `&'tcx TypeckTables<'tcx>` that HIR visitors kept track of. The last commit removes the concept of "empty `TypeckTables`" altogether, guaranteeing that every `TypeckTables` corresponds to a HIR body owner. r? @nikomatsakis
2020-07-02rustc_passes/dead: avoid using TypeckTables::empty for MarkSymbolVisitor.Eduard-Mihai Burtescu-19/+26
2020-07-02rustc_passes/reachable: avoid using TypeckTables::empty for ReachableContext.Eduard-Mihai Burtescu-10/+18
2020-07-02resolve: disallow label use through closure/asyncDavid Wood-10/+1
This commit modifies resolve to disallow `break`/`continue` to labels through closures or async blocks. This doesn't make sense and should have been prohibited anyway. Signed-off-by: David Wood <david@davidtw.co>
2020-07-01Rollup merge of #73449 - ehuss:duplicate-lang-item, r=matthewjasperManish Goregaokar-0/+22
Provide more information on duplicate lang item error. This gives some notes on the location of the files where the lang items were loaded from. Some duplicate lang item errors can be a little confusing, and this might help in diagnosing what has happened. Here's an example when hitting a bug with Cargo's build-std: ``` error: duplicate lang item in crate `core` (which `rustc_std_workspace_core` depends on): `try`. | = note: the lang item is first defined in crate `core` (which `z10` depends on) = note: first definition in `core` loaded from /Users/eric/Proj/rust/cargo/scratch/z10/target/target/debug/deps/libcore-a764da499c7385f4.rmeta = note: second definition in `core` loaded from /Users/eric/Proj/rust/cargo/scratch/z10/target/target/debug/deps/libcore-5b082675aea34986.rmeta ```
2020-06-30Switch crate_extern_paths to a query, and tweak wording.Eric Huss-9/+10