A set of useful proc macros for enums
A small utility for dealing with Segment.io KSUIDs
A parser for AVR's system description files (.atdf).
A bitset whose size is fixed at compile-time
ecstatic-morse/anglistic-sched 0
A scheduler for matching students to presentation time slots by preference
ecstatic-morse/blog.rust-lang.org 0
The Rust Programming Language Blog
The Rust package manager
ecstatic-morse/competitive-coding-demo 0
An example of a solution to a coding problem
ecstatic-morse/compiler-team 0
A home for compiler team planning documents, meeting minutes, and other such things.
home for proposals in and around compile-time function evaluation
pull request commentrust-lang/rust
Sorry for the delay @davidhewitt. I wasn't able to do any Rust stuff this week. r=me after a rebase (bors r=ecstatic-morse).
@bors delegate+ rollup
comment created time in 21 hours
pull request commentrust-lang/rust
Lint for unused borrows as part of `UNUSED_MUST_USE`
About 15000 new warnings in the ecosystem.
> rg 'unused borrow that must be used' | wc -l
14598
Many are in generated code:
> rg -A6 'unused borrow that must be used' | rg 'pin_project' | wc -l
4226
About a third are due to pin-project
rg -A6 'unused borrow that must be used' | rg '[A-Z]+::ptr\(\)' | wc -l
1941
At least an eighth from embedded-hal. For example:
&(*$GPIOX::ptr()).moder.modify(|r, w|
w.bits((r.bits() & !(0b11 << offset)) | (input << offset))
);
> rg -A6 'unused borrow that must be used' | rg 'PackedStruct' | wc -l
594
A few more are due to PackedStruct.
The rest are legitimate regressions, usually due to a misunderstanding of the
autoref rules. Most are benign but unnecessary (e.g. &mut foo.rotate()), and I think users would benefit from learning that their & annotations aren't doing what they think. This is especially true in the following case :smile:.
&vec1.push(0);
> rg -A6 'unused borrow that must be used' | rg '&(mut)?\s*\w+\[' | wc -l
1020
Putting & before calling a method on a slice seems to be pretty common. Presumably a bare slice looks strange to some users
slice[..].method()
> rg -A6 'unused borrow that must be used' | rg --case-sensitive '\.\.\w*\];' | wc -l
60
There's also a few cases where the &foo[..]; pattern appears, and these will need to use let _ = ... instead of simply removing the borrow.
comment created time in 4 days
pull request commentrust-lang/rust
@davidhewitt Did you search for other uses of -C panic=abort in the test suite? A quick grep indicates that it usually appears alongside // no-prefer-dynamic and does work in UI tests. You might try writing a no_std test if that doesn't work.
Also, there's no need for any of this to be a run-pass test, a cfg around something that won't compile is fine (e.g. fn fail() -> i32 {}). It's not terribly important, but I've been chastised recently for writing tests that aren't as efficient as they could be.
comment created time in 7 days
pull request commentrust-lang/rust
Reduce boilerplate with Option::{map, and_then} ...
High-five should work, although all the compiler crates were recently renamed which might have confused it. Might be good to verify with git blame from the command line, since I know that works through renaming.
comment created time in 7 days
pull request commentrust-lang/rust
Monomorphize `calculate_dtor` instead of using function pointers
Seems to be a very tiny win, only enough to matter on very small crates. Still, using a trait object here is saving like two monomorphizations, so I think a generic parameter is fine.
@bors rollup- @bors r+
comment created time in 7 days
pull request commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
that would've meant that TraitRef must be at least Clone since PolyTraitRef needs to get a copy at one point.
hir::TraitRef is trivially copyable. It's just a HirId and a reference to an interned Path.
As for mentoring, here are the steps I would take to resolve #60465:
- Make
hir::TraitRefunconstructable except by calling anewfunction thatspan_bugs when we get aPathpointing to something unexpected. This moves the panic from the point at which the getter is called to when the erroneoushir::TraitRefis constructed, where we should have a bit more information. - Change the
span_bugfor unexpectedPathvariants to adelay_span_bug, and make theErrvariant also adelay_span_bug.
Remember, most of #60465 has already been resolved. We just want to do a better job of encoding the invariants of hir::TraitRef in its API, and delay_span_bug when they are not met.
comment created time in 7 days
pull request commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
TBH, I wish this just went ahead and fixed #60465. This seems like a pretty weird intermediate point given the semantics of try_new and the fact that it is not exclusively the constructor of hir::TraitRef (this changed after I delegated initially). If you think this PR stands on its own @bugadani, I can sign off on it, but I think we could do a bit better here.
comment created time in 7 days
pull request commentrust-lang/rust
Reduce boilerplate with Option::{map, and_then} ...
I don't think this kind of PR, a bunch of loosely-related stylistic changes across the codebase, is very useful.
If this were fixing exactly one thing, like a clippy lint, I might feel differently, but code golfing with combinators and writing x == Variant instead of matches!(x, Variant) are not best practice AFAIK, they're just personal preference. It would be one thing if you were the person tasked with maintaining this code, but I don't think that's true, and the actual maintainers may have different taste.
You're free to split this up a bit and request a review from the original author of each module, but I'm not going to sign off on this.
comment created time in 7 days
push eventecstatic-morse/rust
commit sha da4cb6c650fe07566fbe20b6a0dde9de579e2e22
Define a `PassManager` for managing MIR passes
commit sha 5f985405905dbd2f224533a846a7fd1fd6b619dd
Declare `opt-level` for each MIR transformation
commit sha 5b46f91e3be343d0280ecdfbd1572ca9f5925980
`Validate` is not a MIR transformation In general, read-only passes should not be declared as a `MirPass`, since they always run and their MIR dump provides no additional information.
commit sha 51da28aeaf350969ece7938ad050c075c9e4f385
Add mechanism for skipping MIR passes
commit sha d32556481a4f64a0afbd94bef64490e3eace9068
Add missing flags for `mir-opt` tests of unsound passes These don't actually test anything since whoever implemented `-Zunsound-mir-opts` forgot to set it when unsound passes were checked. They break now that the passes are skipped entirely without `-Zunsound-mir-opts` instead of just being no-ops.
push time in 9 days
push eventecstatic-morse/rust
commit sha 5c76bccfc9af09e6ce9be0f24d89fcd3739c631b
Define a `PassManager` for managing MIR passes
commit sha 4f33bfb99e4f26b9420ead353e46cab92b1d8a47
Declare `opt-level` for each MIR transformation
commit sha 106ed7b62f48e6fed2c9c94faa9df283d27fa855
`Validate` is not a MIR transformation In general, read-only passes should not be declared as a `MirPass`, since they always run and their MIR dump provides no additional information.
commit sha e219bde99b3b6c6e8c55ee9811668d1ad72e12ab
Add mechanism for skipping MIR passes
commit sha 7a8729df580591473aac99627ec9185cae175153
Add missing flags for `mir-opt` tests of unsound passes These don't actually test anything since whoever implemented `-Zunsound-mir-opts` forgot to set it when unsound passes were checked. They break now that the passes are skipped entirely without `-Zunsound-mir-opts` instead of just being no-ops.
push time in 9 days
Pull request review commentrust-lang/rust
use rustc_middle::mir::{ use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt}; -#[derive(Copy, Clone, Debug)]-enum EdgeKind {- Unwind,- Normal,+pub fn validate_body(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, when: &str) {+ validate_body_during_phase(tcx, body, body.phase, when); } -pub struct Validator {- /// Describes at which point in the pipeline this validation is happening.- pub when: String,- /// The phase for which we are upholding the dialect. If the given phase forbids a specific- /// element, this validator will now emit errors if that specific element is encountered.- /// Note that phases that change the dialect cause all *following* phases to check the- /// invariants of the new dialect. A phase that changes dialects never checks the new invariants- /// itself.- pub mir_phase: MirPhase,-}+pub fn validate_body_during_phase(
I'm aware. It'll be useful later.
comment created time in 9 days
Pull request review commentrust-lang/rust
fn test_debugging_options_tracking_hash() { tracked!(link_only, true); tracked!(merge_functions, Some(MergeFunctions::Disabled)); tracked!(mir_emit_retag, true);+ tracked!(mir_opt_skip_pass, vec!["ConstProp".to_owned()]);
I definitely do not want this. See the comment above this block.
comment created time in 9 days
Pull request review commentrust-lang/rust
+use std::borrow::Cow;++use rustc_middle::mir::{Body, MirPhase};+use rustc_middle::ty::TyCtxt;++use super::{dump_mir, validate};++/// A streamlined trait that you can implement to create a pass; the+/// pass will be named after the type, and it will consist of a main+/// loop that goes over each available MIR and applies `run_pass`.+pub trait MirPass<'tcx> {+ const LEVEL: OptLevel;++ fn name(&self) -> Cow<'_, str> {+ let name = std::any::type_name::<Self>();+ name.rsplit(':').next().unwrap().into()+ }++ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>);+}++const UNSOUND_MIR_OPT_LEVEL: u8 = 2;++pub enum OptLevel {+ /// Passes that will run at `-Zmir-opt-level=N` or higher.+ N(u8),++ /// Passes that are known or suspected to cause miscompilations.+ ///+ /// These passes only run if `-Zunsound-mir-opts` is enabled and we are at `mir-opt-level=2` or+ /// above.+ Unsound,
For the record, one unsound MIR opt runs at opt-level 2 or above, the other runs at opt-level 1 or above. I also don't think this matters in practice, although I've switched to running unsound opts at opt-level 1 or above since it made blessing tests slightly easier.
comment created time in 9 days
Pull request review commentrust-lang/rust
+use std::borrow::Cow;++use rustc_middle::mir::{Body, MirPhase};+use rustc_middle::ty::TyCtxt;++use super::{dump_mir, validate};++/// A streamlined trait that you can implement to create a pass; the+/// pass will be named after the type, and it will consist of a main+/// loop that goes over each available MIR and applies `run_pass`.+pub trait MirPass<'tcx> {+ const LEVEL: OptLevel;++ fn name(&self) -> Cow<'_, str> {+ let name = std::any::type_name::<Self>();+ name.rsplit(':').next().unwrap().into()+ }++ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>);+}++const UNSOUND_MIR_OPT_LEVEL: u8 = 2;++pub enum OptLevel {+ /// Passes that will run at `-Zmir-opt-level=N` or higher.+ N(u8),++ /// Passes that are known or suspected to cause miscompilations.+ ///+ /// These passes only run if `-Zunsound-mir-opts` is enabled and we are at `mir-opt-level=2` or+ /// above.+ Unsound,++ /// Passes that clean up the MIR after other transformations.+ ///+ /// A `Cleanup` pass is skipped if the pass immediately preceding it is skipped.+ //+ // FIXME: Maybe we want to run the cleanup unless *all* passes between it and the last cleanup+ // were skipped?
Yeah, I don't really have a good solution for this. The status quo is equivalent to giving each instance of a cleanup pass a different LEVEL. I could do this with const-generics, or I could switch from an associated const to an instance method. The latter would make the MirPass trait object-safe again, meaning I could get rid of the run_passes macro, but I really like the declarative nature of associated constants.
comment created time in 9 days
Pull request review commentrust-lang/rust
+// compile-flags: -Zmir-opt-level=2 -Zunsound-mir-opts
I added a commit message explaining this. Basically, whoever implemented -Zunsound-mir-opts forgot to add the flag to MIR opt tests of unsound passes, so these no longer test anything: the pass is just a no-op. Now the pass doesn't even run without -Zunsound-mir-opts, so there's no MIR dump, meaning I have to fix this now.
comment created time in 9 days
push eventecstatic-morse/rust
commit sha 390a13b06c79d4177b829097b06453e38188081f
needless-lifetime - fix nested elision site FPs
commit sha a60e5de90c7370d4fb3e6561d3cb55495cda2e2a
needless-lifetime / nested elision sites / PR remarks
commit sha c8e9e52303da6dff4bc5cc4db3021d608fca6c70
needless-lifetime / add test cases for nested elision sites
commit sha 1778a1ec4615a42a8ba9497006b07859186c08a1
Restrict `same_item_push` to suppress false positives It emits a lint when the pushed item is a literal, a constant and an immutable binding that are initialized with those.
commit sha 0117ea2b016133145f9e02e27421ac3672b42f57
Refactoring: use inner function
commit sha b80576fba633e1fc214c9f6900d7ca3424bda6d0
Some refactoring
commit sha 14faebe20ea82392f393c3ff5efaab7250e51989
Add some tests to `same_item_push` Add tests in which the variable is initialized with a match expression and function call
commit sha 2972ad3ef661071531a61ec8999b668a6b734b74
Refactoring: tests in `same_item_push`
commit sha 730ca457f580247667ed0cd5965bc08752ebc0b3
Address `items_after_statement`
commit sha 72b402ed38f0c71461038aef8a49a02e49280788
Add pass names to some common dataflow analyses
commit sha dc655b28424549a4775bc2e8c9021d44482bccb1
Prevent stackoverflow
commit sha 5e393c7747d081c45414060f81016e9ea3cb961f
Fix a FP in `explicit_counter_loop` Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented, adjust the test so that counters are incremented at the end of the loop and add the test for this false positive.
commit sha 3e294b22a43be349262405715cf4885296c284ba
Revert "or_fn_call: ignore nullary associated const fns" This reverts commit 7a66e6502dc3c7085b3f4078c01d4957d96175ed.
commit sha ce83d8d4d1b28e73888a616d3ffbf19c6a620588
Revert "Avoid or_fun_call for const_fn with no args" This reverts commit 5d66bd7bb3fd701d70ec11217e3f89fabe5cb0a7.
commit sha 9365660a2fc57210996df733efe468019c671b2f
unnecessary sort by: avoid dereferencing closure param
commit sha d1f9cad102b5686f2b827f3c62a02dfe419128a6
Merge commit 'e636b88aa180e8cab9e28802aac90adbc984234d' into clippyup
commit sha 019c0d5f7f90f959ff92684a04b0d766b22527a5
Auto merge of #6076 - rail-rain:fix_fp_explicit_counter_loop, r=matthiaskrgr Fix a FP in `explicit_counter_loop` Fixes #4677 and #6074 Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented, adjust the test so that counters are incremented at the end of the loop and add the test for this false positive. --- changelog: Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented
commit sha cc1998f7b3cc04c891f92c62a52c0c45fa4c145a
Auto merge of #6077 - ebroto:revert_or_fun_call_const, r=matthiaskrgr Revert: or_fun_call should lint calls to `const fn`s with no args The changes in #5889 and #5984 were done under the incorrect assumption that a `const fn` with no args was guaranteed to be evaluated at compile time. A `const fn` is only guaranteed to be evaluated at compile time if it's inside a const context (the initializer of a `const` or a `static`). See this [zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Common.20misconception.3A.20.60const.20fn.60.20and.20its.20effect.20on.20codegen/near/208059113) for more details on this common misconception. Given that none of the linted methods by `or_fun_call` can be called in const contexts, the lint should make no exceptions. changelog: [`or_fun_call`] lints again calls to `const fn` with no args
commit sha 2892a2b0f578edd290b3be6f5e5c3280bc160f24
Fix FP in `print_stdout` This lint shouldn't be emitted in `build.rs` as `println!` and `print!` are used for the build script.
commit sha a8c60732786626928fe9dceb1ffe0775a2700969
Rollup merge of #76724 - ecstatic-morse:dataflow-pass-names, r=lcnr Allow a unique name to be assigned to dataflow graphviz output Previously, if the same analysis were invoked multiple times in a single compilation session, the graphviz output for later runs would overwrite that of previous runs. Allow callers to add a unique identifier to each run so this can be avoided.
push time in 9 days
Pull request review commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
impl<'hir> LoweringContext<'_, 'hir> { AnonymousLifetimeMode::CreateParameter, |this, _| { let trait_ref = trait_ref.as_ref().map(|trait_ref| {- this.lower_trait_ref(trait_ref, ImplTraitContext::disallowed())- });+ let trait_ref =+ this.lower_trait_ref(trait_ref, ImplTraitContext::disallowed()); - if let Some(ref trait_ref) = trait_ref { if let Res::Def(DefKind::Trait, def_id) = trait_ref.path.res { this.trait_impls .entry(def_id) .or_default() .push(lowered_trait_impl_id); }- }++ trait_ref+ });
Also, this should probably just be if let Some(def_id) = trait_ref.def_id(). Otherwise it skips trait impls. Not sure who to ping about this though, and it shouldn't be changed in this PR.
comment created time in 9 days
Pull request review commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
impl<'hir> LoweringContext<'_, 'hir> { AnonymousLifetimeMode::CreateParameter, |this, _| { let trait_ref = trait_ref.as_ref().map(|trait_ref| {- this.lower_trait_ref(trait_ref, ImplTraitContext::disallowed())- });+ let trait_ref =+ this.lower_trait_ref(trait_ref, ImplTraitContext::disallowed()); - if let Some(ref trait_ref) = trait_ref { if let Res::Def(DefKind::Trait, def_id) = trait_ref.path.res { this.trait_impls .entry(def_id) .or_default() .push(lowered_trait_impl_id); }- }++ trait_ref+ });
Actually, what is the point of this? There's no reason to change control flow here is there?
comment created time in 9 days
pull request commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
@bors delegate-
comment created time in 9 days
pull request commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
r=me with commits squashed and nits fixed.
@bors delegate+ rollup
comment created time in 9 days
Pull request review commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
pub struct TraitRef<'hir> { pub hir_ref_id: HirId, } -impl TraitRef<'_> {+impl TraitRef<'hir> {+ /// Tries to create a new `TraitRef` object from the given path and `HirId`. Returns `None`+ /// if the path resolved to something other than a trait or a trait alias.
You need to mention how this handles Res::Err, since it's a bit surprising.
comment created time in 9 days
Pull request review commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
impl<'a, 'hir> LoweringContext<'a, 'hir> { ) -> hir::TraitRef<'hir> { let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) { hir::QPath::Resolved(None, path) => path,- qpath => panic!("lower_trait_ref: unexpected QPath `{:?}`", qpath),+ qpath => self+ .sess+ .diagnostic()+ .span_bug(p.path.span, &format!("lower_trait_ref: unexpected QPath `{:?}`", qpath)), };- hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }++ hir::TraitRef::try_new(path, self.lower_node_id(p.ref_id)).unwrap_or_else(|| {+ // so if this path is hit, we have something unexpected
No need for this comment. It just repeats the span_bug message.
comment created time in 9 days
pull request commentrust-lang/rust
Recognize discriminant reads as no-ops in RemoveNoopLandingPads
Got it! You could add a name to RemoveNoopLandingPads like SimplifyCfg currently has, but that's not really your responsibility, and it doesn't need to block this. r=me when you're happy.
@bors delegate+
comment created time in 9 days
pull request commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
The basic idea of this PR is correct. We want to check that the QPath for a TraitRef actually resolves to a trait when it is constructed. However, I think we should do this in a way that doesn't break encapsulation and is more amenable to future refactoring (see comments).
comment created time in 9 days
Pull request review commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
pub enum UseKind { #[derive(Debug, HashStable_Generic)] pub struct TraitRef<'hir> { pub path: &'hir Path<'hir>,+ pub def_id: Option<DefId>, // Don't hash the `ref_id`. It is tracked via the thing it is used to access. #[stable_hasher(ignore)] pub hir_ref_id: HirId, } -impl TraitRef<'_> {- /// Gets the `DefId` of the referenced trait. It _must_ actually be a trait or trait alias.- pub fn trait_def_id(&self) -> Option<DefId> {- match self.path.res {- Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),- Res::Err => None,- _ => unreachable!(),- }- }-}-
Don't remove this. It breaks encapsulation.
comment created time in 9 days
Pull request review commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
pub enum UseKind { #[derive(Debug, HashStable_Generic)] pub struct TraitRef<'hir> { pub path: &'hir Path<'hir>,+ pub def_id: Option<DefId>,
There's no need to explicitly store the DefId. It's either a Res::Def of the appropriate kind or it's not. This should be an invariant of TraitRef, which you have done as part of HIR lowering, but should really be moved into a constructor for this type. At a later date, you could start treating unexpected Res variants as if they were Res::Err.
comment created time in 9 days
pull request commentrust-lang/rust
Recognize discriminant reads as no-ops in RemoveNoopLandingPads
LGTM, I'd like to see a MIR opt test in which these changes have an impact, although maybe this is more speculative? I'll check back in once perf results are up.
comment created time in 9 days
pull request commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
If you gave up on it, should it just be closed?
comment created time in 9 days
pull request commentrust-lang/rust
Refactor `TraitRef::trait_def_id`
@bugdani is this ready for review? I mute notifications on draft PRs to which I am assigned, so it's usually beneficial to ping the reviewer when you remove the draft status.
comment created time in 9 days
Pull request review commentrust-lang/rust
Recognize discriminant reads as no-ops in RemoveNoopLandingPads
impl RemoveNoopLandingPads { // These are all nops in a landing pad } - StatementKind::Assign(box (place, Rvalue::Use(_))) => {+ StatementKind::Assign(box (place, Rvalue::Use(_) | Rvalue::Discriminant(_))) => { if place.as_local().is_some() {
I wonder how common it is to have writes to unprojected locals that are not drop flags along the cleanup path? Seems like we could ignore these as well.
comment created time in 9 days
pull request commentrust-lang/rust
The input closure is called in a loop for each relevant impl and is trivial for at least one plausibly hot call (adt_destructor). It's possible that this will speed things up enough to matter.
@bors try @rust-timer queue
comment created time in 9 days
pull request commentrust-lang/rust
Add -Z codegen-backend dylib to deps
I was waiting for @Mark-Simulacrum to have a look, but this seems correct in the abstract.
@bors r+ rollup
comment created time in 9 days
issue commentrust-lang/rust
Must a `const fn` behave exactly the same at runtime as at compile-time?
Transcendental functions (e.g. trigonometry and non-integral exponentiation), can give different results between platforms. I don't think we can take a "hard-line" approach, since then functions like f32::tan that will take advantage of hardware support if it exists can never be const fn; Users would have to opt-in to a software emulated version (either in std or in the ecosystem). I view CTFE as just another platform on which floating point is supported. Users don't (or at least shouldn't) expect cross-platform consistency at runtime, why is CTFE any different?
Even trying to promise that the result given by CTFE is consistent between compiler versions would be foolish, since it would lock us into a particular software emulation strategy that may become outdated. I think we should guarantee that CTFE engine for a given compiler at a given optimization level is deterministic between runs and nothing more. I think we might already have this for NaN payloads, although it would be nice to have an actual set of rules for how they get handled instead of "whatever LLVM does".
comment created time in 10 days
Pull request review commentrust-lang/rust
fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> FxHashSet<LocalDefId> { set } -/// Generates a default name for the pass based on the name of the-/// type `T`.-pub fn default_name<T: ?Sized>() -> Cow<'static, str> {- let name = ::std::any::type_name::<T>();- if let Some(tail) = name.rfind(':') { Cow::from(&name[tail + 1..]) } else { Cow::from(name) }-}--/// A streamlined trait that you can implement to create a pass; the-/// pass will be named after the type, and it will consist of a main-/// loop that goes over each available MIR and applies `run_pass`.-pub trait MirPass<'tcx> {- fn name(&self) -> Cow<'_, str> {- default_name::<Self>()- }-- fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>);-}--pub fn run_passes(- tcx: TyCtxt<'tcx>,- body: &mut Body<'tcx>,- mir_phase: MirPhase,- passes: &[&[&dyn MirPass<'tcx>]],-) {- let phase_index = mir_phase.phase_index();- let validate = tcx.sess.opts.debugging_opts.validate_mir;-- if body.phase >= mir_phase {- return;- }-- if validate {- validate::Validator { when: format!("input to phase {:?}", mir_phase), mir_phase }- .run_pass(tcx, body);- }-- let mut index = 0;- let mut run_pass = |pass: &dyn MirPass<'tcx>| {- let run_hooks = |body: &_, index, is_after| {- dump_mir::on_mir_pass(- tcx,- &format_args!("{:03}-{:03}", phase_index, index),- &pass.name(),- body,- is_after,- );- };- run_hooks(body, index, false);- pass.run_pass(tcx, body);- run_hooks(body, index, true);-- if validate {- validate::Validator {- when: format!("after {} in phase {:?}", pass.name(), mir_phase),- mir_phase,- }- .run_pass(tcx, body);- }-- index += 1;- };-- for pass_group in passes {- for pass in *pass_group {- run_pass(*pass);- }- }-- body.phase = mir_phase;-- if mir_phase == MirPhase::Optimization {- validate::Validator { when: format!("end of phase {:?}", mir_phase), mir_phase }- .run_pass(tcx, body);- }
Good catch! This was accident on my part. Besides disabling unsound optimizations below MIR opt-level 2 and only running cleanup passes if we ran the preceding pass in the pipeline (both up for debate), this PR shouldn't have any functional changes.
comment created time in 12 days
push eventecstatic-morse/rust
commit sha 67142ed48bef72719c645e9acbd6edec58662227
Add mechanism for skipping MIR passes
push time in 12 days
issue commentrust-lang/rust
x.py breaks submodule state when run in a pre-commit hook from a worktree
I've had unset=GIT_DIR at the beginning of my pre-push hook for a while. This seems to work around the problem. No idea what the root cause is.
comment created time in 12 days
push eventecstatic-morse/rust
commit sha 203d27ca3c605ea306ad4a7780e5a5dac185291b
Add mechanism for skipping MIR passes
push time in 12 days
push eventecstatic-morse/rust
commit sha 1e353cec966385db69f18c81230c917de18b1092
Declare `opt-level` for each MIR transformation
commit sha e325b26b5822bf9b59bedc16d5e0be91cf40d69b
`Validate` is not a MIR transformation In general, read-only passes should not be declared as a `MirPass`, since they always run and their MIR dump provides no additional information.
commit sha 41beea065be45c14a21ccc680a2a3b0f01901d51
Add proper flags to mir-opt tests
commit sha 4cb0009bd66f320f0c8d5c1c936cc156d8de7b11
Add mechanism for skipping MIR passes
push time in 12 days
PR opened rust-lang/rust
A minor refactoring to transform/mod.rs. It moves MIR phase handling and optimization level/soundness checking into a single module. By using an RAII-style PassManager, we can interleave calls to run_passes with various lints/error-checking.
I'm not sure this is exactly the direction we want to go, but I really want some form of the declarative OptLevel in this PR.
cc #72515 @rust-lang/wg-mir-opt
r? @wesleywiser
pr created time in 12 days
push eventecstatic-morse/rust
commit sha b4b383981abac7ca8aa180c7ae3e28876615b887
Add PartialEq impls for Vec <-> slice
commit sha a009e2838b25df2761093d727d322a59f69d8f68
There isn't a way to pass --remove yet, but you can rm if u like
commit sha 492826ac144666c75d68bc0a0121453ecc08561f
Add a note about the panic behavior of math operations on time objects
commit sha a6ff925f8b5598a1f6d84964525baa1d4a08fd63
Reduce boilerplate with the matches! macro Replaces simple bool `match`es of the form match $expr { $pattern => true _ => false } and their inverse with invocations of the matches! macro.
commit sha 9ef68f53e1f882afb63f824a10ff33ccd2c4764b
resolve: improve "try using the enum's variant" This commit improves the "try using the enum's variant" suggestion: - Variants in suggestions would not result in more errors (e.g. use of a struct variant is only suggested if the suggestion can trivially construct that variant). Therefore, suggestions are only emitted for variants that have no fields (since the suggestion can't know what value fields would have). - Suggestions include the syntax for constructing the variant. If a struct or tuple variant is suggested, then it is constructed in the suggestion - unless in pattern-matching or when arguments are already provided. - A help message is added which mentions the variants which are no longer suggested. Signed-off-by: David Wood <[email protected]>
commit sha e6027a42e109fef10f4fc27ebede50d1b3d203f0
Add `unclosed_html_tags` lint
commit sha 5fcbf4668ecab0ff798ea076757e27760c90aff5
Add doc for invalid_html_tag lint
commit sha bc6ec6fe36c5c902da900fea67cba30fad4b0b6b
Add test for unclosed_html_tag lint
commit sha 6271a0a46dedd5eaf3eb26afb6ae536939496cd7
Improve invalid_html_tags lint span
commit sha f9a65afb27e0093b56053f810952efcba3e718e5
Make invalid_html_tags lint only run on nightly and being allowed by default
commit sha 4a3746e67b06bfd3bd11c8cae1c3acab944211bf
Fix visitor for invalid_html_tag lint
commit sha 6163d892248a2af02b36a0121bb5bf02a5566d2b
Improve code
commit sha b2321bb8da18c753fe3b9b71937a368ae42b8c4b
Add test for invalid_html_tag lint in deny(rustdoc)
commit sha 30cabfd215f374b855f6d6473b00a55c3511c3e2
Don't warn if the tag is nested inside a <script> or inside a <style>
commit sha 5bc148957efc0bf4640d3d6b3e1824c00f1156e8
Correctly handle unicode characters and tags being open just before the end of the doc comment
commit sha ca199b16e5c06c28b3d35de79ffaaff81bd0d43f
Use char_indices() instead of chars() to prevent more than one-byte characters issue
commit sha d3b7b7e23a58e772194677b54672ff118ecc9093
Enforce closing HTML tags to have a ">" character
commit sha b4e77d21bcf8b15ef7d873005382ba8ca309faf5
rewrite old test so that its attributes are consistent with what we want in the language. (Note that the fact this test existed is a slight sign that we may need a crater run on this bugfix...)
commit sha 9601724b11bbd9081b1bee6f7e478a5d2b9ace41
Avoid unchecked casts in net parser
commit sha f78a7ade61c1c218eead76854abb7d83bb6c6f75
Inline "eof" methods
push time in 12 days
push eventecstatic-morse/rust
commit sha 66fd5d6d834ca0de02bf54a6384149ca50c26351
Define a `PassManager` for managing MIR passes
commit sha ae706214c0fe53141e1e00c1ac5cdca56c370cb6
Declare `opt-level` for each MIR transformation
commit sha e13d4656bd201628912894309f3377dfe182a0fd
`Validate` is not a MIR transformation In general, read-only passes should not be declared as a `MirPass`, since they always run and their MIR dump provides no additional information.
commit sha 8c97e5c085a0e7a2398ea0a7c101d4683b9345c9
Add proper flags to mir-opt tests
commit sha 113a3133a793e4c25fc0d01852b6bd8c50c0a156
Add mechanism for skipping MIR passes
push time in 12 days
pull request commentrust-lang/rust
Revert implementing `Iterator::nth[_back]` in terms of `advance_by[_back]`
@bors try @rust-timer queue
comment created time in 12 days
pull request commentrust-lang/rust
@davidhewitt Did you see https://github.com/rust-lang/rust/pull/74754#issuecomment-669563246? https://github.com/rust-lang/rust/pull/74754#issuecomment-665794892 is still relevant I think. Also, you have accidentally included submodule changes. Ping me when those two things are resolved.
comment created time in 12 days
pull request commentrust-lang/rust
Give `impl Trait` in a `const fn` its own feature gate
@bors r=oli-obk rollup
comment created time in 13 days
pull request commentrust-lang/rust
Implement advance_by, advance_back_by for slice::{Iter, IterMut}
@bors try @rust-timer queue
comment created time in 13 days
Pull request review commentrust-lang/rust
Implement const expressions and patterns (RFC 2920)
impl<'a> Parser<'a> { }) } else if self.eat_keyword(kw::Unsafe) { self.parse_block_expr(None, lo, BlockCheckMode::Unsafe(ast::UserProvided), attrs)+ } else if self.eat_keyword(kw::Const) {+ self.parse_const_expr(lo.to(self.token.span))
There's a comment at the top of this if/else chain that says: Note: when adding new syntax here, don't forget to adjust TokenKind::can_begin_expr()". Did you do that?
comment created time in 13 days
Pull request review commentrust-lang/rust
Implement const expressions and patterns (RFC 2920)
impl<'a> Parser<'a> { let pat = self.parse_pat_with_range_pat(false, None)?; self.sess.gated_spans.gate(sym::box_patterns, lo.to(self.prev_token.span)); PatKind::Box(pat)+ } else if self.eat_keyword(kw::Const) {
This comment is still relevant. The reason you're not preserving the more informative error is that you unconditionally start parsing an inline const pattern after seeing const. If this eat_keyword succeeds, you should check for the presence of { and fall back to the old code path (maybe can_be_ident_pat, maybe something else) if it is absent.
comment created time in 13 days
PR closed rust-lang/rust
r? @ghost
pr closed time in 13 days
pull request commentrust-lang/rust
Add Iterator::advance_by and DoubleEndedIterator::advance_back_by
Ah, didn't even notice the trait object aspect of that benchmark. I'm more concerned about the small regression elsewhere, but perhaps it's a similar issue. I think it's worth doing a perf run with the changes to nth reverted.
comment created time in 13 days
pull request commentrust-lang/rust
Lint for unused borrows as part of `UNUSED_MUST_USE`
@scottmcm, do you have a plan for triaging the crater results? I've never done one for warnings, but I suspect the usual approach is to run with -D the_lint. However, this currently folded into unused_must_use, and I suspect denying this will significantly reduce the corpus.
comment created time in 13 days
push eventecstatic-morse/rust
commit sha b5693a39d9d7d1b5404c188899bf7d983c79dfe3
Update error code page
push time in 13 days
push eventecstatic-morse/this-week-in-rust
commit sha 9e44dd8addebc52cc7fe9dcae8a18b129dd38861
Perf triage 2020-10-05
push time in 13 days
pull request commentrust-lang/rust
Confirmed caused by #76909.
comment created time in 13 days
pull request commentrust-lang/rust
Add Iterator::advance_by and DoubleEndedIterator::advance_back_by
@timvermeulen The rollup containing this PR caused a large regression in instruction counts in the deeply-nested benchmark (a stress-test for iterator chaining). It also caused a small instruction count increase across all other benchmarks. #77594 has not fixed this.
Reverting the changes to nth and nth_back should fix this. @timvermeulen could you give this a try? @Amanieu, consider marking PRs that change widely used iterator methods as rollup=never in the future, or schedule a perf run pre-emptively.
comment created time in 13 days
pull request commentrust-lang/rust
Implement advance_by, advance_back_by for iter::Chain
@bors rollup=never
comment created time in 13 days
push eventecstatic-morse/rust
commit sha c4ef5fdf8f79af3354df5a43c43501b1f03997d5
Remove `fn` from feature name
commit sha 9beb6f81e4112eccf9965d46421a1da351b0593a
Make `impl Trait` unstable in all contexts
commit sha 5cdd1448702fa830d8f59d34a3aa6c4376738e84
Update error code page
push time in 13 days
push eventecstatic-morse/rust
commit sha 7e9e4ce9fb1cac147ccdbffd1cb35a3ee0618f89
Make `impl Trait` unstable in all contexts
push time in 13 days
push eventecstatic-morse/rust
commit sha a313abe3ba989ba4b6c041627c903488886f8559
Manually implement Debug for BTreeMap::{IntoKeys,IntoValues} structs
commit sha 456738e3d1ad7dadffaed287d3055ca38b5fa375
Only print values in the Debug of HashMap::ValuesMut struct
commit sha c346e89db8a57e15111daa35685a2542d3be7c77
Manually implement Debug for BTreeMap::ValuesMut struct Deriving debug prints all the values including keys. But ValuesMut struct should only print the values.
commit sha 8faf550e5f7211188bc9560ae459c155fb1aafdf
Remove the unused bounds from Debug impl of HashMap::{IntoKeys,IntoValues}
commit sha 8894b366fdb976a703fe76010f6e56c591cada1f
Remove error message in specific case In the case that a trait is not implemented for an ADT with type errors, cancel the error.
commit sha 728938346b02a9688c44253c19b15baa7551fd80
Adjust rc::Weak::from_raw to support unsized T
commit sha 0c61ce2cf0560577923abafab2e5bfce14516525
?Sized bounds for rc::Weak::as_ptr and friends
commit sha 5e7406c9569dce75a042ce079918cf03cfca842a
Adjust sync::Weak::from_raw to support unsized T
commit sha 9d9903c5a50bb1f5b5fc3045b86172279eff7d30
Allow Weak::as_ptr and friends for unsized T
commit sha 3d07108d3600dff50e564f57dd390337dbe14d55
Add tests for weak into/from raw
commit sha 247b73939a619ea4dcb2affbe1c285d20d93a0b8
Move Wrapping<T> ui tests into library
commit sha 797cb9526a627c37b9bb9f6be6d3b54789b67c26
Fix to libstd test
commit sha ac96f5b39ca7d9fad8571595c476c2db0bce8438
Test and reject out-of-bounds shuffle vectors
commit sha 3c582db8cb43dac1d13dd653078a68753d4baa99
Implement as_ne_bytes for floats and integers
commit sha 8a011b5da2cc289fb7d970492ea4111980676412
minor doc changes, attribute orderings
commit sha 980e1ff40f51b6b4b86ee70809d0a0055e6f9cc6
Add missing examples for Fd traits
commit sha 5c224a484dc6ba2a70c9cd0d73a04849f6d7aa68
MiniSet/MiniMap moved and renamed into SsoHashSet/SsoHashMap It is a more descriptive name and with upcoming changes there will be nothing "mini" about them.
commit sha 0600b178aa0e9f310067bf8ccaf736e77a03eb1d
SsoHashSet/SsoHashMap API greatly expanded Now both provide almost complete API of their non-SSO counterparts.
commit sha 41942fac7d0711c6b3d0faa69748e22c0eb41388
SsoHashSet reimplemented as a wrapper on top of SsoHashMap SsoHashSet::replace had to be removed because it requires missing API from SsoHashMap. It's not a widely used function, so I think it's ok to omit it for now. EitherIter moved into its own file. Also sprinkled code with #[inline] attributes where appropriate.
commit sha 07fd17f7014de6dc209c7dc4de159a2a5acea173
Only use LOCAL_{STDOUT,STDERR} when set_{print/panic} is used. The thread local LOCAL_STDOUT and LOCAL_STDERR are only used by the test crate to capture output from tests when running them in the same process in differen threads. However, every program will check these variables on every print, even outside of testing. This involves allocating a thread local key, and registering a thread local destructor. This can be somewhat expensive. This change keeps a global flag (LOCAL_STREAMS) which will be set to true when either of these local streams is used. (So, effectively only in test and benchmark runs.) When this flag is off, these thread locals are not even looked at and therefore will not be initialized on the first output on every thread, which also means no thread local destructors will be registered.
push time in 13 days
pull request commentrust-lang/rust
This rollup caused a very large regression in instruction counts on full builds of deeply-nested, a stress test of iterator chaining.
Investigating in #77601
comment created time in 14 days
pull request commentrust-lang/rust
Hint the maximum length permitted by invariant of slices
@lzutao We have an automated script for detecting these kinds of regressions and run it weekly as part of perf-triage. That usually happens on a Monday. Also, there's no max-rss regression here: things were flat this week. max-rss is too unstable to make inferences about with only two data points.
comment created time in 14 days
pull request commentrust-lang/rust
Optimize `IntRange::from_pat`, then shrink `ParamEnv`
Final perf results are in. Looks to be an improvement everywhere except unicode-normaliaztion and the match stress test, as expected.
comment created time in 14 days
pull request commentrust-lang/rust
Hint the maximum length permitted by invariant of slices
Final perf results are in. This seemed to cause a slowdown across the board with the exception of some synthetic benchmarks. Except for the aforementioned stress test, check builds are not improved or a bit slower.
The case in the mir-opt test doesn't seem like it would occur very often in real code, and LLVM seems to explicitly recommend against doing this, so I think it's pretty clear we should revert this.
comment created time in 14 days
pull request commentrust-lang/rust
Re-land PR #71840 (Rework MIR drop tree lowering)
Final perf results are in. Looks like a small win across the board, with one exception. Thanks all!
comment created time in 14 days
pull request commentrust-lang/rust
Revert "Add advance_by and advance_back_by"
@bors try @rust-timer queue
comment created time in 14 days
delete branch ecstatic-morse/rust
delete branch : unified-dataflow-generators
delete time in 14 days
delete branch ecstatic-morse/rust
delete branch : split-promotion-and-validation
delete time in 14 days