Commit Graph

83 Commits

Author SHA1 Message Date
Eduard-Mihai Burtescu
7683180be5 rustc: implement and use Default on more types. 2018-11-21 08:11:50 +02:00
Eduard-Mihai Burtescu
da622a3796 rustc: remove {FxHash,Node,DefId,HirId,ItemLocal}{Map,Set} "constructor" fns. 2018-11-21 07:27:02 +02:00
Oliver Scherer
3c9258e604 Prefer Default::default over FxHash*::default in struct constructors 2018-10-19 14:34:44 +02:00
Oliver Scherer
ee81739dc1 Deprecate the FxHashMap() and FxHashSet() constructor function hack 2018-10-19 14:34:44 +02:00
Diogo Sousa
2d7edf908d Use full name to identify a macro in a FileName.
Before this two macros with same name would be indistinguishable inside a
`FileName`.  This caused a bug in incremental compilation (see #53097) since
two different macros would map out to the same `StableFilemapId`.

Fixes #53097.
2018-09-19 01:12:13 +01:00
ljedrz
2919ecdb5c A few cleanups for hir 2018-09-12 17:07:00 +02:00
Ariel Ben-Yehuda
5415bb6e8f create a valid DefIdTable for proc macro crates
At least the incremental compilation code, and a few other places in the
compiler, require the CrateMetadata for a loaded target crate to contain a
valid DefIdTable for the DefIds in the target.

Previously, the CrateMetadata for a proc macro contained the crate's
"host" DefIdTable, which is of course incompatible with the "target"
DefIdTable, causing ICEs. This creates a DefIdTable that properly refers
to the "proc macro" DefIds.

Fixes #49482.
2018-08-26 18:48:41 +03:00
Donato Sciarra
c655473378 mv CodeMap SourceMap 2018-08-19 23:00:59 +02:00
Oliver Schneider
53d2ebb0ad Implement existential types 2018-07-18 10:53:08 +02:00
Vadim Petrochenkov
4d1a30c92b Remove most of PartialEq impls from AST and HIR structures 2018-07-14 14:56:57 +03:00
Vadim Petrochenkov
fc74e35981 Remove fallback to parent modules from lexical resolution 2018-07-08 18:16:09 +03:00
Michael Woerister
447f1f3f5c Avoid sorting the item_ids array the StableHash impl of hir::Mod. 2018-07-03 11:16:38 +02:00
bors
bfc1ee4968 Auto merge of #51762 - petrochenkov:oh-hi-mark, r=oli-obk
hygiene: Implement transparent marks and use them for call-site hygiene in proc-macros

Fixes https://github.com/rust-lang/rust/issues/50050
2018-06-30 09:19:21 +00:00
Vadim Petrochenkov
9f92fce77c Fortify dummy span checking 2018-06-30 01:53:32 +03:00
Oliver Schneider
013fca8698 Generate DefIds for impl Trait in the def_collector 2018-06-27 11:17:25 +02:00
Vadim Petrochenkov
fffe9fbb51 hygiene: More descriptive names for things involved in late hygienic name resolution 2018-06-23 20:09:21 +03:00
varkor
10229fd9d5 Rename DefPathData::LifetimeDef to LifetimeParam 2018-06-20 12:21:24 +01:00
Oliver Schneider
9b1bd94e37 Add existential type definitons 2018-06-07 17:33:53 +02:00
Zack M. Davis
1b7488d40b scrap find_node_for_hir_id in favor of hir_to_node_id
Michael Woerister pointed out that `hir_to_node_id` (introduced in
August 2017's 28ddd7a4e) supersedes the functionality of
`find_node_for_hir_id` (just a hash lookup compared to that linear
search).
2018-05-28 09:20:14 -07:00
Eduard-Mihai Burtescu
26aad25487 rustc: introduce {ast,hir}::AnonConst to consolidate so-called "embedded constants". 2018-05-19 20:34:42 +03:00
John Kåre Alsaker
4d52751d12 Rename InternedString to LocalInternedString and introduce a new thread-safe InternedString 2018-04-27 03:35:32 +02:00
Niko Matsakis
09bd6f3ee7 introduce new DefPathData variants for traits, assoc types 2018-04-23 13:28:14 -04:00
Basile Desloges
4af749f074 Add a map of DefId to Span in the Definitions struct 2018-03-08 11:22:49 +01:00
Aaron Hill
6728f21d85
Generate documentation for auto-trait impls
A new section is added to both both struct and trait doc pages.

On struct/enum pages, a new 'Auto Trait Implementations' section displays any
synthetic implementations for auto traits. Currently, this is only done
for Send and Sync.

On trait pages, a new 'Auto Implementors' section displays all types
which automatically implement the trait. Effectively, this is a list of
all public types in the standard library.

Synthesized impls for a particular auto trait ('synthetic impls') take
into account generic bounds. For example, a type 'struct Foo<T>(T)' will
have 'impl<T> Send for Foo<T> where T: Send' generated for it.

Manual implementations of auto traits are also taken into account. If we have
the following types:

'struct Foo<T>(T)'
'struct Wrapper<T>(Foo<T>)'
'unsafe impl<T> Send for Wrapper<T>' // pretend that Wrapper<T> makes
this sound somehow

Then Wrapper will have the following impl generated:
'impl<T> Send for Wrapper<T>'
reflecting the fact that 'T: Send' need not hold for 'Wrapper<T>: Send'
to hold

Lifetimes, HRTBS, and projections (e.g. '<T as Iterator>::Item') are
taken into account by synthetic impls

However, if a type can *never* implement a particular auto trait
(e.g. 'struct MyStruct<T>(*const T)'), then a negative impl will be
generated (in this case, 'impl<T> !Send for MyStruct<T>')

All of this means that a user should be able to copy-paste a synthetic
impl into their code, without any observable changes in behavior
(assuming the rest of the program remains unchanged).
2018-02-18 16:29:24 -05:00
Michael Woerister
c9d25e3269 Use different DefIndex representation that is better suited for variable length integer encodings. 2018-01-08 14:15:17 +01:00
Jeffrey Seyfried
dfa6c25afd Fix hygiene bug. 2017-11-28 18:59:12 -08:00
Mikhail Modin
0e5c95ebcb change separator from . to - 2017-11-09 12:37:16 +03:00
Mikhail Modin
7a6832de99 change MIR dump filenames from nodeN to DefPath 2017-11-09 12:00:17 +03:00
Santiago Pastorino
d19faead2d Make DefIndex use newtype_index macro 2017-11-04 19:22:37 -03:00
Igor Matuszewski
7fa64bcef3 Introduce CrateDisambiguator newtype and fix tests 2017-10-24 17:49:58 +02:00
Michael Woerister
b50e8ebbba Fix infinite recursion in <DepNode as Debug>. 2017-10-05 10:20:13 +02:00
Eduard-Mihai Burtescu
da0a47a081 Use NodeId/HirId instead of DefId for local variables. 2017-09-08 22:00:59 +03:00
Alex Crichton
0cdc58a1bc rustc: Store InternedString in DefPathData
Previously a `Symbol` was stored there, but this ended up causing hash
collisions in situations that otherwise shouldn't have a hash collision. Only
the symbol's string value was hashed, but it was possible for distinct symbols
to have the same string value, fooling various calcuations into thinking that
these paths *didn't* need disambiguating data when in fact they did!

By storing `InternedString` instead we're hopefully triggering all the exising
logic to disambiguate paths with same-name `Symbol` but actually distinct
locations.
2017-09-05 07:47:27 -07:00
Michael Woerister
a8cf6cc6db Add some ID conversion methods to HIR map and Definitions. 2017-08-11 12:11:38 +02:00
Michael Woerister
55e04d9c17 Make Definitions::find_node_for_hir_id() a linear search instead of a binary one.
Unfortunately, the NodeId->HirId array is not sorted. Since this search is only
done right before calling bug!(), let's not waste time allocating a faster lookup.
2017-08-11 12:11:38 +02:00
Michael Woerister
783ccc443b Make TypeckTables::type_dependent_defs use ItemLocalId instead of NodeId. 2017-08-11 12:11:38 +02:00
Ariel Ben-Yehuda
70478ca5c8 rustc::hir::map::definitions - fix O(n^2) when disambiguating
Instead of finding the next free disambiguator by incrementing it until
you find a place, store the next available disambiguator in an hash-map.

This avoids O(n^2) performance when lots of items have the same
un-disambiguated `DefPathData` - e.g. all `use` items have
`DefPathData::Misc`.
2017-08-01 14:44:20 +03:00
Michael Woerister
fa91eeb99f Remove unused DefTable::retrace_path(). 2017-07-20 15:32:06 +02:00
Zack M. Davis
f668999153 use field init shorthand in src/librustc
The field init shorthand syntax was stabilized in 1.17.0 (aebd94f); we
are now free to use it in the compiler.
2017-07-05 22:37:10 -07:00
Michael Woerister
d714b9790b incr.comp.: Don't use Ident in DefPath because that's unstable across compilation sessions. 2017-06-13 13:47:13 +02:00
Michael Woerister
8b36d3308e Allocate DefIndices for global crate metadata.
This allows for treating global crate metadata the same as regular metadata with regard to incr. comp.
2017-06-07 12:11:40 +02:00
Michael Woerister
9da83a8daf Don't print the whole crate disambiguator value in debug output 2017-05-31 15:55:35 +02:00
Michael Woerister
f854f8b366 Build DefPathHash->DefId table when incr.comp. is enabled 2017-05-31 14:53:39 +02:00
Michael Woerister
59ebe8e115 Make a newtype for DefPathHash so they are not confused with content hashes 2017-05-31 13:54:38 +02:00
Jeffrey Seyfried
3eb235b45e Improve intercrate hygiene. 2017-05-25 05:52:11 +00:00
Jeffrey Seyfried
dde8dc61dd Improve efficiency. 2017-05-25 05:52:10 +00:00
Jeffrey Seyfried
bfa2ef62a1 Hygienize librustc_typeck. 2017-05-25 05:52:05 +00:00
Michael Woerister
4549423f28 Use 128 instead of 64 bits for DefPath hashes 2017-05-18 11:10:11 +02:00
Michael Woerister
edc1ac3016 ICH: Centrally compute and cache DefPath hashes as part of DefPathTable. 2017-04-07 14:36:51 +02:00
Michael Woerister
c47cdc0d93 Introduce HashStable trait and base ICH implementations on it.
This initial commit provides implementations for HIR, MIR, and
everything that also needs to be supported for those two.
2017-04-06 16:01:51 +02:00