profile
viewpoint

rust-lang/nomicon 1393

The Dark Arts of Advanced and Unsafe Rust Programming

rust-lang/reference 934

The Rust Reference

matthewjasper/book 0

The Rust Programming Language

matthewjasper/cargo 0

The Rust package manager

matthewjasper/chalk 0

A PROLOG-ish interpreter written in Rust, intended eventually for use in the compiler

matthewjasper/compiler-explorer 0

Run compilers interactively from your web browser and interact with the assembly

matthewjasper/gccrs 0

GCC Front-End for Rust

matthewjasper/intellij-rust 0

Rust plugin for the IntelliJ Platform: https://intellij-rust.github.io/

matthewjasper/miri 0

An interpreter for Rust's mid-level intermediate representation

matthewjasper/nomicon 0

The Dark Arts of Advanced and Unsafe Rust Programming

issue openedRust-GCC/gccrs

Literals are not compared correctly in macros

I tried this code:

macro_rules! m {
    (1) => {};
}

m!(2);

I expected to see this happen: an error (rustc produces error: no rules expected the token2``)

Instead, this happened: compiles successfully

Meta

  • What version of Rust GCC were you using, git sha if possible. 2d806801404fc7628a3d022da92b73cd06197f49

created time in 2 days

issue commentRust-GCC/gccrs

Invalid name resolution for non-exported items in modules

The macro doesn't appear to be needed here, the following also compiles.

mod foo {
    fn bar() {}
}

fn main() {
    bar();
}
CohenArthur

comment created time in 4 days

pull request commentRust-GCC/gccrs

Add #[derive(Copy)] support

