summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2022-01-05Combine drain_filter callsAaron Hill-4/+4
2022-01-05Use SsoHashSetAaron Hill-2/+2
2022-01-05Deduplicate projection sub-obligationsAaron Hill-0/+6
2022-01-05Disable LLVM newPM by defaultSimonas Kazlauskas-8/+4
cc #91128
2022-01-05Revert "Set MACOSX_DEPLOYMENT_TARGET env var to default for linking if not set."Hans Kratz-15/+0
This reverts commit b376f5621b801460b911a75048a70698021bbc69, which is the main part of #90499, because it turns out that this causes a good amount of breakage in crates relying on the old behavior. Fixes #91372.
2022-01-05Fix HashStable implementation on InferTyMichael Goulet-0/+1
2021-11-29Don't treat unnormalized function arguments as well-formedjackh726-16/+3
2021-11-26Auto merge of #91253 - matthiaskrgr:rollup-dnlcjmr, r=matthiaskrgrbors-13/+17
Rollup of 4 pull requests Successful merges: - #91169 (Change cg_ssa's get_param to borrow the builder mutably) - #91176 (If the thread does not get the lock in the short term, yield the CPU) - #91212 (Fix ICE due to out-of-bounds statement index when reporting borrowck error) - #91225 (Fix invalid scrollbar display on source code page) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-26Rollup merge of #91212 - compiler-errors:issue91206, r=oli-obkMatthias Krüger-10/+14
Fix ICE due to out-of-bounds statement index when reporting borrowck error Replace an `[index]` with a `.get` when `statement_index` points to a basic-block terminator (and is therefore out-of-bounds in the statements list). Fixes #91206 Cc ``@camsteffen`` r? ``@oli-obk``
2021-11-26Rollup merge of #91169 - RDambrosio016:master, r=bjorn3Matthias Krüger-3/+3
Change cg_ssa's get_param to borrow the builder mutably This is a small change to make `get_param` more flexible for codegens that may need to modify things when retrieving function parameters. This will currently only be used by [rustc_codegen_nvvm](https://github.com/Rust-GPU/Rust-CUDA) (my own project), but may be useful to more codegens in the future. This is needed because cg_nvvm needs to remap certain types to libnvvm-friendly types, such as `i128` -> `<2 x i64>`. Because cg_ssa does not give mutable access to the builder, i resorted to using a mutex: ```rs fn get_param(&self, index: usize) -> Self::Value { let val = llvm::get_param(self.llfn(), index as c_uint); trace!("Get param `{:?}`", val); unsafe { let llfnty = LLVMRustGetFunctionType(self.llfn()); let map = self.remapped_integer_args.borrow(); if let Some((_, key)) = map.get(llfnty) { if let Some((_, new_ty)) = key.iter().find(|t| t.0 == index) { trace!("Casting irregular param {:?} to {:?}", val, new_ty); return transmute_llval( *self.llbuilder.lock().unwrap(), &self.cx, val, *new_ty, ); } } val } } ``` However, i predict this is pretty bad for performance, considering how much builders are called during codegen, so i would greatly appreciate having a more flexible API for this.
2021-11-26Auto merge of #91164 - Badel2:usefulness-stack-overflow, r=davidtwcobors-4/+7
Fix stack overflow in `usefulness.rs` Fix #88747 Applied the suggestion from `@nbdd0121,` not sure if this has any drawbacks. The first call to `ensure_sufficient_stack` is not needed to fix the test case, but I added it to be safe.
2021-11-26Auto merge of #91205 - Aaron1011:visit_param_env, r=lcnrbors-1/+2
Visit `param_env` field in Obligation's `TypeFoldable` impl This oversight appears to have gone unnoticed for a long time without causing issues, but it should still be fixed.
2021-11-26Auto merge of #85102 - estebank:point-at-assignment, r=oli-obkbors-21/+197
Diagnostic tweaks * On type mismatch caused by assignment, point at the source of the expectation * Hide redundant errors * Suggest `while let` when `let` is missing in some cases
2021-11-25Visit `param_env` field in Obligation's `TypeFoldable` implAaron Hill-1/+2
This oversight appears to have gone unnoticed for a long time without causing issues, but it should still be fixed.
2021-11-25Auto merge of #90580 - cjgillot:no-ee-upvar, r=Aaron1011bors-1/+0
Remove eval_always from upvars. Split off https://github.com/rust-lang/rust/pull/86056 r? `@ghost`
2021-11-25Account for type obligation coming from `const` and `static`Esteban Kuber-22/+46
2021-11-25On type mismatch caused by assignment, point at assigneeEsteban Küber-21/+173
* Do not emit unnecessary E0308 after E0070 * Show fewer errors on `while let` missing `let` * Hide redundant E0308 on `while let` missing `let` * Point at binding definition when possible on invalid assignment * do not point at closure twice * do not suggest `if let` for literals in lhs * account for parameter types
2021-11-25Fix issue 91206Michael Goulet-10/+14
2021-11-25Rollup merge of #91185 - camelid:rm-force-overflow-checks, r=wesleywiserMatthias Krüger-8/+1
Remove `-Z force-overflow-checks` It was replaced several years ago by the stable option `-C overflow-checks`. The goal was to delete the `-Z` flag once users had migrated [1]. Now that it's been several years, it makes sense to delete the old flag. See also the discussion on Zulip [2]. [1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097 [2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224 r? ```@wesleywiser``` cc ```@RalfJung```
2021-11-25Rollup merge of #91162 - RalfJung:miri-shift-truncation, r=oli-obkMatthias Krüger-1/+14
explain why CTFE/Miri perform truncation on shift offset Closes https://github.com/rust-lang/miri/issues/1920
2021-11-25Rollup merge of #91111 - cjgillot:hir-no-lower-attrs, r=michaelwoeristerMatthias Krüger-0/+9
Do not visit attributes in `ItemLowerer`. By default, AST visitors visit expressions that appear in key-value attributes. Those expressions should not be lowered to HIR, as they do not correspond to actually compiled code. Since an attribute cannot produce meaningful HIR, just skip them altogether. Fixes https://github.com/rust-lang/rust/issues/81886 Fixes https://github.com/rust-lang/rust/issues/90873 r? `@michaelwoerister`
2021-11-25Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebankMatthias Krüger-75/+282
Print associated types on opaque `impl Trait` types This PR generalizes #91021, printing associated types for all opaque `impl Trait` types instead of just special-casing for future. before: ``` error[E0271]: type mismatch resolving `<impl Iterator as Iterator>::Item == u32` ``` after: ``` error[E0271]: type mismatch resolving `<impl Iterator<Item = usize> as Iterator>::Item == u32` ``` --- Questions: 1. I'm kinda lost in binders hell with this one. Is all of the `rebind`ing necessary? 2. Is there a map collection type that will give me a stable iteration order? Doesn't seem like TraitRef is Ord, so I can't just sort later.. 3. I removed the logic that suppresses printing generator projection types. It creates outputs like this [gist](https://gist.github.com/compiler-errors/d6f12fb30079feb1ad1d5f1ab39a3a8d). Should I put that back? 4. I also added spaces between traits, `impl A+B` -> `impl A + B`. I quite like this change, but is there a good reason to keep it like that? r? ````@estebank````
2021-11-25Rollup merge of #90499 - rusticstuff:macos-target-fixes, r=petrochenkovMatthias Krüger-9/+30
Link with default MACOSX_DEPLOYMENT_TARGET if not otherwise specified. This PR sets the MACOSX_DEPLOYMENT_TARGET environment variable during the linking stage to our default, if it is not specified. This way it matches the deployment target we pass to llvm. If not set the the linker uses Xcode or Xcode commandline tools default which varies by version. Fixes #90342, #91082. Drive-by fixes to make Rust behave more like clang: * Default to 11.0 deployment target for ARM64 which is the earliest version that had support for it. * Set the llvm target to `arm64-apple-macosx<deployment target>` instead of `aarch64-apple-macosx<deployment target>`.
2021-11-25Rollup merge of #89359 - fee1-dead:const-it, r=oli-obkMatthias Krüger-11/+35
Various fixes for const_trait_impl A few problems I found while making `Iterator` easier to const-implement. 1. More generous `~const Drop` check. We check for nested fields with caller bounds. For example, an ADT type with fields of types `A`, `B`, `C`, check if all of them are either: - Bounded (`A: ~const Drop`, `B: Copy`) - Known to be able to destruct at compile time (`C = i32`, `struct C(i32)`, `C = some_fn`) 2. Don't treat trait functions marked with `#[default_method_body_is_const]` as stable const fns when checking `const_for` and `const_try` feature gates. I think anyone can review this, so no r? this time.
2021-11-25Auto merge of #88781 - estebank:emoji-idents, r=oli-obkbors-10/+72
Tokenize emoji as if they were valid identifiers In the lexer, consider emojis to be valid identifiers and reject them later to avoid knock down parse errors. Partially address #86102.
2021-11-25Set MACOSX_DEPLOYMENT_TARGET env var to default for linking if not set.Hans Kratz-0/+15
2021-11-25Set the default deployment target for Macos ARM64 to 11.0.Hans Kratz-6/+13
11.0 (Big Sur) is the first version which supports ARM64 so we use that as default.
2021-11-25The correct LLVM target for aarch64-apple-darwin is arm64-... (as with ios)Hans Kratz-3/+2
2021-11-25Auto merge of #85346 - estebank:issue-84946, r=nagisa,varkorbors-54/+175
Account for incorrect `impl Foo<const N: ty> {}` syntax Fix #84946
2021-11-25Do not visit attributes in `LateResolutionVisitor`.Camille GILLOT-0/+4
2021-11-24Tweak span and add more testsEsteban Kuber-5/+2
2021-11-24Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelidGuillaume Gomez-6/+15
Create rustdoc_internals feature gate As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag. This is pretty much what it would look like (needs to update the tests too). The tracking issue is https://github.com/rust-lang/rust/issues/90418. What do you think ``@rust-lang/rustdoc`` ?
2021-11-24Rollup merge of #90044 - rusticstuff:disable_arm_outline_atomics_for_musl, ↵Guillaume Gomez-5/+1
r=workingjubilee Restrict aarch64 outline atomics to glibc for now. The introduced dependency on `getauxval` causes linking problems with musl, making compiling any binaries for `aarch64-unknown-linux-musl` impossible without workarounds such as using lld or adding liblibc.rlib again to the linker invocation, see #89626. This is a workaround until libc>0.2.108 is merged.
2021-11-24Update error message for doc(keyword)Guillaume Gomez-1/+1
2021-11-24Create rustdoc_internals feature gateGuillaume Gomez-6/+15
2021-11-24Account for incorrect `impl Foo<const N: ty> {}` syntaxEsteban Küber-54/+178
Fix #84946
2021-11-24Remove `-Z force-overflow-checks`Noah Lev-8/+1
It was replaced several years ago by the stable option `-C overflow-checks`. The goal was to delete the `-Z` flag once users had migrated [1]. Now that it's been several years, it makes sense to delete the old flag. See also the discussion on Zulip [2]. [1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097 [2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224
2021-11-24Auto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasperbors-29/+278
Optimize live point computation This refactors the live-point computation to lower per-MIR-instruction costs by operating on a largely per-block level. This doesn't fundamentally change the number of operations necessary, but it greatly improves the practical performance by aggregating bit manipulation into ranges rather than single-bit; this scales much better with larger blocks. On the benchmark provided in #90445, with 100,000 array elements, walltime for a check build is improved from 143 seconds to 15. I consider the tiny losses here acceptable given the many small wins on real world benchmarks and large wins on stress tests. The new code scales much better, but on some subset of inputs the slightly higher constant overheads decrease performance somewhat. Overall though, this is expected to be a big win for pathological cases (as illustrated by the test case motivating this work) and largely not material for non-pathological cases. I consider the new code somewhat easier to follow, too.
2021-11-24Auto merge of #90579 - cjgillot:no-ee-ii, r=Aaron1011bors-5/+1
Remove eval_always for inherent_impls. Split off https://github.com/rust-lang/rust/pull/86056 r? `@ghost`
2021-11-24Add impl polarity to fieldsDeadbeef-26/+27
2021-11-24Allow features like const_try in d_m_b_i_cDeadbeef-0/+6
2021-11-24Allow more cases to match ~const Drop.Deadbeef-32/+48
2021-11-24DebugDeadbeef-4/+5
2021-11-23Feat: make cg_ssa get_param borrow the builder mutablerdambrosio-3/+3
2021-11-23document BinOp behavior quirks in the corresponding enumRalf Jung-0/+8
2021-11-23Auto merge of #91149 - notriddle:notriddle/rustdoc-doctest-semicolon, r=jyn514bors-1/+1
fix(doctest): detect extern crate items in statement doctests This partially reverts #91026, because rustdoc needs to detect the extern statements, even when they appear inside implicit `main()`. It does not entirely revert it, so the old bug is still fixed, by duplicating some of the logic from `parse_mod` instead of trying to use it directly. Fixes #91134
2021-11-23Fix stack overflow in `usefulness.rs`Badel2-4/+7
2021-11-23Do not visit attributes in `ItemLowerer`.Camille GILLOT-0/+5
By default, AST visitors visit expressions that appear in key-value attributes. Those expressions should not be lowered to HIR, as they do not correspond to actually compiled code. Since an attribute cannot produce meaningful HIR, just skip them altogether.
2021-11-23Auto merge of #91159 - matthiaskrgr:rollup-91mgg5v, r=matthiaskrgrbors-45/+85
Rollup of 6 pull requests Successful merges: - #90856 (Suggestion to wrap inner types using 'allocator_api' in tuple) - #91103 (Inhibit clicks on summary's children) - #91137 (Give people a single link they can click in the contributing guide) - #91140 (Split inline const to two feature gates and mark expression position inline const complete) - #91148 (Use `derive_default_enum` in the compiler) - #91153 (kernel_copy: avoid panic on unexpected OS error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-23Sort `FxHashSet`'s contents before emitting errors for consistent outputEsteban Kuber-1/+4