Commit Graph

16 Commits

Author SHA1 Message Date
Matthew Jasper cbcef3effc Rework `rustc_serialize`
- Move the type parameter from `encode` and `decode` methods to
  the trait.
- Remove `UseSpecialized(En|De)codable` traits.
- Remove blanket impls for references.
- Add `RefDecodable` trait to allow deserializing to arena-allocated
  references safely.
- Remove ability to (de)serialize HIR.
- Create proc-macros `(Ty)?(En|De)codable` to help implement these new
  traits.
2020-08-14 17:34:30 +01:00
David Wood ce7c48fa15
trait_sel: only test predicates w/ no substs
This commit modifies the `substitute_normalize_and_test_predicates`
query, renaming it to `impossible_predicates` and only checking
predicates which do not require substs. By making this change,
polymorphization doesn't have to explicitly support vtables.

Signed-off-by: David Wood <david@davidtw.co>
2020-07-20 11:23:26 +01:00
Rich Kadel a6f8b8a211 Generating the coverage map
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-17 11:49:35 -07:00
bors 7e11379f3b Auto merge of #74113 - lcnr:type-dependent-consts-2, r=eddyb
Support const args in type dependent paths (Take 2)

once more, except it is sound this time 🥰 previously #71154

-----
```rust
#![feature(const_generics)]

struct A;
impl A {
    fn foo<const N: usize>(&self) -> usize { N }
}
struct B;
impl B {
    fn foo<const N: usize>(&self) -> usize { 42 }
}

fn main() {
    let a = A;
    a.foo::<7>();
}
```
When calling `type_of` for generic const arguments, we now use the `TypeckTables` of the surrounding body to get the expected type.

This alone causes cycle errors though, as we now have `typeck_tables_of(main)` -> `...` ->
`type_of(main_ANON0 := 7)` -> `typeck_tables_of(main)`  (see https://github.com/rust-lang/rust/issues/68400#issuecomment-611760290)

To prevent this we must not call `type_of(const_arg)` during `typeck_tables_of`. This is achieved by
calling `type_of(param_def_id)` instead.

We have to somehow remember the `DefId` of the param through all of typeck, which is done using the
struct `ty::WithOptConstParam<DefId>`, which replaces `DefId` where needed and contains an `Option<DefId>` to
be able to store the const parameter in case it exists.

Queries which are currently cached on disk are split into two variants: `query_name`(cached) and `query_name_(of|for)_const_arg`(not cached), with `query_name_of_const_arg` taking a pair `(did, param_did): (LocalDefId, DefId)`.

For some queries a method `query_name_of_opt_const_arg` is added to `TyCtxt` which takes a `ty::WithOptConstParam` and either calls `query_name` or `query_name_of_const_arg` depending on the value of `const_param_did`.

r? @eddyb @varkor
2020-07-15 12:49:25 +00:00
Bastian Kauschke a8419099d1 InstanceDef::Item 2020-07-15 12:58:32 +02:00
Nicholas Nethercote 7c4d431c06 Change `SymbolName::name` to a `&str`.
This eliminates a bunch of `Symbol::intern()` and `Symbol::as_str()`
calls, which is good, because they require locking the interner.

Note that the unsafety in `from_cycle_error()` is identical to the
unsafety on other adjacent impls.
2020-07-15 14:37:55 +10:00
Nicholas Nethercote 5930081f34 Remove lots of `Symbol::as_str()` calls.
In various ways, such as changing functions to take a `Symbol` instead
of a `&str`.
2020-07-15 09:01:35 +10:00
Nathan Corbyn 11b56fbfb6 Fix whitespace 2020-06-15 09:40:57 +01:00
Nathan Corbyn ee810a75e4 Fix exports with `#[inline(always)]` 2020-06-15 09:40:56 +01:00
Nathan Corbyn 6b7cacb2c9 Export all fns with extern indicator 2020-06-15 09:40:56 +01:00
Nathan Corbyn f62903b74a Export `#[inline] #[no_mangle]` fns in cdylibs and staticlibs 2020-06-15 09:40:56 +01:00
Wesley Wiser 5063297c79 Add doc comment for `rustc_middle::mir::mono::Linkage` 2020-05-12 08:12:38 -04:00
marmeladema c9f6ffc3b0 Change return type of `entry_fn` query to return a `LocalDefId` 2020-04-27 23:58:11 +01:00
marmeladema bfce24aa67 Modify `as_local_hir_id` to return a bare `HirId` 2020-04-23 23:14:07 +01:00
marmeladema 6148db719f Modify `as_local_hir_id` to accept a `LocalDefId` instead of a `DefId` 2020-04-23 23:14:07 +01:00
Mazdak Farrokhzad 7710f2dd5c rustc -> rustc_middle part 1 2020-03-30 07:02:56 +02:00