lcnr/crow 94
A simple pixel perfect 2D rendering engine
lcnr/akari 35
A showcase game for the crow rendering engine
"Only One"
A simple computer made from scratch
Efficient type based integers
Data-oriented and data-driven game engine written in Rust
The repository for arewegameyet.rs
A list of rust lang mentors tagged by topics of interest
pull request commentrust-lang/rust
Fixed build failure of `rustfmt`
@bors r+ rollup
comment created time in 2 hours
pull request commentrust-lang/rust
Use `DroplessArena` where we know the type doesn't need drop
might influence perf
@bors try @rust-timer queue
comment created time in 2 hours
pull request commentrust-lang/rust
Fixed build failure of `rustfmt`
While it would be nice to get an MVCE here, I think it's fine to merge this as is. @bishtpawan did you test if this is the only ICE when compiling rustfmt? If so, r=me
comment created time in 2 hours
pull request commentrust-lang/rust
Eliminate some temporary vectors
@bors try @rust-timer queue
comment created time in 12 hours
Pull request review commentrust-lang/rust
Eliminate some temporary vectors
struct FulfillProcessor<'a, 'b, 'tcx> { register_region_obligations: bool, } -fn mk_pending(os: Vec<PredicateObligation<'tcx>>) -> Vec<PendingPredicateObligation<'tcx>> {+fn mk_pending(os: &[PredicateObligation<'tcx>]) -> Vec<PendingPredicateObligation<'tcx>> {
hmm, I personally think that this is fine, we can always change it to be generic once we need to :thinking:
But I also don't think using impl IntoIterator is a big problem here so :shrug:
comment created time in 12 hours
issue commentrust-lang/rust
Increasingly slow compilation as more levels of `async` are added in Rust 1.46
To revert this we would have to revert #75443 as that PR caused the perf regression. That PR however is the right thing to do so I don't want to revert that, especially because there is a fairly clean way to fix this.
IMO the way forward here is to do something like #76928 for other affected code paths. I don't have a lot of time at the moment so I don't feel like I have the capacity to look into this without having a self-contained MCVE for the remaining problem.
comment created time in 14 hours
pull request commentrust-lang/rust
Eliminate some temporary vectors
I guess it depends (it always does), but heap allocations are insanely fast nowadays, so unless it happens very frequently it shouldn't matter.
An interesting example here might be #72776 where using a SmallVec quite noticeably worsened perf because SmallVecs indexing is slightly slower than indexing a Vec.
comment created time in 14 hours
pull request commentrust-lang/rust
Fixed build failure of `rustfmt`
requires ./x.py fmt.
r? @lcnr
comment created time in 15 hours
Pull request review commentrust-lang/rust
Eliminate some temporary vectors
impl<K: DepKind> DepGraph<K> { pub fn query(&self) -> DepGraphQuery<K> { let data = self.data.as_ref().unwrap().current.data.lock(); let nodes: Vec<_> = data.iter().map(|n| n.node).collect();- let mut edges = Vec::new();+ let n_edges = data.iter().map(|d| d.edges.len()).sum::<usize>();+ let mut edges = Vec::with_capacity(n_edges);
I personally think that changes like this make the code less readable and therefore should only be applied if they result in a - hopefully noticable - perf benefit.
comment created time in 16 hours
Pull request review commentrust-lang/rust
Eliminate some temporary vectors
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id()); // Keep only those bounds which may apply, and propagate overflow if it occurs.- let mut param_candidates = vec![];+ let mut param_candidates: SmallVec<[_; 2]> = SmallVec::new();
existing issue, but why are we even using a separate vec here instead of using
for bound in matching_bounds {
let wc = self.evaluate_where_clause(stack, bound)?;
if wc.may_apply() {
candidates.vec.push(ParamCandidate(bound));
}
}
comment created time in 15 hours
Pull request review commentrust-lang/rust
Eliminate some temporary vectors
impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> { | ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateAtom::ConstEquate(..) => { let pred = infcx.replace_bound_vars_with_placeholders(binder);- ProcessResult::Changed(mk_pending(vec![- obligation.with(pred.to_predicate(self.selcx.tcx())),- ]))+ let v: SmallVec<[_; 1]> =+ smallvec![obligation.with(pred.to_predicate(self.selcx.tcx()))];+ ProcessResult::Changed(mk_pending(v))
ProcessResult::Changed(mk_pending(
[obligation.with(pred.to_predicate(self.selcx.tcx()))].iter().copied()
))
I also think that using a vec here is fine, I don't think that this code is hot enough for this to matter and adding a generic parameter to mk_pending probably increases the emitted llvmir which does not seem like a positive trade to me.
comment created time in 15 hours
Pull request review commentrust-lang/rust
Eliminate some temporary vectors
tracing = "0.1" rustc_span = { path = "../rustc_span" } rustc_ast = { path = "../rustc_ast" } rustc_target = { path = "../rustc_target" }+smallvec = { version = "1.0" }
smallvec = { version = "1" }
The newest version is 1.4.2 and we should try to use the same version for the whole compiler
comment created time in 16 hours
Pull request review commentrust-lang/rust
Eliminate some temporary vectors
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id()); // Keep only those bounds which may apply, and propagate overflow if it occurs.- let mut param_candidates = vec![];+ let mut param_candidates: SmallVec<[_; 2]> = SmallVec::new();
why are we even using a separate vec here instead of using
for bound in matching_bounds {
let wc = self.evaluate_where_clause(stack, bound)?;
if wc.may_apply() {
candidates.vec.push(ParamCandidate(bound));
}
}
comment created time in 15 hours
pull request commentrust-lang/rust
always try inlining functions which do not call other functions
@bors try @rust-timer queue exclude=deeply-nested
updated metadata encoding to only use 1 byte
comment created time in 18 hours
pull request commentrust-lang/rust
Assert that locals have storage when used
LGTM
r? @jonas-schievink for a final review, am not too familiar with this
comment created time in 18 hours
push eventlcnr/rust
commit sha 05c9c0ee5dcd935f518db151bee2dc88380fb92f
Modify executable checking to be more universal This uses a dummy file to check if the filesystem being used supports the executable bit in general.
commit sha 1ff7da6551a7cdf6ace2a9d00e92bbab550334ee
Move `slice::check_range` to `RangeBounds`
commit sha 1095dcab96d524e700b11edf366d45a0fd173fa0
Fix links
commit sha eb63168e007058dad4af758faf1dca449c049777
Fix doctests
commit sha f055b0bb0847ecf08fe452a270faae8324b55b05
Rename method to `assert_len`
commit sha 549f861f7d53811521cf929cf58fb6828a2a88d9
Use correct article in help message for conversion or cast Before it always used `an`; now it uses the correct article for the type.
commit sha 094f14c554c3a1f103a5d6778d4b4e131c297f11
Add article after "to" Also added missing backtick in "you can cast" message.
commit sha 8a6831a7fd3fc624643b50f494212e0ceaad3c28
Say "doesn't" instead of "wouldn't" in convert message
commit sha 8fe61546696b626ecf68ef838d5d82e393719e80
Use posix_spawn() on unix if program is a path Previously `Command::spawn` would fall back to the non-posix_spawn based implementation if the `PATH` environment variable was possibly changed. On systems with a modern (g)libc `posix_spawn()` can be significantly faster. If program is a path itself the `PATH` environment variable is not used for the lookup and it should be safe to use the `posix_spawnp()` method. [1] We found this, because we have a cli application that effectively runs a lot of subprocesses. It would sometimes noticeably hang while printing output. Profiling showed that the process was spending the majority of time in the kernel's `copy_page_range` function while spawning subprocesses. During this time the process is completely blocked from running, explaining why users were reporting the cli app hanging. Through this we discovered that `std::process::Command` has a fast and slow path for process execution. The fast path is backed by `posix_spawnp()` and the slow path by fork/exec syscalls being called explicitly. Using fork for process creation is supposed to be fast, but it slows down as your process uses more memory. It's not because the kernel copies the actual memory from the parent, but it does need to copy the references to it (see `copy_page_range` above!). We ended up using the slow path, because the command spawn implementation in falls back to the slow path if it suspects the PATH environment variable was changed. Here is a smallish program demonstrating the slowdown before this code change: ``` use std::process::Command; use std::time::Instant; fn main() { let mut args = std::env::args().skip(1); if let Some(size) = args.next() { // Allocate some memory let _xs: Vec<_> = std::iter::repeat(0) .take(size.parse().expect("valid number")) .collect(); let mut command = Command::new("/bin/sh"); command .arg("-c") .arg("echo hello"); if args.next().is_some() { println!("Overriding PATH"); command.env("PATH", std::env::var("PATH").expect("PATH env var")); } let now = Instant::now(); let child = command .spawn() .expect("failed to execute process"); println!("Spawn took: {:?}", now.elapsed()); let output = child.wait_with_output().expect("failed to wait on process"); println!("Output: {:?}", output); } else { eprintln!("Usage: prog [size]"); std::process::exit(1); } () } ``` Running it and passing different amounts of elements to use to allocate memory shows that the time taken for `spawn()` can differ quite significantly. In latter case the `posix_spawnp()` implementation is 30x faster: ``` $ cargo run --release 10000000 ... Spawn took: 324.275µs hello $ cargo run --release 10000000 changepath ... Overriding PATH Spawn took: 2.346809ms hello $ cargo run --release 100000000 ... Spawn took: 387.842µs hello $ cargo run --release 100000000 changepath ... Overriding PATH Spawn took: 13.434677ms hello ``` [1]: https://github.com/bminor/glibc/blob/5f72f9800b250410cad3abfeeb09469ef12b2438/posix/execvpe.c#L81
commit sha 9c302f55bd07a04305dfa2bd815d2559deb8468f
normalize in codegen_fulfill_obligations
commit sha f0487cee7439f3a4b4c7daec0e7f2a0ccc21053c
normalize substs during inlining
commit sha 32739a2ff1b7b6e5c1b475341b01f4a499830a84
add regression test
commit sha ac893b8a02788eec6f6fad0cc89de0177b0c0a50
add test for should_inline incorrect param_env
commit sha 4b96049da2329ba6e9a7fd4cd8224417fb4baede
BTreeMap: refactor Entry out of map.rs into its own file btree/map.rs is approaching the 3000 line mark, splitting out the entry code buys about 500 lines of headroom
commit sha 2ce11afbec1dc1279360063fee0135a09b7fc11b
Use double quote for rustdoc html
commit sha dd5c9bf1392bdc697740e62a1924b7942cdfd86a
Use map_bound(_ref) instead of Binder::bind when possible
commit sha 11d62aa2849b48b850c412cc7ce20d8a60a74ab8
Review comments
commit sha 3c4ad5508242bd560d095f1380bb8d739a0cbba2
Add inline_const feature flag
commit sha c3e8d7965ccef7fe47db591ae0064af0034e3f25
Parse inline const expressions
commit sha 59d07c3ae5a1f53924c7580fa302c397c362f1a2
Parse inline const patterns
push time in 18 hours
issue commentrust-lang/rust
`rustfmt` no longer builds after rust-lang/rust#77306
So I think that the easiest fix is to add tcx.normalize_erasing_regions(param_env, substs) before this call. https://github.com/rust-lang/rust/blob/9832374f6e378971e1a933362cf9781b121bb845/compiler/rustc_mir_build/src/lints.rs#L74-L80
I am however surprised that func.ty(body, tcx) isn't actually normalized here. cc @eddyb @nikomatsakis do we want to instead normalize this in mir building?
comment created time in 18 hours
issue commentrust-lang/rust
`rustfmt` no longer builds after rust-lang/rust#77306
Can you post the resulting backtrace using RUST_BACKTRACE=1?
comment created time in 19 hours
issue openedrust-lang/compiler-team
TypeVisitor: use ops::ControlFlow instead of bool
Proposal
change the visit methods of TypeFoldable and TypeVisitor to use std::ops::ControlFlow<(), ()> instead of bool. In the future we may change the used type to std::ops::ControlFlow<(), Self::BreakTy> but this is not part of this MCP for now.
This makes it more intuitive and means that we can stop adding comments like false // keep visiting, for example in https://github.com/rust-lang/rust/blob/9832374f6e378971e1a933362cf9781b121bb845/compiler/rustc_trait_selection/src/opaque_types.rs#L696.
Mentors or Reviewers
If you have a reviewer or mentor in mind for this work, mention then here. You can put your own name here if you are planning to mentor the work.
Process
The main points of the Major Change Process is as follows:
- [x] File an issue describing the proposal.
- [ ] A compiler team member or contributor who is knowledgeable in the area can second by writing
@rustbot second.- Finding a "second" suffices for internal changes. If however you are proposing a new public-facing feature, such as a
-C flag, then full team check-off is required. - Compiler team members can initiate a check-off via
@rfcbot fcp mergeon either the MCP or the PR.
- Finding a "second" suffices for internal changes. If however you are proposing a new public-facing feature, such as a
- [ ] Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.
You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
created time in 20 hours
pull request commentrust-lang/rust
Add some MIR-related regression tests
thanks
@bors r+ rollup
comment created time in a day
issue closedrust-lang/rust
Odd inference error reporting around generics
I made a MRE of a bug I encountered (in someone else's code actually):
struct S<T> {
_t: std::marker::PhantomData<T>
}
impl<T> S<T> {
fn f<U: ?Sized>(k: &U) where
T: std::borrow::Borrow<U> {}
}
fn main() {
let _ = |_: String| {};
S::<String>::f("".as_ref());
}
I expected to see this happen: A compile error mentioning something about not being able to infer the type that as_ref should return, I suppose.
Instead, this happened:
error[E0283]: type annotations needed
--> src/main.rs:12:5
|
6 | / fn f<U: ?Sized>(k: &U) where
7 | | T: std::borrow::Borrow<U> {}
| |________________________________- required by `S::<T>::f`
...
12 | S::<String>::f("".as_ref());
| ^^^^^^^^^^^^^^ cannot infer type for struct `std::string::String`
|
= note: cannot satisfy `std::string::String: std::borrow::Borrow<_>`
error: aborting due to previous error
Meta
Tested on playground, using stable, beta, and nightly (same error for all):
1.45.2
1.46.0-beta.4
1.47.0-nightly (2020-08-10 770bd3d1d03f0de2e27b)
Interesting variation:
struct S<T> {
_t: std::marker::PhantomData<T>
}
impl<T> S<T> {
fn f<U: ?Sized>(k: &U) where
T: std::borrow::Borrow<U> {}
}
fn main() {
S::<String>::f("".as_ref());
}
Which instead yields:
error[E0283]: type annotations needed
--> src/main.rs:11:5
|
6 | / fn f<U: ?Sized>(k: &U) where
7 | | T: std::borrow::Borrow<U> {}
| |________________________________- required by `S::<T>::f`
...
11 | S::<String>::f("".as_ref());
| ^^^^^^^^^^^^^^ cannot infer type for struct `std::string::String`
|
= note: cannot satisfy `std::string::String: std::borrow::Borrow<_>`
error: aborting due to previous error
(which is just a poor error, I think)
closed time in a day
izik1issue commentrust-lang/rust
Odd inference error reporting around generics
The error message has been fixed by #78111 and now is
error[E0283]: type annotations needed
--> src/main.rs:12:5
|
6 | / fn f<U: ?Sized>(k: &U) where
7 | | T: std::borrow::Borrow<U> {}
| |_____________________________- required by `S::<T>::f`
...
12 | S::<String>::f("".as_ref());
| ^^^^^^^^^^^^^^ ----------- this method call resolves to `&T`
| |
| cannot infer type for type parameter `U` declared on the associated function `f`
|
= note: cannot satisfy `String: Borrow<_>`
As we already added a very similar test in that PR I am closing this as is without adding an additional test for it.
Thanks for opening this issue.
comment created time in a day
issue commentrust-lang/rust
type annotation warning involving completely unrelated scopes
This should have been fixed by #78111, marking as E-needs-test.
comment created time in a day
issue commentrust-lang/rust
Bad error message when closure parameter type can't be inferred
The error message should have been fixed by #78111, marking as E-needs-test.
comment created time in a day
pull request commentrust-lang/rust
Trait predicate ambiguities are not always in `Self`
will mark these issues as E-needs-test and close #75398
comment created time in a day
pull request commentrust-lang/rust
Trait predicate ambiguities are not always in `Self`
Hmm, also not sure about that. I think #72616, #71732 are useful as additional tests but we probably can just close #75398 as is
comment created time in a day
pull request commentrust-lang/rust
Don't run `resolve_vars_if_possible` in `normalize_erasing_regions`
I don't expect the result to be free to inference variables, I expect the result to be free of Known inference variables.
My personal expectation is that this should be an invariant and believe that this is already the case, even if not documented rn.
I have only recently familiarized myself with this code so I might be incorrect here though
comment created time in a day
pull request commentrust-lang/rust
Trait predicate ambiguities are not always in `Self`
@bors r+ rollup
comment created time in 2 days
Pull request review commentrust-lang/rust
Trait predicate ambiguities are not always in `Self`
impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { // known, since we don't dispatch based on region // relationships. + // Pick the first substitution that still contains inference variables as the one+ // we're going to emit an error for. If there are none (see above), fall back to+ // the substitution for `Self`.+ let subst = {+ let substs = data.trait_ref.substs;+ substs.iter().find(|s| s.needs_infer()).unwrap_or_else(|| substs[0])
yeah, that looks like the best solution to me :+1:
comment created time in 2 days
Pull request review commentrust-lang/rust
Trait predicate ambiguities are not always in `Self`
impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { // known, since we don't dispatch based on region // relationships. + // Pick the first substitution that still contains inference variables as the one+ // we're going to emit an error for. If there are none (see above), fall back to+ // the substitution for `Self`.+ let subst = {+ let substs = data.trait_ref.substs;+ substs.iter().find(|s| s.needs_infer()).unwrap_or_else(|| substs[0])
We probably want to use something like find(|s| s.needs_infer() && !matches!(s.unpack(), ty::GenericArgKind::Lifetime(_))) as emit_inference_failure_err can't deal with lifetimes rn.
I expect this to ICE for a trait like trait Foo<'a, T> if both 'a and T is unknown.What I am thinking of is something close to https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=66c6ee4894a18b7386ac056405b7cd02
trait Foo<'a, T> {
fn test(&self) -> T {
todo!()
}
}
impl<'a> Foo<'static, u32> for &'a () {}
impl<'a> Foo<'a, i16> for &'a () {}
fn main() {
let x = &();
assert_eq!(x.test(), 7);
}
comment created time in 2 days
pull request commentrust-lang/rust
Trait predicate ambiguities are not always in `Self`
@bors r- missed something in my review
comment created time in 2 days
pull request commentrust-lang/rust
Trait predicate ambiguities are not always in `Self`
damn, that's beautiful :heart: Previously while looking into this with @doctorn I never even thought about this, at least partially because emit_inference_failure_err still took a Ty<'tcx> back then which would have made implementing this PR harder.
Thank you
@bors r+ rollup
comment created time in 2 days
push eventlcnr/awesome-rust-mentors
commit sha d3082dc9e9aac4b5a41a310abe05a3a42ccd64b4
update mentors
push time in 2 days
PR opened rust-lang/rust
pr created time in 2 days
pull request commentrust-lang/rust
feat: Update hashbrown to instantiate less llvm IR
@bors try @rust-timer queue
comment created time in 2 days
issue commentrust-lang/rust
`rustfmt` no longer builds after rust-lang/rust#77306
yes, so we do not want to use tcx.normalize_erasing_regions in codegen_fulfill_obligations as that can be a bit costly but instead normalize eagerly before then.
To detect cases where we are still using unnormalized values #77306 added a debug assert there.
If we look at the backtrace we can find out where the trait_ref is coming from and normalize it there
comment created time in 2 days
issue commentrust-lang/rust
`rustfmt` no longer builds after rust-lang/rust#77306
won't be able to get to this myself in the next few days. To fix this we probably have to compile it with RUST_BACKTRACE=1, find the place where we call Instance::resolve and put a tcx.normalize_erasing_regions before that
comment created time in 2 days
Pull request review commentrust-lang/rust
[WIP] Refactor `Binder` to track bound vars
impl<'tcx> PredicateVisitor<'tcx> for HasEscapingVarsVisitor { } } +crate struct CountBoundVars<'tcx> {+ crate outer_index: ty::DebruijnIndex,+ crate bound_tys: SsoHashSet<ty::BoundTy>,+ crate bound_regions: SsoHashSet<ty::BoundRegion>,+ crate bound_consts: SsoHashSet<ty::BoundVar>,+ crate visited: SsoHashSet<Ty<'tcx>>,+}++impl<'tcx> CountBoundVars<'tcx> {+ crate fn new() -> Self {+ CountBoundVars {+ outer_index: ty::INNERMOST,+ bound_tys: SsoHashSet::default(),+ bound_regions: SsoHashSet::default(),+ bound_consts: SsoHashSet::default(),+ visited: SsoHashSet::default(),+ }+ }+}++impl<'tcx> TypeVisitor<'tcx> for CountBoundVars<'tcx> {+ fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> bool {+ self.outer_index.shift_in(1);+ let result = t.super_visit_with(self);+ self.outer_index.shift_out(1);+ result+ }++ fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {+ if t.outer_exclusive_binder >= self.outer_index || !self.visited.insert(t) {
isn't this incorrect?
Don't you instead want to exit early if t.outer_exclusive_binder <= self.outer_index?
comment created time in 2 days
pull request commentrust-lang/rust
Fix issue with specifying generic arguments for primitive types
:+1:
@bors r+ rollup
comment created time in 2 days
pull request commentrust-lang/rust
Calculate visibilities once in resolve
https://github.com/rust-lang/compiler-team/blob/master/content/experts/map.toml mentions @davidtwco but feel free to reassign
r? @davidtwco for now
comment created time in 3 days
Pull request review commentrust-lang/rust
Calculate visibilities once in resolve
impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> pub fn provide(providers: &mut Providers) { *providers = Providers {+ visibility, privacy_access_levels, check_private_in_public, check_mod_privacy, ..*providers }; } +fn visibility(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Visibility {+ let def_id = def_id.expect_local();+ match tcx.visibilities.get(&def_id) {+ Some(vis) => *vis,+ None => {+ let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);+ match tcx.hir().get(hir_id) {+ // Unique types created for closures participate in type privacy checking.+ // They have visibilities inherited from the module they are defined in.+ Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => {+ ty::Visibility::Restricted(tcx.parent_module(hir_id).to_def_id())+ }+ // - AST lowering may clone `use` items and the clones don't+ // get their entries in the resolver's visibility table.+ // - AST lowering also creates opaque type items with inherited visibilies.+ // Visibility on them should have no effect, but to avoid the visibility+ // query failing on some items, we provide it for opaque types as well.+ Node::Item(hir::Item {+ vis,+ kind: hir::ItemKind::Use(..) | hir::ItemKind::OpaqueTy(..),+ ..+ }) => ty::Visibility::from_hir(vis, hir_id, tcx),+ // Visibilities of trait impl items are inherited from their traits+ // and are not filled in resolve.+ Node::ImplItem(impl_item) => {+ match tcx.hir().get(tcx.hir().get_parent_item(hir_id)) {+ Node::Item(hir::Item {+ kind: hir::ItemKind::Impl { of_trait: Some(trait_ref), .. },+ ..+ }) => trait_ref+ .path+ .res+ .opt_def_id()+ .map_or(ty::Visibility::Public, |def_id| tcx.visibility(def_id)),
is opt_def_id only None here if we already emitted an error?
Can we use a delay_span_bug here?
comment created time in 3 days
Pull request review commentrust-lang/rust
impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc // "Lift" into the tcx -- once regions are erased, this type should be in the // global arenas; this "lift" operation basically just asserts that is true, but // that is useful later.- tcx.lift(&drop_place_ty).unwrap();+ tcx.lift(drop_place_ty).unwrap();
Isn't this function call fairly useless now that we only have one global context?
comment created time in 3 days
Pull request review commentrust-lang/rust
[WIP] Refactor `Binder` to track bound vars
impl<'tcx> PredicateVisitor<'tcx> for HasEscapingVarsVisitor { } } +crate struct CountBoundVars {+ crate outer_index: ty::DebruijnIndex,+ crate bound_tys: FxHashSet<ty::BoundTy>,+ crate bound_regions: FxHashSet<ty::BoundRegion>,+ crate bound_consts: FxHashSet<ty::BoundVar>,+}
it probably makes sense to use MiniSet instead of FxHashSet here as these sets should mostly be nearly empty
comment created time in 3 days
Pull request review commentrust-lang/rust
[WIP] Refactor `Binder` to track bound vars
impl<'tcx> PredicateVisitor<'tcx> for HasEscapingVarsVisitor { } } +crate struct CountBoundVars {+ crate outer_index: ty::DebruijnIndex,+ crate bound_tys: FxHashSet<ty::BoundTy>,+ crate bound_regions: FxHashSet<ty::BoundRegion>,+ crate bound_consts: FxHashSet<ty::BoundVar>,+}++impl<'tcx> TypeVisitor<'tcx> for CountBoundVars {+ fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> bool {+ self.outer_index.shift_in(1);+ let result = t.super_visit_with(self);+ self.outer_index.shift_out(1);+ result+ }++ fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {+ match t.kind {
you can also implement PredicateVisitor here to do the same for ty::Predicate
comment created time in 3 days
Pull request review commentrust-lang/rust
[WIP] Refactor `Binder` to track bound vars
impl<'tcx> PredicateVisitor<'tcx> for HasEscapingVarsVisitor { } } +crate struct CountBoundVars {+ crate outer_index: ty::DebruijnIndex,+ crate bound_tys: FxHashSet<ty::BoundTy>,+ crate bound_regions: FxHashSet<ty::BoundRegion>,+ crate bound_consts: FxHashSet<ty::BoundVar>,+}++impl<'tcx> TypeVisitor<'tcx> for CountBoundVars {+ fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> bool {+ self.outer_index.shift_in(1);+ let result = t.super_visit_with(self);+ self.outer_index.shift_out(1);+ result+ }++ fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {+ match t.kind {
can you exit early with ty.has_vars_bound_at_or_above(self.outer_index) here? Should greatly reduce the perf impact I think
comment created time in 3 days
Pull request review commentrust-lang/rust
[WIP] Refactor `Binder` to track bound vars
impl<'tcx> PredicateVisitor<'tcx> for HasEscapingVarsVisitor { } } +crate struct CountBoundVars {+ crate outer_index: ty::DebruijnIndex,+ crate bound_tys: FxHashSet<ty::BoundTy>,+ crate bound_regions: FxHashSet<ty::BoundRegion>,+ crate bound_consts: FxHashSet<ty::BoundVar>,+}++impl<'tcx> TypeVisitor<'tcx> for CountBoundVars {+ fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> bool {+ self.outer_index.shift_in(1);+ let result = t.super_visit_with(self);+ self.outer_index.shift_out(1);+ result+ }++ fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {+ match t.kind {+ ty::Bound(debruijn, ty) if debruijn >= self.outer_index => {
Why do we consider for for<T> for<U> Struct<T, U> that the inner binder (for<U>) binds T and U while for
for<'a> for<'b> Struct<'a, 'b> the inner binder only binds b afaict?
In case I am misunderstanding something here: why do we use debruijn >= self.outer_index for types and debruijn == self.outer_index for regions?
comment created time in 3 days
pull request commentrust-lang/rust
Make sure arenas don't allocate bigger than HUGE_PAGE
well, then
@bors r+ rollup
comment created time in 3 days
pull request commentrust-lang/rust
Make sure arenas don't allocate bigger than HUGE_PAGE
this code is really hot, so it's better to be safe here
@bors try @rust-timer queue
comment created time in 3 days
Pull request review commentrust-lang/rust
Make sure arenas don't allocate bigger than HUGE_PAGE
impl<T> TypedArena<T> { // If the previous chunk's len is less than HUGE_PAGE // bytes, then this chunk will be least double the previous // chunk's size.- new_cap = last_chunk.storage.len();- if new_cap < HUGE_PAGE / elem_size {- new_cap = new_cap.checked_mul(2).unwrap();- }+ new_cap = last_chunk.storage.len().min(HUGE_PAGE / 2);
you now use HUGE_PAGE instead of HUGE_PAGE / elem_size here, is that intentional?
comment created time in 4 days
pull request commentrust-lang/rust
always try inlining functions which do not call other functions
what the heck happened to deeply-nested here? :scream:
Ignoring that one, it does look like both incremental and full builds profit from this change :thinking:
I personally would love to land this, potentially after disabling it for check builds. iirc there are still some blocking issues though regarding the source info of the inlined function. cc @oli-obk
comment created time in 4 days
pull request commentrust-lang/rust
Suggest correct place to add `self` parameter when inside closure
cc @estebank
@bors r+ rollup
comment created time in 4 days
pull request commentrust-lang/rust
Fix grammar in note for orphan-rule error [E0210]
thanks!
@bors r+ rollup
comment created time in 4 days
pull request commentrust-lang/rust
yeah, I guess that's about as expected. Mostly think that taking self by value here is cleaner
comment created time in 4 days
issue openedrust-lang/compiler-team
Change type folding to take self by value
Proposal
Try changing both fold_with and super_fold_with to take self by value instead of by reference.
This removes a lot of unnecessary borrows and clones. It will have an influence on perf, which if negative will
result in this MCP being discarded.
https://github.com/rust-lang/rust/pull/78027 implements the same change for Lift.
Mentors or Reviewers
:shrug:
Process
The main points of the Major Change Process is as follows:
- [x] File an issue describing the proposal.
- [ ] A compiler team member or contributor who is knowledgeable in the area can second by writing
@rustbot second.- Finding a "second" suffices for internal changes. If however you are proposing a new public-facing feature, such as a
-C flag, then full team check-off is required. - Compiler team members can initiate a check-off via
@rfcbot fcp mergeon either the MCP or the PR.
- Finding a "second" suffices for internal changes. If however you are proposing a new public-facing feature, such as a
- [ ] Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.
You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
created time in 4 days
pull request commentrust-lang/rust
always try inlining functions which do not call other functions
Let's try another perf run, caching is_trivial_mir on disk should hopefully fix most of the incremental cost.
@bors try @rust-timer queue
comment created time in 4 days
Pull request review commentrust-lang/rust
always try inlining functions which do not call other functions
define_tables! { super_predicates: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>, // As an optimization, a missing entry indicates an empty `&[]`. explicit_item_bounds: Table<DefIndex, Lazy!([(ty::Predicate<'tcx>, Span)])>,+ is_trivial_mir: Table<DefIndex, Lazy<bool>>,
I am using Lazy<bool> here because I don't know how any of this works :sweat_smile: using Table<DefIndex, ()> seems interesting. Will look into this
comment created time in 4 days
push eventlcnr/rust
commit sha f23559451b0dc5181d73ddd89657266d4e150b6a
Rollup merge of #77303 - lcnr:const-evaluatable-TooGeneric, r=oli-obk,varkor const evaluatable: improve `TooGeneric` handling Instead of emitting an error in `fulfill`, we now correctly stall on inference variables. As `const_eval_resolve` returns `ErrorHandled::TooGeneric` when encountering generic parameters on which we actually do want to error, we check for inference variables and eagerly emit an error if they don't exist, returning `ErrorHandled::Reported` instead. Also contains a small bugfix for `ConstEquate` where we previously only stalled on type variables. This is probably a leftover from when we did not yet support stalling on const inference variables. r? @oli-obk cc @varkor @eddyb
commit sha 6d3cfd9d51e9c25452a28d18af130ad7e1fc2c90
Rollup merge of #77305 - lcnr:candidate_from_obligation, r=davidtwco move candidate_from_obligation_no_cache It's only called from `candidate_from_obligation` which is already in this file.
commit sha 70740b1b82be274c63a4f7c3795db8a5d2b15d3b
Rollup merge of #77315 - exrook:rename-allocerror, r=joshtriplett Rename AllocErr to AllocError Implements rust-lang/wg-allocators#57
commit sha 0044a9c08478d54047abc812a86220cd33f5f120
Rollup merge of #77319 - tgnottingham:siphasher_endianness, r=nnethercote Stable hashing: add comments and tests concerning platform-independence SipHasher128 implements short_write in an endian-independent way, yet its write_xxx Hasher trait methods undo this endian-independence by byte swapping the integer inputs on big-endian hardware. StableHasher then adds endian-independence back by also byte-swapping on big-endian hardware prior to invoking SipHasher128. This double swap may have the appearance of being a no-op, but is in fact by design. In particular, we really do want SipHasher128 to be platform-dependent, in order to be consistent with the libstd SipHasher. Try to clarify this intent. Also, add and update a couple of unit tests. --- Previous commit text: ~SipHasher128: fix platform-independence confusion~ ~StableHasher is supposed to ensure platform independence by converting integers to little-endian and extending isize and usize to 64 bits as necessary, but in fact, much of that work is already handled by SipHasher128.~ ~In particular, SipHasher128 implements short_write in an endian-independent way, yet both StableHasher and SipHasher128 additionally attempt to achieve endian-independence by byte swapping on BE hardware before invoking short writes. This double swap has no effect, so let's remove it.~ ~Because short_write is endian-independent, SipHasher128 is already handling part of the platform-independence, and it would be somewhat difficult to make it *not* handle that part with the current implementation. As splitting platform-independence responsibilities between StableHasher and SipHasher128 would be confusing, let's make SipHasher128 handle all of it.~ ~Finally, update some incorrect comments and increase test coverage. Unit tests pass on both LE and BE systems.~
commit sha 73258f87eaacd0b0b9dfbda5603119d425866801
Rollup merge of #77324 - Aaron1011:fix/const-item-mutation-ptr, r=petrochenkov Don't fire `const_item_mutation` lint on writes through a pointer Fixes #77321
commit sha 849e5636ea91a09a7e7a34a0cb3183978bed9887
Rollup merge of #77343 - varkor:rustc_args_required_const-validation, r=lcnr Validate `rustc_args_required_const` Fixes https://github.com/rust-lang/rust/issues/74608.
commit sha ffb771bc7988ffb5ba862d2d794246ab0ede747d
Rollup merge of #77349 - ehuss:update-cargo, r=ehuss Update cargo 8 commits in 05c611ae3c4255b7a2bcf4fcfa65b20286a07839..75615f8e69f748d7ef0df7bc0b064a9b1f5c78b2 2020-09-23 23:10:38 +0000 to 2020-09-29 18:42:19 +0000 - Correct mistake about supporting sub-makes and document CARGO_MAKEFLAGS (rust-lang/cargo#8741) - Properly set for_host for proc-macro tests. (rust-lang/cargo#8742) - Add Zsh completion for target triples (rust-lang/cargo#8740) - Reinitialize index on "Object not found" error. (rust-lang/cargo#8735) - Normalize raw string indentation. (rust-lang/cargo#8739) - Update links to rustup docs. (rust-lang/cargo#8738) - Add contributor guide. (rust-lang/cargo#8715) - Fix minor error in `cargo update` docs. (rust-lang/cargo#8737)
commit sha cc1513b860900f87a1077193f0a1dd4e1beeb577
Rollup merge of #77360 - oli-obk:zst_const_pat_regression, r=RalfJung References to ZSTs may be at arbitrary aligned addresses fixes #77320 r? @RalfJung
commit sha 85e77edc82f8052b865cf35f9aaade2d668ea4f1
Rollup merge of #77371 - camelid:remove-extra-space-in-diagnostic, r=varkor Remove trailing space in error message - Add test for error message - Remove trailing space in error message
commit sha b218b952f800c1160b8b5e764ca651b02d678565
Auto merge of #77381 - Dylan-DPC:rollup-0sr6p5p, r=Dylan-DPC Rollup of 12 pull requests Successful merges: - #76909 (Add Iterator::advance_by and DoubleEndedIterator::advance_back_by) - #77153 (Fix recursive nonterminal expansion during pretty-print/reparse check) - #77202 (Defer Apple SDKROOT detection to link time.) - #77303 (const evaluatable: improve `TooGeneric` handling) - #77305 (move candidate_from_obligation_no_cache) - #77315 (Rename AllocErr to AllocError) - #77319 (Stable hashing: add comments and tests concerning platform-independence) - #77324 (Don't fire `const_item_mutation` lint on writes through a pointer) - #77343 (Validate `rustc_args_required_const`) - #77349 (Update cargo) - #77360 (References to ZSTs may be at arbitrary aligned addresses) - #77371 (Remove trailing space in error message) Failed merges: r? `@ghost`
commit sha 2033eb1495b4a0386a0ab08815769477baf20c89
Write manifest for MAJOR.MINOR channel to enable rustup convenience This connects to https://github.com/rust-lang/rustup/issues/794. It's hard to remember if there have been patch releases for old versions when you'd like to install the latest in a MAJOR.MINOR series. When we're doing a stable release, we write duplicate manifests to `stable`. With this change, only when we're doing a stable release, also write duplicate manifests to `MAJOR.MINOR` to eventually enable rustup (and any other tooling that builds Rust release URLs) to request, say, `1.45` and get `1.45.2` (assuming `1.45.2` is the latest available `1.45` and assuming that we never publish patch releases out of order).
commit sha 86e30b605c585f2841dfd4bddb5afb696ab03cb5
Fix typo in vec doc "tries to reserves"
commit sha 20202da09e86bd15ffcd0ce22b5ebe8a27ef17a0
Improve the example for ptr::copy Fixes #77220
commit sha 3bbc443cc6657b5df623101f74688ec92e35f35d
Auto merge of #77379 - camelid:improve-wording-crate-resolution-error, r=davidtwco Improve wording for external crate resolution error I think it reads better this way.
commit sha 17db1cb5d5a864d611e17d6e2466731c3b50a794
Bypass const_item_mutation if const's type has Drop impl
commit sha 0dfe7b6434f6aabbe9673a891ba74c7c7922661d
Add justification of the destructor filter
commit sha bb760b53bf7f9593c09a03e5dea28ef5f31065d7
Simplify defid destructor check
commit sha 0f6284c88d521904bb0ada34325a0372a1ea26f1
Add test of const item mutation with Drop impl
commit sha 352ce8b29990d62465675b46b42a695a4206d5be
Test a type with drop glue but no Drop impl
commit sha 41baa090ad1c40a7fc96f96664543ce4c26746c2
Skip dropck::check_drop_impl in is_const_item_without_destructor adt_destructor by default also validates the Drop impl using dropck::check_drop_impl, which contains an expect_local(). This leads to ICE in check_const_item_mutation if the const's type is not a local type. thread 'rustc' panicked at 'DefId::expect_local: `DefId(5:4805 ~ alloc[d7e9]::vec::{impl#50})` isn't local', compiler/rustc_span/src/def_id.rs:174:43 stack backtrace: 0: rust_begin_unwind 1: rustc_span::def_id::DefId::expect_local::{{closure}} 2: rustc_typeck::check::dropck::check_drop_impl 3: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::calculate_dtor::{{closure}} 4: rustc_middle::ty::trait_def::<impl rustc_middle::ty::context::TyCtxt>::for_each_relevant_impl 5: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::calculate_dtor 6: rustc_typeck::check::adt_destructor 7: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::adt_destructor>::compute 8: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl 9: rustc_query_system::query::plumbing::get_query_impl 10: rustc_mir::transform::check_const_item_mutation::ConstMutationChecker::is_const_item_without_destructor
push time in 4 days
push eventlcnr/rust
commit sha 18080f9b434339fe6f4f1454b8ebad98fd2c311c
cache me on disk
commit sha 54fcb47ce840b88f5acb398f3878cd0241d37734
allow intrinsics
push time in 4 days
pull request commentrust-lang/rust
Don't run `resolve_vars_if_possible` in `normalize_erasing_regions`
I believe that resolve_vars_if_possible should always be a noop after normalize in a fresh InferCtxt as I expect all infer variables created during normalization to be still unknown after it.
So I do think it is valuable to remove that afaict unnecessary step here.
comment created time in 4 days
pull request commentrust-lang/rust
Use rebind instead of Binder::bind when possible
looking fairly neutral to me
@bors r+
comment created time in 4 days
PR opened rust-lang/rust
seems small enough to not warrant an MCP :shrug:
pr created time in 5 days
pull request commentrust-lang/rust
Use map_bound(_ref) instead of Binder::bind when possible
we have been bitten by perf in the past here, so better safe than sorry
@bors try @rust-timer queue
if perf is clean r=me
comment created time in 5 days
Pull request review commentrust-lang/rust
Eliminate some temporary vectors
dependencies = [ "rustc_ast", "rustc_span", "rustc_target",+ "smallvec 1.4.2",
specifying a version number here works :O
comment created time in 5 days
Pull request review commentrust-lang/rust
Use map_bound(_ref) instead of Binder::bind when possible
impl<'tcx> Predicate<'tcx> { } } + /// Converts this to a `Binder<PredicateAtom<'tcx>>`. If the value was an+ /// `Atom`, then it is not allowed to contain escaping bound vars.+ pub fn bound_atom(self, _tcx: TyCtxt<'tcx>) -> Binder<PredicateAtom<'tcx>> {+ match self.kind() {+ &PredicateKind::ForAll(binder) => binder,+ &PredicateKind::Atom(atom) => {+ assert!(!atom.has_escaping_bound_vars());
also, is there a reason you did not remove the _tcx argument here? Do you expect us to need it in the future?
comment created time in 5 days
Pull request review commentrust-lang/rust
Use map_bound(_ref) instead of Binder::bind when possible
impl<'a, 'tcx> ProbeContext<'a, 'tcx> { // FIXME: do we want to commit to this behavior for param bounds? debug!("assemble_inherent_candidates_from_param(param_ty={:?})", param_ty); - let bounds =- self.param_env.caller_bounds().iter().map(ty::Predicate::skip_binders).filter_map(- |predicate| match predicate {- ty::PredicateAtom::Trait(trait_predicate, _) => {- match trait_predicate.trait_ref.self_ty().kind() {- ty::Param(ref p) if *p == param_ty => {- Some(ty::Binder::bind(trait_predicate.trait_ref))- }- _ => None,+ let tcx = self.tcx;+ let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| {+ let bound_predicate = predicate.bound_atom(tcx);+ match bound_predicate.skip_binder() {+ ty::PredicateAtom::Trait(trait_predicate, _) => {+ match trait_predicate.trait_ref.self_ty().kind() {+ ty::Param(ref p) if *p == param_ty => {
match *trait_predicate.trait_ref.self_ty().kind() {
ty::Param(p) if p == param_ty => {
comment created time in 5 days
Pull request review commentrust-lang/rust
Use map_bound(_ref) instead of Binder::bind when possible
fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( // could be extended easily also to the other `Predicate`. let predicate_matches_closure = |p: Predicate<'tcx>| { let mut relator: SimpleEqRelation<'tcx> = SimpleEqRelation::new(tcx, self_param_env);+ let bound_predicate = predicate.bound_atom(tcx);+ let bound_p = p.bound_atom(tcx); match (predicate.skip_binders(), p.skip_binders()) {
nit: style
maybe instead shadow p and predicate here and match on (predicate.skip_binder(), p.skip_binder())
comment created time in 5 days
Pull request review commentrust-lang/rust
Use map_bound(_ref) instead of Binder::bind when possible
impl<'tcx> Predicate<'tcx> { } } + /// Converts this to a `Binder<PredicateAtom<'tcx>>`. If the value was an+ /// `Atom`, then it is not allowed to contain escaping bound vars.+ pub fn bound_atom(self, _tcx: TyCtxt<'tcx>) -> Binder<PredicateAtom<'tcx>> {+ match self.kind() {+ &PredicateKind::ForAll(binder) => binder,+ &PredicateKind::Atom(atom) => {+ assert!(!atom.has_escaping_bound_vars());
debug_assert!(!atom.has_escaping_bound_vars());
i expect this method to be faily hot, so it might also make sense to mark this #[inline]
comment created time in 5 days
Pull request review commentrust-lang/rust
Use map_bound(_ref) instead of Binder::bind when possible
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } let result = ensure_sufficient_stack(|| {- match obligation.predicate.skip_binders() {+ let bound_predicate =+ obligation.predicate.bound_atom_with_opt_escaping(self.infcx().tcx);
why do you use ...with_opt_escaping here? We previously used skip_binders which failed on unbound vars
comment created time in 5 days
Pull request review commentrust-lang/rust
Use map_bound(_ref) instead of Binder::bind when possible
impl<T> Binder<T> { Binder(f(self.0)) } + /// Wraps a `value` in a binder, using the same bound variables as the+ /// current `Binder`. This should not be used if the new value *changes*+ /// the bound variables. Note: the (old or new) value itself does not+ /// necessarily need to *name* all the bound variables.+ pub fn rebind<U>(&self, value: U) -> Binder<U> {
It might make sense to add a comment here which says that we do not yet track bound variables.
I am also kind of suprised that none of the methods on ty::Binder are marked as inline even though they are very frequently used and really simple. Might be interesting to check if that has a perf impact.
comment created time in 5 days
Pull request review commentrust-lang/rust
Use map_bound(_ref) instead of Binder::bind when possible
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::Array(element_ty, _) => { // (*) binder moved here- Where(ty::Binder::bind(vec![element_ty]))+ Where(obligation.predicate.rebind(vec![*element_ty]))
can you instead of using *element_ty here change the match statement to
match *self_ty.kind() {
comment created time in 5 days
pull request commentrust-lang/rust
Check for frequent types in type folding
@bors try @rust-timer queue
comment created time in 5 days