Closed
Description
Compiling mount v0.3.0 (file:///var/www/sites/current/mount)
error: `derive` can be only be applied to items
--> /var/www/sites/current/mount/src/mount.rs:63:14
|
63 | #[derive(Debug)]
| ^^^^^
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
thread 'rustc' panicked at 'adding a def'n for node-id NodeId(4294967295) and data TypeParam("H") but a previous def'n exists: DefKey { parent: Some(DefIndex(29)), disambiguated_data: DisambiguatedDefPathData { data: ValueNs("mount"), disambiguator: 0 } }', /checkout/src/librustc/hir/map/definitions.rs:479
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Could not compile `mount`.
Code:
impl Mount {
/// Creates a new instance of `Mount`.
pub fn new() -> Mount {
Mount {
inner: SequenceTrie::new()
}
}
/// Mounts a given `Handler` onto a route.
///
/// This method may be called multiple times with different routes.
/// For a given request, the *most specific* handler will be selected.
///
/// Existing handlers on the same route will be overwritten.
#[derive(Debug)]
pub fn mount<H: Handler>(&mut self, route: &str, handler: H) -> &mut Mount {
// Parse the route into a list of strings. The unwrap is safe because strs are UTF-8.
let key: Vec<&str> = Path::new(route).components().flat_map(|c|
match c {
Component::RootDir => None,
c => Some(c.as_os_str().to_str().unwrap())
}
).collect();
// Insert a match struct into the trie.
let match_length = key.len();
self.inner.insert(key, Match {
handler: Box::new(handler) as Box<Handler>,
length: match_length,
});
self
}
}
I assume this is because of where I put the derive debug line.