Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

un-closed delimiter causes compiler to crash. #33823

Closed
Arzte opened this issue May 23, 2016 · 4 comments
Closed

un-closed delimiter causes compiler to crash. #33823

Arzte opened this issue May 23, 2016 · 4 comments

Comments

@Arzte
Copy link
Contributor

Arzte commented May 23, 2016

I ran this code:

// External Crate Imports
extern crate clap;
extern crate diesel;

// Distro enum import
use super::distro::{Distro, which_distro};

// Imports needed to run each command
use std::process::Command;
// Std Lib Imports
use std::process::exit;
use std::collections::HashSet;

use db;

// Gets what distro is being used from distro.rs
// then sets that as a function.

pub fn getWhichDistro() {
    let opt_dist = which_distro();
    if opt_dist.is_none() {
        println!("Your distribution is not supported");
        exit(0);
}

/// Installs packages for what ever Distro is returned
/// from which_distro();
///
/// #Examples
///
/// ```
/// let mut packages: HashSet<&str> = HashSet::new();
/// packages.push("sudo");
/// packages.push("postgresql");
/// void_install(packages);
/// ```
///
pub fn opt_distro_install(packages: HashSet<String>) {
    let opt_distro_packages = convert_to_opt_distro(packages);
    if !opt_distro_packages.is_empty() {
        pac(opt_distro_packages);
    }
}

/// Convert package names from other distros to void
fn convert_to_opt_distro(input_packages: HashSet<String>) -> HashSet<String> {
    let results = db::pack_query(input_packages);
    let mut pac_converted: HashSet<String> = HashSet::new();

    // Using the querys store into the HashSet the actual
    // void package name for use later
    for i in results {
        // All querys will either be a string or '' in the db
        // allowing us to use is_empty()
        if !i.opt_distro.is_empty() {
            pac_converted.insert(i.opt_distro);
        }
    }

    pac_converted
}

// Figures out the current package manager based on Distro

pub fn setFunctionVaribles() {
    if opt_distro().contains("Ubuntu") {
        let opt_pac_install = "apt-get";
        let opt_pac_install_args = "install";
        let opt_pac_refresh = "apt-get";
        let opt_pac_refresh_args = "update";
        let opt_pac_upgrade = "apt-get";
        let opt_pac_upgrade_args = "upgrade";
    } else if opt_distro().contains("Void") {
        let opt_pac_install = "xbps-install";
        let opt_pac_install_args = "-S";
        let opt_pac_refresh = "xbps-install";
        let opt_pac_refresh_args = "-Sy";
        let opt_pac_upgrade = "xbps-install";
        let opt_pac_upgrade_args = "-Syu";
    } else if opt_distro().contains("Debian") {
        let opt_pac_install = "apt-get";
        let opt_pac_install_args = "install";
        let opt_pac_refresh = "apt-get";
        let opt_pac_refresh_args = "update";
        let opt_pac_upgrade = "apt-get";
        let opt_pac_upgrade_args = "upgrade";
    } else if opt_distro().contains("Mint") {
        let opt_pac_install = "apt-get";
        let opt_pac_install_args = "install";
        let opt_pac_refresh = "apt-get";
        let opt_pac_refresh_args = "update";
        let opt_pac_upgrade = "apt-get";
        let opt_pac_upgrade_args = "upgrade";
    } else if opt_distro().contains("FreeBSD") {
        let opt_pac_install = "pkg";
        let opt_pac_install_args = "install";
        let opt_pac_refresh = "pkg";
        let opt_pac_refresh_args = "update";
        let opt_pac_upgrade = "pkg";
        let opt_pac_upgrade_args = "upgrade";
    }
}

// Package Manager specific functions

/// Calls the package manager program to install packages
///
/// #Examples
///
/// ```
/// let mut packages: HashSet<String> = HashSet::new();
/// packages.push("sudo".to_owned());
/// pac(packages);
/// ```
///
pub fn pac(mut packages: HashSet<String>) {
    let mut child = match Command::new(opt_pac_install)
        .arg(opt_pac_install_args)
        .args(packages.drain()
            .collect::<Vec<String>>()
            .as_slice())
        .spawn() {
        Ok(child) => child,
        Err(e) => panic!("Failed to execute child: {}", e),
    };
    let _unused = child.wait();
}

/// Calls the xbps-install program to refresh the package list
///
/// #Examples
///
/// ```
/// refresh_list();
/// ```
///
pub fn refresh_list() {
    let mut child = match Command::new(opt_pac_refresh)
        .arg(opt_pac_refresh_args)
        .spawn() {
        Ok(child) => child,
        Err(e) => panic!("Failed to execute child: {}", e),
    };
    let _unused = child.wait();
}

/// Calls the xbps-install program to upgrage all packages
///
/// #Examples
///
/// ```
/// refresh_list();
/// ```
///
pub fn upgrade_packages() {
    let mut child = match Command::new(opt_pac_upgrade)
        .arg(opt_pac_upgrade_args)
        .spawn() {
        Ok(child) => child,
        Err(e) => panic!("Failed to execute child: {}", e),
    };
    let _unused = child.wait();
}

I expected it to tell me whats wrong with the code.
Instead it crashed with a un-closed delimiter error.

Meta

rustc --version --verbose

rustc 1.10.0-nightly (d91f8ab0f 2016-05-07)
binary: rustc
commit-hash: d91f8ab0f58fa123857d96b9e151fc5185f5ff08
commit-date: 2016-05-07
host: x86_64-unknown-linux-gnu
release: 1.10.0-nightly

Backtrace:

   Compiling Alchemist v0.4.0 (file:///home/benjamin/git-projects/Alchemist)
src/alchemy/function.rs:163:3: 163:3 error: this file contains an un-closed delimiter
src/alchemy/function.rs:163:3: 163:3 error: this file contains an un-closed delimiter
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'no annotations resulted from: Line { line_index: 162, annotations: [Annotation { start_col: 2, end_col: 2, is_primary: true, label: None }] }', ../src/libsyntax/errors/snippet/mod.rs:495
stack backtrace:
   1:     0x7fdf604f8d20 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:     0x7fdf6050656b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:     0x7fdf6050610c - std::panicking::default_hook::hc2c969e7453d080c
   4:     0x7fdf604cb8cf - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e25
   5:     0x7fdf604cd9b8 - std::sys_common::unwind::begin_unwind_fmt::hb2de8a9968d38523
   6:     0x7fdf5bb3a3f0 - _<std..iter..FlatMap<I, U, F> as std..iter..Iterator>::next::h5f2bd9e6e7475c71
   7:     0x7fdf5bb2529d - syntax::errors::snippet::SnippetData::render_lines::hcf468c4f4b065b33
   8:     0x7fdf5bb1de5d - _<errors..emitter..EmitterWriter as errors..emitter..CoreEmitter>::emit_message::h90dab4fc68091626
   9:     0x7fdf5cdb581d - _<T as syntax..errors..emitter..Emitter>::emit_struct::h7b7bf4316e311f87
  10:     0x7fdf5bbfea79 - syntax::parse::parser::Parser::parse_token_tree::hd7887691a0224788
  11:     0x7fdf5bbecd8e - syntax::parse::parser::Parser::parse_all_token_trees::hd7d5e9405b2cb448
  12:     0x7fdf5bbedb06 - syntax::parse::filemap_to_tts::hef694d21976dabc3
  13:     0x7fdf5bbed222 - syntax::parse::filemap_to_parser::haaf76e155992a193
  14:     0x7fdf5bbed5a5 - syntax::parse::new_sub_parser_from_file::h958bfc7a4123d826
  15:     0x7fdf5bc66c0e - syntax::parse::parser::Parser::eval_src_mod::hc1b930270df2f2db
  16:     0x7fdf5bc46dfa - syntax::parse::parser::Parser::parse_item_::h42775dc76ed27882
  17:     0x7fdf5bbebea2 - syntax::parse::parser::Parser::parse_item::h10c52ea29e5c06b9
  18:     0x7fdf5bc64985 - syntax::parse::parser::Parser::parse_mod_items::h66337b460d5459b0
  19:     0x7fdf5bbea357 - syntax::parse::parser::Parser::parse_crate_mod::hab124b9c61eef337
  20:     0x7fdf5bbea0ee - syntax::parse::parse_crate_from_file::h9d8c63cd0dc10cd2
  21:     0x7fdf60a5ba7f - rustc_driver::driver::phase_1_parse_input::_$u7b$$u7b$closure$u7d$$u7d$::h356ebaf3d4ce86d0
  22:     0x7fdf60a36698 - rustc_driver::driver::phase_1_parse_input::h338b1890954f9a2c
  23:     0x7fdf60a11e97 - rustc_driver::driver::compile_input::h0629572e6f316b31
  24:     0x7fdf60a0857d - rustc_driver::run_compiler::h8902aebf8b1849a8
  25:     0x7fdf60a0583d - std::sys_common::unwind::try::try_fn::h4c74456035d0fcc7
  26:     0x7fdf604f64fb - __rust_try
  27:     0x7fdf604f648d - std::sys_common::unwind::inner_try::h47a4d9cd4a369dcd
  28:     0x7fdf60a0626a - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
  29:     0x7fdf605046d4 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  30:     0x7fdf5829e3f3 - start_thread
                        at /builddir/glibc-2.23/nptl/pthread_create.c:333
  31:     0x7fdf60161bac - clone
                        at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
  32:                0x0 - <unknown>

Build failed, waiting for other jobs to finish...
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'no annotations resulted from: Line { line_index: 162, annotations: [Annotation { start_col: 2, end_col: 2, is_primary: true, label: None }] }', ../src/libsyntax/errors/snippet/mod.rs:495
stack backtrace:
   1:     0x7f1398831d20 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:     0x7f139883f56b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:     0x7f139883f10c - std::panicking::default_hook::hc2c969e7453d080c
   4:     0x7f13988048cf - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e25
   5:     0x7f13988069b8 - std::sys_common::unwind::begin_unwind_fmt::hb2de8a9968d38523
   6:     0x7f1393e733f0 - _<std..iter..FlatMap<I, U, F> as std..iter..Iterator>::next::h5f2bd9e6e7475c71
   7:     0x7f1393e5e29d - syntax::errors::snippet::SnippetData::render_lines::hcf468c4f4b065b33
   8:     0x7f1393e56e5d - _<errors..emitter..EmitterWriter as errors..emitter..CoreEmitter>::emit_message::h90dab4fc68091626
   9:     0x7f13950ee81d - _<T as syntax..errors..emitter..Emitter>::emit_struct::h7b7bf4316e311f87
  10:     0x7f1393f37a79 - syntax::parse::parser::Parser::parse_token_tree::hd7887691a0224788
  11:     0x7f1393f25d8e - syntax::parse::parser::Parser::parse_all_token_trees::hd7d5e9405b2cb448
  12:     0x7f1393f26b06 - syntax::parse::filemap_to_tts::hef694d21976dabc3
  13:     0x7f1393f26222 - syntax::parse::filemap_to_parser::haaf76e155992a193
  14:     0x7f1393f265a5 - syntax::parse::new_sub_parser_from_file::h958bfc7a4123d826
  15:     0x7f1393f9fc0e - syntax::parse::parser::Parser::eval_src_mod::hc1b930270df2f2db
  16:     0x7f1393f7fdfa - syntax::parse::parser::Parser::parse_item_::h42775dc76ed27882
  17:     0x7f1393f24ea2 - syntax::parse::parser::Parser::parse_item::h10c52ea29e5c06b9
  18:     0x7f1393f9d985 - syntax::parse::parser::Parser::parse_mod_items::h66337b460d5459b0
  19:     0x7f1393f23357 - syntax::parse::parser::Parser::parse_crate_mod::hab124b9c61eef337
  20:     0x7f1393f230ee - syntax::parse::parse_crate_from_file::h9d8c63cd0dc10cd2
  21:     0x7f1398d94a7f - rustc_driver::driver::phase_1_parse_input::_$u7b$$u7b$closure$u7d$$u7d$::h356ebaf3d4ce86d0
  22:     0x7f1398d6f698 - rustc_driver::driver::phase_1_parse_input::h338b1890954f9a2c
  23:     0x7f1398d4ae97 - rustc_driver::driver::compile_input::h0629572e6f316b31
  24:     0x7f1398d4157d - rustc_driver::run_compiler::h8902aebf8b1849a8
  25:     0x7f1398d3e83d - std::sys_common::unwind::try::try_fn::h4c74456035d0fcc7
  26:     0x7f139882f4fb - __rust_try
  27:     0x7f139882f48d - std::sys_common::unwind::inner_try::h47a4d9cd4a369dcd
  28:     0x7f1398d3f26a - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
  29:     0x7f139883d6d4 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  30:     0x7f13905d73f3 - start_thread
                        at /builddir/glibc-2.23/nptl/pthread_create.c:333
  31:     0x7f139849abac - clone
                        at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
  32:                0x0 - <unknown>

error: Could not compile `Alchemist`.

To learn more, run the command again with --verbose.
@TimNN
Copy link
Contributor

TimNN commented May 24, 2016

This seems to have been fixed on the latest nightly.

@TimNN
Copy link
Contributor

TimNN commented May 24, 2016

More specifically, this was probably fixed by #33369.

@alexcrichton
Copy link
Member

Yay!

@Arzte
Copy link
Contributor Author

Arzte commented May 24, 2016

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants