diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-01-09 16:30:10 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-03-15 13:25:10 +0200 |
| commit | 5616ca857dd05e5e62b4bfcd11bd1ea0f2e22f5e (patch) | |
| tree | bc27aad1498276b5f667407e894b10bec4c6cafd /src/librustdoc | |
| parent | 972af5e808eb76b449e7af6ee087bb611c722326 (diff) | |
| download | rust-5616ca857dd05e5e62b4bfcd11bd1ea0f2e22f5e.tar.gz rust-5616ca857dd05e5e62b4bfcd11bd1ea0f2e22f5e.zip | |
rustc: uniformize ty::print's error handling by requiring Result.
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 24 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 1 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index bfc7c7859f5..2a8db6455bf 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -4230,10 +4230,15 @@ where F: Fn(DefId) -> Def { struct AbsolutePathPrinter; impl Printer for AbsolutePathPrinter { + type Error = !; + type Path = Vec<String>; - fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path { - vec![self.tcx.original_crate_name(cnum).to_string()] + fn path_crate( + self: &mut PrintCx<'_, '_, '_, Self>, + cnum: CrateNum, + ) -> Result<Self::Path, Self::Error> { + Ok(vec![self.tcx.original_crate_name(cnum).to_string()]) } fn path_qualified( self: &mut PrintCx<'_, '_, 'tcx, Self>, @@ -4241,7 +4246,7 @@ where F: Fn(DefId) -> Def { self_ty: Ty<'tcx>, trait_ref: Option<ty::TraitRef<'tcx>>, _ns: Namespace, - ) -> Self::Path { + ) -> Result<Self::Path, Self::Error> { let mut path = impl_prefix.unwrap_or(vec![]); // This shouldn't ever be needed, but just in case: @@ -4251,15 +4256,15 @@ where F: Fn(DefId) -> Def { path.push(format!("<{}>", self_ty)); } - path + Ok(path) } fn path_append( self: &mut PrintCx<'_, '_, '_, Self>, mut path: Self::Path, text: &str, - ) -> Self::Path { + ) -> Result<Self::Path, Self::Error> { path.push(text.to_string()); - path + Ok(path) } fn path_generic_args( self: &mut PrintCx<'_, '_, 'tcx, Self>, @@ -4268,13 +4273,14 @@ where F: Fn(DefId) -> Def { _substs: SubstsRef<'tcx>, _ns: Namespace, _projections: impl Iterator<Item = ty::ExistentialProjection<'tcx>>, - ) -> Self::Path { - path + ) -> Result<Self::Path, Self::Error> { + Ok(path) } } let names = PrintCx::new(tcx, AbsolutePathPrinter) - .print_def_path(def_id, None, Namespace::TypeNS, iter::empty()); + .print_def_path(def_id, None, Namespace::TypeNS, iter::empty()) + .unwrap(); hir::Path { span: DUMMY_SP, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 2ac44d0109f..fccf5a67ad4 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -18,6 +18,7 @@ #![feature(const_fn)] #![feature(drain_filter)] #![feature(inner_deref)] +#![feature(never_type)] #![recursion_limit="256"] |