"this field does not implement Copy" is checked for all Copy implementations (when type checking the impl

CohenArthur

comment created time in 5 days

Pull request review commentrust-lang/nomicon

phantom-data: Add `Send` and `Sync` columns

 standard library made a utility for itself called `Unique<T>` which:  Here’s a table of all the wonderful ways `PhantomData` could be used: -| Phantom type                | `'a`      | `T`                       |-|-----------------------------|-----------|---------------------------|-| `PhantomData<T>`            | -         | covariant (with drop check) |-| `PhantomData<&'a T>`        | covariant | covariant                 |-| `PhantomData<&'a mut T>`    | covariant | invariant                 |-| `PhantomData<*const T>`     | -         | covariant                 |-| `PhantomData<*mut T>`       | -         | invariant                 |-| `PhantomData<fn(T)>`        | -         | contravariant             |-| `PhantomData<fn() -> T>`    | -         | covariant                 |-| `PhantomData<fn(T) -> T>`   | -         | invariant                 |-| `PhantomData<Cell<&'a ()>>` | invariant | -                         |+| Phantom type                | `'a`      | `T`                         | `Send`    | `Sync`    |+|-----------------------------|-----------|-----------------------------|-----------|-----------|+| `PhantomData<T>`            | -         | covariant (with drop check) | `T: Send` | `T: Sync` |+| `PhantomData<&'a T>`        | covariant | covariant                   | `T: Send` | `T: Sync` |

Are these not both T: Sync?

Enselic

comment created time in 7 days

PullRequestReviewEvent
PullRequestReviewEvent

issue commentRust-GCC/gccrs

Macro hygene not implemented

Relevant for #1078 too

powerboat9

comment created time in 7 days

Pull request review commentRust-GCC/gccrs

derive: Add base for builtin derives and #[derive(Clone)]

  #include "rust-expand-visitor.h" #include "rust-attributes.h"+#include "rust-ast.h"+#include "rust-type.h"+#include "rust-derive.h"  namespace Rust { +bool+is_derive (AST::Attribute &attr)+{+  auto path = attr.get_path ();+  return attr.has_attr_input ()+	 && attr.get_attr_input ().get_attr_input_type ()+	      == AST::AttrInput::TOKEN_TREE+	 && path == "derive";+}++bool+is_builtin (AST::Attribute &attr)+{+  auto &segments = attr.get_path ().get_segments ();+  return !segments.empty ()+	 && !Analysis::BuiltinAttributeMappings::get ()+	       ->lookup_builtin (segments[0].get_segment_name ())+	       .is_error ();+}+ /* Expand all of the macro invocations currently contained in a crate */ void ExpandVisitor::go (AST::Crate &crate)+{+  expand_inner_items (crate.items);+}++/**+ * Returns a list of all the derive macros to apply, as well as the Attribute+ * they are from.+ *+ * ```rust+ * #[derive(Clone, Copy)] // attr1+ * struct S;+ *+ * // returns [{Clone, &attr1}, {Copy, &attr1}]+ *+ * #[derive(Clone)] // attr1+ * #[derive(Copy, PartialEq, Ord)] // attr2+ * struct S;+ *+ * // returns [{Clone, &attr1}, {Copy, &attr2}, {PartialEq, &attr2}, {Ord,+ * &attr2}]+ * ```+ *+ * @param outer_attrs The list of attributes on the item to derive+ */+static std::vector<+  std::pair<std::string, std::reference_wrapper<const AST::Attribute>>>+get_traits_to_derive (std::vector<AST::Attribute> &outer_attrs)+{+  std::vector<+    std::pair<std::string, std::reference_wrapper<const AST::Attribute>>>+    to_derive;+  for (auto it = outer_attrs.begin (); it != outer_attrs.end ();)+    {+      auto &attr = *it;++      if (is_derive (attr))+	{+	  auto &input = attr.get_attr_input ();+	  switch (input.get_attr_input_type ())+	    {+	      // isn't there a better way to do this?? like parse it or+	      // something idk. some function I'm not thinking of?+	      case AST::AttrInput::TOKEN_TREE: {+		auto &tokens = static_cast<AST::DelimTokenTree &> (input)+				 .get_token_trees ();++		// erase the delimiters+		rust_assert (tokens.size () >= 3);+		tokens.erase (tokens.begin ());+		tokens.pop_back ();++		for (auto &token : tokens)+		  {+		    // skip commas, as they are part of the token stream+		    if (token->as_string () == ",")+		      continue;++		    to_derive.emplace_back (token->as_string (), attr);

This should be parsing and name resolving paths (e.g. #[derive(std::clone::Clone)]). But that can be raised as a follow-up issue.

CohenArthur

comment created time in 8 days

PullRequestReviewEvent

Pull request review commentRust-GCC/gccrs

derive: Add base for builtin derives and #[derive(Clone)]

+// Copyright (C) 2020-2023 Free Software Foundation, Inc.++// This file is part of GCC.++// GCC is free software; you can redistribute it and/or modify it under+// the terms of the GNU General Public License as published by the Free+// Software Foundation; either version 3, or (at your option) any later+// version.++// GCC is distributed in the hope that it will be useful, but WITHOUT ANY+// WARRANTY; without even the implied warranty of MERCHANTABILITY or+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License+// for more details.++// You should have received a copy of the GNU General Public License+// along with GCC; see the file COPYING3.  If not see+// <http://www.gnu.org/licenses/>.++#include "rust-derive-clone.h"++namespace Rust {+namespace AST {++std::unique_ptr<Expr>+DeriveClone::clone_call (std::unique_ptr<Expr> &&to_clone)+{+  // $crate::core::clone::Clone::clone for the fully qualified path - we don't+  // link with `core` yet so that might be an issue. Use `Clone::clone` for now?+  // TODO: `has_opening_scope_resolution`? Does it have it?

It does not

CohenArthur

comment created time in 8 days

Pull request review commentRust-GCC/gccrs

derive: Add base for builtin derives and #[derive(Clone)]

 Mappings::insert_macro_def (AST::MacroRulesDefinition *macro) 		   });   if (should_be_builtin)     {-      auto builtin-	= MacroBuiltin::builtin_transcribers.find (macro->get_rule_name ());-      if (builtin != MacroBuiltin::builtin_transcribers.end ())-	macro->set_builtin_transcriber (builtin->second);-      else+      auto builtin = MacroBuiltin::builtins.lookup (macro->get_rule_name ());+      if (!MacroBuiltin::builtins.is_iter_ok (builtin)) 	rust_error_at (macro->get_locus (), 		       "cannot find a built-in macro with name %qs", 		       macro->get_rule_name ().c_str ());+      return;

Are some braces missing here?

CohenArthur

comment created time in 9 days

PullRequestReviewEvent
PullRequestReviewEvent

issue commentRust-GCC/gccrs

Cannot parse statement after curly bracket macro invocation

#2206 left a bunch of cases with macros not correctly implemented. I'll try to get a follow up for those cases soon.

CohenArthur

comment created time in 11 days

delete branch matthewjasper/rust

delete branch : validate-match-guards

delete time in 12 days

pull request commentrust-lang/rust

Run AST validation on match guards correctly

Regressions look supurious. @bors r=compiler-errors

matthewjasper

comment created time in 13 days

issue openedRust-GCC/gccrs

ICE when failing to match repetition

Code

Minimized from core (https://github.com/rust-lang/rust/blob/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/str/iter.rs#L707). This also ICEs without a doc comment being used, instead of erroring.

macro_rules! generate_pattern_iterators {
    {
        $(#[$forward_iterator_attribute:meta])*
    } => {
    }
}

generate_pattern_iterators! {
    /// Created with the method [`split`].
}

Meta

  • What version of Rust GCC were you using, git sha if possible. 6521333e402a2f71e34591666ae697cab7af7316

Error output

crab1: internal compiler error: in match_matcher, at rust/expand/rust-macro-expand.cc:472

<details><summary>Backtrace</summary> <p>

crab1: internal compiler error: in match_matcher, at rust/expand/rust-macro-expand.cc:472
0x755627 Rust::MacroExpander::match_matcher(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatcher&, bool)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:472
0x755627 Rust::MacroExpander::match_matcher(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatcher&, bool)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:440
0xa1ed53 Rust::MacroExpander::match_n_matches(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatchRepetition&, unsigned long&, unsigned long, unsigned long)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:629
0xa1ef7f Rust::MacroExpander::match_repetition(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatchRepetition&)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:684
0xa1f405 Rust::MacroExpander::match_matcher(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatcher&, bool)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:510
0xa1f405 Rust::MacroExpander::match_matcher(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatcher&, bool)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:440
0xa1f7b7 Rust::MacroExpander::try_match_rule(Rust::AST::MacroRule&, Rust::AST::DelimTokenTree&)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:356
0xa1fa23 Rust::MacroExpander::expand_decl_macro(Location, Rust::AST::MacroInvocData&, Rust::AST::MacroRulesDefinition&, bool)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:83
0xa1ff8b Rust::MacroExpander::expand_invoc(Rust::AST::MacroInvocation&, bool)
      ../../gccrs/gcc/rust/expand/rust-macro-expand.cc:284
0xa76152 Rust::ExpandVisitor::go(Rust::AST::Crate&)
      ../../gccrs/gcc/rust/expand/rust-expand-visitor.cc:36
0xa0541e Rust::Session::expansion(Rust::AST::Crate&)
      ../../gccrs/gcc/rust/rust-session-manager.cc:884
0xa0b20e Rust::Session::compile_crate(char const*)
      ../../gccrs/gcc/rust/rust-session-manager.cc:591
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

</p> </details>

created time in 14 days

Pull request review commentrust-lang/rust

Run AST validation on match guards correctly

 impl<'a, 'tcx> Builder<'a, 'tcx> {         let category = Category::of(&expr.kind).unwrap();         debug!(?category, ?expr.kind);         match category {-            Category::Constant if let NeedsTemporary::No = needs_temporary || !expr.ty.needs_drop(this.tcx, this.param_env) => {

"Why is rust analyzer complaning about this file? Wait, why is rustc compiling this file?"

matthewjasper

comment created time in 14 days

PullRequestReviewEvent

pull request commentrust-lang/rust

fix recursion depth handling after confirmation

@bors r+

lcnr

comment created time in 14 days

pull request commentrust-lang/rust

Run AST validation on match guards correctly

Not sure if this deserves a crater run or not for.

matthewjasper

comment created time in 15 days

PR opened rust-lang/rust

Run AST validation on match guards correctly

AST validation was being skipped on match guards other than if let guards.

+240 -38

0 comment

6 changed files

pr created time in 15 days

create barnchmatthewjasper/rust

branch : validate-match-guards

created branch time in 15 days

issue openedRust-GCC/gccrs

Macro-expanded macro definitions are not resolved

I tried this code:

macro_rules! one {
    () => {
        macro_rules! two {
            () => {
                
            }
        }
    }
}

one!();
two!();

I expected to see this happen: compiles

Instead, this happened:

<source>:12:1: error: unknown macro: [two]
   12 | two!();
      | ^~~

Meta

  • What version of Rust GCC were you using, git sha if possible. gccrs (Compiler-Explorer-Build-gcc-c7b7e297ea4b688ef9fb51a8aee2a8b2af39ac1c-binutils-2.40) 13.0.1 20230417 (experimental)

created time in 15 days

issue openedRust-GCC/gccrs

Imports are order dependent

I tried this code (from general experimentation with the compiler):

mod a {
    pub fn f() {}
}

// Compiles if moved below b
mod c {
    use crate::b::{f, g};

    pub fn h() {
        f();
        g();
    }
}

mod b {
    pub use crate::a::f;

    pub fn g() {
        f();
    }
}

I expected to see this happen: Compiles

Instead, this happened: error

<source>:6:20: error: cannot find simple path segment 'f' in this scope
    6 |     use crate::b::{f, g};
      |                    ^
<source>:9:9: error: Cannot find path 'f' in this scope
    9 |         f();
      |         

Meta

  • What version of Rust GCC were you using, git sha if possible. gccrs (Compiler-Explorer-Build-gcc-c7b7e297ea4b688ef9fb51a8aee2a8b2af39ac1c-binutils-2.40) 13.0.1 20230417 (experimental)

created time in 15 days

delete branch matthewjasper/gccrs

delete branch : macro-resolve

delete time in 15 days

push eventmatthewjasper/gccrs

Matthew Jasper

commit sha b834f517dc9edc55cba36e150b2ed23583afb49e

gccrs: Fix macro resolutions in middle of multiple nested macro_use modules gcc/rust/ChangeLog: * resolve/rust-early-name-resolver.cc (EarlyNameResolver::accumulate_escaped_macros): Remove unnecessary visit. gcc/testsuite/ChangeLog: * rust/compile/nested_macro_use3.rs: New test. Signed-off-by: Matthew Jasper <mjjasper1@gmail.com>

view details

push time in 15 days

pull request commentRust-GCC/gccrs

Fix macro resolutions in middle of multiple nested macro_use modules

There's already an invocation of a in the test, do you want another one?

matthewjasper

comment created time in 15 days

delete branch matthewjasper/gccrs

delete branch : cfg-attr-parsing

delete time in 15 days

issue commentrust-lang/rust

Tracking issue for RFC 2294, "if let guard"

Is the code here supposed to work? I would expect only direct use of a let expression (or maybe a chain with && if if let chains is also enabled) to be accepted.

https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/build/expr/as_operand.rs#L121

Centril

comment created time in 15 days

more