about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2020-07-29Auto merge of #73767 - P1n3appl3:rustdoc-formats, r=tmandrybors-1072/+1203
Refactor librustdoc html backend This PR moves several types out of the librustdoc::html module so that they can be used by a future json backend. These changes are a re-implementation of [some work done 6 months ago](https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:multiple-output-formats) by @GuillaumeGomez. I'm currently working on said json backend and will put up an RFC soon with the proposed implementation. There are a couple of changes that are more substantial than relocating structs to a different module: 1. The `Cache` is no longer part of the `html::render::Context` type and therefor it needs to be explicitly passed to any functions that access it. 2. The driving function `html::render::run` has been rewritten to use the `FormatRenderer` trait which should allow different backends to re-use the driving code. r? @GuillaumeGomez cc @tmandry @betamos
2020-07-29Pass by valueJoseph Ryan-3/+3
2020-07-29Refactor DocFS to fix error handling bugsJoseph Ryan-55/+34
2020-07-29Auto merge of #74733 - richkadel:llvm-coverage-map-gen-5, r=tmandrybors-690/+794
Fixed coverage map issues; better aligned with LLVM APIs Found some problems with the coverage map encoding when testing with more than one counter per function. While debugging, I realized some better ways to structure the Rust implementation of the coverage mapping generator. I refactored somewhat, resulting in less code overall, expanded coverage of LLVM Coverage Map capabilities, and much closer alignment with LLVM data structures, APIs, and naming. This should be easier to follow and easier to maintain. r? @tmandry Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-29Auto merge of #74837 - xldenis:mir-dump-crate-file, r=oli-obkbors-422/+224
Fix #70767 This PR changes the format of MIR dump filenames to include the crate name rather than `rustc` at the start. As a result, we can now place mir-opt tests in the same directory as the source files, like with UI tests. I had to make sure that `compiletest` added a bit_width suffix to the expected files when appropriate but otherwise the change is only moving the files to the correct location and ensuring that the `EMIT_MIR` lines are correct. Fixes #70767 cc @oli-obk
2020-07-29Auto merge of #72488 - KodrAus:stabilize/const_type_id, r=nikomatsakisbors-25/+4
Stabilize const_type_id feature The tracking issue for `const_type_id` points to the ill-fated #41875. So I'm re-energizing `TypeId` shenanigans by opening this one up to see if there's anything blocking us from stabilizing the constification of type ids. Will wait for CI before pinging teams/groups. ----- This PR stabilizes the `const_type_id` feature, which allows `TypeId::of` (and the underlying unstable intrinsic) to be called in constant contexts. There are some [sanity tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/consts/const-typeid-of-rpass.rs) that demonstrate its usage, but I’ve included some more below. As a simple example, you could create a constant item that contains some type ids: ```rust use std::any::TypeId; const TYPE_IDS: [TypeId; 2] = [ TypeId::of::<u32>(), TypeId::of::<i32>(), ]; assert_eq!(TypeId::of::<u32>(), TYPE_IDS[0]); ``` Type ids can also now appear in associated constants. You could create a trait that associates each type with its constant type id: ```rust trait Any where Self: 'static { const TYPE_ID: TypeId = TypeId::of::<Self>(); } impl<T: 'static> Any for T { } assert_eq!(TypeId::of::<usize>(), usize::TYPE_ID); ``` `TypeId::of` is generic, which we saw above in the way the generic `Self` argument was used. This has some implications for const evaluation. It means we can make trait impls evaluate differently depending on information that wasn't directly passed through the trait system. This violates the _parametricity_ property, which requires all instances of a generic function to behave the same way with respect to its generic parameters. That's not unique to `TypeId::of`, other generic const functions based on compiler intrinsics like `mem::align_of` can also violate parametricity. In practice Rust doesn't really have type parametricity anyway since it monomorphizes generics into concrete functions, so violating it using type ids isn’t new. As an example of how impls can behave differently, you could combine constant type ids with the `const_if_match` feature to dispatch calls based on the type id of the generic `Self`, rather than based on information about `Self` that was threaded through trait bounds. It's like a rough-and-ready form of specialization: ```rust #![feature(const_if_match)] trait Specialized where Self: 'static { // An associated constant that determines the function to call // at compile-time based on `TypeId::of::<Self>`. const CALL: fn(&Self) = { const USIZE: TypeId = TypeId::of::<usize>(); match TypeId::of::<Self>() { // Use a closure for `usize` that transmutes the generic `Self` to // a concrete `usize` and dispatches to `Self::usize`. USIZE => |x| Self::usize(unsafe { &*(x as *const Self as *const usize) }), // For other types, dispatch to the generic `Self::default`. _ => Self::default, } }; fn call(&self) { // Call the function we determined at compile-time (Self::CALL)(self) } fn default(x: &Self); fn usize(x: &usize); } // Implement our `Specialized` trait for any `Debug` type. impl<T: fmt::Debug + 'static> Specialized for T { fn default(x: &Self) { println!("default: {:?}", x); } fn usize(x: &usize) { println!("usize: {:?}", x); } } // Will print "usize: 42" Specialized::call(&42usize); // Will print "default: ()" Specialized::call(&()); ``` Type ids have some edges that this stabilization exposes to more contexts. It's possible for type ids to collide (but this is a bug). Since they can change between compiler versions, it's never valid to cast a type id to its underlying value.
2020-07-29Move mir-opt tests to toplevelXavier Denis-266/+67
2020-07-29Moved structs/enums with repr(C) to LLVM types into ffi.rs cratesRich Kadel-214/+227
Some were in librustc_codegen_llvm, but others are not tied to LLVM, so I put them in a new crate: librustc_codegen_ssa/coverageinfo/ffi.rs
2020-07-29Auto merge of #72049 - mati865:mingw-lld, r=petrochenkovbors-14/+61
MinGW: enable dllexport/dllimport Fixes (only when using LLD) https://github.com/rust-lang/rust/issues/50176 Fixes https://github.com/rust-lang/rust/issues/72319 This makes `windows-gnu` on pair with `windows-msvc` when it comes to symbol exporting. For MinGW it means both good things like correctly working dllimport/dllexport, ability to link with LLD and bad things like https://github.com/rust-lang/rust/issues/27438. Not sure but maybe this should land behind unstable compiler option (`-Z`) or environment variable?
2020-07-29Add test for #50176Mateusz Mikuła-0/+14
2020-07-29MinGW: emit dllexport/dllimport by rustcMateusz Mikuła-14/+47
This fixes various cases where LD could not guess dllexport correctly and greatly improves compatibility with LLD which is not going to support linker scripts anytime soon
2020-07-29add crate name to mir dumpsXavier Denis-157/+158
2020-07-29Fix opening docs for std crates with ./x.py doc --open library/*Tomasz Miąsko-1/+1
The directories for core, alloc, std, proc_macro, and test crates now correspond directly to the crate name and stripping the "lib" prefix is no longer necessary.
2020-07-29Auto merge of #74887 - Mark-Simulacrum:cache-non-exhaustive, r=petrochenkovbors-14/+16
Cache non-exhaustive separately from attributes This prevents cross-crate attribute loading from metadata just for non_exhaustive checking; cross-crate attribute loading implies disk reading and is relatively slow.
2020-07-28FunctionCoverage: improve type checking with newtype_index typesRich Kadel-40/+88
2020-07-29Rollup merge of #74891 - lcnr:auto-trait-finder, r=varkorYuki Okushi-0/+50
handle ConstEquate in rustdoc fixes #74882 r? @varkor cc @eddyb
2020-07-29Rollup merge of #74864 - lzutao:ayu-doccolor, r=GuillaumeGomezYuki Okushi-3/+2
ayu theme: Change doccomment color to `#a1ac88` Before: ![image](https://user-images.githubusercontent.com/15225902/88621499-d1cbff80-d0ca-11ea-99c3-5e2632709274.png) After: ![image](https://user-images.githubusercontent.com/15225902/88621471-bf51c600-d0ca-11ea-9455-9c297f50f15f.png) Close #74788
2020-07-29Rollup merge of #74859 - mark-i-m:patch-1, r=JohnTitorYuki Okushi-1/+1
Update outdated readme
2020-07-29Rollup merge of #74671 - rust-lang:const-generics-coerce-unsized, r=nikomatsakisYuki Okushi-0/+11
add const generics array coercion test
2020-07-29Rollup merge of #74266 - GuillaumeGomez:cleanup-e0720, r=Dylan-DPCYuki Okushi-3/+5
Clean up E0720 explanation r? @Dylan-DPC
2020-07-28Refactor MIR coverage instrumentationRich Kadel-120/+151
Lays a better foundation for injecting more counters in each function.
2020-07-29handle ConstEquate in rustdocBastian Kauschke-0/+50
2020-07-28Auto merge of #74861 - mark-i-m:mv-std-followup, r=Mark-Simulacrumbors-16/+16
Re-enable linkcheck after moving std
2020-07-28Cache non-exhaustive separately from attributesMark Rousskov-14/+16
2020-07-28Auto merge of #74471 - da-x:string-type-diagnostic-item, r=petrochenkovbors-1/+6
librustc_typeck: use diag item instead of string compare
2020-07-28Collect library features from library/Mark Rousskov-3/+6
2020-07-28reenable tests after moving stdmark-13/+10
2020-07-28Auto merge of #73964 - jyn514:sane-defaults, r=Mark-Simulacrumbors-533/+654
Improve defaults in x.py - Make the default stage dependent on the subcommand - Don't build stage1 rustc artifacts with x.py build --stage 1. If this is what you want, use x.py build --stage 2 instead, which gives you a working libstd. - Change default debuginfo when debug = true from 2 to 1 I tried to fix CI to use `--stage 2` everywhere it currently has no stage, but I might have missed a spot. This does not update much of the documentation - most of it is in https://github.com/rust-lang/rustc-dev-guide/ or https://github.com/rust-lang/rust-forge and will need a separate PR. See individual commits for a detailed rationale of each change. See also the MCP: https://github.com/rust-lang/compiler-team/issues/326 r? @Mark-Simulacrum , but anyone is free to give an opinion.
2020-07-28Use --stage 2 in checktoolsJoshua Nelson-6/+6
- Remove useless --stage 2 argument to checktools.sh - Fix help text for expand-yaml-anchors (it had a typo)
2020-07-28Fix bad rebaseJoshua Nelson-1/+1
2020-07-28Auto merge of #74855 - jyn514:separate-lints, r=Manishearthbors-103/+113
Separate `missing_doc_code_examples` from intra-doc links These two lints have no relation other than both being nightly-only. This allows stabilizing intra-doc links without stabilizing `missing_doc_code_examples`. Fixes one of the issues spotted by @ollie27 in https://github.com/rust-lang/rust/pull/74430#issuecomment-664693080. r? @Manishearth
2020-07-28ayu theme: Change doccomment color to `#a1ac88`Lzu Tao-3/+2
Co-authored-by: Cldfire <cldfire@3grid.net>
2020-07-28update stderr for polymorphic ui testAshley Mannix-4/+4
2020-07-28Auto merge of #74841 - infinity0:fix-exec, r=Mark-Simulacrumbors-26/+24
rustbuild: use Display for exit status instead of Debug, see #74832 for justification
2020-07-28remove unstable const_type_id featureAshley Mannix-2/+0
2020-07-28stabilize const_type_id featureAshley Mannix-19/+0
2020-07-27private_items_doc_tests -> doc_test_lintsJoshua Nelson-3/+3
2020-07-27Use exhaustive match for assertJoshua Nelson-1/+1
2020-07-27Add assert that tests happen with stage 2 in CIJoshua Nelson-18/+32
- Use stage 2 for makefile - Move assert to builder - Don't add an assert for --help - Allow --stage 0 if passed explicitly - Don't assert defaults during tests Otherwise it's impossible to test the defaults!
2020-07-27Use --stage 2 explicitly in CIJoshua Nelson-33/+33
- expand yaml anchors - don't use --stage 2 for dist; that's already the default
2020-07-27Add tests for the new behaviorJoshua Nelson-3/+92
- Only set stage 2 in dist tests - Add test for `x.py doc` without args - Add test for `x.py build` without args - Add test for `x.py build --stage 0`
2020-07-27Move tests into a submoduleJoshua Nelson-461/+470
2020-07-27Fix most bootstrap testsJoshua Nelson-2/+3
Uses --stage 2 for all the existing tests
2020-07-27Change debuginfo to default to 1 if `debug = true` is setJoshua Nelson-1/+1
From [a conversation in discord](https://discordapp.com/channels/442252698964721669/443151243398086667/719200989269327882): > Linking seems to consume all available RAM, leading to the OS to swap memory to disk and slowing down everything in the process Compiling itself doesn't seem to take up as much RAM, and I'm only looking to check whether a minimal testcase can be compiled by rustc, where the runtime performance isn't much of an issue > do you have debug = true or debuginfo-level = 2 in config.toml? > if so I think that results in over 2GB of debuginfo nowadays and is likely the culprit > which might mean we're giving out bad advice :( Anecdotally, this sped up my stage 1 build from 15 to 10 minutes. This still adds line numbers, it only removes variable and type information. - Improve wording for debuginfo description Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
2020-07-27Don't build rustc without stdJoshua Nelson-2/+2
- Set rustc to build only when explicitly asked for This allows building the stage2 rustc artifacts, which nothing depends on. Previously the behavior was as follows (where stageN <-> stage(N-1) artifacts, except for stage0 libstd): - `x.py build --stage 0`: - stage0 libstd - stage1 rustc (but without putting rustc in stage0/) This leaves you without any rustc at all except for the beta compiler (https://github.com/rust-lang/rust/issues/73519). This is never what you want. - `x.py build --stage 1`: - stage0 libstd - stage1 rustc - stage1 libstd - stage1 rustdoc - stage2 rustc This leaves you with a broken stage2 rustc which doesn't even have libcore and is effectively useless. Additionally, it compiles rustc twice, which is not normally what you want. - `x.py build --stage 2`: - stage0 libstd - stage1 rustc - stage1 libstd - stage2 rustc - stage2 rustdoc and tools This builds all tools in release mode. This is the correct usage for CI, but takes far to long for development. Now the behavior is as follows: - `x.py build --stage 0`: - stage0 libstd This is suitable for contributors only working on the standard library, as it means rustc never has to be compiled. - `x.py build --stage 1`: - stage0 libstd - stage1 rustc - stage1 libstd - stage1 rustdoc This is suitable for contributors working on the compiler. It ensures that you have a working rustc and libstd without having to pass `src/libstd` in addition. - `x.py build --stage 2`: - stage0 libstd - stage1 rustc - stage1 libstd - stage2 rustc - stage2 libstd - stage2 rustdoc This is suitable for debugging errors which only appear with the stage2 compiler. - `x.py build --stage 2 src/libstd src/rustc` - stage0 libstd - stage1 rustc - stage1 libstd - stage2 rustc - stage2 libstd - stage2 rustdoc, tools, etc. - stage2 rustc artifacts ('stage3') This is suitable for CI, which wants all tools in release mode. However, most of the use cases for this should use `x.py dist` instead, which builds all the tools without each having to be named individually.
2020-07-27Make the default stage dependent on the subcommandJoshua Nelson-1/+14
### x.py build/test: stage 1 I've seen very few people who actually use full stage 2 builds on purpose. These compile rustc and libstd twice and don't give you much more information than a stage 1 build (except in rare cases like https://github.com/rust-lang/rust/pull/68692#discussion_r376392145). For new contributors, this makes the build process even more daunting than it already is. As long as CI is changed to use `--stage 2` I see no downside here. ### x.py bench/dist/install: stage 2 These commands have to do with a finished, optimized version of rustc. It seems very rare to want to use these with a stage 1 build. ### x.py doc: stage 0 Normally when you document things you're just fixing a typo. In this case there is no need to build the whole rust compiler, since the documentation will usually be the same when generated with the beta compiler or with stage 1. Note that for this release cycle only there will be a significant different between stage0 and stage1 docs: https://github.com/rust-lang/rust/pull/73101. However most of the time this will not be the case.
2020-07-27Don't duplicate builder codeJoshua Nelson-19/+14
- Add Builder::new_internal
2020-07-27Update outdated readmeWho? Me?!-1/+1
2020-07-27Move `look_for_tests` to `private_items_doc_tests`Joshua Nelson-56/+61
2020-07-27Separate `missing_doc_code_examples` from intra-doc linksJoshua Nelson-29/+34
These two lints have no relation other than both being nightly-only. This allows stabilizing intra-doc links without stabilizing missing_doc_code_examples.