From f53eca6ea1b6222cf9607aa83a57958a739b96d4 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Tue, 3 Sep 2024 09:23:14 -0400 Subject: [PATCH 1/2] Revert "Don't use `raw` in comparisons." This reverts commit 9ff9176b6707c259c2546c2500867181372ce6da. Per the discussion in #6, having the `Eq` and `Ord` instances ignore the `raw` field of `Ident` causes more trouble than it's worth, as it causes the parser to incorrectly deem raw identifiers like `r#return` to be keywords. While we could fix this issue by changing the parser, this would take quite a bit of code changes to accomplish. As such, we revert the change here, and we make a note in the Haddocks for the `Eq` and `Ord` instances to beware of the fact that `raw` is taken into account. After this change, the `rustc-tests` test suite passes once more. As such, this change fixes #6. --- src/Language/Rust/Data/Ident.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Language/Rust/Data/Ident.hs b/src/Language/Rust/Data/Ident.hs index f68adac..512110a 100644 --- a/src/Language/Rust/Data/Ident.hs +++ b/src/Language/Rust/Data/Ident.hs @@ -33,13 +33,15 @@ data Ident = Ident { hash :: {-# UNPACK #-} !Int -- ^ hash for quick comparision , name :: Name -- ^ payload of the identifier , raw :: Bool -- ^ whether the identifier is raw - } deriving (Data, Typeable, Generic, NFData) - -instance Eq Ident where - x == y = (hash x, name x) == (hash y, name y) - -instance Ord Ident where - compare x y = compare (hash x, name x) (hash y, name y) + } + deriving ( Data, Typeable, Generic, NFData + -- | Note that this instance takes the 'raw' field into account, so + -- the identifiers @x@ and @r#x@ are judged /not/ to be equal. + , Eq + -- | Note that this instance takes the 'raw' field into account, so + -- the identifiers @x@ and @r#x@ are judged /not/ to be equal. + , Ord + ) -- | Shows the identifier as a string (for use with @-XOverloadedStrings@) instance Show Ident where From 9acd23debed5d99ecb0431fe77c09004d08db5a9 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Tue, 3 Sep 2024 09:44:23 -0400 Subject: [PATCH 2/2] CI: Migrate from Travis to GitHub Actions Fixes #5. --- .github/workflows/ci.yaml | 64 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 36 ---------------------- 2 files changed, 64 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..565d313 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,64 @@ +name: CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +# The CACHE_VERSION can be updated to force the use of a new cache if +# the current cache contents become corrupted/invalid. This can +# sometimes happen when (for example) the OS version is changed but +# older .so files are cached, which can have various effects +# (e.g. cabal complains it can't find a valid version of the "happy" +# tool). +env: + CACHE_VERSION: 1 + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + ghc: ["9.4.8", "9.6.6", "9.8.2"] + cabal: ["3.10.3.0"] + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - uses: haskell-actions/setup@v2 + id: setup-haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - uses: actions/cache/restore@v4 + name: Restore cabal store cache + with: + path: | + ${{ steps.setup-haskell.outputs.cabal-store }} + dist-newstyle + key: ${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc)) }}-${{ github.sha }} + restore-keys: | + ${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc)) }}- + + - name: Update + run: cabal update + - name: Configure + run: cabal configure --enable-tests + - name: Build + run: cabal build + - name: Run tests + run: cabal test + + - uses: actions/cache/save@v4 + name: Save cabal store cache + if: always() + with: + path: | + ${{ steps.setup-haskell.outputs.cabal-store }} + dist-newstyle + key: ${{ env.CACHE_VERSION }}-cabal-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles(format('cabal.GHC-{0}.config', matrix.ghc)) }}-${{ github.sha }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 95caabf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -# Sudo used for custom apt setup -sudo: true - -# Add new environments to the build here: -env: - - GHCVER=8.0.2 CABALVER=3.0 - - GHCVER=8.2.2 CABALVER=3.0 - - GHCVER=8.4.4 CABALVER=3.0 - - GHCVER=8.6.5 CABALVER=3.0 - - GHCVER=8.8.1 CABALVER=3.0 - - GHCVER=head CABALVER=head - -# Allow for develop branch to break -matrix: - allow_failures: - - env: GHCVER=8.8.1 CABALVER=3.0 - - env: GHCVER=head CABALVER=head - -# Manually install ghc and cabal -before_install: - - travis_retry sudo add-apt-repository -y ppa:hvr/ghc - - travis_retry sudo apt-get update - - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER - - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH - - export PATH=$HOME/.cabal/bin:$PATH - - travis_retry cabal update - -# Install Happy and Alex first, before installing -install: - - echo $PATH - - cabal --version - - ghc --version - - cabal configure --verbose --enable-tests - -script: - - cabal test